RobotLabs
  • Welcome
  • ESP32
    • PlatformIO
      • 1.1 Arduino Basics
      • 1.2 Install PlatformIO
      • 2.1 GPIO - LED Blink
      • 2.2 GPIO - LED Multi
      • 2.3 GPIO - LED Button
      • 3.1 PWM - LED Fade
      • 3.2 ADC - Analog Input
      • 4.1 IIC - OLED
    • MicroPython
    • ESP32 Projects
  • ROS
    • ROS2 Jazzy
      • 1.1 Install ROS 2 Jazzy
      • 1.2 Install VS Code
      • 1.3 Save ROS code on GitHub
      • 2.1 Create a Mobile Robot with URDF and Visualize it
      • 2.3 Create Launch Files to Display the URDF in RViz
      • 2.4 Simulation with Gazebo
      • 2.5 Gazebo sensors
      • 2.6 Sensor fusion and SLAM
    • MoveIt2
      • Moveit 2 joint position control with keyboard
      • Moveit2 joint velocity control for Panda robot arm
    • Perception
      • PCL-ROS
  • FOC
    • SimpleFOC
      • Install simpleFOC Lib
  • Template
    • Markdown
    • Interactive blocks
    • OpenAPI
    • Integrations
Powered by GitBook
On this page
  • Introduction
  • Install ROS2 Jazzy
  • Installation procedure
  • Set Up the Environment Variables
  • Check environment variables
  • Run ROS2 example - Turtlesim
  • Install Gazebo Harmonic
  • Test Gazebo Installation
  • Install useful tools
  • References:
  1. ROS
  2. ROS2 Jazzy

1.1 Install ROS 2 Jazzy

PreviousROS2 JazzyNext1.2 Install VS Code

Last updated 3 months ago

In this tutorial, we will install ROS 2 Jazzy, Gazebo Harmonic and some useful packages.

You will need a computer or virtual machine running Ubuntu 24.04, and you can create a virtual machine from scratch as following video:

Introduction

ROS2 Jazzy Jalisco is the latest Long-term support version in 2025 that works comatible with Gazebo Harmonic:

For Gazebo simulator, there might be confusing about its version, and let's make it clear:

  1. Basically, the "old" versions of gazebo is called classic like Gazebo 11 (Gazebo+VersionNo.)

  2. There used to be a new Gazebo version called Ignition to replace the classic.

  3. For some reason, Ignition is renamed to Gazebo again, and use Gazebo+VersionName for the new generations of Gazebo simulator.

  4. Although the new Gazebo has a different user interface with the classic, most of fundamental designs are same or similar, so it is not difficult to move to the new version. While there are lots of differences like the plugins, we will cover this in future tutorials.

For Gazebo Harmonic installation, there are two ways:

  1. Install and run Gazebo Harmonic independently from ROS2.

  2. Install and run Gazebo Harmonic with ROS2. For ROS developers, I recommend this way.

Install ROS2 Jazzy

Installation procedure

Set Up the Environment Variables

After installation, you need to set up the important environment variables, which tell your computer how to find and use ROS 2 commands and packages. Open a terminal and type:

echo "source /opt/ros/jazzy/setup.bash" >> ~/.bashrc

This wil add the line source /opt/ros/jazzy/setup.bash to your ~/.bashrc file.

Why do this? Each time you open a new terminal window, you are starting a bash session. The bash session needs to know what version of ROS 2 you are using. By adding this line, you can use ROS 2 Jazzy commands and tools without having to manually run the setup.bash script every time.

To take effect, open a new terminal window, or run following cmd in the current terminal:

source ~/.bashrc

You can verify that line was added by typing:

sudo apt-get install gedit -y
gedit ~/.bashrc

Check environment variables

If you ever have problems finding or using your ROS 2 packages, make sure that your environment is properly set up using the following command:

printenv | grep -i ROS
# Also, you can type:
echo $ROS_DISTRO
printenv ROS_DISTRO
lsb_release -a  #check Ubuntu

If the environment variables are not set correctly, return to the ROS 2 package installation section.

Set up the system to manage ROS package dependencies.

sudo rosdep init
rosdep update

Run ROS2 example - Turtlesim

Install turtlesim

sudo apt update
sudo apt install ros-jazzy-turtlesim

Start turtlesim

ros2 run turtlesim turtlesim_node

Open a new terminal and run control node

ros2 run turtlesim turtle_teleop_key

Install and run rqt tool

sudo apt update
sudo apt install '~nros-jazzy-rqt*'
rqt

Install Gazebo Harmonic

sudo apt-get install ros-${ROS_DISTRO}-ros-gz -y

Test Gazebo Installation

If you want to run an example Gazebo simulation world now, you can type:

LIBGL_ALWAYS_SOFTWARE=1 QT_QPA_PLATFORM=xcb gz sim -v 4 shapes.sdf
The environment variables explanation

The environment variables “LIBGL_ALWAYS_SOFTWARE=1 QT_QPA_PLATFORM=xcb” help you avoid the following error which happens by default when you try to launch Gazebo from a fresh ROS 2 Jazzy installation:

[GUI] [Err] [Ogre2RenderEngine.cc:1301] Unable to create the rendering window: OGRE EXCEPTION(3:RenderingAPIException): currentGLContext was specified with no current GL context in GLXWindow::create at ./.obj-x86_64-linux-gnu/gz_ogre_next_vendor-prefix/src/gz_ogre_next_vendor/RenderSystems/GL3Plus/src/windowing/GLX/OgreGLXWindow.cpp (line 165)

You can see the error, if you open a new terminal window and type:

gz sim -v 4 shapes.sdf

To make these environment variables permanent, open a terminal window and type:

echo 'export LIBGL_ALWAYS_SOFTWARE=1' >> ~/.bashrc
echo 'export QT_QPA_PLATFORM=xcb' >> ~/.bashrc
source ~/.bashrc

Now test your Gazebo installation again by typing the following command:

gz sim

Click on one simulation, and click Run. Close the simulation by typing CTRL + C in the terminal window.

Install useful tools

Let’s install some other useful packages like pip (the Python package manager), NumPy (a scientific computing library for Python) etc.

sudo apt-get install python3-vcstool
sudo apt-get install python3 python3-pip -y
sudo apt-get install python3-numpy

Install terminator to show multiple terminal windows in a single window.

sudo apt-get install terminator -y
# to run it, type:
terminator

Right-click on the terminator screen, and click “Split Horizontally”.

References:

To install Gazebo Harmonic binaries on Ubuntu 24.04 simply follow the steps .

on this link
https://docs.ros.org/en/rolling/Releases.html
https://docs.ros.org/en/jazzy/Installation.html#
https://gazebosim.org/home
https://gazebosim.org/docs/harmonic/ros_installation/
Ubuntu (deb packages) — ROS 2 Documentation: Jazzy documentation
Logo