ROS-Based Obstacle Avoidance with a Two-Wheeled Robot

Robotics • ROS • SLAM • GMapping • Navigation Algorithms

This project explored the design and development of an autonomous two-wheeled robot capable of avoiding obstacles in a simulated environment using the Robot Operating System (ROS). The primary objective was to build a complete pipeline—from robot design to motion planning and real-time decision-making using sensor input.

Building the Robot

The journey began by modeling a basic robot using URDF and XACRO files within ROS. The chassis, wheels, and joints were defined, and the design was visualized using Rviz. Once complete, the robot was deployed in the Gazebo simulation environment with differential drive plugins.

Sensor Integration

We added a laser scanner to provide environmental feedback. Using ROS plugins and real-time data topics, the robot began detecting obstacles through its front-facing sensors. We divided the 180° scan range into five distinct zones for fine-grained obstacle detection.

Motion Planning with the Bug 2 Algorithm

A major highlight was implementing the Bug 2 algorithm for obstacle avoidance. Unlike simpler navigation techniques, Bug 2 maintains a direct path to the goal and only deviates when obstacles are encountered. The robot would "hug" the obstacle boundary until it could safely rejoin the original path.

Mapping the Environment with SLAM

To enable map creation, we incorporated GMapping, a ROS package for Simultaneous Localization and Mapping (SLAM). Using real-time data from the laser scanner and odometry sensors, the robot built a 2D map of its surroundings while navigating.

Key Takeaways

  • Developed a custom robot from the ground up using URDF and XACRO
  • Integrated sensors and extracted real-time data for obstacle tracking
  • Implemented Bug 2 navigation for intelligent pathfinding
  • Built accurate environment maps with GMapping and SLAM
  • Strengthened understanding of state machines and motion planning

Development Stages

Robot design in Rviz

Stage 1: Design

Gazebo simulation

Stage 2: Simulation

Sensor integration

Stage 3: Sensors

SLAM mapping

Stage 4: SLAM