Skip to the content.

🚜 Autonomous 4WD Mobile Robot in ROS 2 & Gazebo

ROS 2 Gazebo License: MIT GitHub Pages

An autonomous 4-wheel drive (4WD) skid-steer mobile robot developed in ROS 2 and Gazebo. Featuring real-time sensor fusion across LiDAR and RGB camera streams, ROS-Gz message bridging, 2D SLAM occupancy grid mapping, and a reactive Finite State Machine (FSM) obstacle avoidance navigator.


🌟 Key Features


🏛️ System Architecture

flowchart LR
    GZ[Gazebo Sim Environment] <-->|ros_gz_bridge| ROS[ROS 2 Core]
    ROS --> SENSOR[/scan LiDAR & /odom/]
    SENSOR --> NAV[SimpleNavigator Node]
    GOAL[Goal Pose /goal_pose] --> NAV
    NAV --> CMD[/cmd_vel Velocity Commands/]
    CMD -->|ros_gz_bridge| GZ
    ROS --> RVIZ[RViz2 Visualization]

📁 Repository Structure

wheeled_robot_ros2/
├── config/
│   └── ros_gz_bridge.yaml          # Topic mappings between Gazebo & ROS 2
├── launch/
│   ├── display.launch.py           # RViz visualization & robot_state_publisher
│   └── gazebo.launch.py            # World spawn, bridge launch & simulation
├── map/
│   ├── map_1784564885.pgm          # Occupancy grid map bitmap
│   └── map_1784564885.yaml         # Map metadata and resolution config
├── nodes/
│   └── obstacle_avoidance.py       # FSM reactive navigator & obstacle avoider
├── rviz/
│   ├── camera.rviz                 # RViz configuration with camera stream
│   └── config.rviz                 # Base RViz configuration
├── urdf/
│   └── four_wheel.urdf             # 4WD robot kinematics & sensor URDF
├── worlds/
│   └── world.sdf                   # Gazebo simulation world with obstacles
├── CMakeLists.txt                  # Build configuration
└── package.xml                     # ROS 2 package metadata

⚙️ Hardware & Sensor Bridge Mapping

ROS 2 Topic Gazebo Topic Message Type Direction
/clock /clock rosgraph_msgs/msg/Clock Gazebo ➔ ROS 2
/cmd_vel /cmd_vel geometry_msgs/msg/Twist ROS 2 ➔ Gazebo
/odom /odom nav_msgs/msg/Odometry Gazebo ➔ ROS 2
/tf /model/four_wheel/tf tf2_msgs/msg/TFMessage Gazebo ➔ ROS 2
/scan /scan sensor_msgs/msg/LaserScan Gazebo ➔ ROS 2
/joint_states /joint_states sensor_msgs/msg/JointState Gazebo ➔ ROS 2
/camera/image_raw /camera/image_raw sensor_msgs/msg/Image Gazebo ➔ ROS 2

🚀 Quick Start Guide

1. Requirements

2. Build the Package

mkdir -p ~/ros2_ws/src
cd ~/ros2_ws/src
git clone https://github.com/Arkz-Deepak/wheeled_robot_ros2.git
cd ~/ros2_ws
colcon build --symlink-install --packages-select wheeled_robot_ros2
source install/setup.bash

3. Launch the Simulation

Launch Gazebo world and bridge all sensor streams:

ros2 launch wheeled_robot_ros2 gazebo.launch.py

4. Launch RViz Visualization

ros2 launch wheeled_robot_ros2 display.launch.py

5. Run the Autonomous FSM Navigator

ros2 run wheeled_robot_ros2 obstacle_avoidance.py

Send a goal pose via RViz 2D Goal Pose or publish directly:

ros2 topic pub --once /goal_pose geometry_msgs/msg/PoseStamped "{header: {frame_id: 'map'}, pose: {position: {x: 2.0, y: 1.5, z: 0.0}}}"

👨‍💻 Author