stack-of-tasks / pinocchio

A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
http://stack-of-tasks.github.io/pinocchio/
BSD 2-Clause "Simplified" License
1.7k stars 366 forks source link

About \dot {q} in Pinocchio #2243

Closed Czworldy closed 1 month ago

Czworldy commented 2 months ago

My question is very simple, we have a float-based robot, and we add the floating-base to pinocchio model by the code

// add 6 DoF for the floating base
pinocchio::JointModelComposite jointComposite(2);
jointComposite.addJoint(pinocchio::JointModelTranslation());
jointComposite.addJoint(pinocchio::JointModelSphericalZYX());
pinocchio::ModelTpl<double> model;
pinocchio::urdf::buildModel(urdfTree, jointComposite, model);

and when call pinocchio::forwardKinematics(model, data, qPinocchio, vPinocchio); or pinocchio::rnea(mode, data, qPinocchio, vPinocchio, aPinocchio......);functions, we konw that the qPinocchio.head<6>() should be [x, y, z, z-,y-,x-euler angles] but how about qPinocchio and aPinocchio? Should we use Euler Angles Zyx (second) Derivatives or Global Angular Velocity /Acceleration? Thanks a lot!

ManifoldFR commented 1 month ago

Hello ! Thanks for your interest in Pinocchio.

If you have a floating-base robot defined using the free-flyer joint model, then the corresponding part of the $q$ configuration vector is actually the xyz for the base position followed by the 4D quaternion corresponding the orientation of the robot (so, not the Euler angles). Notably, this means the part of $q$ you want is actually qPinocchio.head<7>(). Pinocchio does not use Euler angles, but the appropriate double-covering quaternion representation (although you can convert between these representations using tools provided in the library).

For the velocity and acceleration vectors $v$ you'll get the 6D $(v_x,v_y,v_z,\omega_x,\omega_y,\omega_z)$ spatial velocity from vPinocchio.head<6>().