orocos / orocos_kinematics_dynamics

Orocos Kinematics and Dynamics C++ library
710 stars 409 forks source link

Scaling of RigidBodyInertia values #434

Closed Afrobeat closed 1 year ago

Afrobeat commented 1 year ago

Hello,

I realized that when creating a RigidBodyInertia the input values of the COM (h) and the Rotational Inertia (I) are scaled by some kind of value. Here's an example for the values of the COM when initializing a new RigidBodyInertia: Outside of RigodBodyInertia: KDL::Vector COM = {-29.110382080078125, -0.00011015097697963938, 93.30975341796875}

Inside RigidBodyInertia: COM = {-299.4989056680908, -0.001133275989745598, 960.00694734838862}

Same for the Rotational Inertia values. Is there a reason for this? And is there a way to create a new RigidBodyInertia without the scaling? Since I've got the feeling that this scaling might be the reason for huge torque values I get when using the KDL::ChainIdSolver_RNE.

I would be very happy about any help.

MatthijsBurgh commented 1 year ago

Are you using the constructor correctly? Please check these docs

Also note that getCOG returns h/m see here

Afrobeat commented 1 year ago

Thanks for the reply and the links to the documentation.

I actually misunderstood the documentation and did not realize that the RigidBodyInertia does not take the COM but a vector between a reference point and the COM (oc).

If I understand the documentation correctly getCOM() should return the actual COM. However, it returns oc. Is this how it should be?

MatthijsBurgh commented 1 year ago

The COM/COG is the mass weighted center point, so it is a vector. Just like any point this is relative to another point.

So I don't understand your comment about it not taking the COM as argument. You probably assumed a different reference frame. Or did you assume it takes the mass scaled COM vector? Please elaborate

Internally it stores the COM vector scaled by the mass, h. This is probably done for code optimization.

in getCOG() it divides h by the mass, so you get the COM vector again.