11 #include <mrpt/system/filesystem.h> 18 using namespace mvsim;
25 m_simul_timestep(0.010),
63 for (TListVehicles::iterator it =
m_vehicles.begin();
68 for (std::list<WorldElementBase*>::iterator it =
81 catch (std::exception&)
91 m_timlogger.registerUserMeasure(
"run_simulation.dt", dt);
99 const double timetol =
120 CTimeLoggerEntry tle(
m_timlogger,
"timestep.0.prestep");
121 for (TListVehicles::iterator it =
m_vehicles.begin();
123 it->second->simul_pre_timestep(context);
125 for (TListVehicles::iterator it =
m_vehicles.begin();
129 for (VehicleBase::TListSensors::iterator itSen = sensors.begin();
130 itSen != sensors.end(); ++itSen)
132 (*itSen)->simul_pre_timestep(context);
138 it->second->simul_pre_timestep(context);
140 for (std::list<WorldElementBase*>::iterator it =
143 (*it)->simul_pre_timestep(context);
148 CTimeLoggerEntry tle(
157 CTimeLoggerEntry tle(
161 for (TListVehicles::iterator it =
m_vehicles.begin();
164 it->second->simul_post_timestep_common(context);
165 it->second->simul_post_timestep(context);
170 it->second->simul_post_timestep_common(context);
171 it->second->simul_post_timestep(context);
177 CTimeLoggerEntry tle(
m_timlogger,
"timestep.4.poststep");
178 for (TListVehicles::iterator it =
m_vehicles.begin();
180 it->second->simul_post_timestep(context);
182 for (TListVehicles::iterator it =
m_vehicles.begin();
186 for (VehicleBase::TListSensors::iterator itSen = sensors.begin();
187 itSen != sensors.end(); ++itSen)
189 (*itSen)->simul_post_timestep(context);
195 it->second->simul_post_timestep(context);
197 for (std::list<WorldElementBase*>::iterator it =
200 (*it)->simul_post_timestep(context);
205 (ts > dt ?
"timestep_too_slow_alert" :
"timestep"), ts);
213 const std::string
s = mrpt::system::trim(s_in);
218 bool is_relative =
true;
219 if (s.size() > 2 && s[1] ==
':' && (s[2] ==
'/' || s[2] ==
'\\'))
221 if (s.size() > 0 && (s[0] ==
'/' || s[0] ==
'\\')) is_relative =
false;
225 if (!ret.empty() && ret[ret.size() - 1] !=
'/' &&
226 ret[ret.size() - 1] !=
'\\')
236 return mrpt::system::filePathSeparatorsToNative(ret);
242 for (TListVehicles::iterator it =
m_vehicles.begin();
const b2Vec2 b2Vec2_zero(0.0f, 0.0f)
Useful constant.
void Step(float32 timeStep, int32 velocityIterations, int32 positionIterations)
int m_b2d_pos_iters
Velocity and position iteration count (Box2D)
TListWorldElements m_world_elements
CTicTac m_timer_iteration
double m_simul_time
evaluate weights for friction, etc.
void runVisitorOnWorldElements(WorldElementVisitorBase &v)
double simul_time
Current time in the simulated world.
void clear_all(bool acquire_mt_lock=true)
virtual void visit(VehicleBase *obj)=0
void internal_one_timestep(double dt)
std::string resolvePath(const std::string &in_path) const
std::mutex m_world_cs
first time the GUI window is created.
b2Body * m_b2_ground_body
Used to declare friction between vehicles-ground.
virtual void visit(WorldElementBase *obj)=0
int m_b2d_vel_iters
integration.
std::vector< SensorBase::Ptr > TListSensors
void runVisitorOnVehicles(VehicleVisitorBase &v)
World()
Default ctor: inits an empty world.
void run_simulation(double dt)
std::string m_base_path
Path from which to take relative directories.
b2World * m_box2d_world
objects from multithreading access.
b2Body * CreateBody(const b2BodyDef *def)