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

Can't visualize Pepper's PointCloud using PCL viewer

asked 2018-02-16 05:24:56 -0600

metalaman gravatar image

updated 2018-02-18 09:08:56 -0600

lucasw gravatar image

I have written a piece of code which subscribes to my Pepper Robot's depth_registered/points topic, converts the Sensor::msg object to pcl::PointCloud using pcl::fromROSMsg(), when I try to visualize the pcl point cloud via PCL viewer I get a green red black screen(refer this) I'm able to see the pointcloud on RViZ. I've tried converting the Sensor::msg PointCloud2 object to both pcl::PointCloud<pcl::pointxyzrgb> and pcl::PointCloud<pcl::pointxyz>, both gives the same output.

Here's the snippet of code,

void callback(const sensor_msgs::PointCloud2ConstPtr &cloud) {

pcl::PointCloud<pcl::PointXYZ>::Ptr cloudGround(new pcl::PointCloud<pcl::PointXYZ>);
pcl::fromROSMsg(*cloud, *cloudGround);
pcl::visualization::CloudViewer viewer ("Simple Cloud Viewer");
viewer.showCloud (cloud);
while (!viewer.wasStopped ())
const std::string file_name = "pointcloud.pcd";
pcl::io::savePCDFileASCII (file_name, *cloudGround);


Also the depth coordinates from Pepper that I'm printing are very small in the order of 10^35. Is this expected? ROS Kinetic Ubuntu 16.04 Any help?

edit retag flag offensive close merge delete


Some suggestions: save a pcd file, try it with pcl_viewer on the command line and share the file here. Print out the xyz of the first 10 points or so. Add a screenshot of what the proper cloud looks like in rviz. Supply your cloud viewer small artificial pointcloud instead of real data.

lucasw gravatar image lucasw  ( 2018-02-16 12:58:10 -0600 )edit

Thanks for the suggestions, I tried saving to a pcd file, I'm able to see the point cloud on pcl_viewer, but it's inverted. Dunno why it didn't work programmatically. Also, I can't upload the screenshot, less karma. Thanks anyway.

metalaman gravatar image metalaman  ( 2018-02-17 06:21:47 -0600 )edit

If you can put your code in the question text it may be possible to see what is wrong.

lucasw gravatar image lucasw  ( 2018-02-17 21:04:22 -0600 )edit

Hi, I've added the code. Also I subscribed to depth/image_rect, which I think is the rectified depth image, and now all the depth values are normal.

metalaman gravatar image metalaman  ( 2018-02-18 04:45:06 -0600 )edit

The viewer ought to be created outside the callback while the callback only updates the viewer with new points- but CloudViewer doesn't support multithreading - PCLVisualizer is supposed to. Though when I last tried it it crashed a lot

lucasw gravatar image lucasw  ( 2018-02-18 09:14:14 -0600 )edit

It may not be your issue but it isn't a good design to have a ros message callback that comes to a halt for an interactive viewer rather than returning as quickly as possible.

lucasw gravatar image lucasw  ( 2018-02-18 09:36:45 -0600 )edit

So, how to show point cloud with pcl? I create the viewer outside the callback but the it does not refresh. Do you mean the message uses multithreading method and the view will not work?

七小丘人 gravatar image 七小丘人  ( 2019-04-15 03:53:55 -0600 )edit

Crosslinking to #q321133

lucasw gravatar image lucasw  ( 2019-04-15 09:38:05 -0600 )edit

1 Answer

Sort by » oldest newest most voted

answered 2019-05-25 16:17:26 -0600

daniel-s-ingram gravatar image

What you're seeing is just the three axes zoomed in. Use the mouse wheel to scroll out and you'll see your scene. I felt pretty silly when I finally figured that out.

edit flag offensive delete link more

Question Tools



Asked: 2018-02-16 05:24:56 -0600

Seen: 2,100 times

Last updated: Dec 08 '20