How to install a ros2 binary package

Written by Bayode Aderinola

13/10/2022

In this post, you will learn how to install a ros2 binary package and make it available for use. This post was written in response to this question on ROS Answers.

Step 1: Fire up a system with ROS2 installation

“Hey, do you mean I have to install ros2 first?” Absolutely not! Just login to The Construct to get access to virtual machines pre-installed with ROS.

Once logged in, click on My Rosjects, then Create a New Rosject, supply the information as shown in the video and click Create. Then RUN the rosject.

Create a new Rosject

You might also want to try this on a local PC if you have ros2 installed. However, please note that we cannot support local PCs and you will have to fix any errors you run into on your own. The rest of the instruction assumes that you are working on The Construct; please adapt them to your local PC and ros2 installation.

Step 2: Check the ros2 binaries currently installed

Open Code Editor
Open a web shell

Open a web shell and run the following commands. You should see a long list of many binaries!

cd /opt/ros/foxy/share/
ls -al

ROS binaries are stored in /opt/ros/{distro}/share/ If you would like to check if some binary is already installed without going through the long list, use grep. In this case we want to check binaries related to joint_state.

user:/opt/ros/foxy/share$ ls -al | grep joint_state
drwxr-xr-x  1 root root 4096 Sep 17  2021 joint_state_broadcaster
drwxr-xr-x  1 root root 4096 Sep 17  2021 joint_state_controller
drwxr-xr-x  1 root root 4096 Sep 17  2021 joint_state_publisher
drwxr-xr-x  1 root root 4096 Sep 17  2021 joint_state_publisher_gui

Heck, if you were the user in this post, you wouldn’t need to install anything. “What would I do then?!” Read on to find out!

Step 3: Install the ros2 binary package

We will demo this with the same package the user was struggling with: ros-foxy-joint-state-publisher-gui. Since the package is already installed in our case, we need to uninstall it first, just to demonstrate. Run the following on the current shell:

sudo apt update -y
sudo apt remove ros-foxy-joint-state-publisher-gui -y

Now verify that this GUI binary is no longer present.

user:/opt/ros/foxy/share$ ros2 pkg list | grep joint_state
joint_state_broadcaster
joint_state_controller
joint_state_publisher

Gone! Now we will install this package again.

sudo apt install ros-foxy-joint-state-publisher-gui -y

Before anything else, and this is probably what was missing for our friend who also installed the package successfully, SOURCE the ros2 distribution!

source /opt/ros/foxy/setup.bash

And that’s it! Installation complete. We are going to use the package now, but let’s check that it’s in the list of binaries.

user:/opt/ros/foxy/share$ ls -al | grep joint_state
drwxr-xr-x  1 root root 4096 Sep 17  2021 joint_state_broadcaster
drwxr-xr-x  1 root root 4096 Sep 17  2021 joint_state_controller
drwxr-xr-x  1 root root 4096 Sep 17  2021 joint_state_publisher
drwxr-xr-x  2 root root 4096 Oct 11 15:10 joint_state_publisher_gui

Step 4: Use the ros2 binary package

The user got an error when they tried to launch the GUI binary. Let’s see what we get (fingers crossed).

ros2 run joint_state_publisher_gui joint_state_publisher_gui

You should get a GUI like the image below pop up, confirming that the binary is really there. Cheers!

Hello, I am Joint State GUI

Step 5: Check your learning

Do you understand how to install a ros2 binary package and make it available for use? The magic word here is source.

If you didn’t get the point above, please go over the post again, more carefully this time.

(Extra) Step 6: Watch the video to understand how to install a ros2 binary package

Here you go:

Feedback

Did you like this post? Do you have any questions about how to install a ros2 binary package? Please leave a comment on the comments section below, so we can interact and learn from each other.

If you want to learn about other ROS2 topics, please let us know in the comments area and we will do a video or post about it.

Masterclass 2023 batch2 blog banner

Check Out These Related Posts

0 Comments

Submit a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Pin It on Pinterest

Share This