0
$\begingroup$

Rosanswers logo

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
}

Originally posted by Sofie on ROS Answers with karma: 16 on 2023-01-13

Post score: 0


Original comments

Comment by gvdhoorn on 2023-01-13:\

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?

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

Comment by Sofie on 2023-01-14:
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

Comment by gvdhoorn on 2023-01-14:
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.

Comment by Sofie on 2023-01-16:
@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 told me the data was empty eventho it wasnt. For the future I will be sure to state why I closed the question more clearly, even if there was no "solution" per se.

Comment by gvdhoorn on 2023-01-16:\

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.

Comment by Sofie on 2023-01-16:
@gvdhoorn Oh wait I didnt notice its reopened and im able to answer, gonna copy that to an answer and close it, thank u

Comment by Sofie on 2023-01-16:
I cant accept my own answer XD I guess I will just close it without accepting it

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

**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.


Originally posted by Sofie with karma: 16 on 2023-01-16

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.