Inertia calculation problem


I noticed that the formula used in the calculation py file is the situation if the origin at the center of mass, or the geometry center. But I guess the convention to set a link origin is at the tip where connects with the joint but not the CoM. Will this cause any problem?



Not at all. You can specify in Gazebo to use a different pose for the inertia (CoM) from the visual and collision elements.

    <!-- NOTE:reflect==-1 for right side, reflect==1 for the left side -->
    <mass value="6.01769" />
    <origin xyz="${0.5*((reflect+1)*ual_xyz1+(1-reflect)*uar_xyz1)} ${0.5*((reflect+1)*ual_xyz2+(1-reflect)*uar_xyz2)} ${0.5*((reflect+1)*ual_xyz3+(1-reflect)*uar_xyz3)}" />
    <inertia  ixx="${0.5*((reflect+1)*ual_ixx+(1-reflect)*uar_ixx)}"
              izz="${0.5*((reflect+1)*ual_izz+(1-reflect)*uar_izz)}" />

    <origin xyz="0 0 0" rpy="0 0 0" />
      <mesh filename="package://pr2_description/meshes/upper_arm_v0/upper_arm.dae"  />

    <material name="Green" />

    <origin xyz="0 0 0" rpy="0 0 0" />
      <mesh filename="package://pr2_description/meshes/upper_arm_v0/upper_arm.stl"  />


Here you see that the inertial and the visual/collision have different origins ;).

Have a look ath these examples of URDF and you will see a lot of examples concerning this matter:

Thanks for your reply, but I’m still a bit confused about the origins of inertia, visual, and collision.

Using the first case in the Building the Visual Robot with URDF chapter and the tutorial here: Inertial/Visual/Collision origin is the reference frame of the element with respect to the reference frame of the link.

  1. The origin of the base_link origin is w.r.t the world frame and the origin of the roll_M1_link is defined w.r.t the joint(child) frame. Am I correct?

  2. When I need to import a 3D cad model into the gazebo world, there is one step to set the origin of the model. Definition of it is “the location of this point determines where the object is located in 3D space”, and there is another parameter Transform in blender need to be set, I checked in the Rviz that the TF frame will follow the setting of Transform in blender. But I don’t understand why the origin and Transform can be two different points, in my understanding, the origin should be the origin of the Transform in blender. Besides, Is the Transform in belnder also the reference frame of the link?

  3. I assume the inertia parameter will be used for calculating the controller torque and you said that the origin of inertia can be different from the origins of visual and collision. Does that mean we always set the inertia origin at the CoM no matter how the visual origin is defined and the ROS will figure out the actual inertia with the TF frame itself? Or the inertia origin relates to the visual origin?

In this case, the visual origin is modified so the TF frame is at the bottom of the cylinder, and if we want to use the given formula in that py file, we have to set the inertia origin (0, 0, h/2). Otherwise, we have to consider the parallel axis theorem with the default inertia origin (0, 0, 0)


So point by point:

  1. So the refference frame of a link is defined inside the link itself. Inside a lnk you have three distinct elements ( Inertial, visual an dcollision ). You can change all of them. If you dont change them they will be set to xyz= 0 0 0 and rpy= 0 0 0 ( so no modification to theexisting ones). This means that for example if the visual mesh used has fram in certain position, thats where it will be. If you change it it ill move that frame, so you will have the “isplacement” of the frame of the mesh itself lus the one you put in the pose tag. Once that is set, it also affect the way you position the joint. Here you are moving the child frame w.r.t. the parent frame.

  2. One thing is the frame of the visual mesh with respect the mesh itself ( thats the one that blender sets and the one you are changing in the ose tag of the visual element ) and another is pose in the world ( thats the one you put in the world file, which positions that element in the scene ).

  3. Not exactly. The visual element plays NO role in the inertias. The only thing that affects innertiats is what is inside of the inertial tag. You can have a really wierd c¡shape in the visual tag an dthen a completely different inertial element.