This project demonstrates the creation of a differential drive robot simulation in ROS 2. It includes a myrobot_description package to load and visualize the robot in RViz, and a separate myrobot_gazebo package with an empty world to spawn the robot in Gazebo. The project integrates velocity command plugins (/cmd_vel) and enables robot control using the teleop_twist_keyboard package to verify movement in the simulated environment.
Click here for the simulation video.
- Ubuntu: 22.04 LTS
- ROS 2: Humble Hawksbill
- Gazebo: Ignition Garden
Install required ROS 2 packages:
sudo apt install ros-humble-robot-state-publisher \
ros-humble-joint-state-publisher \
ros-humble-xacro \
ros-humble-teleop-twist-keyboard \
ros-humble-ros-gz-sim \
ros-humble-ros-gz-bridge- Create Workspace and Clone Repository
mkdir -p my_ws/src && cd my_ws/src
git clone https://github.com/yashikasharma0301/diff_drive_robot_control.git .- Build the Workspace
cd ..
colcon build- Source the Workspace
source install/setup.bash- Launch Robot Visualization in RViz
ros2 launch myrobot_description myrobot.launch.py
If the robot model doesn't load automatically in RViz, click on the RobotModel dropdown arrow in the RViz panel and type /robot_description infront of Description Topic
- Launch Gazebo Simulation
Source the workspace again if opening a new terminal and run:
ros2 launch myrobot_gazebo myrobot.launch.pyNOTE: If using Gazebo Harmonic, just change the gazebo launch command in launch file to "cmd=['gz', 'sim', world_path, '--verbose', '-r'],"
- Control the Robot
In a new terminal, start keyboard teleoperation:
ros2 run teleop_twist_keyboard teleop_twist_keyboard
Control Keys:
i- Move forwardk- Stopj- Turn leftl- Turn rightu- Move forward + turn lefto- Move forward + turn rightm- Move backward + turn left.- Move backward + turn right,- Move backward
Robot Model: This project uses a URDF model adapted from the TortoiseBot example in the OSRF ROS Book. The original model has been modified for ROS 2 Humble and Gazebo Ignition integration.
Original Authors: Open Source Robotics Foundation (OSRF)