How to properly publish a frame of data?

asked 2019-09-19 03:12:54 -0600

3fmeow gravatar image

updated 2019-09-19 04:02:02 -0600

Hi, I tried to change the LeGO-LOAM input to Quanergy M8 lidar data. I created getdata.cpp to parse the lidar data and publish it to /Velodyne_points topic, and LeGO-LOAM will subscribe to /velodyne_points topic to get every frame of data. The following is an overview of the main function of getdata.cpp.

ros::init(argc, argv, "getLidarData");    
ROS_INFO("\033[1;32m---->\033[0m Get Lidar Data Started.");

ros::NodeHandle nh;   
pubLaserCloud = nh.advertise<sensor_msgs::PointCloud2> (pointCloudTopic, 1);    
ros::Rate loop_rate(10);     

while (ros::ok())
    if (decodeLidarData())


I found two problems at run time after the build passed.

  1. I found that the program would block at loop_rate.sleep();,why does loop_rate.sleep(); block all the time? Theoretically it would only sleep 0.1 seconds.
  2. I shielded loop_rate.sleep(); and re-executed the program. LeGO-LOAM can receive the data from the /Velodyne_points topic and display it in rviz, but the effect is not a continuous image. It looks like the image of the latter frame is directly added to the image of the previous frame. No reset will occur after each frame is displayed, which leads to the increasing number of point clouds displayed. Eventually, rviz collapsed[rviz-1] process has died [pid 21771, exit code -9, cmd /opt/ros/kinetic/lib/rviz/rviz -d /home/charile/catkin_ws/src/LeGO-LOAM-JY/LeGO-LOAM/launch/test.rviz __name:=rviz __log:=/home/charile/.ros/log/978ae40c-daa9-11e9-98b3-00044bc52231/rviz-1.log]. log file: /home/charile/.ros/log/978ae40c-daa9-11e9-98b3-00044bc52231/rviz-1*.log.

Before that, I successfully ran lego-loam with velodyne VLP16 laser radar. Now I want to implement it with Quanergy M8 laser radar. I just want to modify its input data and display it, but I don't know what is wrong. Can someone help me. Thanks advance.

edit retag flag offensive close merge delete


I've come a long way in my work! I tried using rosrun rosbag record -O /home/nvidia/SSD_Data/PointCloudDetect/dataset/WireData/M8.bag /quanergyM8Topic to save the data in the getdata.cpp publish /Velodyne_points topic to a bag file, which succeeded, and then I tried the rosbag play bag file, using the following command,

rosbag play my.bag --clock --topic /velodyne_points /imu/data

And then successfully show the correct point cloud image in rviz! Then I made some changes to the command.

rosbag play my.bag --clock

The display effect has not changed. But when I deleted the --clock option rosbag play my.bag, repeated the second question above. Can someone tell me what impact --clock will have and how I can add it to my getdata.cpp ?

3fmeow gravatar image 3fmeow  ( 2019-09-19 05:31:25 -0600 )edit