18 using namespace mvsim;
24 if (node && 0 != strcmp(node->name(),
"friction"))
25 throw std::runtime_error(
"<friction>...</friction> XML node was expected!!");
36 const mrpt::poses::CPose2D wRot(0, 0, input.
wheel.
yaw);
39 const mrpt::math::TVector2D vel_w = wRot.inverseComposePoint(input.
wheelCogLocalVel);
43 const double mu =
mu_;
46 const double max_friction = mu * partial_mass * gravity;
50 double wheel_lat_friction = 0.0;
53 wheel_lat_friction = -vel_w.y * partial_mass / input.
context.
dt;
55 wheel_lat_friction =
b2Clamp(wheel_lat_friction, -max_friction, max_friction);
60 double wheel_long_friction = 0.0;
68 const double lon_constraint_desired_wheel_w = vel_w.x /
R;
70 const double desired_wheel_w_impulse = (lon_constraint_desired_wheel_w - input.
wheel.getW());
72 const double desired_wheel_alpha = desired_wheel_w_impulse / input.
context.
dt;
82 double F_friction_lon =
83 (input.
motorTorque - I_yy * desired_wheel_alpha - C_damping * input.
wheel.getW()) /
R;
86 F_friction_lon =
b2Clamp(F_friction_lon, -max_friction, max_friction);
89 const double actual_wheel_alpha =
95 wheel_long_friction = F_friction_lon;
99 const mrpt::math::TPoint2D result_force_wrt_wheel(wheel_long_friction, wheel_lat_friction);
102 mrpt::math::TVector2D res;
103 wRot.composePoint(result_force_wrt_wheel, res);