Collision origins, and center of mass

Content

Collision origins, and center of mass

In this tutorial, we will be taking a look at how collision origins play a role in determining the center of mass for a link.

Links with one collision shape

When a link only has one collision element, the only reason to modify the collision origin is when the center of mass needs to be moved from the center of that collision shape. 

Basic collision geometries

All of the basic collision shapes are already centered and will have the center of mass in the middle independent of how the dimensions are changed. Here is a sphere that can be modeled to either have the center of mass right in the middle or placed somewhere else. The black outer sphere has a collision shape while the blue inner sphere is only visual and is only there to show where the link origin is.

In this case, the collision does not have an origin, so the center of mass will be kept in the middle of the black sphere.

Here, the collision origin and the visual origin of the black sphere have been moved. However, the center of mass will still be in the origin of the link where the blue sphere is.

Mesh collision geometries

When using a mesh object for the collision shape, an easy way of giving it a correct center of mass is to make sure to export the .glb model with the center of mass in the right position. This can be estimated in Blender by selecting the object(s), right-clicking, and choosing “Set origin” → “Origin to Center of Mass” and then right-clicking again and choosing “Snap” → “Selection to Cursor (keep offset)”. Make sure that the 3D Cursor is at the world origin, you can press SHIFT + C to reset it.

Links with multiple collision shapes

When a link has multiple collision elements, the origins of those collisions need to be adjusted so that the link origin is in the place where the center of mass should be, taking all collision elements into account. Below is an example component that is constructed with multiple collision cylinders. 

In this case, the center of mass (link origin) is far to the right, which gives unexpected results.

Here, the center of mass (link origin) is in the middle of the big cylinders and the results are realistic.