How to Install and Demo the Webots Robot Simulator for ROS 2


In this tutorial, I will show you how to install, build, and demo the ROS 2 package for Webots, the free open-source 3D robot simulator created by Cyberbotics Ltd. Installing Webots was a bit difficult, so it is important you follow the steps below click-by-click, command-by-command so that everything installs properly. Here is what the demo looks like:


ROS 2 Foxy Fitzroy installed on Ubuntu Linux 20.04 (if you are using another distribution, you will need to replace ‘foxy’ with the name of your distribution).


Below are the exact steps I took to install, build, and demo Webots successfully.

First, open a new terminal window, and create a new workspace. You can call it any name, but we will call it “webots”. Inside the workspace, we will create a source (i.e. src) directory. This is where your packages will go.

mkdir -p ~/webots/src

Navigate to the workspace.

cd ~/webots/src

To install the Webots software, open a new terminal window, and type the following commands:

sudo apt-get install ros-$ROS_DISTRO-webots-ros2

Type Y and then Enter to continue.

Next, we need to clone the repository into our workspace.

git clone

Let’s see if the package is in the source folder of our workspace.


Open a new terminal window, and try to run the demo.

ros2 launch webots_ros2_demos

You will be asked if you want to install the latest version of Webots.

Type Y and press Enter.

It will take some time to install.


You will see this demo pop up.


Press CTRL+C in all terminal windows to shutdown the demo.

Go to the following directory:

cd webots/src/webots_ros2/webots_ros2_importer/webots_ros2_importer
git clone
cd urdf2webots
pip3 install -r requirements.txt

At this stage, I was having install errors when I tried to build the package. So here is what I did next.

Remove the webots package. Either go to the file explorer in Linux and delete the webots_ros2 folder manually, or you can run the following commands to delete the folder.

cd ~/webots/src
rmdir webots_ros2

Now, download the package again.

cd ~/webots/src
git clone --recurse-submodules -b $ROS_DISTRO webots_ros2


Go to the root of the workspace.

cd ~/webots/

Check the dependencies.

rosdep update
rosdep install --from-paths src --ignore-src --rosdistro $ROS_DISTRO
colcon build

Add the sourcing of the workspace to the bashrc file.

gedit ~/.bashrc

At the bottom of the bash file, add the following line:

source ~/webots/install/setup.bash


How to Run the Robotic Arm Demo

Open a new terminal window, and type the following command.

ros2 launch webots_ros2_demos

When you’re done watching the demo, press CTRL + C in all terminal windows.

That’s it. Keep building!