Getting Started with ROS on Jetson Xavier NX
The new $399 embedded board from NVIDIA® is an ideal fit for autonomous robotics. Learn how to get started with ROS on the Jetson Xavier NX.
The Jetson Xavier NX is the latest embedded board of the NVIDIA Jetson family. Designed for autonomous machines, it is a tiny, low power and affordable platform with a high level of computing power allowing to perform real time computer vision and deep learning operations at the edge.
How to Install ROS on Jetson Xavier NX
ROS is the natural choice when building a multi-sensory autonomous robot.
After setting up the Jetson Xavier NX with its JetPack image using our Getting Started guide, we are going to install the latest version of ROS that runs on Ubuntu 18 Bionic Beaver: Melodic Morenia.
Note: A newer ROS version is available, ROS Noetic Ninjemys, but it targets Ubuntu 20.04 Focal Fossa. Ubuntu Focal does not yet officially supports CUDA and is not available on Nvidia® Jetson boards at this time.
Open a new terminal by pressing Ctrl + Alt + T or execute the “Terminal” application using the Ubuntu 18 launch system.
Set the Jetson Xavier NX to accept software from packages.ros.org:
$ sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
Add a new apt key:
$ sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
Update the Debian packages index:
$ sudo apt update
Install the ROS Desktop package, including support for
rvizand other useful robotics packages:
$ sudo apt install ros-melodic-desktop
Note: “ROS Desktop Full” is a more complete package, however it is not recommended for embedded platforms; 2D/3D simulators will be installed, requiring increased storage space and compute power.
Initialize rosdep. rosdep allows you to easily install system dependencies for source code you want to compile and is required to run some core components in ROS:
$ sudo rosdep init $ rosdep update
It is recommended to load the ROS environment variables automatically when you execute a new shell session. Update your
$ echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc $ source ~/.bashrc
Now the Jetson Xavier NX is ready to execute ROS packages and become the brain of your autonomous robot.
Configure your catkin workspace
Install the following dependencies:
$ sudo apt-get install cmake python-catkin-pkg python-empy python-nose python-setuptools libgtest-dev python-rosinstall python-rosinstall-generator python-wstool build-essential git
Create the catkin root and source folders:
$ mkdir -p ~/catkin_ws/src $ cd ~/catkin_ws/
Configure the catkin workspace by issuing a first “empty” build command:
Finally, update your
.bashrc script with the information about the new workspace:
$ echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc $ source ~/.bashrc
Your catkin workspace is now ready to compile your ROS packages from source directly onto the Jetson Xavier NX.
Adding a 3D camera for AI on Jetson Xavier NX
If you’re building an autonomous robot, there are good chances that you will need a 3D camera for depth perception, motion tracking and AI object detection.
At Stereolabs, we support the NVIDIA Jetson platforms natively from the start with the ZED stereo camera family. These 3D depth cameras are ideal companions for a Jetson Xavier NX and a ROS-powered robot.
To get your ZED up and running with ROS on Xavier NX, go to the source folder of the catkin workspace that you just created:
$ cd ~/catkin_ws/src
Clone the ZED ROS wrapper Github repository. The ZED wrapper allows you to add real-time depth sensing, stereo visual odometry, 3D SLAM, Object Detection and Skeleton Tracking to your autonomous robot.
$ git clone https://github.com/stereolabs/zed-ros-wrapper.git
Clone the ZED ROS examples Github repository to get many useful examples and tutorials about how to use the ZED ROS Wrapper:
$ git clone https://github.com/stereolabs/zed-ros-examples.git
Check the dependencies:
$ cd ~/catkin_ws $ rosdep install --from-paths src --ignore-src -r -y
rosdep command explores all the packages available in the
src folder and verifies that all the declared dependencies are available, automatically installing the missing ones.
Compile the new ROS packages:
$ catkin_make -DCMAKE_BUILD_TYPE=Release
You can now visualize the video and depth data that your ZED camera captures using this simple command:
$ roslaunch zed_display_rviz display_zedm.launch # if using ZED Mini $ roslaunch zed_display_rviz display_zed2.launch # if using ZED 2
Note: people tracking, available in the object detection module only using a ZED2 camera, can be enabled automatically when the node start setting the
true or when the node is running calling the service
For more information on using the ZED ROS wrapper, read our Getting Started guide.