-
Notifications
You must be signed in to change notification settings - Fork 401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Passivity-based RNEA Algorithms #2421
base: devel
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👋 Hi,
This is a reminder message to assign an extra build label to this Pull Request if needed.
By default, this PR will be build with minimal build options (URDF support and Python bindings)
The possible extra labels are:
- build_collision (build Pinocchio with coal support)
- build_casadi (build Pinocchio with CasADi support)
- build_autodiff (build Pinocchio with CppAD support)
- build_codegen (build Pinocchio with CppADCodeGen support)
- build_extra (build Pinocchio with extra algorithms)
- build_mpfr (build Pinocchio with Boost.Multiprecision support)
- build_sdf (build Pinocchio with SDF parser)
- build_accelerate (build Pinocchio with APPLE Accelerate framework support)
- build_all (build Pinocchio with ALL the options stated above)
Thanks.
The Pinocchio development team.
include/pinocchio/algorithm/rnea.hxx
Outdated
// data.f[i] = model.inertias[i]*data.a_gf[i];// + model.inertias[i].vxiv(data.v[i]); | ||
// // -f_ext data.h[i] = model.inertias[i]*data.v[i]; | ||
|
||
// model.inertias[i].__mult__(data.v_r[i], data.h[i]); // option 1 | ||
data.B[i] = model.inertias[i].variation(Scalar(0.5) * data.v[i]); | ||
model.inertias[i].__mult__(data.v[i], data.h[i]); | ||
addForceCrossMatrix(Scalar(0.5) * data.h[i], data.B[i]); // option 3 (Christoffel-consistent factorization) | ||
|
||
model.inertias[i].__mult__(data.a_gf[i], data.f[i]); | ||
// data.f[i] += data.v[i].cross(data.h[i]); // option 1 | ||
data.f[i] += Force(data.B[i] * data.v_r[i].toVector()); // option 3 (Christoffel-consistent factorization) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is option 2? We might also add all the conventions and use a switch case to select the most appropriate one if needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I can add option 2 with more comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added option 2 but commented both option 1 and 2 out. not sure what's the best way to incorporate the switch case. Maybe add the factorization option inside the template of this algorithm?
option 1 and option 2 will pass test_passivityrnea_vs_rnea
test but not test_passivityrnea_compute_coriolis
test since they are not consistent with the implementation in the Coriolis matrix.
option 3 will pass both tests.
include/pinocchio/algorithm/rnea.hxx
Outdated
template<typename ForceDerived, typename M6> | ||
static void | ||
addForceCrossMatrix(const ForceDense<ForceDerived> & f, const Eigen::MatrixBase<M6> & mout) | ||
{ | ||
M6 & mout_ = PINOCCHIO_EIGEN_CONST_CAST(M6, mout); | ||
addSkew( | ||
-f.linear(), mout_.template block<3, 3>(ForceDerived::LINEAR, ForceDerived::ANGULAR)); | ||
addSkew( | ||
-f.linear(), mout_.template block<3, 3>(ForceDerived::ANGULAR, ForceDerived::LINEAR)); | ||
addSkew( | ||
-f.angular(), mout_.template block<3, 3>(ForceDerived::ANGULAR, ForceDerived::ANGULAR)); | ||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should rather try to not duplicate code if possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, I just figured out how to deal with that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reused addForceCrossMatrix
inside passivityRNEA. However, I have to change the order so that passivityRNEA appears after computeCoriolisMatrix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Cfather for adding these features to Pinocchio. It definitely makes sense to have them in Pinocchio.
4badd5e
to
252effb
Compare
…io into passivity_based_rnea_dev
Hi, @jcarpent, apologize for pestering you, is there anything else I can do for this pull request? |
This pull request corresponds to Discussion #2406.
Motivation
which introduces a modified RNEA algorithm for passivity-based controllers. To be more specific, the passivity-based RNEA algorithm computes the following term:
$$\tau = M(q) \ddot{q}_r + C(q, \dot{q}) \dot{q}_r + g(q).$$ $\dot{q}_r = \dot{q}_d + K_r (q_d - q)$ is defined as auxiliary velocity, where $q_d$ is the desired position and $\dot{q}_d$ is the desired velocity. $K_r$ is a positive definite diagonal matrix, that serves as feedback gains.
Here
A more detailed introduction to passivity-based controllers can be found in Section 6.5.3 in Springer Handbook of Robotics.
Changes
The main difference between this and the original RNEA is that it needs to plug in two different velocities in the Coriolis vector. Here are the changes:
passivityRNEA
is introduced ininclude/pinocchio/algorithm/rnea.hpp
. The implementation is ininclude/pinocchio/algorithm/rnea.hxx
.MotionTpl
calledv_r
is introduced ininclude/pinocchio/multibody/data.hpp
, which corresponds to auxiliary joint velocities expressed in the local frame of the joint.unittest/rnea.cpp
to verify the correctness ofpassivityRNEA
. One test compares betweenpassivityRNEA
andrnea
when the auxiliary joint velocities are equal to joint velocities. The other test compares betweenpassivityRNEA
andcomputeCoriolisMatrix
to ensure Christoffel-consistent factorization insidepassivityRNEA
.Notes
Future Work
It might be useful to also implement a passivity-based regressor for inverse dynamics. To be more specific, we can introduce a passivity-based regressor$Y(q, \dot{q}, \dot{q}_r, \ddot{q}_r)$ so that $Y(q, \dot{q}, \dot{q}_r, \ddot{q}_r)\pi$ is equal to the $\pi$ is the dynamic parameters of the robot.
passivityRNEA
output, whereA Matlab version of the code can be found at spatial_v2_extended, provided by @pwensing.