ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
This is possible, although the the PointCloud2 messages are not designed to be used this way. It may well take less code to create a new PointCloud2 message, however if you need to work on the message in-place for performance reasons then there is a way. Just to clarify if you're not doing this for performance reasons then I would recommend extracting the cloud from the message, modifying it and creating a new message.
The PointCloud2 message type stores the actual point data in it's data member as a byte array. it is possible to work out exactly where within this array each value lies and its type and then overwrite them in place.
The data structure of the PointCloud2 message is defined by an array of PointField Messages and the point_step and row_step byte spacing. If you're only going to work with a single type of point cloud you could ignore this an hard code the solution, but you'll need to look at it at least once to know what the structure is in the first place.
If you still want to try and do this and need some more pointers, let me know and I can give you some more detailed info.