File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change 11#include " simple-mpc/friction-compensation.hpp"
2-
2+ # include < iostream >
33namespace simple_mpc
44{
55
66 FrictionCompensation::FrictionCompensation (const Model & model, const bool with_free_flyer)
77 {
88 if (with_free_flyer)
99 {
10- // Ignore universe and root joints
11- nu_ = model.njoints - 2 ;
10+ // Ignore free flyer joint
11+ nu_ = model.nv - 6 ;
1212 }
1313 else
1414 {
15- // Ignore universe joint
16- nu_ = model.njoints - 1 ;
15+ // If no free flyer
16+ nu_ = model.nv ;
1717 }
1818 dry_friction_ = model.friction .tail (nu_);
1919 viscuous_friction_ = model.damping .tail (nu_);
2020 }
2121
2222 void FrictionCompensation::computeFriction (Eigen::Ref<const VectorXd> velocity, Eigen::Ref<VectorXd> torque)
2323 {
24- assert ((" Velocity size must be equal to actuation size" , velocity.size () == nu_));
25- assert ((" Torque size must be equal to actuation size" , torque.size () == nu_));
24+ if (velocity.size () != nu_)
25+ throw std::runtime_error (" Velocity has wrong size" );
26+ if (torque.size () != nu_)
27+ throw std::runtime_error (" Torque has wrong size" );
28+
2629 torque += viscuous_friction_.cwiseProduct (velocity)
2730 + dry_friction_.cwiseProduct (velocity.unaryExpr (std::function (signFunction)));
2831 }
You can’t perform that action at this time.
0 commit comments