Using ROS

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).
  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

  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.

    Edit the configuration file on your target of the ROS sensor publisher node (/opt/ros/sensor_publisher/share/sensor_publisher/config.yaml). In the file, 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 rostopic commands. 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 installed Robot OS Examples Source Code ($QNX_BASE/source/adas-ros-examples-version.zip). After extract the contents of the ZIP file, the keypoint.py script is located at extraction_directory/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.