RigidBodyDynamics URDF inertia values

I am building my models directly from a relational database and the RigidBody components are loaded with those inertia values. (I can simply call up different configurations of robot arm with various numbers of links/joints.)

I check that every RigidBody component has received the correct data using spatial_inertia(rigidLink[iLink]) in a print statement. They’re all correct.

When the Mechansim is build, I output a URDF file, however, some of them are wrong, mostly the diagonal terms. But weirdly not all of them. Much is correct, i.e the plant names match up with the masses and most of the inertia terms. E.g. I get

<inertia ixx="37.799" ixy="0.0003302" ixz="-0.144" iyy="-152.01851737749996" iyz="-5.652e-6" izz="-173.30051737749994"/>

But it should be:

<inertia ixx="37.799" ixy="0.0003302" ixz="-0.144" iyy="243.38" iyz="-5.652e-6" izz="222.098"/>

The original inertia tensor has eigenvalues that satisfy the triangle inequality but the URDF values don’t.

At least one of the inertia tensors is shown correctly in URDF form.

The simulation runs fine for all possible configurations and looks OK.

I am assuming that this is a bug in my code but it just run through loops so it uses the same instruction for each RigidBody. And anyway, they are correctly loaded! I thought it might be a CoM problem (wrong frame) but changing these had no effect on the output. (I checked using meld - the files are identical.)

Is there any reason that the URDF inertia terms should be different? What have I done??

Thanks,

Roger

Hmm, that’s very weird. The diagonal terms should of course never be negative. Could you open an issue with RigidBodyDynamics.jl and if possible provide a minimal running example that reproduces this behavior?

Thank you. I’ll do some more digging before I bat it across as an issue. Your answer tells me it’s on my side!

Ref More asserts in URDF write.jl · Issue #520 · JuliaRobotics/RigidBodyDynamics.jl · GitHub.