You're reading the documentation for a development version. For the latest released version, please have a look at Iron.
Goal: Install the
webots_ros2 package and run simulation examples on Ubuntu.
Tutorial level: Advanced
Time: 10 minutes
webots_ros2 package provides an interface between ROS 2 and Webots.
It includes several sub-packages, including
webots_ros2_driver, which allows you to start Webots and communicate with it.
This interface is used in most of the following tutorials, so it is required to install it beforehand.
Other sub-packages are mainly examples that show multiple possible implementations using the interface.
In this tutorial, you are going to install the package and learn how to run one of these examples.
Alternatively, you can also let
webots_ros2 download and install Webots automatically.
This option appears when you launch an example of the package and no Webots installation is found.
If you have installed different versions of Webots on your computer,
webots_ros2 will look for Webots at the following locations (in this order):
ROS2_WEBOTS_HOMEenvironment variable is set, ROS 2 will use the Webots in this folder, regardless of its version.
WEBOTS_HOMEenvironment variable is set, ROS 2 will use the Webots in this folder, regardless of its version.
If none of these variables is set,
webots_ros2will look for Webots in the default installation paths for a compatible version:
If Webots couldn’t be found,
webots_ros2will show a window offering the automatic installation of the latest compatible version of Webots.
You can either install the official released package, or install it from the latest up-to-date sources from Github.
Run the following command in a terminal.
sudo apt-get install ros-rolling-webots-ros2
Create a ROS 2 workspace with its
mkdir -p ~/ros2_ws/src
Source the ROS 2 environment.
Retrieve the sources from Github.
cd ~/ros2_ws git clone --recurse-submodules https://github.com/cyberbotics/webots_ros2.git src/webots_ros2
Install the package dependencies.
sudo apt install python3-pip python3-rosdep python3-colcon-common-extensions sudo rosdep init && rosdep update rosdep install --from-paths src --ignore-src --rosdistro rolling
Build the package using
Source this workspace.
The following instructions explain how to start a provided example.
First source the ROS 2 environment, if not done already.
WEBOTS_HOME environment variable allows you to start a specific Webots installation.
If installed from sources, source your ROS 2 workspace, if not done already.
cd ~/ros2_ws source install/local_setup.bash
Use the ROS 2 launch command to start demo packages (e.g.
ros2 launch webots_ros2_universal_robot multirobot_launch.py