leggedrobotics / ocs2

Optimal Control for Switched Systems
https://leggedrobotics.github.io/ocs2
BSD 3-Clause "New" or "Revised" License
874 stars 225 forks source link

Inconsistency in using derivatives of ZYX Euler angle vs. angular velocity in rnea() and dccrba() of Pinocchio #71

Open YangLiu-tum opened 1 year ago

YangLiu-tum commented 1 year ago

Hi ocs2 team,

Really appreciate for the efforts and work in creating and sharing this valuable repo with the robotics community! It has been a great resource for many developers and researchers!

Recently I have been reading and learning the code of ocs2. And I've just come across an tiny inconsistency in the way the angular velocities are represented in the code. Particularly when calculating the inverse dynamics per rnea() and the derivative of the centroidal momentum matrix Adot using Pinocchio library functions.

https://github.com/leggedrobotics/ocs2/blob/ebde452b10d0eceaac45364f7bb8f0ac1038b637/ocs2_pinocchio/ocs2_centroidal_model/src/CentroidalModelRbdConversions.cpp#L225

https://github.com/leggedrobotics/ocs2/blob/ebde452b10d0eceaac45364f7bb8f0ac1038b637/ocs2_pinocchio/ocs2_centroidal_model/src/CentroidalModelRbdConversions.cpp#L84

In computing the Adot, the vPinocchio is used as function input. The vPinocchio is defined in as follows, where base_orientation_zyx_derivatives is used to represent the change of base orientation. https://github.com/leggedrobotics/ocs2/blob/ebde452b10d0eceaac45364f7bb8f0ac1038b637/ocs2_pinocchio/ocs2_centroidal_model/include/ocs2_centroidal_model/CentroidalModelPinocchioMapping.h#L58

However, when computing the rnea(), the vDesired contains the base angular velocities expressed in the world frame, since it consists of the output from computeBaseKinematicsFromCentroidalModel(). https://github.com/leggedrobotics/ocs2/blob/ebde452b10d0eceaac45364f7bb8f0ac1038b637/ocs2_pinocchio/ocs2_centroidal_model/src/CentroidalModelRbdConversions.cpp#L186

https://github.com/leggedrobotics/ocs2/blob/ebde452b10d0eceaac45364f7bb8f0ac1038b637/ocs2_pinocchio/ocs2_centroidal_model/src/CentroidalModelRbdConversions.cpp#L82

I'm curious as to the convention used here. Is there something crucial I'm missing or some specific requirements related to the Pinocchio library?