19 using namespace mvsim;
63 const std::map<std::string, std::string> varValues = {{
"NAME",
m_name}};
78 *xml_chassis, attribs, {},
79 "[DynamicsAckermann::dynamics_load_params_from_xml]");
87 "[DynamicsAckermann::dynamics_load_params_from_xml]");
94 const char* w_names[4] = {
101 for (
size_t i = 0; i < 4; i++)
112 double front_x = 1.3;
113 double front_d = 2.0;
116 ack_ps[
"f_wheels_x"] =
TParamEntry(
"%lf", &front_x);
117 ack_ps[
"f_wheels_d"] =
TParamEntry(
"%lf", &front_d);
122 *xml_node, ack_ps, varValues,
123 "[DynamicsAckermann::dynamics_load_params_from_xml]");
142 if (!control_class || !control_class->
value())
144 "[DynamicsAckermann] Missing 'class' attribute in " 145 "<controller> XML node");
147 const std::string sCtrlClass = std::string(control_class->
value());
159 "[DynamicsAckermann] Unknown 'class'='%s' in " 160 "<controller> XML node",
161 sCtrlClass.c_str()));
173 const TSimulContext& context, std::vector<double>& out_torque_per_wheel)
176 out_torque_per_wheel.assign(4, 0.0);
201 const double desired_equiv_steer_ang,
double& out_fl_ang,
202 double& out_fr_ang)
const 209 const double w_l = w / l;
213 const bool delta_neg = (desired_equiv_steer_ang < 0);
214 ASSERT_LT_(delta, 0.5 *
M_PI - 0.01);
215 const double cot_do = 1.0 / tan(delta) + 0.5 * w_l;
216 const double cot_di = cot_do - w_l;
219 (delta_neg ? out_fr_ang : out_fl_ang) =
220 atan(1.0 / cot_di) * (delta_neg ? -1.0 : 1.0);
221 (delta_neg ? out_fl_ang : out_fr_ang) =
222 atan(1.0 / cot_do) * (delta_neg ? -1.0 : 1.0);
242 "The two wheels of a differential vehicle CAN'T by at the same Y " 245 const double w_veh = (w1 * R1 - w0 * R0) / Ay;
250 odo_vel.
omega = w_veh;
255 printf(
"\n gt: vx=%7.03f, vy=%7.03f, w= %7.03fdeg\n", gt_vel.
vx, gt_vel.
vy, mrpt::RAD2DEG(gt_vel.
omega));
256 printf(
"odo: vx=%7.03f, vy=%7.03f, w= %7.03fdeg\n", odo_vel.
vx, odo_vel.
vy, mrpt::RAD2DEG(odo_vel.
omega));
mrpt::img::TColor m_chassis_color
This file contains rapidxml parser and DOM implementation.
void updateMaxRadiusFromPoly()
excludes the mass of wheels)
virtual void invoke_motor_controllers(const TSimulContext &context, std::vector< double > &out_force_per_wheel) override
std::map< std::string, TParamEntry > TParameterDefinitions
void parse_xmlnode_children_as_param(const rapidxml::xml_node< char > &xml_node, const TParameterDefinitions ¶ms, const std::map< std::string, std::string > &variableNamesValues={}, const char *functionNameContext="")
DynamicsAckermann(World *parent)
ControllerBasePtr m_controller
The installed controller.
GLubyte GLubyte GLubyte GLubyte w
virtual mrpt::math::TTwist2D getVelocityLocalOdoEstimate() const override
void parse_xmlnode_attribs(const rapidxml::xml_node< char > &xml_node, const TParameterDefinitions ¶ms, const std::map< std::string, std::string > &variableNamesValues={}, const char *functionNameContext="")
virtual void dynamics_load_params_from_xml(const rapidxml::xml_node< char > *xml_node) override
xml_node< Ch > * first_node(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const
mrpt::math::TTwist2D getVelocityLocal() const
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
xml_attribute< Ch > * first_attribute(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const
void computeFrontWheelAngles(const double desired_equiv_steer_ang, double &out_fl_ang, double &out_fr_ang) const
std::vector< Wheel > m_wheels_info
std::shared_ptr< ControllerBase > ControllerBasePtr
T b2Clamp(T a, T low, T high)
double steer_ang
Equivalent ackerman steering angle.
std::vector< b2Fixture * > m_fixture_wheels
double m_chassis_z_min
each change via updateMaxRadiusFromPoly()
void parse_xmlnode_shape(const rapidxml::xml_node< char > &xml_node, mrpt::math::TPolygon2D &out_poly, const char *functionNameContext="")
static const char * class_name()
mrpt::math::TPolygon2D m_chassis_poly
#define ASSERTMSG_(f, __ERROR_MSG)
b2Fixture * m_fixture_chassis
Created at.
static const char * class_name()
static const char * class_name()
GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint GLdouble w1