28 #include <mrpt/poses/CPose2D.h> 30 #include <mrpt/opengl/CSetOfObjects.h> 31 #include <mrpt/opengl/CSetOfLines.h> 32 #if MRPT_VERSION<0x199 33 #include <mrpt/utils/TColor.h> 34 using mrpt::utils::TColor;
36 #include <mrpt/img/TColor.h> 37 using mrpt::img::TColor;
71 double fx,
double fy,
double local_ptx = 0.0,
72 double local_pty = 0.0);
95 return m_wheels_info[idx];
98 const mrpt::math::TPose3D&
getPose()
const 102 void setPose(
const mrpt::math::TPose3D& p)
const 105 const_cast<mrpt::math::TPose3D&
>(m_q) = p;
120 std::vector<mrpt::math::TPoint2D>& vels,
121 const vec3& veh_vel_local)
const;
144 return m_chassis_poly;
153 for (
auto& logger :
m_loggers) logger.second->setRecording(record);
157 for (
auto& logger :
m_loggers) logger.second->clear();
161 for (
auto& logger :
m_loggers) logger.second->newSession();
170 virtual void gui_update(mrpt::opengl::COpenGLScene& scene);
175 std::map<std::string, std::shared_ptr<CSVLogger>>
m_loggers;
193 std::vector<double>& out_force_per_wheel) = 0;
202 mrpt::opengl::COpenGLScene& scene,
bool defaultVehicleBody =
true);
215 b2Body* m_b2d_vehicle_body;
220 TListSensors m_sensors;
231 double m_chassis_mass;
232 mrpt::math::TPolygon2D m_chassis_poly;
234 double m_chassis_z_min, m_chassis_z_max;
236 TColor m_chassis_color;
238 mrpt::math::TPoint2D m_chassis_com;
241 void updateMaxRadiusFromPoly();
244 std::vector<Wheel> m_wheels_info;
251 std::vector<b2Fixture*> m_fixture_wheels;
256 void internal_gui_update_sensors(
257 mrpt::opengl::COpenGLScene&
259 void internal_gui_update_forces(
260 mrpt::opengl::COpenGLScene&
263 mrpt::opengl::CSetOfObjects::Ptr m_gl_chassis;
264 std::vector<mrpt::opengl::CSetOfObjects::Ptr> m_gl_wheels;
265 mrpt::opengl::CSetOfLines::Ptr m_gl_forces;
266 std::mutex m_force_segments_for_rendering_cs;
267 std::vector<mrpt::math::TSegment3D> m_force_segments_for_rendering;
270 static constexpr
char DL_TIMESTAMP[] =
"timestamp";
271 static constexpr
char LOGGER_POSE[] =
"logger_pose";
272 static constexpr
char LOGGER_WHEEL[] =
"logger_wheel";
274 static constexpr
char PL_Q_X[] =
"Qx";
275 static constexpr
char PL_Q_Y[] =
"Qy";
276 static constexpr
char PL_Q_Z[] =
"Qz";
277 static constexpr
char PL_Q_YAW[] =
"Qyaw";
278 static constexpr
char PL_Q_PITCH[] =
"Qpitch";
279 static constexpr
char PL_Q_ROLL[] =
"Qroll";
280 static constexpr
char PL_DQ_X[] =
"dQx";
281 static constexpr
char PL_DQ_Y[] =
"dQy";
282 static constexpr
char PL_DQ_Z[] =
"dQz";
284 static constexpr
char WL_TORQUE[] =
"torque";
285 static constexpr
char WL_WEIGHT[] =
"weight";
286 static constexpr
char WL_VEL_X[] =
"velocity_x";
287 static constexpr
char WL_VEL_Y[] =
"velocity_y";
288 static constexpr
char WL_FRIC_X[] =
"friction_x";
289 static constexpr
char WL_FRIC_Y[] =
"friction_y";
296 #define DECLARES_REGISTER_VEHICLE_DYNAMICS(CLASS_NAME) \ 297 DECLARES_REGISTER_CLASS1(CLASS_NAME, VehicleBase, World*) 299 #define REGISTER_VEHICLE_DYNAMICS(TEXTUAL_NAME, CLASS_NAME) \ 301 TClassFactory_vehicleDynamics, classFactory_vehicleDynamics, \ 302 TEXTUAL_NAME, CLASS_NAME)
virtual void create_multibody_system(b2World *world)
b2Body * getBox2DChassisBody()
void setPose(const mrpt::math::TPose3D &p) const
ClassFactory< VehicleBase, World * > TClassFactory_vehicleDynamics
void getWheelsVelocityLocal(std::vector< mrpt::math::TPoint2D > &vels, const vec3 &veh_vel_local) const
const std::string & getName() const
virtual void dynamics_load_params_from_xml(const rapidxml::xml_node< char > *xml_node)=0
virtual void initLoggers()
std::shared_ptr< FrictionBase > FrictionBasePtr
virtual void apply_force(double fx, double fy, double local_ptx=0.0, double local_pty=0.0)
virtual vec3 getVelocityLocalOdoEstimate() const =0
std::shared_ptr< CSVLogger > getLoggerPtr(std::string logger_name)
virtual void simul_post_timestep(const TSimulContext &context)
const TListSensors & getSensors() const
const mrpt::math::TPolygon2D & getChassisShape() const
TClassFactory_vehicleDynamics classFactory_vehicleDynamics
size_t getNumWheels() const
A rigid body. These are created via b2World::CreateBody.
VehicleBase(World *parent, size_t nWheels)
Wheel & getWheelInfo(const size_t idx)
size_t getVehicleIndex() const
virtual void simul_pre_timestep(const TSimulContext &context)
virtual ControllerBaseInterface * getControllerInterface()=0
virtual float getMaxVehicleRadius() const
static void register_vehicle_class(const rapidxml::xml_node< char > *xml_node)
std::map< std::string, std::shared_ptr< CSVLogger > > m_loggers
const Wheel & getWheelInfo(const size_t idx) const
virtual void invoke_motor_controllers(const TSimulContext &context, std::vector< double > &out_force_per_wheel)=0
void gui_update_common(mrpt::opengl::COpenGLScene &scene, bool defaultVehicleBody=true)
void setRecording(bool record)
const mrpt::math::TPose3D & getPose() const
virtual void gui_update(mrpt::opengl::COpenGLScene &scene)
std::vector< SensorBase::Ptr > TListSensors
virtual void writeLogStrings()
void simul_post_timestep_common(const TSimulContext &context)
TListSensors & getSensors()
void setVehicleIndex(size_t idx)
mrpt::poses::CPose2D getCPose2D() const
vec3 getVelocityLocal() const
virtual double getChassisMass() const
const vec3 & getVelocity() const
mrpt::math::TPoint2D getChassisCenterOfMass() const
In local coordinates (this excludes the mass of wheels)
std::string m_name
User-supplied name of the vehicle (e.g. "r1", "veh1")
static VehicleBase * factory(World *parent, const rapidxml::xml_node< char > *xml_node)