17 using namespace mvsim;
19 static double sign(
double x) {
return (
double)((x > 0) - (x < 0)); }
30 if (node && 0 != strcmp(node->
name(),
"friction"))
31 throw std::runtime_error(
32 "<friction>...</friction> XML node was expected!!");
47 MRPT_UNSCOPED_LOGGER_START;
49 MRPT_UNSCOPED_LOGGER_END;
65 const double mu =
m_mu;
68 const double max_friction = mu * partial_mass * gravity;
72 double wheel_lat_friction = 0.0;
75 wheel_lat_friction = -vel_w.
y * partial_mass / input.
context.
dt;
78 b2Clamp(wheel_lat_friction, -max_friction, max_friction);
83 double wheel_long_friction = 0.0;
91 const double lon_constraint_desired_wheel_w = vel_w.
x / R;
92 const double desired_wheel_w_impulse =
93 (lon_constraint_desired_wheel_w - input.
wheel.
getW());
94 const double desired_wheel_alpha =
95 desired_wheel_w_impulse / input.
context.
dt;
107 -
sign(vel_w.
x) * partial_mass * gravity *
112 m_logger.lock()->updateColumn(
"F_rr", F_rr);
115 const double I_yy = input.
wheel.
Iyy;
117 double F_friction_lon = (input.
motor_torque - I_yy * desired_wheel_alpha -
123 F_friction_lon =
b2Clamp(F_friction_lon, -max_friction, max_friction);
126 const double actual_wheel_alpha = (input.
motor_torque - R * F_friction_lon -
134 wheel_long_friction = F_friction_lon;
139 wheel_long_friction, wheel_lat_friction);
142 wRot.
composePoint(result_force_wrt_wheel, out_result_force_local);
This file contains rapidxml parser and DOM implementation.
void setW(double val)
Spinning velocity (rad/s) wrt shaft.
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="")
GLenum GLenum GLenum input
void composePoint(double lx, double ly, double &gx, double &gy) const
WardIagnemmaFriction(VehicleBase &my_vehicle, const rapidxml::xml_node< char > *node)
std::weak_ptr< CSVLogger > m_logger
#define MRPT_LOG_DEBUG(_STRING)
static double sign(double x)
double get_gravity() const
double getW() const
Spinning velocity (rad/s) wrt shaft.
GLint GLint GLint GLint GLint x
double m_C_damping
For wheels "internal friction" (N*m*s/rad)
virtual void evaluate_friction(const FrictionBase::TFrictionInput &input, mrpt::math::TPoint2D &out_result_force_local) const override
T b2Clamp(T a, T low, T high)
double m_mu
friction coeficient (non-dimensional)
double m_R2
Ward-Iagnemma rolling resistance coefficient.
VehicleBase & m_my_vehicle