Skip to content

Navigate TurtleBot3

Darko Lukić edited this page Jan 13, 2021 · 19 revisions

TurtleBot3 Burger Navigation

Before proceeding, make sure you have the webots_ros2 package installed — Getting Started.

In this tutorial, we want to show you how to navigate TurtleBot3 Burger in Webots simulation. You will see that Webots uses a standard ROS2 interface that can be used with the TurtleBot3 Navigation2 package without modifications.

Install turtlebot3_navigation2 Package for ROS2

sudo apt install ros-foxy-turtlebot3-navigation2

# Patch the `turtlebot3_navigation2` package
sudo sed -i 's/nav2\_bringup\_launch.\py/bringup\_launch.\py/g' /opt/ros/foxy/share/turtlebot3_navigation2/launch/navigation2.launch.py
or compile the package from source

To compile the turtlebot3_navigation2 package do the following:

source /opt/ros/${ROS_DISTRO}/local_setup.bash

# Retrieve the sources
cd /path/to/ros2_ws
git clone -b ${ROS_DISTRO}-devel https://github.com/ROBOTIS-GIT/turtlebot3.git src/turtlebot3

# Check dependencies
rosdep update
rosdep install --from-paths src --ignore-src --rosdistro ${ROS_DISTRO}

# Building packages
colcon build --packages-up-to turtlebot3_navigation2
source install/local_setup.bash

Run Webots and Navigation2

Once the turtlebot3_navigation2 package is ready you can launch a Webots simulation:

ros2 launch webots_ros2_turtlebot robot_launch.py
before webots_ros2 1.0.3
ros2 launch webots_ros2_core robot_launch.py \
    executable:=webots_differential_drive_node \
    node_parameters:=$(ros2 pkg prefix webots_ros2_examples --share)/resource/turtlebot3_burger.yaml \
    world:=$(ros2 pkg prefix webots_ros2_examples --share)/worlds/turtlebot3_burger_example.wbt

In the second terminal, launch Navigation2 as:

export TURTLEBOT3_MODEL='burger'
ros2 launch turtlebot3_navigation2 navigation2.launch.py \
    use_sim_time:=true \
    map:=$(ros2 pkg prefix webots_ros2_turtlebot --share)/resource/turtlebot3_burger_example_map.yaml
before webots_ros2 1.0.3
export TURTLEBOT3_MODEL='burger'
ros2 launch turtlebot3_navigation2 navigation2.launch.py \
    use_sim_time:=true \
    map:=$(ros2 pkg prefix webots_ros2_examples --share)/resource/turtlebot3_burger_example_map.yaml

The command will initialize the Navigation2 package and open RVIz2. Make sure you set the initial pose by clicking 2D Pose Estimate button in RViz2 or by executing the following command:

ros2 topic pub --once /initialpose geometry_msgs/msg/PoseWithCovarianceStamped '{
    "header": { "frame_id": "map" },
    "pose": {
        "pose": {
            "position": { "x": 0.0, "y": 0.0, "z": 0.0 },
            "orientation": { "x": 0.0, "y": 0.0, "z": 0.0, "w": 1.0 }
        }
    }
}'

On the official TurtleBot3 website you can find more information about navigation.

TurtleBot3 Burger Navigation

Clone this wiki locally