Fortress And Humble Tutorial
Installing ROS Humble
Introduction and explanation
What software are we using and why
All of these instructions have been tested using the current version of Ubuntu: Jammy Jellyfish.We are going to use two packages: Gazebo for the physics based Simulator and ROS (Robot Operating System) for the control system. There are many releases of each of these, and only some combinations are mutually compatible. Also, since we are focusing on a stable development platform, we will use the Long Term Support (LTS) versions that are current at the time we are posting this. As of 20Mar2024, this means we will use Gazebo Fortress (release 6) which is supported until 2025.
One quirk: the current LTS version of Gazebo only seems to work with the LTS version of Ubuntu
How will the demonstration proceed.We will go through 7 steps: 1) Install Gazebo Fortress and confirm that it is correct. 2) Examine an empty world 3) Build a simple robot and test it using keyboard controls. 4) Build a 'world' for our robot to explore. 5) Install ROS (and its components) and confirm the installation. 6) Add Lidar to the robot 7) Write control software in ROS to make the robot autonomous.
This post covers Step 5
One quirk: the current LTS version of Gazebo only seems to work with the LTS version of Ubuntu
How will the demonstration proceed.We will go through 7 steps: 1) Install Gazebo Fortress and confirm that it is correct. 2) Examine an empty world 3) Build a simple robot and test it using keyboard controls. 4) Build a 'world' for our robot to explore. 5) Install ROS (and its components) and confirm the installation. 6) Add Lidar to the robot 7) Write control software in ROS to make the robot autonomous.
This post covers Step 5
Installing Humble
Alright, at this point we have a fully controllable robot and an arena to play in. But we want to do more than just drive the robot around, right? We want an autonomous robot that can drive itself.
There are a number of steps to get everything set up:
1) Setup the environment to allow ROS and Gazebo to talk
2) Install ROS
3) Install the bridge between ROS and Gazebo
4) Test the system using some built in ROS utilities to send commands to the simulated robot
5) Add some sensors to the robot to send simulated data over to ROS
Let's get started.
Set up Locales
One or more of the programs needs to look up the LC_ALL to get the correct character set. Check LocalesIn a terminal window type “locale”you should see: LANG=en_US.UTF-8 LANGUAGE= LC_CTYPE="en_US.UTF-8" LC_NUMERIC="en_US.UTF-8" LC_TIME="en_US.UTF-8" LC_COLLATE="en_US.UTF-8" LC_MONETARY="en_US.UTF-8" LC_MESSAGES="en_US.UTF-8" LC_PAPER="en_US.UTF-8" LC_NAME="en_US.UTF-8" LC_ADDRESS="en_US.UTF-8" LC_TELEPHONE="en_US.UTF-8" LC_MEASUREMENT="en_US.UTF-8" LC_IDENTIFICATION="en_US.UTF-8" LC_ALL=en_US.UTF-8If Ubuntu complains about not finding locales, you can install it by typing • sudo apt update && sudo apt install locales
Generally, the locale that is missing is the last one LC_ALL, it is often blank.If the locale does not match the locale above, you will have to generate a new locale and change the values. • sudo locale-gen en_US en_US.UTF-8 • The response should be ◦ Generating locales (this might take a while)... ◦ en_US.ISO-8859-1... done ◦ en_US.UTF-8... done ◦ Generation complete. • Then modify the locale ◦ sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 • Export the Locale ◦ export LANG=en_US.UTF-8 • Reboot ◦ Type locale and it should show you the above locale
Nowwe are ready to install ROS
Install ROS
Set up the repository
We will add the ubuntu universe repository:
Pull down the pgp key
Connect to the repository
Update and install ROS
Add some support software
Okay, at this point we can run ros. But, we will need to add a few packages to support the next steps of building our own ros packages.
Step 1: Install rosdep - a tool to check for missing dependencies
Rosdep was loaded when you installed ROS.
Note - if rosdep is not installed by default, ubuntu will suggest installing it
jgunders@Tweenie:~$ rosdepCommand 'rosdep' not found, but can be installed with:sudo apt install python3-rosdep2
Follow those instructions and you should be good to go
Before you can use rosdep, you need to run these commands to initialize it and update it.You only need to do this once - when you first install ROS
Step 2: confirm that ColCon is installed
The easiest way to do this is to type:
> colcon -h
If you get the usage file, you are good to go.
If you don't get the usage file,you may need to re-install ROS
Let's put ROS to work
At this point we have ROS installed, and the ROS dev tools come with a nifty little system to bridge between ROS and Gazebo. Think of it like a translator. The first thing we will do is test the set up. t
To do that we are going to:
1) Launch our Gazebo simulation of the robot.
2) Launch a bridge between ROS and Gazebo.
3) Use a built in ROS utility to send keystrokes to the simulator
Last session, we lauched the simulator and used a tool in Gazebo (Key Publisher) to listen for key presses and publish them so the robot could react. This time we will use ROS to listen for the key presses, and the ROS / Gazebo bridge to publish them for the robot can react. It will act the same - but there is one big difference.
Once we enable ROS to send commands to the robot, we can write software running under ROS to control the robot. We can make the robot autonomous rather than human operated.
Then we can add bridges from the simulator to the software to enable sensor data to be available. That means we can make an intelligent, autonomous robot.
Shal we get started?
1) Launch our Gazebo simulation of the robot.
Okay, this part is just like the last session, with one exception. You won't need to remember to start the Key Publisher, since we will do that over in ROS.
1) Start the simulator with: > ign gazebo pong-world-4.sdf2) Press the run simulator button in the lower left (play arrow)
Now the simultor is running, let's build a bridge
2) Launch a bridge between ROS and Gazebo.
The bridge is a program that listens one one side, translates what it hears into another format, and then sends the newly formatted message out.
How does this work?
Back when we build the simple robot we added the plugins for movement, they looked like this:
When you look at the code there is the line labeled input type. It specifies a message type (ignition.msgs.Int32) and a topic (/keyboard/keypress).
So we want to create a bridge that will supply that message type to that topic on the Gazebo side, and an equivalent message type from the ROS side.
First Bridge from ROS to Gazebo
First we will send a keyboard command directly to the robot movement plugin.
We have Gazebo running in one terminal window, we will launch the bridge is a new terminal window:In a new terminal window, source the ros setup, then start a ros_gz_bridge for keyboard messages
The sets up a translator from ROS2 keypress topic to gazebo keypress topic.
Note that this creates a one directional bridge from Ros to Gazebo – this is controlled by the character between the message type specifiers: • @ - set up two bridges, one in each direction ◦ /keyboard/keypress@std_msgs/msg/Int32@gz.msgs.Int32 • ] - set up one bridge from Ros to Gazebo ◦ /keyboard/keypress@std_msgs/msg/Int32]gz.msgs.Int32 • [ - set up one bridge from Gazebo to Ros ◦ /keyboard/keypress@std_msgs/msg/Int32[gz.msgs.Int32
At this point, The Fortress simulation is listening for keypresses published on the keypress topic.AndThe bridge is ready to translate ROS2 keypresses into gazebo keypresses.So, let’s send a keypress!
ROS provides some very low level utilities. One of them is a simple command line publisher
You tell it what topic name to use, what message type to send, and what data should be in the message.
Since it is a command line application, we will need to launch another terminal window to use it.
In a new terminal window, source the ros setup and send a keypress:
This will cause 1. ROS to send a left arrow keypress to the ROS2 keyboard/keypress topic, 2. The bridge will hear that simulated keypress and translate it into a gazebo keypress and publish it on the Gazebo keypress topic. 3. The robot model plugin for rotate right will hear the keypress and publish a Twist message. 4. The Differential drive plugin on the robot will hear the Twist message and simulate the wheel rotations, and 5. Finally, the simulator will determine what changes will happen in the simulated world and display them.
For more information on the ROS topic command check out this summary from The Robotics Back-End.
Okay, That sets up communication between the ROS environment and the Simulator.
But if our little robot is going to be controlled, we also need to get the data from the Simulator over to ROS.
So, let's do a quick test of that cabability
Send data from the Simulator to ROS
We will do this in the same basic way:
1. Launch a bridge from Gazebo to ROS
2. Launch the simulator and set ti up to publish keypresses
3. Launch a ROS utility to monitor and display whatever gets published on the topic.
As before, we will need to open three terminals:
Terminal 1: open the terminal, change directory to your work area, and source the ROS setup file
Terminal 2: open the terminal, change directory into your work area, and launch Gazebo
You can load up the pong_world file, or jusst open an empty world for this test.
When the Sim is up, select the Key Publisher from the pull down menu
Start the Sim
Terminal 3: open the terminal, change directory to your work area, and source the ROS setup file
Now we are going to use a new tool: the ROS topic echo app. All this does is subscribe to a topic and echo any messages that get published to the screen.
So, now we have
The simulator running and the Key publisher will publish any key presses to the Gazebo KeyPress topic
The Gazebo ROS bridge is subscribed to the gazebo KeyPress topic and will translate any key presses into ROS KeyPress messages and publish them on the ROS KeyPress topic.
The ROS echo app is subscribed to the ROS KeyPress topic and will echo any messagfes to the terminal window.
So, put the mouse cursor in the Simulation window and type on the keyboard.
In the screen shot below,
The Bridge is running in the top terminal
Gazebo was launched in the next terminal down, and the Client is below that
The ROS echo app is running in the terminal on the right
I typed 'robot' in the Simulator and you can see the ASCII values echoed on the ROS side
What we did
This has been a long one, but we got a lot done:
We have:
1) We set up the environment to work with ROS
2) Installed thr ROS robot operating system and its tools
3) Launched the Gazebo simulated world and connected it to a ROS/Gazebo bridge
4) Used the ROS topic utility to send commands to out simulated robot
5) Used the ROS echo utility to get information from the simulator
Next step - Create an autonomous robot
Previous Step | Current Step | Next Step |
Install ROS |