osrf / gazebo_tutorials

Tutorials for gazebo
http://gazebosim.org/tutorials
145 stars 71 forks source link

[inertia/tutorial.md] possible wrong matrix correction in "Getting the Inertia Tensor" section #49

Open osrf-migration opened 8 years ago

osrf-migration commented 8 years ago

Original report (archived issue) by Alessandro Tondo (Bitbucket: alextoind).


I've done few experiments on getting the inertia tensor of some .dae meshes following the inertia/tutorial.md and I found out something strange.

It is said that scaling by a factor S (e.g 10 per axis with the default uniform scaling flag enabled, thus a factor of 1000 on the mesh volume), the scaled inertia matrix Iscaled is such that Iscaled = S^2 * I. However, it appears to be Iscaled = S^5 * I, where in the above example S = 10 (not 1000). I don't know if it is physically correct, but I've tested with several values of S and it has a linear dependancy with the parameter S^5.

It could be possible that the value in the tutorial represents the volume scaling (e.g. 1000) and that its square has been confused with the previous S^5 (actually in many cases the result is very similar: just one order wrong in the above example, but it could be greater depending on the scale factor).

Last but not least I think that, in the following, s is not the reciprocal but exactly the scaling factor.

The only thing that remains is to copy the inertia tensor into a mathematical software and multiply it by 1/s^2 where s is the reciprocal of the scale used for upscaling the model.

Am I wrong?

Here are some tests:

Scale 1:
Vol: 0.000152
Inertia Tensor is :
| 0.000000 0.000000 -0.000000 |
| 0.000000 0.000000 -0.000000 |
| -0.000000 -0.000000 0.000000 |

Scale: 10 (each direction)
Vol: 0.151635
Inertia Tensor is :
| 0.012751 0.000255 -0.000250 |
| 0.000255 0.017781 -0.000309 |
| -0.000250 -0.000309 0.010201 |

scale: 100 (each direction)
Vol: 151.634659
Inertia Tensor is :
| 1275.088989 25.531651 -24.984613 |
| 25.531651 1778.113037 -30.901112 |
| -24.984613 -30.901112 1020.051270 |

scale: 1000 (each direction)
Vol: 151634.656250
Inertia Tensor is :
| 127508912.000000 2553160.000000 -2498458.500000 |
| 2553160.000000 177811296.000000 -3090116.500000 |
| -2498458.500000 -3090116.500000 102005104.000000 |

Scale: 18.7378 (each direction)
Vol: 0.997595
Inertia Tensor is :
| 0.294533 0.005898 -0.005771 |
| 0.005898 0.410726 -0.007138 |
| -0.005771 -0.007138 0.235622 |
osrf-migration commented 8 years ago

Original comment by Steve Peters (Bitbucket: Steven Peters, GitHub: scpeters).


Well the units of inertia are mass * length^2. If the dimensions are scaled by s, then s^2 seems reasonable based on length^2. I do wonder, though, if the mass is changed by this scaling as well. I'm not sure how meshlab makes that calculation.

osrf-migration commented 8 years ago

Original comment by Alessandro Tondo (Bitbucket: alextoind).


You are absolutely right and that could be the point. Indeed, from the tutorial (few rows above):

In MeshLab, there is no way to tell what the mass of the model is.

Therefore the S^5 of the tests could come from the computation of the mass: S^2 from the length^2 term and S^3 from the "scale" of the mass, i.e. a contribution of S from each direction (with the hypothesis of constant density).

osrf-migration commented 8 years ago

Original comment by Steve Peters (Bitbucket: Steven Peters, GitHub: scpeters).


I think you're right that it should be S^5 and not S^2. I just tested with a clean spherical mesh and it seems to be using a density value of 1 with mass proportional to volume. I'll update the tutorial accordingly.

osrf-migration commented 8 years ago

Original comment by Alessandro Tondo (Bitbucket: alextoind).


Perfect, thank you for your time.

osrf-migration commented 8 years ago

Original comment by Steve Peters (Bitbucket: Steven Peters, GitHub: scpeters).


see pull request #333

osrf-migration commented 8 years ago

Original comment by Alessandro Tondo (Bitbucket: alextoind).


Well done!

I also appreciate the duplicate faces note which I didn't even know it could happen.

osrf-migration commented 8 years ago

Original comment by Steve Peters (Bitbucket: Steven Peters, GitHub: scpeters).


I didn't know about the duplicate faces issue either. I found it while trying to use that robocub ball as an example, but it was giving big numbers. It's helpful when you find bugs while writing tutorials!