Note: Instructions here are based on the official ROS and Gazebo documentation.
Welcome! If you’re here, I assume that you (like me) have a need to work with robotics projects that have not yet been ported from ROS 1 to ROS 2.
The end of support for the last version of ROS 1 (ROS 1 Noetic) is fast approaching, with support ending in 2025. Unfortunately, a lot of open source, research, and hobbyist code still uses ROS 1. Some of this code also depends on simulated environments that run in Gazebo 9 or Gazebo 11 (the simulators most commonly used in concert with ROS 1).
So what’s to be done? Most newer systems (newer than Ubuntu 20) do not officially support ROS 1. Your best bet is to set up an Ubuntu 20 desktop and use that to host ROS 1 and Gazebo 9 (or 11).
You can:
- Host Ubuntu 20 in a VM using VirtualBox
- Follow along with this blog post to set up a GPU-enabled Ubuntu 20 desktop on AWS EC2
Once you’ve done that, read on. Note that the steps here are borrowed directly from the ROS documentation, here.
Setting up package repositories Link to heading
You’ll need to add ROS’s package repo in order to install ROS 1 in Ubuntu. Start by updating your sources.list
:
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
Fetch keys (I assume you already have curl
installed, if not install it with sudo apt install curl
):
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
Update your package repos:
sudo apt update
Finally, install ROS 1 Noetic with:
sudo apt install ros-noetic-desktop-full
Building a ROS package Link to heading
Great! This should pull in most of the most common ROS 1 packages as well as the gazebo11
simulator package. Now, we need a way to test it all. I have recently been testing the NanoCar Pro from BingDa Robot (冰达机器人), a company in Shenzhen, China. If you are in China, you can find the 冰达机器人 store on Taobao (淘宝). If not, use this link to purchase it from AliExpress.
The company provides ROS 1 workspaces for most of its vehicles (including the NanoCar Pro) here. Specifically, a simulated environment, URDF file, and ROS 1 launchers are available in this repo. Let’s clone into that and try spinning up a simulated environment with a single car.
Clone the repo:
git clone https://gitee.com/bingda-robot/nanocarpro_description.git
Before we perform the build, let’s make sure all the ROS environment variables are set (important, because when we build the nanocarpro project, we’ll need to be able to find the ROS 1 build tool, catkin
):
source /opt/ros/noetic/setup.bash
Great, now we’re ready to build (we must build the nanocarpro_description
project before we can call roslaunch
on any of the launch scripts it includes):
cd nanocarpro_description
cmake .
Running a simulation with ROS 1 and Gazebo 11 Link to heading
The build process should complete without errors. Once it’s over we need to source the setup.bash
file provided by the nanocar_description
workspace, on top of our existing ROS 1 workspace, which we already enabled when we ran source /opt/ros/noetic/setup.bash
earlier:
source devel/bash.setup
We can now start a simulated environment and insert a virtual copy of the nanocar robot with the roslaunch
command, like this:
roslaunch nanocarpro_description display.launch
This should open up a Gazebo 11 window where we can see our little virtual car, like this:
Controlling the simulation Link to heading
We can control the car manually using teleop
, similar to how the turtlebot
robot is controlled in the ROS tutorials on https://ros.org. Let’s try that out:
rosrun teleop_twist_keyboard teleop_twist_keyboard.py
We can now drive the car around:
We should even be able to view the car’s front-facing camera using rqt
, with:
rosrun rqt_image_view rqt_image_view
Note: Don’t forget that you need to re-run your source
commands (both for ROS 1 itself and the nanocar_description
workspace) before executing each of the commands above).
You should now see the car’s camera:
Sorry if the .gif
is a little unclear, I had to compress it a little to get the size down.
Awesome! We now see what the car sees (which is not much…I have driven the car up to a doorway in the simulated world, from which we can see the corner of a desk).
Note: The pixelted appearance and washed out colors in the screenshot are not a problem with Gazebo. They are the result of connecting to the remote desktop where ROS 1 and Gazebo are running using a poor Internet connection. Sorry about that.
And that’s it! You now have a working ROS 1 Noetic / Gazebo 11 environment in which to test and debug ROS 1 code.