ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

Pointcloud conversion slows down simulation

asked 2019-10-07 02:10:44 -0500

NTkot gravatar image

updated 2022-06-11 08:56:39 -0500

lucasw gravatar image

After spawning a model in rviz, ROS Time (indicator on the bottom left) runs smoothly until I run a pointCloud conversion node. Then, ROS Time seems to update based on the update_rate gazebo tag of the sensor that returns the PointCloud I'm trying to convert to PointCloud2. This is the code I'm using for the conversion node:

#include <ros/ros.h>
#include <sensor_msgs/PointCloud.h>
#include <sensor_msgs/PointCloud2.h>
#include <sensor_msgs/point_cloud_conversion.h>
#include <ros/publisher.h>

ros::Publisher pointcloud2Publisher;

void p2p2Converter(const sensor_msgs::PointCloud& msg) {
    sensor_msgs::PointCloud2 pointcloud2;
    if (sensor_msgs::convertPointCloudToPointCloud2(msg,pointcloud2))
        ROS_INFO("Failed to publish PointCloud2");


int main(int argc, char **argv) {
    ros::init(argc, argv, "p2p2_node");
    ros::NodeHandle n;
    pointcloud2Publisher = n.advertise<sensor_msgs::PointCloud2>("/lidar/pointcloud2", 1);
    ros::Subscriber pointcloudListener = n.subscribe("/lidar/pointcloud", 1, p2p2Converter);
    return 0;

Here's my CMakeLists.txt:

cmake_minimum_required(VERSION 2.8.3)

find_package(catkin REQUIRED COMPONENTS



add_executable(p2p2_node src/p2p2.cpp)


EDIT: I cloned the following point_cloud_converter pkg but the issue remains.

edit retag flag offensive close merge delete


What do you actually mean by "slows down simulation"? You can try echoing the topics to see if the timestamps make sense.

pavel92 gravatar image pavel92  ( 2019-10-07 02:26:46 -0500 )edit

Sorry for not clarifying but by slow-down I mean that every second in real life is the equivalent of 1/update_rate of the sensor. When not running the conversion node, ROS real time factor seems to be almost 1 (meaning that 1 second in real life is 1 second in ROS). After running rostopic echo /lidar/pointcloud2 and rostopic echo /lidar/pointcloud, it seems that ROS moves to the next simulation step everytime a PointCloud is published on the /lidar/pointcloud topic

NTkot gravatar image NTkot  ( 2019-10-07 06:18:46 -0500 )edit

1 Answer

Sort by » oldest newest most voted

answered 2019-10-07 10:59:48 -0500

NTkot gravatar image

Turns out the problem was the number of rays published in /lidar/pointcloud. After reducing it, ROS Time was updating smoothly again.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2019-10-06 16:09:25 -0500

Seen: 199 times

Last updated: Oct 07 '19