Question about data structure for /cloud_map and /octomap_occupied_space
Hello, I am subscribing to the output of the PointCloud2 topics /cloud_map and /octomap_occupied_space. When receiving a new message I want to compare it to the old version I have and find the new points that were added (in case there is no loop closure and the whole map changes). The PointCloud2 messages that I am getting have an is_dense (bool) value of true so that means that the point cloud in the data field (uint8[]) is unstructured. I presumed that the new points were appended to the end of the array but checks revealed that this was not the case. I was curious if the points are stored in a specific data structure (such as a tree) that I could leverage to efficiently extract the most recent points.
Thank you.
For cloud_map, the new points are appended to previous assembled point cloud, then a voxel filter is applied. The voxel filter may not keep the points ordered. On loop closure, the whole point cloud is re-assembled and voxel filter applied again, some old points may disappear or would be "merged" together with the new points. Another thing is that cloud_map is the result of cloud_obstacles + cloud_ground, which both expand when a new node is added. I would suggest to subscribe to cloud_obstacles and cloud_ground directly, then if you disable the voxel filter (cloud_output_voxelized:=false), you may see only the new points appended at the end.
For octomap_occupied_space, it is an exported point cloud from the current occupied cells in the OctoMap. If you want a structured format, you can subscribe to /octomap_full or /octomap_binary topics (Octree format), though I am not sure you could know efficiently which cells switched between occupied and empty (in particular if ray tracing is enabled).