ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

My program slows down while operating with a loop in pointcloud

asked 2022-06-04 19:38:02 -0500

sidharth.jeyabal gravatar image

Hi everyone. So I'm in the process of writing my own library for pointcloud . Now I'm stuck on a path. I have a function that I'm currently designing to give out x,y, and z values of the points in pointcould and then publish the same pointcloud after the iteration of the current pointcloud is over. But because there is a loop inside the function because of which the rate at which the pointcloud is published after its iteration is slowed down..Could you please find me a way to increase the published rate of the pointcloud than you? thanks in advance ..

        int i;
        sensor_msgs::PointCloud2 dummy;
        sensor_msgs::PointCloud2 &outputpass =dummy;
        outputpass=cloud_msg;
        for ( sensor_msgs::PointCloud2ConstIterator<float> it(outputpass,  "x"); it != it.end(); ++it) 
          {     
          cout <<" POINT CLOUD :"<< endl;
          cout<<" "<<endl;
          cout << "z " << it[2] << '\n'; 
          i++;
          }

pubpass.publish(outputpass);
edit retag flag offensive close merge delete

Comments

Can you please elaborate the following? I have a function that I'm currently designing to give out x,y, and z values of the points in pointcould and then publish the same pointcloud after the iteration of the current pointcloud is over.

ravijoshi gravatar image ravijoshi  ( 2022-06-11 01:13:33 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-06-10 22:56:18 -0500

fergs gravatar image

Terminal output (such as cout) is generally VERY slow, and point clouds are usually VERY big. There really isn't any way to to speed this up other than removing the terminal output.

One note with the PointCloud2Iterator - make sure you are compiling in RELEASE mode, which is usually about 300x faster than debug mode.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2022-06-04 19:38:02 -0500

Seen: 150 times

Last updated: Jun 10 '22