18 using namespace mvsim;
20 static double sign(
double x) {
return (
double)((x > 0) - (x < 0)); }
26 if (node && 0 != strcmp(node->
name(),
"friction"))
27 throw std::runtime_error(
28 "<friction>...</friction> XML node was expected!!");
42 "WardIagnemmaFriction", my_vehicle.
parent() );
51 const mrpt::poses::CPose2D wRot(0, 0, input.
wheel.
yaw);
52 const mrpt::poses::CPose2D wRotInv(0, 0, -input.
wheel.
yaw);
53 mrpt::math::TPoint2D vel_w;
58 const double mu =
mu_;
61 const double max_friction = mu * partial_mass * gravity;
65 double wheel_lat_friction = 0.0;
68 wheel_lat_friction = -vel_w.y * partial_mass / input.
context.
dt;
71 b2Clamp(wheel_lat_friction, -max_friction, max_friction);
76 double wheel_long_friction = 0.0;
84 const double lon_constraint_desired_wheel_w = vel_w.x /
R;
85 const double desired_wheel_w_impulse =
86 (lon_constraint_desired_wheel_w - input.
wheel.
getW());
87 const double desired_wheel_alpha =
88 desired_wheel_w_impulse / input.
context.
dt;
101 -
sign(vel_w.x) * partial_mass * gravity *
106 logger_.lock()->updateColumn(
"F_rr", F_rr);
109 const double I_yy = input.
wheel.
Iyy;
111 double F_friction_lon = (input.
motorTorque - I_yy * desired_wheel_alpha -
117 F_friction_lon =
b2Clamp(F_friction_lon, -max_friction, max_friction);
120 const double actual_wheel_alpha = (input.
motorTorque - R * F_friction_lon -
128 wheel_long_friction = F_friction_lon;
132 const mrpt::math::TPoint2D result_force_wrt_wheel(
133 wheel_long_friction, wheel_lat_friction);
136 mrpt::math::TVector2D res;
137 wRot.composePoint(result_force_wrt_wheel, res);
This file contains rapidxml parser and DOM implementation.
void setW(double val)
Spinning velocity (rad/s) wrt shaft.
std::weak_ptr< CSVLogger > logger_
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="", mrpt::system::COutputLogger *logger=nullptr)
WardIagnemmaFriction(VehicleBase &my_vehicle, const rapidxml::xml_node< char > *node)
static double sign(double x)
double getW() const
Spinning velocity (rad/s) wrt shaft.
double C_damping_
For wheels "internal friction" (N*m*s/rad)
const std::map< std::string, std::string > & user_defined_variables() const
T b2Clamp(T a, T low, T high)
INLINE Rall1d< T, V, S > exp(const Rall1d< T, V, S > &arg)
virtual mrpt::math::TVector2D evaluate_friction(const FrictionBase::TFrictionInput &input) const override
double mu_
friction coeficient (non-dimensional)
double get_gravity() const