0
$\begingroup$

Rosanswers logo

Hello!I've obtained a 3D data set and its stored in a txt file, the question would be how it is possible to load it into RViz? Thank you.

Im trying to build up a PointCloud message, the 3D data set is loaded from a vector, im stucked how to insert the values of pC into cloud.channels.values. In this way there is no msg reeived in RViz.

sensor_msgs::PointCloud cloud;
    cloud.header.stamp = ros::Time::now();
    cloud.header.frame_id = "/base_link";
    
    cloud.channels.resize(1);
    int32_t countX = 24120;
    int32_t countY = 24120;
    int32_t countZ = 24120;
    int32_t total = countX * countY * countZ; 
    cloud.points.resize(total);
    
    cloud.channels[0].values.resize(total);
    cloud.channels[0].name = "rgb";     
    
    while (it < myvector.end())
    {
          geometry_msgs::Point32& pC = cloud.points[i]; 
          pC.y = *(it) * 0.001;
          myfile2 << *(it++) * 0.001 <<"\n";
          pC.x = *(it) * 0.001;
          myfile2 << *(it++) * 0.001 <<"\n";
          pC.z = *(it) * 0.001;
          myfile2 << *(it++) * 0.001 <<"\n";
          
          cloud.channels[0].values[i++] = 1.0f;                       
     }
     myfile2.close();
     cloud_pub.publish(cloud);    

Originally posted by szokei on ROS Answers with karma: 80 on 2011-06-02

Post score: 1


Original comments

Comment by Ivan Dryanovski on 2011-06-07:
I don't get the logic behind int32_t total = countX * countY * countZ; If you have 24120 points, shouldn't it be cloud.points.resize(24120); ?

Comment by Asomerville on 2011-06-02:
The format is important. You should probably include the format info in your question in case someone has already parsed it before.

$\endgroup$

3 Answers 3

0
$\begingroup$

Rosanswers logo

You can write a publisher, that publishes a PointCloud to rviz. That should be fairly easy to do.

For publishing a pointcloud it should be quite easy, if you use a pointcloud class from the pcl. An example can be found here.


Originally posted by dornhege with karma: 31395 on 2011-06-02

This answer was ACCEPTED on the original site

Post score: 4


Original comments

Comment by szokei on 2011-06-08:
I've tried also with handcoded data and I obtained the same results.

Comment by dornhege on 2011-06-08:
Did you try manually inserting handcoded points instead of real data? If that works your data is wrong.

Comment by szokei on 2011-06-08:
I'm using the code given in your example im pushing in the message all the 24120 points but on the subscription side both RViz and the subscriber from the pcl example are receiving just the first point.

Comment by szokei on 2011-06-07:
Im writing a PointCloud publisher, i've inserted my code related to this, there something that i'm messing up while creating the message.

$\endgroup$
0
$\begingroup$

Rosanswers logo

If you want to see an example of dornhege's suggestion - take a look at ncd_parser, which does the same task using the New College Dataset.


Originally posted by Ivan Dryanovski with karma: 4954 on 2011-06-02

This answer was NOT ACCEPTED on the original site

Post score: 5

$\endgroup$
0
$\begingroup$

Rosanswers logo

The PCL point cloud file format (.pcd, see here) is also a text format; a quick text-to-text transformation would be easy to do. Then, publishing the PointCloud to rviz (or pcd_viewer, if you prefer), as described above, would be easier.


Originally posted by Mac with karma: 4119 on 2011-06-02

This answer was NOT ACCEPTED on the original site

Post score: 3

$\endgroup$

Your Answer

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