Why is point_cloud2.py missing from sensor_msgs in ROS2?
After subscribing to a PointCloud2 message in ROS2, I want to extract the PointCloud2 points from the message. In ROS1 I could do that with: sensor_msgs.point_cloud2.read_points(). However, point_cloud2 seems to be missing from sensor_msgs in ROS2. Here is the basic code I am trying to write:
import rclpy
from rclpy.node import Node
from sensor_msgs.msg import PointCloud2
from sensor_msgs import point_cloud2
class my_node(Node):
def __init__(self):
super().__init__('my_node')
self.subscription = self.create_subscription(PointCloud2,'/points',self.lidar_callback,1)
def lidar_callback(self, msg):
pts = point_cloud2.read_points(msg, field_names=['x','y','z','intensity'])
#Now process pts...
The 4th line fails, namely:
from sensor_msgs import point_cloud2
Any insights on how to do this in ROS2 Foxy?