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.
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 rqt
, rviz
and 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 computing power.
It is recommended to load the ROS environment variables automatically when you execute a new shell session. Update your .bashrc
script:
$ echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc $ source ~/.bashrc
Install and 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 apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential $ sudo rosdep init $ rosdep update
Now the Jetson Xavier NX is ready to execute ROS packages and become the brain of your autonomous robot.
To start running your own ROS packages or install other packages from the source (such as the ROS wrapper for ZED 3D cameras), you must create and configure a 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:
$ catkin_make
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.
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
The 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
People tracking, visible in the video above, is available in the object detection module only using a ZED 2 camera. It can be enabled automatically when the node starts setting the object_detection
/od_enabled
to true
or when the node is running calling the service start_object_detection
.
For more information on using the ZED ROS wrapper, read our Getting Started guide.
If you need help with setting up ROS on your Jetson Nano or using your ZED stereo camera, don’t hesitate to contact us on the support portal or GitHub issue system.