Ask Your Question

Why is 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):
        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

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

Not ported yet. looks pretty trivial to port though if you need it. Submit a PR!

edit flag offensive delete link more


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


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

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

flynneva gravatar image

this has been ported now

just waiting on the release to update

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools


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

Seen: 269 times

Last updated: Dec 10 '20