Having trouble understanding the velodyne ROS driver

asked 2021-08-12 16:08:38 -0600

sda273 gravatar image

Hello All,

I have a ubuntu 18.04.5 LTS 64-bit with ROS melodic installed in it. I am currently working with the velodyne VLP-16 LiDAR. I have installed the velodyne ros driver (ros-melodic-velodyne) and VeloView in my ubuntu. I am also able to run the launch file (roslaunch velodyne_pointcloud VL16_points.launch). I have set the LiDAR to its default configuration. (600 rpm, 0 to 359 FOV, strongest return, ip:

My objective of this LiDAR is to scan targets with only vertical layer (laser with 1 deg vertical angle). Initially i opened the sensor stream through VeloView and was able to select only the desired vertical layer through laser selection and was able to record 5 seconds of data looking at a flat surface. I saved the format into a csv file for each frame. So 5 seconds gave around 50 frames (5 sec*10Hz = 50 frames) and was able to look at the data. The azimuth value started at around 10(0.1 deg) to 35999 (359.99 deg) for each frame corresponding to one rotation. The corresponding x, y, z values seemed to agree with the flat surface's shape.

I tried to do the same step with the ROS. I assumed that the subscriber receives data every frame so the function pc2callback gets called for every frame (i.e 5 times a second). I used the ros_numpy to get an array of data and used the ring number (ring number for vertical layer 1 deg is '8') to just take only the points containing that layer. Once i get all the points of one frame, i print them out. When i compared those points they are all over the place and don't match the flat surface's shape. What am i doing wrong here?

Really looking forward for some help.

Thanks a lot

Code Sample:

import numpy as np
import rospy
import ros_numpy
import sensor_msgs.point_cloud2 as pc2 
from sensor_msgs.msg import PointCloud2
from std_msgs.msg import String  

def pc2callback(lidar_cloud):
    points = []
    pc = ros_numpy.numpify(lidar_cloud)
    for i in range(0, len(pc)):
        if pc['ring'][i] == 8:
            points.append((pc['x'][i], pc['y'][i], pc['z'][i]))
    print "scan_1", points

def listener():
    rospy.init_node('lidarpub', anonymous=False)
    rospy.Subscriber('/velodyne_points', PointCloud2, pc2callback)

if __name__ == '__main__':
edit retag flag offensive close merge delete