Ask Your Question

How to visualize a message of type sensor_msgs/PointCloud2[] in Rviz?

asked 2020-03-18 08:18:09 -0500

Anubhav Singh gravatar image

updated 2020-03-18 08:21:46 -0500

Hey guys, I hope you all are doing well. I am facing a problem related to visualizing a topic in Rviz. So, I have a custom message of type sensor_msgs/PointCloud2[]. I have created an instance of this message type and pushing sensor_msgs/PointCloud2 data to it and eventually publishing the final message/array on a topic, let's suppose /topic_name. My question is:

How to visualize it inside Rviz?

I can see the data by running rostopic echo /topic_name, but unfortunately can't see the topic name under topic section of PointCloud2 display in Rviz. I would really appreciate your help on this.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-03-18 10:28:28 -0500

gvdhoorn gravatar image

As you're using a custom message, you can't use the built-in displays, as they don't work with your message, only with the standard message set.

I believe you have two options:

  1. write a new RViz display plugin which can consume your custom message (possibly extending the current PointCloud2 display)
  2. use an intermediate node to "unpack" your list of PointCloud2 into separate messages and then republish those

Option 2 would incur lots of overhead, but would allow the use of the built-in display plugin for PointCloud2.

Option 1 would require you to write your own RViz display plugin, which comes with its own form of overhead.

edit flag offensive delete link more


What you encounter is actually why the recommendation is to try and use standard messages as much as possible.

If you created your custom message because the PointCloud2s in the list "belong together", then perhaps looking into wiki/message_filters (ExactTime or ApproximateTime) may help here.

gvdhoorn gravatar image gvdhoorn  ( 2020-03-18 10:30:46 -0500 )edit

Thank you so much for your answer. And, it completely make sense. What I did is create an object of type pcl.PointCloud_PointXYZRGB() and make elements of my array of type PointCloud2 as its points using .from_list method . Then convert the PCL data to ROS messages and eventually publish it on a topic of type PointCloud2.

Anubhav Singh gravatar image Anubhav Singh  ( 2020-03-19 10:49:28 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2020-03-18 08:18:09 -0500

Seen: 73 times

Last updated: Mar 18