If I use the command roslaunch turtlebot3_gazebo turtlebot3_simulation.launch, the robot can automatically move around the environment's floor. I would like to know the algorithm running behind this autonomous navigation.

I searched and found that this is a "A simple collision avoidance node is prepared which keeps certain distance from obstacles and make turns to avoid collision." as per their documentation. But which algorithm actually run behind it that I am not sure.

Any help would be appreciated.


1 Answer 1


To look at the algorithm behind any ROS package, you can view the source code directly. Using any text editor or IDE, navigate to the package's directory and open the launch file.

In this case, it is likely that your filepath is ~/catkin_ws/src/turtlebot3_gazebo. Or, you can execute roscd turtlebot3_gazebo in a Linux terminal to find the correct filepath otherwise.

Then, navigate to the launch folder and open turtlebot3_simulation.launch. You'll see that there are 2 arguments for cmd_vel and name, a parameter for cmd_vel_topic_name, and a single ROS node linking to turtlebot3_drive. This is the source code.

This leads you to navigate back to the turtlebot3_gazebo folder, then open turtlebot3_drive.cpp under the src folder.

Now you can view the algorithm in its entirety. At a high level, what the robot is doing is understanding its orientation in space through its odometry messages, looking for obstacles using its laser scan, then sending geometry_msgs/Twist messages based on that information to send velocity commands to move around in the simulated environment and avoid obstacles. The bulk of the algorithm is in the controlLoop function.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.