Skip to main content

Section 2: Gazebo Properties

Estimated Reading Time: 9 minutes Bloom's Level: Understand, Apply Key Learning: Physics simulation, inertia, collision geometry


From Visualization to Simulation​

In Section 1, you learned to describe robot structure with links and joints. In RViz, this works greatβ€”you can see the robot in 3D.

But what if you want to simulate the robot? What if you want to:

  • βœ… Drop a robot and have it fall realistically
  • βœ… Simulate motors pushing against gravity
  • βœ… Detect when the gripper hits an object
  • βœ… Calculate how long it takes to move

RViz can't do thisβ€”it's just a visualization tool. You need Gazebo, a physics simulator.

Gazebo needs to know:

  • How much does each part weigh? (mass)
  • How hard is it to spin this part? (inertia)
  • What shape is this part for collisions? (collision geometry)

Without this information:

  • ❌ Robots fall through the floor
  • ❌ Motors spin indefinitely (no gravity resistance)
  • ❌ Collisions don't work
  • ❌ Physics calculations fail

With this information:

  • βœ… Realistic gravity and weight
  • βœ… Motors need real force to move parts
  • βœ… Objects bounce and collide correctly
  • βœ… Simulation matches real robot behavior

Mass and Weight​

What is Mass?​

Mass is how much material is in a link (measured in kilograms).

Light link (easy to move):     mass="0.5"  (500 grams)
Heavy link (hard to move): mass="5.0" (5 kilograms)

Adding Mass to URDF​

<link name="arm_segment">
<inertial>
<!-- Mass in kilograms -->
<mass value="1.5"/>

<!-- Where is the mass centered? -->
<origin xyz="0.5 0 0" rpy="0 0 0"/>
<!-- This says: center of mass is 0.5m along X-axis -->

<!-- Inertia matrix (next section) -->
<inertia .../>
</inertial>

<!-- Visual and collision geometry -->
<visual>...</visual>
<collision>...</collision>
</link>

Estimating Mass​

Real robots: Weigh each part on a scale Simulation: Estimate based on size:

Material density guide:
- Plastic: ~1000 kg/mΒ³
- Aluminum: ~2700 kg/mΒ³
- Steel: ~7850 kg/mΒ³

Example: Aluminum box 0.1m Γ— 0.1m Γ— 0.4m
Volume = 0.004 mΒ³
Mass = 0.004 Γ— 2700 = 10.8 kg

For safety, use:
- Motors/servos: ~0.5-2.0 kg each
- Robot links: ~1-5 kg each
- Gripper: ~0.5-1.0 kg

Inertia Matrix​

What is Inertia?​

Inertia is resistance to spinning. Just like mass resists acceleration, inertia resists angular acceleration.

Simple analogy:

  • Spinning a pencil around its long axis: Easy (low inertia)
  • Spinning a pencil around its short axis: Hard (high inertia)

Same mass, different shapes β†’ different inertia.

The Inertia Matrix​

<inertia
ixx="0.0167" ixy="0.0" ixz="0.0"
iyy="0.0167" iyz="0.0"
izz="0.0167"/>

What each means:

  • ixx: Resistance to rolling (rotation around X-axis)
  • iyy: Resistance to pitching (rotation around Y-axis)
  • izz: Resistance to yawing (rotation around Z-axis)
  • ixy, ixz, iyz: Off-diagonal terms (usually 0 for symmetric shapes)

Computing Inertia for Common Shapes​

Solid Box (width W, depth D, height H, mass M):

ixx = (1/12) Γ— M Γ— (DΒ² + HΒ²)
iyy = (1/12) Γ— M Γ— (WΒ² + HΒ²)
izz = (1/12) Γ— M Γ— (WΒ² + DΒ²)

Example: Box 0.2m Γ— 0.2m Γ— 0.1m, mass 2.0 kg

ixx = (1/12) Γ— 2.0 Γ— (0.2Β² + 0.1Β²) = 0.0167
iyy = (1/12) Γ— 2.0 Γ— (0.2Β² + 0.1Β²) = 0.0167
izz = (1/12) Γ— 2.0 Γ— (0.2Β² + 0.2Β²) = 0.0267

Solid Cylinder (radius R, height H, mass M):

ixx = (1/12) Γ— M Γ— (3Γ—RΒ² + HΒ²)
iyy = (1/12) Γ— M Γ— (3Γ—RΒ² + HΒ²)
izz = (1/2) Γ— M Γ— RΒ²

For quick estimates: Use online inertia calculators or approximations in your CAD software.

Common Mistake: Bad Inertia Values​

<!-- ❌ WRONG: Inertia too small -->
<inertia
ixx="0.00001" ixy="0.0" ixz="0.0"
iyy="0.00001" iyz="0.0"
izz="0.00001"/>

Problem: Gazebo simulator becomes unstable. Robot vibrates or explodes.

<!-- βœ… CORRECT: Reasonable inertia values -->
<inertia
ixx="0.01" ixy="0.0" ixz="0.0"
iyy="0.01" iyz="0.0"
izz="0.01"/>

Rule: Inertia should be roughly: 0.001 Γ— (mass in kg) Γ— (size in meters)Β²


Collision Geometry​

Visual vs. Collision Geometry​

A robot link has two geometries:

  1. Visual geometry: What RViz shows (can be fancy meshes)
  2. Collision geometry: What Gazebo uses for physics (must be simple shapes)
      VISUAL (RViz)              COLLISION (Gazebo)
Detailed 3D mesh Simple box/cylinder
~Pretty to look at ~Fast to compute
~High detail ~Physics accurate

Why Two Geometries?​

Visual meshes are complex (thousands of triangles) β†’ slow physics calculations. Collision shapes are simple (box, cylinder, sphere) β†’ fast physics.

<link name="arm">
<!-- Visual: detailed mesh -->
<visual>
<geometry>
<mesh filename="package://my_robot/meshes/arm.obj"/>
</geometry>
</visual>

<!-- Collision: simple box -->
<collision>
<geometry>
<box size="0.05 0.05 0.4"/> <!-- Approximate with box -->
</geometry>
</collision>
</link>

Collision Shape Types​

Box (rectangular)

<box size="width depth height"/>
<!-- Example: 0.2m Γ— 0.2m Γ— 0.1m -->

Cylinder (circular pipe)

<cylinder radius="0.05" length="0.4"/>
<!-- Example: 5cm radius, 40cm tall -->

Sphere (ball)

<sphere radius="0.1"/>
<!-- Example: 10cm radius -->

Here's a complete link from simple_robot.urdf with all physics properties:

<link name="link_1">
<!-- Physics properties -->
<inertial>
<!-- Mass in kilograms -->
<mass value="0.8"/>

<!-- Center of mass (middle of the segment) -->
<origin xyz="0.5 0 0" rpy="0 0 0"/>

<!-- Inertia for elongated rod -->
<inertia
ixx="0.0133" ixy="0.0" ixz="0.0"
iyy="0.0533" iyz="0.0"
izz="0.0533"/>
</inertial>

<!-- Appearance (what RViz shows) -->
<visual>
<origin xyz="0.5 0 0" rpy="0 0 0"/>
<geometry>
<box size="1.0 0.05 0.05"/> <!-- 1m Γ— 5cm Γ— 5cm -->
</geometry>
<material name="blue">
<color rgba="0.0 0.0 1.0 1.0"/> <!-- Blue color -->
</material>
</visual>

<!-- Physics shape (what Gazebo uses) -->
<collision>
<origin xyz="0.5 0 0" rpy="0 0 0"/>
<geometry>
<box size="1.0 0.05 0.05"/> <!-- Same as visual -->
</geometry>
</collision>
</link>

This describes:

  • An elongated link (like a robot arm segment)
  • Mass: 0.8 kg
  • Shape: Box 1m long, 5cm Γ— 5cm thick
  • Inertia calculated for this shape
  • Blue color in RViz
  • Can collide with other objects in Gazebo

Gazebo-Specific Tags​

Gazebo physics simulation uses some special tags:

Surface Properties​

<gazebo reference="link_1">
<!-- Friction: how much the surface grips -->
<mu1>0.8</mu1> <!-- Friction coefficient: 0.8 (realistic) -->

<!-- Bounciness: how much it bounces -->
<restitution_coefficient>0.1</restitution_coefficient>
</gazebo>

Common values:

  • Rubber on concrete: ΞΌ = 0.8-1.0 (grippy)
  • Metal on metal: ΞΌ = 0.3-0.5 (slippery)
  • Ice: ΞΌ = 0.02-0.1 (very slippery)

Material Definition​

<gazebo reference="link_1">
<material>Gazebo/Blue</material> <!-- Gazebo material -->
</gazebo>

Validation Checklist​

When you add physics properties to URDF:

  • Every <link> with motion has <mass> and <inertia>
  • Inertia is symmetric: ixx, iyy, izz are all positive
  • Off-diagonal inertia (ixy, ixz, iyz) are ~0 for simple shapes
  • Collision geometry is simple (box, cylinder, sphere)
  • Visual and collision geometry are similar
  • Mass values are reasonable (0.1 - 100 kg for most robots)
  • check_urdf passes without errors
# Validate URDF with physics properties
check_urdf simple_robot.urdf
# Output: OK (no errors)

Try It Yourself​

Modify simple_robot.urdf:

  • Change the mass of base_link from 2.0 to 5.0 kg
  • Calculate new inertia values (heavier = larger inertia)
  • Add collision geometry to link_2 (currently has none)
  • Change a collision shape from box to cylinder
  • Validate with check_urdf

Key Takeaways​

βœ… Mass is weight; inertia is resistance to spinning βœ… Inertia matrix has three diagonal values (ixx, iyy, izz) βœ… Collision geometry is simple shapes for fast physics βœ… Visual geometry can be detailed (meshes) for appearance βœ… Gazebo uses both to simulate robot behavior realistically βœ… Use check_urdf to validate physics properties


Next: Visualizing Robots​

Now that your URDF has physics properties, let's visualize it in RViz and Gazebo!

πŸ‘‰ Next: Section 3: Visualizing Robots

Or review:


Section Status: Complete βœ