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

Why is point_cloud2.py missing from sensor_msgs in ROS2?

asked 2020-07-24 09:45:41 -0500

Morris gravatar image

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?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2020-07-24 12:49:59 -0500

https://github.com/ros2/common_interf...

Not ported yet. https://github.com/ros/common_msgs/tr... looks pretty trivial to port though if you need it. Submit a PR!

edit flag offensive delete link more

Comments

Ah yes, I will do that, but I'm new to this. How to submit a PR?

Thanks!

Morris gravatar image Morris  ( 2020-07-24 12:58:44 -0500 )edit

Through GitHub, you have to understand Git to do so (if you don't know Git, you should really learn, its the basis for modern software development).

stevemacenski gravatar image stevemacenski  ( 2020-07-24 13:29:44 -0500 )edit

Okay, I submitted this as a feature request. Hopefully that is the right thing to do. Thanks.

Morris gravatar image Morris  ( 2020-07-24 15:09:01 -0500 )edit

Sure thing, can you mark this answer as correct then?

stevemacenski gravatar image stevemacenski  ( 2020-07-24 15:31:57 -0500 )edit
2

answered 2020-12-10 13:00:29 -0500

flynneva gravatar image

this has been ported now https://github.com/ros2/common_interf....

just waiting on the release to update

edit flag offensive delete link more

Comments

also see the answer from April 6, 2023 https://answers.ros.org/question/4114...

Hazel-rah gravatar image Hazel-rah  ( 2023-05-03 13:27:21 -0500 )edit

Question Tools

Stats

Asked: 2020-07-24 09:45:41 -0500

Seen: 3,741 times

Last updated: Dec 10 '20