Monday, May 27, 2019

Displaying Velodyne PCAP data in ROS' RViz

Pre-recorded data in PCAP format from Velodyne's LiDAR sensors such as the HDL-32E, VLP-16, etc. can be displayed in the RViz application software from the Robotic Operating System (ROS). The following steps show how:
  1. In Ubuntu, open up a Terminal. Change directory to the location of the PCAP file e.g. /path/to/download/HDL32-V2_Monterey_Highway.pcap.

    $ cd /path/to/download/
    $ roslaunch velodyne_pointcloud 32e_points.launch pcap:=$(pwd)/HDL32-V2_Monterey_Highway.pcap


    Note 1: 32e_points.launch is the sample launch file for HDL-32E sensors (change this for different sensors),
    $(pwd) is a macro that points to the current working directory, and
    pcap:= points to the input PCAP file name
    .

    Note 2: By default, the LiDAR points are published in the velodyne coordinate reference frame, i.e. the points are relative to the Velodyne sensor.
  2. Open up another Terminal. Startup RViz by entering the following commands.

    $ rosrun rviz rviz -f velodyne

    Note: the -f option tells RViz to use the velodyne coordinate transformation frame.

    The RViz application starts up.

  3. Click the Add button as shown above.

    The Choose visualization dialog box appears.

  4. Click By topic and choose the topic /velodyne_points/PointCloud2. click OK.

    The PCAP point cloud is displayed.


    Note: the HDL-32E sensor is mounted on top of the car so the road is below zero as shown below.


  5. To transform the PCAP data to the car (so called odom frame), we have to define the transformation parameters from the odom frame to the velodyne frame. For example, say the HDL-32E is 2 meters above the odom frame origin. Open another Terminal and type in the following command:

    $ rosrun tf static_transform_publisher 0 0 2 0 0 0 odom velodyne 100
    Note: 0 0 2 0 0 0 values are equal to dx, dy, dz, and yaw, pitch, roll (in rads),
    odom is the parent or from frame,
    velodyne is the child or to frame, and
    100 is the time interval for publishing the transformation in msec
    .
  6. In the Fixed frame field of the RViz application, change the value to odom.

    The point cloud is displayed in the odom frame as shown below.

No comments: