Home

ROS2 Basics Applied: Autonomous Patrol with Turtlebot3 (II)

Developing and Deploying Advanced ROS2 Services and Actions for Robot Control

24 March 2024

Introduction

This project stands as a culmination of the skills and knowledge acquired in the ROS2 Basics course, applied to both a simulated and a real-world scenario using the Turtlebot3 robot. It highlights the transition from simulation to real-world application, involving the development of ROS2 services and actions to control the robot’s navigation in a given environment. The project underscores the capability to operate the robot remotely, executing tasks in Barcelona, Spain, from a simulation environment, thereby showcasing the power of ROS2 in robotics development.

Objectives

  • To implement ROS2 services that analyze laser sensor data to guide robot movement decisions.
  • To create ROS2 actions for sending the robot to specific goal positions.
  • To demonstrate seamless transition from simulated to real-world robot control.

Tools and Technologies

  • Programming Languages: C++
  • Frameworks and Libraries: ROS2 actions & services, Gazebo for simulation
  • Hardware: Turtlebot3 Robot
  • Version Control: Git

Source Code

Process and Development

The project’s execution was divided into two primary tasks, each focusing on different aspects of robot control through ROS2.

Task 1: Services for Robot Navigation

Simulation Setup: Commenced with launching the Turtlebot3 robot simulation in Gazebo, preparing the ground for developing navigation services.

Service Development: Created a ROS2 service server in C++ (direction_service.cpp) that receives laser data from the Turtlebot3 and analyzes it to determine the safest direction for the robot to move, enhancing its obstacle avoidance capabilities.

Integration with Patrol Behavior: Modified the existing patrol behavior script (patrol_with_service.cpp) to include calls to the newly developed ROS2 service, allowing for dynamic obstacle avoidance based on real-time sensor data. After successfully testing the navigation node in simulation, it was deployed to the real robot.

Task 2: Actions for Position Goals

Action Server Creation: Developed an action server (go_to_pose_action.cpp) that accepts goal positions and navigates the Turtlebot3 to these locations using odometry and velocity commands, showcasing advanced robot control techniques.

Real-world Deployment: After rigorous testing in the simulation, the project was deployed to control a real Turtlebot3 robot. This involved remote connection and operation, demonstrating the practical application of ROS2 actions and services beyond a simulated environment.

Results

The project successfully demonstrated the application of ROS2 services and actions in controlling the Turtlebot3 robot, both in simulation and in a real-world environment. It highlighted the capability of ROS2 to facilitate complex robotics operations, including navigation and obstacle avoidance, in diverse environments.

Key Insights

  • Having a proper understanding of linear algebra proves to be crucial when dealing with robot orientation.
  • It is necessary to account for topic rate when deploying an algorithm to real robots.