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

How convert `sensor_msgs/PointCloud2` message to 3D coordinate

asked 2022-07-17 19:25:59 -0500

farhad-bat gravatar image

Hello,

As it is explained here: http://docs.ros.org/en/lunar/api/sens...

sensor_msgs/PointCloud2 has different attributes like header, fields, is_bigendian, point_step, ..., data.

Different attribute, especially fields and is_bigendian, has confused me. How can I convert sensor_msgs/PointCloud2 message to a 3D coordinate? I want to convert it to a NumPy array with shape (N, 3)

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2022-08-04 08:08:19 -0500

Hi There, I came across similar situation, wherein I needed points in (N ,3 ) format. if using python, then there is a package ros_numpy. Try installing it. Then its

import ros_numpy

data_np = ros_numpy.numpify(data)

where data_np is in numpy format, and data is in PointCloud2. the data_np not only has the xyz coordinates, but also has other fields related to the particular PointCloud2 data (eg., Intensity, Color Information). So filter out the numpy array once you get it right.

edit flag offensive delete link more
0

answered 2022-07-18 09:11:51 -0500

Mike Scheutzow gravatar image

Typing pointcloud2 into the search box at the top of this page would show you very-similar previous questions. For example, see #q401077.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2022-07-17 19:25:59 -0500

Seen: 245 times

Last updated: Jul 18 '22