Spawning a cube in gazebo
I tried to spawn a cube in gazebo with the following URDF.
<robot name="simple_box">
<link name="my_box">
<inertial>
<origin xyz="2 0 0" />
<mass value="1.0" />
<inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="100.0" iyz="0.0" izz="1.0" />
</inertial>
<visual>
<origin xyz="0.7 0 0.56"/>
<geometry>
<box size="0.02 0.02 0.02" />
</geometry>
</visual>
<collision>
<origin xyz="0.7 0 0.56"/>
<geometry>
<box size="0.02 0.02 0.02" />
</geometry>
</collision>
</link>
<gazebo reference="my_box">
<material>Gazebo/Blue</material>
</gazebo>
</robot>
with the following entry in my launch file :
<!-- spawn a cube for pick and place -->
<node name="spawn_cube" pkg="gazebo_ros" type="spawn_model" args="-file $(find ur5_pnp)/urdf/object.urdf -urdf -model cube" />
But I see some strange behavior of the cube as it never stops moving. https://youtu.be/HPc2xJXtPhc
I am guessing it has something to do with inertia / mass?
Should your mass origin and visual/collision origin not be the same? I'm not an expert with URDF, I always solve this by try and error. But this movement looks like your mass center is wrong.
Perfect! Works fine
@JohnDoe2991 not always. But for the cube, you're right.
@intelharsh, your inertia tensor is miles away from a real tensor, given that your cube mass is 1 kg.
You can use this xacro to compute a viable inertia tensor to the cube.
@emersonfs can I find a documentation somewhere regarding this?
@emersonfs I used the macro you mentioned and it seems to work fine, though I'll need to read about it to understand what's happening.
This xacro file implements some known moment of inertia tensors for certain shapes. To understand why inertia tensors are so importants to physics, you can read the chapter 6 "Manipulator dynamics", section 3 "Mass distribution", from Craig's book, "Introduction to Robotics".
@emersonfs thanks! Will go through it