Integrating Royale with a ROS Application Print

 

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:

  1. Build the Royale ROS node:
    1. Copy royale-ros-sample.bb to meta-emcraft-imx8mm/recipes-applications/royale.
    2. Copy royale_ros_sample.zip to meta-emcraft-imx8mm/recipes-applications/royale/files.
    3. Copy (overwrite) image-pmd.bb to meta-emcraft-imx8mm/recipes-core/images.
    4. Add "ROS_DISTRO="melodic"" to local.conf.
    5. Include the meta-ros layer from branch zeus.
    6. Copy (overwrite) ros-world-recipe-blacklist.inc to meta-ros-common/conf/ros-distro/include/ros-world-recipe-blacklist.inc.
    7. Rebuild and install image-pmd - new image will be called image-pmd-debug-melodic-imx8mmcube2g.sdcard.bz2.
  2. Run the Royale ROS node on the i.MX8M Mini:
    1. Make sure Royaleviewer is not running. To stop Roaylviewer run:
    2. root@imx8mmcube2g:~# systemctl stop royaleviewer

    3. Enable the ROS environment:
    4. root@imx8mmcube2g:~# source /opt/ros/melodic/setup.sh

    5. Take note of the IP address of the device.
    6. Run the node:

      root@imx8mmcube2g:~# roslaunch royale_ros_sample camera_driver.launch

  3. Visualize data from the Royale ROS node using rviz on PC (Ubuntu 18.04):
    1. Install and configure ROS melodic follow the instructions on http://wiki.ros.org/melodic/Installation/Ubuntu
      Follow the instructions for ros-melodic-desktop-full.
    2. Enable the ROS environment:
    3. [user@localhost ~]$ source /opt/ros/melodic/setup.sh

    4. Set the i.MX8M Mini as the master ROS node:
    5. [user@localhost ~]$ export ROS_MASTER_URI=http://[ip-address-imx8]:11311

    6. Run rviz:
    7. [user@localhost ~]$ rosrun rviz rviz

    8. Add the topics in rviz:
      • point_cloud topic:
        1. Set the Fixed frame to royale_camera_link;
        2. 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:
        1. Add Image from By display type and set Image Topic;
          or add topics from By topic;
        2. 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.