Developing and Testing an Obstacle-Avoidance Robot in Simulation and Real-World Scenarios
20 March 2024
Embarking on a journey to bridge the gap between theoretical knowledge and practical application, this project showcases the culmination of skills acquired from the ROS2 basic concepts. By commanding a Turtlebot3 robot, both in a simulated environment and in reality, the project demonstrates the capability to develop autonomous behaviors that enable a robot to patrol a designated area while adeptly avoiding obstacles.
The development process is segmented into initial simulation setup, programming the patrol behavior, and real-world testing.
Initial Actions: The simulation environment in Gazebo is set up to mimic real-world scenarios, where the robot’s patrol behavior can be tested and refined. This involves launching the simulation through ROS2 commands and ensuring the virtual Turtlebot3 is ready for programming.
Creating the ROS2 Package: A package named robot_patrol
was developed, containing a C++ file patrol.cpp
that defines the patrol behavior. This includes subscribing to laser sensor topics to navigate and avoid obstacles based on the data received.
Algorithm Implementation: A simplistic algorithm was designed to analyze 180 degrees in front of the robot, determining the safest direction by identifying the largest distance free of obstacles. This direction informs the robot’s movement, ensuring continuous patrolling without collisions.
Testing in Simulation: Before real-world deployment, the patrol behavior was rigorously tested in the simulation to ensure reliable obstacle avoidance.
Deployment on the Real Robot: With successful simulation tests, the program was then executed on an actual Turtlebot3 robot. This real-world test was conducted remotely, with the robot located in Barcelona, Spain. Adjustments and debugging were carried out in real-time to adapt the patrol behavior to the nuances of the physical environment.
The project achieved its goal of developing an autonomous patrol behavior that effectively navigates and avoids obstacles, both in a simulated environment and in real-world testing. The seamless transition from simulation to real-world application underscores the robustness of the developed program and the adaptability of ROS2 for robot programming.