Robot OS example

Use Robot Operating System (ROS) to share data between two nodes.

Generally, the steps to set up one node as a master node (on your host machine), and a second node on a target (e.g., from your reference image) so that you can see the data that's passed from a target to host over ROS are:

  1. Set up your host (master node). For information about setting up your host node, see Installing ROS.”
  2. Set up the target.
  3. Share data between the target and host (master node)

The host machine where your master node resides isn't necessarily your development host.

Set up the host (master node)

In a terminal on your host machine where you have installed the ROS Desktop software, set up your master node:
  1. Source the setup.bash that was installed with your native ROS installation.
    $ . /opt/ros/kinetic/setup.bash
                        
    Note:

    If your development host and the host machine where your master node resides are one and the same, then ensure that the terminal from where you set up your master node is different from the terminal you may be using to build your ROS sensor publisher node.

    The setup script that you use to set up the master node and the one that you use to build your ROS sensor publisher node set your environment variables differently. Therefore, you must use separate terminals if you're using the same host machine for your master node and for building.

  2. Run ROS and check that it's running:
    $ roscore&
    $ ps -ae | grep ros
                        
  3. After you confirm that ROS is running, run these commands in your terminal:
    • rosnode to see the master node:
      $rosnode list
      /rosout
                               
    • rostopic to see the topics (or data) For example:
      $ rostopic list
      /rosout
      /rosout_agg

Set up the target

The target is what publishes the data. The necessary files should be on the image you booted on the board.

  1. On your target image, source the setup scripts to set up the necessary environment variables to use ROS.
    # . /opt/ros/kinetic/setup.sh
    # . /opt/ros/sensor_publisher/setup.sh --extend                    
  2. Set the ROS_MASTER_URI variable to the URL, including port 11311 to your host machine where your master node resides. For example:
    # export ROS_MASTER_URI=http://10.123.123.10:11311
                        

    The URL should indicate where your roscore process is running.

  3. Set the publish_cameras parameter of the ROS sensor publisher node.

    In the configuration file on your target of the ROS sensor publisher node (/opt/ros/sensor_publisher/share/sensor_publisher/config.yaml), set the publish_cameras parameter to true. Do so such that the ROS sensor publisher node can publish camera raw video data.

    ROS supports the transfer of raw video data using messages. However, the support is limited to a single YUV format, and the high bandwidth associated to transferring raw video data can result in performance degradation.

Share data between the target and host machine (master node)

It's important to note that if you are sharing data from a camera, only the CbYCrY video format (SENSOR_FORMAT_VIDEO_CYBRY) can be published to ROS.

For sensors (lidar, radar, GPS, IMU), the following formats are supported:

  1. On the target (with the Sensor service is already running), start the ROS sensor publisher node. For example:
    # roslaunch /opt/ros/sensor_publisher/share/sensor_publisher/launch/sensor_publisher_standalone_nodelet.launch
                        

    If you have built a customized sensor publisher node, you can use the appropriate launch file that's associated with your custom application.

  2. On the host machine where your master node resides, in the terminal where you started ROS (roscore), run the rosnode and roslist command. You should now see data appear from the target. The list of topics that you'll see may vary according to your sensor configuration and sensors that are operating on your target. For example, you may see the following list of topics if the Sensor service was started with the adas_example_capture.conf configuration file:
    $ rosnode list
    /QNX/sensor_publisher
    /rosout
    
    $ rostopic list
    /QNX/sensor_publisher/esr2_5
    /QNX/sensor_publisher/novatel_oem6_gps
    /QNX/sensor_publisher/novatel_oem6_imu
    /QNX/sensor_publisher/vlp_16
    /QNX/sensor_publisher/vu8
    /QNX/sensor_publisher/xsens_mti_g_710_gps
    /QNX/sensor_publisher/xsens_mti_g_710_imu
    /rosout
    /rosout_agg
                        
  3. Run a visualization tool from your host machine (where your master node resides) to visualize the data sent from the target. You can use the following visualization tools:

    keypoint.py
    This tools is a script that you can run on your linux host machine to visualize only camera data. For example:
    $ . /keypoint.py
                                    

    The script visualizes the data for you. You should see the camera data from the target appear in your terminal on your host machine. This script is available from the QNX Software Center (QNX Platform for ADAS 2.0 Robot OS Examples Source Code from Source Bundles > ADAS). After you install and extract the contents of this package, the keypoint.py script is located at $QNX_BASE/source/source_package_adas_ros/apps/sensor/rospy_camera_example.

    Note that in the available reference images, the recorded video that's provided as the default in the sensor configuration files (e.g., /etc/system/config/adas_example_capture.conf) uses a recorded video file that keypoint.py isn't able to visualize. Therefore, to display a viewfinder with keypoint.py, you must instead, connect a PointGrey USB 3.0 camera to the target, and configure the Sensor service to use the USB camera configuration that's provided in the reference image. For example:

    # slay sensor
    # sensor -U 521:521,1001 -r /accounts/1000/shared/camera -c /base/etc/system/config/usb_camera.conf &                                        
                                    
    rviz
    Use the rviz visualization tool on linux and other platforms to visualize sensor data (i.e., not camera data).

    This tool is available with the standard full-desktop ROS software installation. For more information, see http://wiki.ros.org/rviz.

Build the Robot OS example application

On your host computer, the source code is provided for Robot OS example application as part of a ZIP file. You can build the source and deploy the binary on to your target.

  1. A ZIP file installed with the QNX Platform for ADAS - Base is located at $QNX_BASE/adas-ros-examples-version.zip. You must extract it to get the ZIP file for the sensor examples.
  2. In the extraction_directory/source_package_adas_ros/ apps/sensor/ros_publisher directory, there's a README.txt that you can follow to build the application.
  3. Navigate to extraction_directory/source_package_adas_ros/ apps/sensor/ros_publisher/ install/target/qnx7/aarch64/opt and transfer the contents of the directory (recursively) to the /opt directory on the target. You can use the QNX Momentics IDE to transfer the files or a program such as SCP.
    Note: Ensure that you can create a backup of the original /opt/ros/sensor_publisher directory on your target before you deploy your newly built version of the Robot OS example application.
  4. On your target, in a terminal connection, run the Robot OS example application.