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

sensor_msgs::PointCLoud empty in Callback but rostopic echo gives values

asked 2023-01-13 09:39:02 -0500

Sofie gravatar image

Hello, I want to work with a sensor_msgs::PointCloud I am provided with by a laser scanner. I subscribed to the topic /riegl3d and the Callback is executed but the PointCloud is empty. For example the msg->points.size() is 0 (header id gets printed as riegl and channel name as intensity, while channel size is 0 too). When I do rostopic echo /riegl3d the topic is received and a lot of data printed, so the point cloud is not empty! Im honestly at a lost cause I subscribed to a PointCloud2 message exactly the same and everything worked. Im working with cpp and noetic on a linux system.

The initialisation of my subscriber in the Class head:

ros::Subscriber rieglsub;

The subscriber in my class constructor:

rieglsub = n.subscribe("/riegl3d", 1000, &SubscribeAndPublish::rieglCallback, this);

My Callback:

void rieglCallback(const sensor_msgs::PointCloudConstPtr& msg) //TODO: msg empty
{
   ROS_INFO("[IntensityCorrection] got riegl pointcloud with frame id: %s", msg->points.size().c_str());
   //do something with pointcloud data
}
edit retag flag offensive close merge delete

Comments

msg->points.size().c_str()

I'm confused. std::vector::size() returns a size_t. That doesn't have any c_str() method (it doesn't have any methods at all, as it's a primitive).

Have you tried compiling this?

gvdhoorn gravatar image gvdhoorn  ( 2023-01-13 12:15:17 -0500 )edit

what happens if you use ROS_INFO_STREAM("[IntensityCorrection] got riegl pointcloud with frame id: " << msg->points.size()); instead?

ignacio gravatar image ignacio  ( 2023-01-13 19:01:24 -0500 )edit

sorry everyone I tried looking if I even get the id and had my code with msg->header.frame_id.c_str() before publishing the question. I wanted to change it back to my original problem of %ld msg->points.size() not getting anything. Didnt edit the question right tho, sorry for that. I already got further and now get data. Sorry for that

Sofie gravatar image Sofie  ( 2023-01-14 05:26:47 -0500 )edit

If you've solved your original issue, please don't just close your question. Post the solution as an answer and accept your own answer.

That way future visitors would benefit from what you learned instead of coming to a question which was only closed with "Oh I figured it out" without any information as to how you solved your problem.

gvdhoorn gravatar image gvdhoorn  ( 2023-01-14 10:19:18 -0500 )edit

@gvdhoorn I closed it as irrelevant cause there practically was no issue. I did get the data. I did a typo in my print statement to see if the problem is me not getting a cloud via the callback, after the original problem arose that my processing didn't work. That did not work because the point I retrieved from the rxp pointcloud file (riegl pointcloud fileformat) is for some reason in another scale/coordinate system then the points I get from the topic. After figuring out how to look at the topic pointcloud with rviz (I only get one single topic with the finished pointcloud, so I had to set a delay time) and taking point coordinates from there, everything worked fine. It was just that the coordinates I used before didnt exist in the pointcloud, and sadly I made a typo in my debug print, so that it ...(more)

Sofie gravatar image Sofie  ( 2023-01-16 07:01:48 -0500 )edit

After figuring out how to look at the topic pointcloud with rviz (I only get one single topic with the finished pointcloud, so I had to set a delay time) and taking point coordinates from there, everything worked fine. It was just that the coordinates I used before didnt exist in the pointcloud

so this would be your answer to post.

Even "typos" and "I misinterpreted something" are valid answers.

gvdhoorn gravatar image gvdhoorn  ( 2023-01-16 08:41:00 -0500 )edit

@gvdhoorn Oh wait I didnt notice its reopened and im able to answer, gonna copy that to an answer and close it, thank u

Sofie gravatar image Sofie  ( 2023-01-16 11:03:14 -0500 )edit

I cant accept my own answer XD I guess I will just close it without accepting it

Sofie gravatar image Sofie  ( 2023-01-16 11:06:51 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-01-16 11:06:08 -0500

Sofie gravatar image

*Typo and Misinterpretation, closing the question. *

Detailed reason: There practically was no issue. I did get the data. I did a typo in my print statement to see if the problem is me not getting a cloud via the callback, after the original problem arose that my processing didn't work. That did not work because the point I retrieved from the rxp pointcloud file (riegl pointcloud file format) is for some reason in another scale/coordinate system than the points I get from the topic. After figuring out how to look at the topic pointcloud with rviz (I only get one single topic with the finished pointcloud, so I had to set a delay time) and taking point coordinates from there, everything worked fine. It was just that the coordinates I used before didn't exist in the pointcloud, and sadly I made a typo in my debug print, so it told me the data was empty even tho it wasn't.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2023-01-13 09:39:02 -0500

Seen: 157 times

Last updated: Jan 16 '23