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

publish rtab point cloud from rviz

asked 2015-08-05 06:56:27 -0500

Salocin808 gravatar image

updated 2015-08-05 09:52:52 -0500


I am currently following this tutorial on my turtlebot:

Therefore I started turtlebot and rviz like this:

$ roslaunch turtlebot_bringup minimal.launch
$ roslaunch rtabmap_ros demo_turtlebot_mapping.launch
$ roslaunch rtabmap_ros demo_turtlebot_rviz.launch

It all works fine but I don't know how to export the point cloud I created. My goal is to have a list of XYZ coordinates from all points. Anyone got any ideas?


I tried to run

rosservice call /rtabmap/get_map 1 0 0

but that does nothing... and when I click the get map option in RVIZ it is first trying to call get_map and then I get the error: screenshot rviz

rtab/get_map is in the namespace though. Here is part of my rosservice list:

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2015-08-05 12:30:53 -0500

matlabbe gravatar image

updated 2015-08-06 06:24:56 -0500

You can subscribe to /rtabmap/cloud_map topic to get the point cloud.

$ rosrun pcl_ros pointcloud_to_pcd input:=rtabmap/cloud_map
$ pcl_viewer ###.pcd

If the mapping is paused, you can force rtabmap to publish the map again:

$ rosrun pcl_ros pointcloud_to_pcd input:=rtabmap/cloud_map
$ rosservice call /rtabmap/publish_map 1 1 0
$ pcl_viewer ###.pcd

For the get_map service error, I can't reproduce the problem with RVIZ (the clouds are correctly downloaded and shown). If you call it from terminal, you would see a lot of numbers printed. Note that I tested with rtabmap_ros 0.10.4 (binaries on Indigo have just been released).


To have the point cloud in PLY format (to open it in MeshLab or any other 3D programs), you can use pcd2ply tool from PCL:

$ pcl_pcd2ply ###.pcd output.ply
edit flag offensive delete link more


Thank you very much for your help! I am definately closer to where I want to be now. pcl_ros was a good tip. I can generate the .pcd files now but I want to have the coordinates with RGB values. So I figured, I could just convert it back with pcd_to_pointcloud. After these lines nothing's happening:

Salocin808 gravatar image Salocin808  ( 2015-08-06 03:10:16 -0500 )edit

salocin@salocin-laptop:~$ rosrun pcl_ros pcd_to_pointcloud ~/1438846855801553.pcd [ INFO] [1438848137.530670782]: Publishing data on topic /cloud_pcd with frame_id /base_link. [ INFO] [1438848137.542530309]: Loaded a point cloud with 1670 points (total size is 26720) and the following channels: x y

Salocin808 gravatar image Salocin808  ( 2015-08-06 03:11:07 -0500 )edit

The PCD already contains RGB values. In pcl_viewer, you have to press "6" or "5" to see the RGB point cloud. The other keys "1", "2"... show different overlays (similar to that video).

matlabbe gravatar image matlabbe  ( 2015-08-06 06:20:02 -0500 )edit

Oh ok perfect. I have one more question: when opening the file, I get X Y Z RGB values for the points. But the RGB values are float. The representation looks like this: 1.8005456 -0.7766516 -0.0509897 4.8842062e-39 The fourth number should be RGB but how? Can I get values for the three channels?

Salocin808 gravatar image Salocin808  ( 2015-08-06 07:27:13 -0500 )edit

PCD format documentation here. In your case, the RGB field is a float 4 bytes (A-R-G-B). 4.8842062e-39=0x00352f2e -> RGB hex code=352F2E which is R=53 G=47 B=46 on decimal 0->255

matlabbe gravatar image matlabbe  ( 2015-08-06 08:16:16 -0500 )edit

Ok thank you very much, it has been very helpful!

Salocin808 gravatar image Salocin808  ( 2015-08-06 08:31:48 -0500 )edit

Question Tools

1 follower


Asked: 2015-08-05 06:56:27 -0500

Seen: 2,198 times

Last updated: Aug 06 '15