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!!");
37 std::map<std::string, TParamEntry> params;
47 MRPT_UNSCOPED_LOGGER_START;
48 MRPT_LOG_DEBUG(
"WardIagnemma Creates!");
49 MRPT_UNSCOPED_LOGGER_END;
55 mrpt::math::TPoint2D& out_result_force_local)
const 58 const mrpt::poses::CPose2D wRot(0, 0, input.
wheel.
yaw);
59 const mrpt::poses::CPose2D wRotInv(0, 0, -input.
wheel.
yaw);
60 mrpt::math::TPoint2D vel_w;
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;
138 const mrpt::math::TPoint2D result_force_wrt_wheel(
139 wheel_long_friction, wheel_lat_friction);
142 wRot.composePoint(result_force_wrt_wheel, out_result_force_local);
virtual void evaluate_friction(const FrictionBase::TFrictionInput &input, mrpt::math::TPoint2D &out_result_force_local) const
This file contains rapidxml parser and DOM implementation.
void setW(double val)
Spinning velocity (rad/s) wrt shaft.
WardIagnemmaFriction(VehicleBase &my_vehicle, const rapidxml::xml_node< char > *node)
std::weak_ptr< CSVLogger > m_logger
static double sign(double x)
double get_gravity() const
void parse_xmlnode_children_as_param(const rapidxml::xml_node< char > &xml_node, const std::map< std::string, TParamEntry > ¶ms, const char *function_name_context="")
double getW() const
Spinning velocity (rad/s) wrt shaft.
double m_C_damping
For wheels "internal friction" (N*m*s/rad)
double diameter
[m,rad] (in local coords)
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