The NVIDIA Jetson edge AI platform is widely used for the development of autonomous machines and robotics. In this article we will explain how to connect your Xsens MTi device to the NVIDIA Jetson hardware, and how to easily communicate with it by using our MT Software Development Kit (MT SDK).
NVIDIA Jetson Developer Kits run on ARM Cortex CPUs, which means that they are not compatible with the regular Xsens Device API. Fortunately, Xsens has made a large part of the API open source, allowing users to develop applications for ARM-based platforms as well. Xsens provides C++ example codes as well as a ROS driver that make use of this open source API.
We have used the Jetson Nano Developer Kit for this article, but the guidelines can also be used for other Jetson hardware. Xsens has tested the following motion trackers with the Jetson Nano:
- MTi 1-series Development Kit (USB, UART)
- MTi 600-series Development Kit (USB, UART)
- MTi 10-series (USB)
- MTi 100-series (USB)
Setup
Start by downloading the latest MT Software Suite for Linux from our website and unpack the .tar.gz package at your desired location. Then, install the MT SDK:
sudo ./mtsdk_linux-xxx_xxxx.x.x.sh
This article will cover two hardware interfaces of the Jetson Developer Kit: USB and TTL UART. If possible, we recommend using USB as a starting point, to verify that your hardware and software can detect and communicate with external sensors. Simply connect your MTi to one of the USB ports of the Jetson Developer Kit using the USB cable included in your Development Kit.
1. C++ example codes
Inside the MT SDK you will find an examples folder. Open it and navigate to the xda_public_cpp folder. You will find two example codes:
- example_mti_receive_data: Scans for, and connects with MTi devices, configures their outputs, and prints/logs the received data.
- example_mti_parse_logfile: Opens a .mtb log file and parses its contents.
In this folder, open a terminal and build the example codes:
sudo make
sudo make HAVE_LIBUSB=1
2. ROS driver
Inside the MT SDK you will find the xsens_ros_mti_driver. Simply follow the README.txt file inside this folder or our guidelines at http://wiki.ros.org/xsens_mti_driver to install and launch the ROS driver. Your MTi should be detected automatically, and a variety of data topics are available to subscribe to. We refer to the Troubleshooting section at the end of this article if the MTi is not detected.
Note: the ROS driver publishes data, but unlike the C++ example code, it does not actually configure the outputs of the MTi. Use the C++ example code or a PC with our GUI MT Manager to configure the MTi such that it outputs the data that are required for your application.
Serial hardware interfaces
Next to the plug-and-play USB interface, Jetson Developer Kit offer various other interfaces that allow you to communicate with MTi devices. In the case of the Jetson Nano, we used a UART interface that is accessible via the J41 header, pins 8 (TxD) and 10 (RxD). We also used the 3V3/5V and GND pins on that same header to power the MTi.
Note: The UART interface of an MTi 1-series Development Board will be disabled when the board is powered at 5V. Use the 3.3V output of the Jetson Developer Kit instead.
In Ubuntu, this UART port will show up as /dev/ttyTHS1. By default, the ROS driver and C++ example code do not scan this location. Fortunately, it is easy to modify the source code such that it scans for your specific location:
Open example_mti_receive_data.cpp (in case of the C++ example code) or xsens_ros_mti_driver/src/xdainterface.cpp (in case of the ROS driver) and replace the following lines:
XsPortInfoArray portInfoArray = XsScanner::scanPorts();
XsPortInfo mtPort;
for (auto const &portInfo : portInfoArray) { if (portInfo.deviceId().isMti() || portInfo.deviceId().isMtig()) { mtPort = portInfo; break; } }
with
XsPortInfo mtPort = XsScanner::scanPort("/dev/ttyTHS1",XBR_230k4);
Alternatively, the ROS driver also allows you to configure the desired port and baud rate manually without modifying the source code. To do so, uncomment and modify the following lines in the file xsens_mti_node.yaml, located at xsens_ros_mti_driver/param:
# port: '/dev/ttyUSB0' # baudrate: 921600
You should now be able to detect and access the MTi via the UART interface.
Troubleshooting
- “No MTi device found.” or “Could not open port.”
- Ensure that you have the rights to access the port of the MTi (e.g. /dev/ttyUSB0). If you are using the C++ example code, you can check this by executing the code with sudo. Possibly you are not in the right group to access the port of the MTi. See MTSDK.README, located in your MT SDK folder, for further guidelines on changing group access permissions.
- If you are using the MTi 10-series or MTi 100-series with a direct USB cable, make sure to have libusb installed, and build your code as:
sudo make HAVE_LIBUSB=1
- If you are using a robust MTi 600-series with a USB dongle, make sure to have the relevant drivers installed.
- If you are not using the USB port or if you are using a custom serial-to-USB converter, try specifying the exact port and baud rate at which your MTi is communicating. See paragraph Serial hardware interfaces of this article.
- My USB-connected MTi does not show up as /dev/ttyUSB#.
- If you are using the MTi 10-series or MTi 100-series with a direct USB cable, then it is not necessary for the MTi to show up as /dev/ttyUSB#. Make sure to have libusb installed, and build your code as:
sudo make HAVE_LIBUSB=1
The MTi should now be recognized whenever you launch the ROS driver or C++ example code.
If you do require the device to show up as /dev/ttyUSB#, recompiling the kernel module or reinstalling the USB driver can help. This is typically seen with AGX/TX1/TX2 platforms:- https://github.com/xsens/xsens_mti_ros_node/issues/53
- https://forums.developer.nvidia.com/t/tx2-and-xsens-imu-through-micro-usb-adapter/49583/5
- https://forums.developer.nvidia.com/t/xavier-cannot-recognize-xsens-solved/66673/16
- https://xsenstechnologies.force.com/knowledgebase/s/question/0D52o0000BI1JERCQ3/mti300-interfacing-with-nvidia-tx1-platform-kernel-31096
- If you are using the MTi 10-series or MTi 100-series with a direct USB cable, then it is not necessary for the MTi to show up as /dev/ttyUSB#. Make sure to have libusb installed, and build your code as:
- The data I am receiving never reaches the expected data output rate (e.g. 400 Hz).
- We have noticed that the ROS node can cause a high CPU load, leading to lower data output rates. This issue has been fixed in ROS nodes available in MTSS2019.3.2 and later. We recommend migrating to the latest version.
- If you have connected the MTi via the USB interface, we recommend enabling the low latency mode using setserial:
- Install setserial if not already installed
- Enable low latency mode:
setserial [/path/to/xsens/port] low_latency
- Check the output rate of the published topics, e.g:
rostopic hz imu/data
- Note that the low_latency mode is lost after rebooting, so you will probably need to create a udev rule for this.
- Error "Skipping incompatible xxx when searching for xxx" after catkin_make.
- Try inserting the following at the end of your CMakeLists.txt:
add_custom_COMMAND(TARGET xsens_mti_node PRE_BUILD COMMAND $(MAKE) --always-make -j 1 -C ${CMAKE_CURRENT_SOURCE_DIR}/lib/xspublic )
- Try inserting the following at the end of your CMakeLists.txt:
Still facing challenges? Don’t hesitate to contact our Product Specialists for further support.