Calculating inertial matrix for Gazebo
I am having issues following the tutorial to calculate the inertial matrix for my gripper. This is the behaviour I see. I am able to successfully create a config package with PR2 gripper, so I am pretty sure it is because of the inertial matrix.
In Meshlab, following are the values I get at no-scale:
Mesh Bounding Box Size 0.164416 0.063248 0.077500
Mesh Bounding Box Diag 0.192456
Mesh Volume is 0.000214
Mesh Surface is 0.089074
Thin shell barycenter -0.040913 -0.000254 0.039031
Center of Mass is -0.041006 -0.000043 0.037458
Inertia Tensor is :
| 0.000000 -0.000000 0.000000 |
| -0.000000 0.000001 0.000000 |
| 0.000000 0.000000 0.000000 |
Principal axes are :
| 0.938629 0.011849 0.344725 |
| 0.004914 0.998849 -0.047710 |
| -0.344893 0.046476 0.937491 |
axis momenta are :
| 0.000000 0.000001 0.000001 |
For a scale of 100, following are the values I get :
Mesh Bounding Box Size 16.441637 6.324847 7.750000
Mesh Bounding Box Diag 19.245613
Mesh Volume is 214.333633
Mesh Surface is 890.744385
Thin shell barycenter -4.091284 -0.025389 3.903062
Center of Mass is -4.100575 -0.004325 3.745764
Inertia Tensor is :
| 1597.194946 -17.950985 1307.758423 |
| -17.950985 5213.373047 9.511752 |
| 1307.758423 9.511752 4675.780273 |
Principal axes are :
| 0.938629 0.011848 0.344725 |
| 0.004914 0.998849 -0.047710 |
| -0.344893 0.046475 0.937491 |
axis momenta are :
| 1116.573364 5213.602539 5156.172363 |
How do I use these values? I didn't quite understand the scaling part of the tutorial. Also, ideally, shouldn't the simulation work when I consider the gripper to be almost weightless?
<inertial>
<mass value="0.001" />
<inertia ixx="0.001" ixy="0" ixz="0"
iyy="0.001" iyz="0"
izz="0.001" />
</inertial>
A unity matrix or the above value as well gives the same behaviour as in the video.
Edit 1:
I have tested the macro mentioned by @Stefan Kohlbrecher. Also, I divided the inertia matrix given by Meshlab by volume which gives me :
<inertial>
<mass value="1.0" />
<origin xyz="-0.041006 -0.000043 0.037458" />
<inertia ixx="0.000746353" ixy="0" ixz="0"
iyy="0.002436156" iyz="0"
izz="0.002184945" />
</inertial>
Still I observe the same behaviour. Does Gazebo need the inertia matrix wrt origin or wrt center of mass?
Edit 2:
@MarioSelvaggio 's solution seems to work perfectly fine. The arm is stable and I am also able to plan and execute trajectories. But the solution only works when in my final urdf file I translate the gripper :
<joint name="gripper_joint" type="fixed">
<parent link="ur5_arm_ee_link" />
<child link = "gripper" />
<origin xyz="0.04100575 0.00004325 -0.03745764" rpy="0.0 4.71 3.14" />
</joint>
Observe that the sign of origin xyz
has been inverted. Here's how it looks: http://i.imgur.com/7hE8OdD.png
For rest of the cases, the simulation remains unstable ...