Integrating Royale with a ROS Application |
|
Understanding the Royale ROS Node
This application note explains how to perform integration of the Royale TOF camera stack running on the Emcraft i.MX 8M Mini System-On-Module with a ROS application.
Specifically, you will be able to build a ROS node, which runs on the i.MX 8M Mini device and streams pointclouds, depth images, and IR images from the 38K TOF camera. This node makes use of the Royale APIs available to the Linux userspace to start the TOF camera automatically and then drive the camera for continued operation. The node translates the Royale point cloud, depth image, IR image types to ROS types and publishes it for other ROS nodes to use. In addition, the node publishes a small set of configuration options like the use cases as strings.
The TOF camera node provides a sufficient framework for the Rviz ROS visualiser running on a Linux PC host to interact with the ROS node running on the i.MX 8M Mini and represent the live video video stream in the GUI. This is what Rviz looks like running on the Linux PC showing the point cloud streamed from the i.MX8M Mini Royale node:
Running the Sample
Step through the following procedure to run the above-described sample on your i.MX 8M Mini kit:
- Build the Royale ROS node:
- Copy royale-ros-sample.bb to meta-emcraft-imx8mm/recipes-applications/royale.
- Copy royale_ros_sample.zip to meta-emcraft-imx8mm/recipes-applications/royale/files.
- Copy (overwrite) image-pmd.bb to meta-emcraft-imx8mm/recipes-core/images.
- Add to local.conf:
ROS_DISTRO = "melodic" PNBLACKLIST[gstreamer1.0-plugins-bad] = "" PNBLACKLIST[packagegroup-core-tools-testapps] = "" OPENCV_PKGS_remove_imxgpu = " python3-opencv " CORE_IMAGE_EXTRA_INSTALL += " royale-ros-sample "
- Clone the meta-ros layer:
$ cd sources $ git clone -b zeus --single-branch
This e-mail address is being protected from spambots. You need JavaScript enabled to view it
:ros/meta-ros
- Add to bblayers.conf:
BBLAYERS += "${BSPDIR}/sources/meta-ros/meta-ros-common" BBLAYERS += "${BSPDIR}/sources/meta-ros/meta-ros-backports-dunfell" BBLAYERS += "${BSPDIR}/sources/meta-ros/meta-ros1" BBLAYERS += "${BSPDIR}/sources/meta-ros/meta-ros1-melodic"
- Copy (overwrite) ros-world-recipe-blacklist.inc to meta-ros/meta-ros-common/conf/ros-distro/include/ros-world-recipe-blacklist.inc.
- Rebuild and install image-pmd - new image will be called image-pmd-debug-melodic-imx8mmcube2g.sdcard.bz2.
- Run the Royale ROS node on the i.MX8M Mini:
- Make sure Royaleviewer is not running. To stop Roaylviewer run:
root@imx8mmcube2g:~# systemctl stop royaleviewer
- Enable the ROS environment:
root@imx8mmcube2g:~# source /opt/ros/melodic/setup.sh
- Take note of the IP address of the device.
- Run the node:
root@imx8mmcube2g:~# roslaunch royale_ros_sample camera_driver.launch
- Visualize data from the Royale ROS node using rviz on PC (Ubuntu 18.04):
- Install and configure ROS melodic follow the instructions on http://wiki.ros.org/melodic/Installation/Ubuntu
Follow the instructions for ros-melodic-desktop-full.
- Enable the ROS environment:
[user@localhost ~]$ source /opt/ros/melodic/setup.sh
- Set the i.MX8M Mini as the master ROS node:
[user@localhost ~]$ export ROS_MASTER_URI=http://[ip-address-imx8]:11311
- Add the record below to /etc/hosts:
[ip-address-imx8] imx8mmcube2g
- Run rviz:
[user@localhost ~]$ rosrun rviz rviz
- Add the topics in rviz:
- point_cloud topic:
- Set the Fixed frame to royale_camera_link;
- Add PointCloud2 from By display type, set Topic to royale_camera_driver/point_cloud and set Channel Name to z;
or add PointCloud2 from By topic and set Channel Name to z.
- image topics:
- Add Image from By display type and set Image Topic;
or add topics from By topic;
- The both image topics support for sub-topics Camera and DepthCloud too. Before adding these two sub-topics, the Fixed frame has to been set earlier.
|