18 using namespace mvsim;
25 if (node && 0 != strcmp(node->
name(),
"friction"))
26 throw std::runtime_error(
27 "<friction>...</friction> XML node was expected!!");
40 const mrpt::poses::CPose2D wRot(0, 0, input.
wheel.
yaw);
43 const mrpt::math::TVector2D vel_w =
48 const double mu =
mu_;
51 const double max_friction = mu * partial_mass * gravity;
55 double wheel_lat_friction = 0.0;
58 wheel_lat_friction = -vel_w.y * partial_mass / input.
context.
dt;
61 b2Clamp(wheel_lat_friction, -max_friction, max_friction);
66 double wheel_long_friction = 0.0;
74 const double lon_constraint_desired_wheel_w = vel_w.x /
R;
76 const double desired_wheel_w_impulse =
77 (lon_constraint_desired_wheel_w - input.
wheel.
getW());
79 const double desired_wheel_alpha =
80 desired_wheel_w_impulse / input.
context.
dt;
90 double F_friction_lon = (input.
motorTorque - I_yy * desired_wheel_alpha -
95 F_friction_lon =
b2Clamp(F_friction_lon, -max_friction, max_friction);
98 const double actual_wheel_alpha = (input.
motorTorque - R * F_friction_lon -
106 wheel_long_friction = F_friction_lon;
110 const mrpt::math::TPoint2D result_force_wrt_wheel(
111 wheel_long_friction, wheel_lat_friction);
114 mrpt::math::TVector2D res;
115 wRot.composePoint(result_force_wrt_wheel, res);
double mu_
friction coeficient (non-dimensional)
This file contains rapidxml parser and DOM implementation.
void setW(double val)
Spinning velocity (rad/s) wrt shaft.
DefaultFriction(VehicleBase &my_vehicle, const rapidxml::xml_node< char > *node)
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="", mrpt::system::COutputLogger *logger=nullptr)
double C_damping_
For wheels "internal friction" (N*m*s/rad)
double getW() const
Spinning velocity (rad/s) wrt shaft.
virtual mrpt::math::TVector2D evaluate_friction(const FrictionBase::TFrictionInput &input) const override
const std::map< std::string, std::string > & user_defined_variables() const
T b2Clamp(T a, T low, T high)
const TParameterDefinitions params_
double get_gravity() const