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:
- Visual geometry: What RViz shows (can be fancy meshes)
- 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 -->
Complete Example: Link with Physicsβ
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_urdfpasses 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_linkfrom 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 β