Gazebo Simulation Setup for Tekbot
This documentation explains how to set up a basic Gazebo simulation using URDF and XACRO files for a robot called Tekbot, including wheels and a sample environment object (cylinder). It is designed for complete beginners using ROS 2 and Gazebo.
Table of Contents
Overview
The goal of this setup is to simulate a mobile robot (Tekbot) in Gazebo using:
- URDF (Unified Robot Description Format) to describe the robot
- XACRO (XML Macros) to simplify repetitive URDF elements like wheels
- Gazebo plugins for simulation behavior
Project Structure
tekbot_ws/
└── src/
└── tekbot_description/
├── urdf/
│ ├── tekbot.urdf
│ ├── wheel.urdf.xacro
│ └── cylinder.urdf.xacro
├── launch/
│ └── gazebo.launch.py
└── world/
└── my_world.world
URDF and XACRO Explanation
tekbot.urdf
This is the main file that builds the robot by connecting multiple parts together.
Purpose:
- Declares the robot name and base
- Loads the wheel models using macros
- Assembles all parts into one robot
Structure:
Robot Declaration:
xml<robot name="tekbot" xmlns:xacro="http://ros.org/wiki/xacro">
Base Link:
base_footprint
is the main body of the robot. It serves as the central frame.- It is defined as a simple box or cylinder (optional visual/collision not shown in this file).
Including the Wheels:
Two wheels are loaded using the
wheel
macro fromwheel.urdf.xacro
Example:
xml<xacro:wheel name="left_wheel" x="0" y="0.1" z="0.03" yaw="0"/> <xacro:wheel name="right_wheel" x="0" y="-0.1" z="0.03" yaw="0"/>
Joints:
- Joints are added to connect the wheels to the base.
- They are continuous joints, allowing the wheels to rotate endlessly.
- Positioned using the same coordinates defined for the wheels.
wheel.urdf.xacro
This file defines a reusable macro to generate a wheel. It is used in tekbot.urdf
to create the left and right wheels.
Purpose:
- Allows customization of each wheel's position and name
- Reduces code duplication
- Wraps the actual wheel geometry in a macro
Structure:
Macro Declaration:
xml<xacro:macro name="wheel" params="name x y z yaw">
Transform:
- A
<joint>
is defined to position the wheel relative to the base - Uses
<origin>
tag withx
,y
,z
, andyaw
as input parameters
- A
Wheel Link:
- Loads a cylinder shape by calling the
cylinder.urdf.xacro
macro - The
link name
is passed along with pose and size info
- Loads a cylinder shape by calling the
cylinder.urdf.xacro
This file defines the geometry of a cylinder (used for the wheel body).
Purpose:
- Reusable shape for cylindrical objects like wheels
- Abstracts out the URDF for a basic cylinder
Structure:
Macro Declaration:
xml<xacro:macro name="cylinder" params="name radius length">
Link Block:
- Defines the
visual
,collision
, andinertial
properties - Cylinder is defined along the Z-axis
- Defines the
Geometry:
xml<geometry> <cylinder radius="${radius}" length="${length}"/> </geometry>
Material and Color:
- The cylinder is given a gray color using a
<material>
tag
- The cylinder is given a gray color using a