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

Parsing 3D txt data set

asked 2011-06-02 00:33:54 -0600

szokei gravatar image

updated 2011-06-07 03:29:24 -0600

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);
edit retag flag offensive close merge delete

Comments

The format is important. You should probably include the format info in your question in case someone has already parsed it before.
Asomerville gravatar image Asomerville  ( 2011-06-02 07:39:03 -0600 )edit
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); ?
Ivan Dryanovski gravatar image Ivan Dryanovski  ( 2011-06-07 03:46:42 -0600 )edit

3 Answers

Sort by ยป oldest newest most voted
4

answered 2011-06-02 00:37:10 -0600

dornhege gravatar image

updated 2011-06-07 03:28:54 -0600

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.

edit flag offensive delete link more

Comments

Im writing a PointCloud publisher, i've inserted my code related to this, there something that i'm messing up while creating the message.
szokei gravatar image szokei  ( 2011-06-07 03:10:50 -0600 )edit
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.
szokei gravatar image szokei  ( 2011-06-08 02:23:45 -0600 )edit
Did you try manually inserting handcoded points instead of real data? If that works your data is wrong.
dornhege gravatar image dornhege  ( 2011-06-08 02:59:13 -0600 )edit
I've tried also with handcoded data and I obtained the same results.
szokei gravatar image szokei  ( 2011-06-08 20:28:58 -0600 )edit
5

answered 2011-06-02 01:05:38 -0600

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.

edit flag offensive delete link more
3

answered 2011-06-02 05:39:49 -0600

Mac gravatar image

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.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2011-06-02 00:33:54 -0600

Seen: 613 times

Last updated: Jun 07 '11