Getting Started with ROS on Embedded Systems - Getting Started
Getting Started with ROS on Embedded Systems RidgeRun documentation is currently under development. |
Getting Started with ROS on Embedded Systems |
---|
ROS on Embedded Systems Basics |
Getting Started |
C++ User Guide |
Examples |
Basic pipelines |
Performance |
Xavier |
Contact Us |
Introduction
The Robot Operating System (ROS) is a flexible framework for writing robot software. It is a collection of tools, libraries, and conventions that aim to simplify the task of creating complex and robust robot behavior across a wide variety of robotic platforms.
Why? Because creating truly robust, general-purpose robot software is hard. From the robot's perspective, problems that seem trivial to humans often vary wildly between instances of tasks and environments. Dealing with these variations is so hard that no single individual, laboratory, or institution can hope to do it on their own.
As a result, ROS was built from the ground up to encourage collaborative robotics software development. For example, one laboratory might have experts in mapping indoor environments and could contribute a world-class system for producing maps. Another group might have experts at using maps to navigate, and yet another group might have discovered a computer vision approach that works well for recognising small objects in clutter. ROS was designed specifically for groups like these to collaborate and build upon each other's work, as is described throughout this site.
Currently, there are 2 main versions: ROS and ROS2. This wiki will be focused on on ROS2. For additional project support, see RidgeRun's Embedded Engineering Services.
Installation
The following installation steps were tested on a Jetson Xavier NX running Jetpack 5.1.2. The target will be ros-humble.
Using docker
NVIDIA provides custom made ROS images, ready to use for Jetson devices, You can check the different versions here. In this case, we will use the image that is closer to our setup, dustynv/ros:humble-ros-base-l4t-r35.2.1.
Simple test
FROM dustynv/ros:humble-ros-base-l4t-r35.2.1 RUN apt-get update && apt-get install -y \ python3-pip ENTRYPOINT ["/bin/bash"]
To build it and test it:
sudo docker build -t ros_test:5.1.2 -f Dockerfile . sudo docker run --runtime nvidia -it --rm --network=host ros_test:5.1.2
On the container, we can then launch the setup script:
source /ros_entrypoint.sh
If we don't run that command every time we start a new console, all ROS related packages and commands will not be found or will fail. Then we can check that the correct version was loaded:
printenv ROS_DISTRO
This will result in:
root@vision:/# printenv ROS_DISTRO humble
Local installation
ROS can also be installed directly on the host to run without docker. The target will be one of the currently available ros packages for Jetson, ros2 melodic. The process can change depending on the environment and the current ros packages, so if this process fails, it's recommended to follow the DustyNV repo. Specifically the ros2_build.sh and Dockerfile.
Get repos
sudo apt-add-repository universe sudo apt-add-repository multiverse sudo apt-add-repository restricted sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
Then we add the repo key:
sudo apt install curl -y sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
Now we can pull from the ROS repos:
sudo apt update sudo apt-get install ros-melodic-core -y
If you encounter key errors during this process, like:
Err:3 http://packages.ros.org/ros/ubuntu focal InRelease The following signatures couldn't be verified because the public key is not available: NO_PUBKEY F42ED6FBAB17C654 Reading package lists... Done W: GPG error: http://packages.ros.org/ros/ubuntu focal InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY F42ED6FBAB17C654 E: The repository 'http://packages.ros.org/ros/ubuntu focal InRelease' is not signed. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details.
You can add the offending key and then retry:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F42ED6FBAB17C654
Configure ROS
Before you can use ROS, you will need to initialize rosdep. rosdep enables you to easily install system dependencies for the source you want to compile and is required to run some core components in ROS.
To install the ROS initializer:
sudo apt-get install python-rosdep -y sudo apt-get install python-rosinstall python-rosinstall-generator python-wstool build-essential python3-colcon-common-extensions -y sudo c_rehash /etc/ssl/certs
Then execute:
sudo rosdep init rosdep update
Environment Setup
It's convenient if the ROS environment variables are automatically added to your bash session every time a new shell is launched:
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc source ~/.bashrc
Execute ROS
You will need to launch the ROS process from a terminal:
roscore
Which will generate an output similar to the following:
botuser@vision:~/test_docker/installROS$ roscore ... logging to /home/botuser/.ros/log/1f1c8c94-dbe1-11ee-8ec9-48b02d3b0ae0/roslaunch-vision-18894.log Checking the log directory for disk usage. This may take a while. Press Ctrl-C to interrupt Done checking log file disk usage. Usage is <1GB. started roslaunch server http://vision:34035/ ros_comm version 1.14.13 SUMMARY ======== PARAMETERS * /rosdistro: melodic * /rosversion: 1.14.13 NODES auto-starting new master process[master]: started with pid [18908] ROS_MASTER_URI=http://vision:11311/ setting /run_id to 1f1c8c94-dbe1-11ee-8ec9-48b02d3b0ae0 process[rosout-1]: started with pid [18921] started core service [/rosout]
To verify ros was correctly launched, from another terminal, while keeping the last one opened, you can run rosnode list
nvidia@nvidia-desktop:~$ rosnode list /rosout