webots
webots copied to clipboard
CoM and Inertia matrix is not computed correctly until reload
Hello,
CoM and Intertia matrix is not computed correctly until reload
To reproduce :
Load the following world : (not that the Shape, look like à box, but, it's actually a IndexedFaceSet) The bug doesn't appear if the shape is a regular Box (not tested with others types of shapes)
World
#VRML_SIM R2022b utf8 WorldInfo { } Viewpoint { orientation -0.027788337355049333 0.03381763434421385 0.9990416287194458 0.7555422126100662 position 116.74824686377895 135.81333526873226 1.3837473743471866 } TexturedBackground { } TexturedBackgroundLight { } Solid { translation 120.518 138.54 1.14327 rotation 0.12600000613053045 0.9475610461035838 0.293687014289342 -0.8503153071795859 children [ DEF t Transform { translation -0.045 0.652 0.005 rotation 0 0 -1 4.712389 children [ Shape { geometry IndexedFaceSet { coord Coordinate { point [ 0.351 0.369 0.05 -0.239 0.369 0 -0.239 0.369 0.05 0.351 0.369 0 0.351 -0.385 0 0.351 -0.385 0.05 -0.239 -0.385 0.05 -0.239 -0.385 0 ] } coordIndex [ 0, 1, 2, -1, 0, 2, 6, -1, 0, 3, 1, -1, 0, 4, 3, -1, 0, 5, 4, -1, 0, 6, 5, -1, 1, 3, 7, -1, 1, 6, 2, -1, 1, 7, 6, -1, 3, 4, 7, -1, 4, 5, 6, -1, 4, 6, 7, -1 ] } } ] } ] physics Physics { density -1 mass 1 } }
Select the solid, and the tab "Mass", see :
That's ok, the Solid have no bounding object
In the bounding object, "USE t" (to use the shape of the box)
Select the solid, and the tab "Mass", see :
The CoM and matrix are wrong
Save the world, reload, select the solid, and the tab "Mass", see :
Now the CoM and matrix are correct.
Expected behavior : CoM and matrix should get the right value since we change to bounding object, without needing to reload.
I figure out that simply changing the value of translation of the transform node show the same issue : we need to reload the world to get the correct CoM and Matrix of inertia.
The issue comes from the fact that at load the ODE trimesh position used to compute the mass is relative (finalization is still not complete and the trimesh final absolute position is still not available in the ODE object). On the other hand when applying changes after the world has been loaded the absolute position of the trimesh is used by ODE to compute the mass.