We have seen how to simulate a Velodyne sensor; now let's have a look at how we can interface a real Velodyne sensor with ROS.
The following commands are to install the Velodyne ROS driver package to convert Velodyne data into point cloud data.
For ROS Melodic, install the package using the following command:
$ sudo apt-get install ros-melodic-velodyne
Here is the command to start the driver nodelets:
$ roslaunch velodyne_driver nodelet_manager.launch model:=32E
In the preceding command, you need to mention the model name along with the launch file to start the driver for a specific model.
The following command will start the converter nodelets to convert Velodyne messages (velodyne_msgs/VelodyneScan) into a point cloud (sensor_msgs/PointCloud2). Here is the command to perform this conversion:
$ roslaunch velodyne_pointcloud cloud_nodelet.launch calibration:=~/calibration_file.yaml
This will launch the calibration file for Velodyne, which is necessary for correcting noise from the sensor.
We can write all of these commands to a launch file, which is shown in the following code block. If you run this launch file, the driver node and point cloud convertor nodelets will start, and we can work with the sensor data:
<launch> <!-- start nodelet manager and driver nodelets --> <include file="$(find velodyne_driver)/launch/nodelet_manager.launch" /> <!-- start transform nodelet --> <include file="$(find velodyne_pointcloud)/launch/transform_nodelet.launch"> <arg name="calibration" value="$(find velodyne_pointcloud)/params/64e_utexas.yaml"/> </include> </launch>
The calibration files for each model are available in the velodyne_pointcloud package. We can now move on to simulating a laser scanner.