Showing posts with label Velodyne. Show all posts
Showing posts with label Velodyne. Show all posts

Monday, September 2, 2019

Resolving VeloView not displaying live sensor data from Velodyne Lidar sensors

This is a fairly common problem when running VeloView with a real Velodyne Lidar sensor on Windows - even though the sensor e.g. VLP-16 or HDL-32 are powered on and connected to the host computer, no live point cloud data is displayed in VeloView. All you get is a blank screen as shown below.


The probable reason is that the Windows Defender firewall is set to block VeloView from accessing the ports used by the Velodyne sensors. Normally, Windows will prompt whether to allow the program to access the ports on the first startup of the program. If you click no to the prompt, then Windows will never ask again. To enable the ports for VeloView, you will have to manually open the ports. The steps are shown below.

  1. Click the Windows Start button. Start typing "firewall with advanced...".

    A list of matches appear.


  2. Click on Windows Defender Firewall with Advanced Security.

    The Windows Defender Firewall with Advanced Security dialog box appears.

  3. Click on Inbound Rules. Scroll the list and look for entries with the name Veloview.


  4. For each Veloview entry, double click on it.

    The Veloview Properties appear.

  5. Toggle on Enabled. Choose Allow the Connection. Click OK. Repeat for each Veloview entry.

    The entry in the list should be marked with a green tick icon.

  6. Close the dialog.

    VeloView should be able to display the live data from the Velodyne sensor.

Monday, August 5, 2019

Convert a Velodyne PCAP file into a ROS bag file

Normally Velodyne laser sensors record LiDAR data packets in PCAP format (*.pcap) file. If later on you want to process this recorded PCAP file in some SLAM algorithm in ROS e.g. ROS Cartogropher, then it may be necessary to convert it into a ROS bag file.

To convert the PCAP file e.g. HDL32-V2_Monterey_Highway.pcap, perform the following:
  1.  Open up a Terminal. Enter the command to record the messages under the ROS topic /velodyne_points to an output bag file.

    $ rosbag record -O /path/to/output.bag /velodyne_points
    Note: /velodyne_points is the message to record. Leave blank if you want to record all messages.
  2. Open up another Terminal. Change directory to the location of the PCAP file, e.g. /path/to/Downloads/.

    $ cd /path/to/Downloads
  3. Enter the command to playback the Velodyne PCAP file and publish as a point cloud.

    $ roslaunch velodyne_pointcloud 32e_points.launch pcap:=$(pwd)/HDL32-V2_Monterey_Highway.pcap readonce:=true


    Note: this command publishes a HDL-32E PCAP file as a point cloud.
  4. Wait until the PCAP file is fully read. You can use the following command in another Terminal to check if anymore data is published.

    $ rostopic echo /velodyne_points

    A stream of points appear.
  5. When no more messages appear, the PCAP file is fully read. In the first Terminal, press CTRL-C to interrupt and complete the recording process to the bag file.

    The bag file is created.

Monday, July 29, 2019

ROS: Fix "Unable to get message class for type custom_msgs/gnssSample"

I recently received a ROS bag file recorded with a Velodyne VLP-16 LiDAR sensor and a XSens IMU-GPS sensor. When playing back the bag file, the ROS rqt plugins could not expand the XSens messages. The error message: can not get message class for type "custom_msgs/gnssSample" is shown in the screen shot below.
 
I found a deprecated Github repository for the XSens MTi ROS node at https://github.com/xsens/xsens_mti_ros_node that has the definitions for the custom message gnssSample. However, the repository's package name is xsens_msgs while the bag file's package name is custom_msgs. I had to rename the package to get ROS to recognize the bag file's messages. So the following steps were how I resolved the problem.
  1. Follow the tutorial at https://wiki.ros.org/ROS/Tutorials/CreatingPackage to create a Catkin workspace e.g. /home/yourname/catkin_ws/.
  2. Open up a Terminal and change the directory to /home/yourname/catkin_ws/src/.

    $ cd /home/yourname/catkin_ws/src
  3. Download the XSens MTi ROS Node repository.

    $ git clone https://github.com/xsens/xsens_mti_ros_node
  4. Using a text editor, open up the file /home/yourname/catkin_ws/src/xsens_mti_ros_node/src/xsens_msgs/package.xml.


  5. Change the package name to custom_msgs as shown below.


  6. Open up the file /home/yourname/catkin_ws/src/xsens_mti_ros_node/src/xsens_msgs/CMakeLists.txt.



  7. Change the project name to custom_msgs as shown below.


  8. Now in a Terminal change to the catkin root directory.

    $ cd /home/yourname/catkin_ws
  9. Compile the package by entering the command:

    $ catkin_make
If the compilation is successful, now when reviewing the messages with rqt, the custom_msgs/gnssSample message can be expanded, as shown below.

Monday, July 8, 2019

Setup an Ubuntu VirtualBox instance on Windows 10 to connect to a Velodyne VLP-16 sensor

An Ubuntu 18.04 guest OS virtual machine running on a Windows 10 host can connect to a Velodyne VLP-16 LiDAR sensor and process the sensor's data and positioning packets. However, the VirtualBox Ubuntu guest OS must be configured properly to transfer the LiDAR data packets from the host OS to the guest OS. The following steps show how to perform the settings.
  1. On Windows, open the Internet and Network Settings.

     
  2.  Click the Change adapter options.

    The Network Connections window opens.
  3. Right click on the Local Area Connection icon. Choose Properties.

    The Local Area Connection Properties dialog box appears.
  4. Select Internet Protocol Version 4. Click Properties.

    The Internet Protocol Version 4 (TCP/IPV4) Properties appear.
  5. Toggle on Use the following IP address. In the IP address field, type in the following address:

    192.168.1.77
  6. Click OK to all the dialog boxes.

    The local Windows machine IP address is changed to 192.168.1.77


  7. Optional. If necessary, use the Windows Defender Firewall with Advanced Security App to open up the host Windows OS UDP ports for Oracle VirtualBox. In the Inbound Rules, make sure the VirtualBox Manager entries are enabled, as shown below.



  8. Now start Oracle VirtualBox.

    The Oracle VM VirtualBox Manager appears.
  9. Select the Ubuntu instance, e.g. Ubuntu18. Then click Settings.

    The Ubuntu18 Settings dialog box appears.
  10. Click Network. Then click the Port forwarding button.

    The Port forwarding rules dialog box appears.
  11. Click the Plus icon and add in two UDP protocol rules as shown below.



    Note: The rules will forward UDP packets from ports 2368 and 8308 on the Windows host to the same ports on the Ubuntu guest.
  12. Click OK.
  13. Now start the Ubuntu18 host.
  14. Login to Ubuntu and run Veloview. In Veloview, connect to the Velodyne VLP-16 sensor stream as per normal.

    The LiDAR point cloud is displayed.

Monday, June 3, 2019

Installing and running the Velodyne Height Map package on ROS Melodic distribution

The ROS Velodyne Height Map package (https://wiki.ros.org/velodyne_height_map) is a useful tool for identifying obstacles in a point cloud. An example of potential obstacles is shown below (the red squares).

However the last supported ROS distribution seems to be Indigo, a few releases from the latest Melodic distribution. But it is still possible to install and run the package on the latest ROS distribution. To do that, the source code from https://github.com/jack-oquin/velodyne_height_map must be downloaded and compiled on the ROS installation. The following steps illustrate the procedure.

Create a ROS Catkin workspace
  1. Follow the tutorial here at https://wiki.ros.org/catkin/Tutorials/create_a_workspace to create an empty workspace, e.g /path/to/catkin_ws/.
Download the Velodyne Height Map source code
  1. Open up a Terminal. Change the directory to the location of the Catkin workspace's src directory created earlier.

    $ cd /path/to/catkin_ws/src
  2.  Assuming git is installed, clone the velodyne height map source code.

    $ git clone https://github.com/jack-oquin/velodyne_height_map.git
Build the package
  1. In the Terminal, change the directory to the root of the Catkin workspace.

    $ cd /path/to/catkin_ws
  2. Type in the following command to build the packages.

    $ catkin_make
Once the package is built, the Velodyne Height Map package can be executed according to the instructions here at https://wiki.ros.org/velodyne_height_map. For example,

$ rosrun velodyne_height_map heightmap_node

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.

Monday, May 20, 2019

Setup Ubuntu network settings to Velodyne VLP-16 for ROS

After installing ROS (Robotic Operating System) and the Velodyne drivers and utilities on Ubuntu 18.04 LTS, the computer needs to be able to communicate with the Velodyne VLP-16 sensor unit.

Note: this post is specific to the VLP-16 unit but should be applicable to the other units, with some address changes.

By default, the IP address of the VLP-16 is set to be 192.168.1.201 by the factory. The network interface for the computer should be set to be on the same network, i.e. 192.168.1.77 for example, with the network masks at 255.255.255.255 and the gateway to be 192.168.1.255.

  1. To set the Ubuntu network settings, click the network icon on the top left bar and choose Wired Settings in the pop down menu.


  2. In the Settings dialog box, click the gear icon as shown below.




    The Wired dialog box appears.

  3. Click the IPv4 tab. Toggle on the Manual IPv4 Method.


  4. Type in the following address values, as shown below.


  5. Scroll down. Type in the Routes (to the VLP-16) values as shown below.



  6. Click Apply. If all the values are correct, Ubuntu should show you a Network connected status. Otherwise, recheck the values and try again.
  7. Now to start ROS and run a sample Velodyne launch file, the following commands can be executed in separate terminals.


    $ roscore

    $ roslaunch velodyne_pointcloud VLP16_points.launch

    The VLP-16 /velodyne_points topic is published



Monday, May 6, 2019

Export Velodyne PCAP to LAS files in VeloView

VeloView is an open source application for working with Velodyne's popular LiDAR sensors (HDL-64E, HDL-32E, VLP-16 etc.). It is available from this website https://www.paraview.org/veloview/.

VeloView has an export to LAS file format command but you would not know it as it is not available from the graphical user interface. To generate LAS files, it is necessary to use the Python command line interface. The steps below show how it can be done.
  1. Run VeloView and load a Velodyne PCAP file.

  2. Choose Tools | Python Console.

    The Python Console appears.
  3. To export out the current frame, type in the following command at the Python prompt.

    >>> vv.saveLASCurrentFrame('c:/path/to/output.las', 0)

    Note 1: the last argument indicates the coordinate transformation mode. 0 = raw, 1 = absolute, 2 = relative.
    Note 2: Replace c:/path/to/ with your actual file system path
  4. To export a range of frames by frame numbers, type in the following command at the Python prompt.

    >>> vv.saveLASFrames('c:/path/to/output.las', 10, 20, 0)

    Note: in this example, 10 is the starting frame, 20 is the ending frame, and 0 is the raw transformation mode.
  5. To export a list of frames by time steps, type in the following command at the Python prompt.

    >>> vv.saveLAS('c:/path/to/output/las', timesteps, 0)

    Note: timesteps is an array of integers specifying the time steps e.g. [0,1,2,...10] and 0 is the raw transformation mode.

    To get the available time steps in the PCAP file, type in the following command at the Python prompt.

    >>> timesteps = vv.getCurrentTimesteps()
  6. Optional. Display the resultant LAS file in a viewer.

Monday, February 8, 2016

Resolving the ImportError: No module named paraview.simple when running VeloView

VeloView is an open source viewer for displaying point cloud data from a Velodyne laser sensor, you know the one used in driverless Google cars. After downloading and compiling the VeloView source code on an Ubuntu computer, I encountered some error messages when running the VeloView application, as shown below.
"ImportError: No module named paraview.simple"

Even though the application's main window appears, none of the commands work. And the reference grid is not displayed in the 3D view.

I figured the problem has something to do with Python being unable to locate required modules, and I added all the locations of all the other VeloView compiled packages - Paraview, VeloView, VTK into the PYTHONPATH environment variable, as shown below.


  1. Open up the .profile file in the user's home directory in a text editor, e.g.

    $ cd
    $ vi .profile
  2. Add in the following line.

    export PYTHONPATH=$PYTHONPATH:/usr/local/lib/paraview-4.3/site-packages:/usr/local/lib/veloview-3.1/site-packages:/usr/local/lib/paraview-4.3/site-packages/vtk

    A part of the .profile file is shown in the screenshot below.


  3. Save and close the .profile file.


Now when the VeloView application is run, the ImportError message no longer appears.