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

Revision history [back]

click to hide/show revision 1
initial version

ANSWER BELOW

I'm having the same issue. Still working on it, will update if I find solution.

In 2020 it wasn't ported yet... https://answers.ros.org/question/357944/why-is-point_cloud2py-missing-from-sensor_msgs-in-ros2/ but it was supposed to have been finished that year. https://github.com/ros2/common_interfaces/pull/128

EDIT:

use sensor_msgs_py. The following assume Ubuntu 20/ROS2 Foxy.

download with: sudo apt-get install ros-foxy-sensor-msgs-py

in your script:

from sensor_msgs_py import point_cloud2

...

x_points = list(point_cloud2.read_points(pcl2_msg, field_names=('x')))

ANSWER BELOW

I'm having the same issue. Still working on it, will update if I find solution.

In 2020 it wasn't ported yet... https://answers.ros.org/question/357944/why-is-point_cloud2py-missing-from-sensor_msgs-in-ros2/ but it was supposed to have been finished that year. https://github.com/ros2/common_interfaces/pull/128

EDIT:UPDATE:

use sensor_msgs_py. The following assume Ubuntu 20/ROS2 Foxy.

download with: sudo apt-get install ros-foxy-sensor-msgs-py

in your script:

from sensor_msgs_py import point_cloud2

...

x_points = list(point_cloud2.read_points(pcl2_msg, field_names=('x')))

In 2020 it wasn't ported yet... https://answers.ros.org/question/357944/why-is-point_cloud2py-missing-from-sensor_msgs-in-ros2/ but it was supposed to have been finished that year. https://github.com/ros2/common_interfaces/pull/128

UPDATE:

use sensor_msgs_py. The following assume Ubuntu 20/ROS2 Foxy.

download with: sudo apt-get install ros-foxy-sensor-msgs-py

in your script:

from sensor_msgs.msg import PointCloud2 #used as the subscription message type from sensor_msgs_py import point_cloud2 #used to read points ... self.subscription = self.create_subscription( # message_type PointCloud2, 'topic', self.listener_callback, 10 ) ... x_points = list(point_cloud2.read_points(msg, field_names=('x','y','z','intensity')))

...

x_points = list(point_cloud2.read_points(pcl2_msg, field_names=('x')))

In 2020 it wasn't ported yet... https://answers.ros.org/question/357944/why-is-point_cloud2py-missing-from-sensor_msgs-in-ros2/ but it was supposed to have been finished that year. https://github.com/ros2/common_interfaces/pull/128

UPDATE:

use sensor_msgs_py. The following assume Ubuntu 20/ROS2 Foxy.

download with: sudo apt-get install ros-foxy-sensor-msgs-py

in your script:

from sensor_msgs.msg import PointCloud2 #used as the subscription message type type

from sensor_msgs_py import point_cloud2 #used to read points

...

...

self.subscription = self.create_subscription( # message_type PointCloud2, 'topic', self.listener_callback, 10 ) ... x_points )

...

xyz_points = list(point_cloud2.read_points(msg, field_names=('x','y','z','intensity')))field_names=('x','y','z')))

In 2020 it wasn't ported yet... https://answers.ros.org/question/357944/why-is-point_cloud2py-missing-from-sensor_msgs-in-ros2/ but it was supposed to have been finished that year. https://github.com/ros2/common_interfaces/pull/128

UPDATE:

use sensor_msgs_py. The following assume Ubuntu 20/ROS2 Foxy.

download with: sudo apt-get install ros-foxy-sensor-msgs-py

in your script:

from sensor_msgs.msg import PointCloud2 #used as the subscription message type

from sensor_msgs_py import point_cloud2 #used to read points

...

self.subscription = self.create_subscription( PointCloud2, 'topic', self.listener_callback, 10 )

...

xyz_points = list(point_cloud2.read_points(msg, field_names=('x','y','z')))