Quantcast
Channel: ROS Answers: Open Source Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 171

In-Place Modification of PointCloud2 message?

$
0
0
I am subscribing to a `sensor_msgs/PointCloud2` message (points with: x,y,z,intensity) and I would like to change the intensity value based on some heuristic in my code. In principle the code looks like this: import sensor_msgs.point_cloud2 def handle_cloud(self, msg): field_names = ("x", "y", "z", "intensity") reader = sensor_msgs.point_cloud2.read_points(msg, field_names) for p in reader: new_intensity = some_code(p) # assign new intensity to point p[3] = new_intensity # TODO: is this possible somehow? # republish with new intensity values publisher.publish(msg) Can I do this in-place, similarly to the code above? Or do I need to build a new message, using [`sensor_msgs.point_cloud2.create_cloud()`](http://docs.ros.org/melodic/api/sensor_msgs/html/namespacesensor__msgs_1_1point__cloud2.html#a1dd7d701c1207e788076cf9e28ec3200) ?

Viewing all articles
Browse latest Browse all 171