As per the title, I'm trying to update a map (nav_msgs::msg::OccupancyGrid) without use slam_toolbox, nav2, etc. For fun, I'm trying to do mapping with a basic RGB camera like the Raspberry PI camera, for which I just check the pixels for a certain color and not use SLAM or any form of depth camera. I cannot use a SLAM stack because almost all of them rely on laser scans to get their data (the practical way), which I figure is going to be hard to rewrite, even if they're open source.
Furthermore, I must be subscribed to the /camera/raw_image topic while getting the pixel information from the camera, so it's not like I can copy the information by subscribing to a /map topic at the same time. In fact, the only way it seems to be possible to get both the information of the /map and /camera would be to do my current process of a message_filter. Something like:
time_sync = std::make_shared<message_filters::Sychronizer<message_fitlers::sync_policies::ApproximateTime<
sensor_msgs::msg::Image, nav_msgs::msg::OccupancyGrid>>>(20, image_sub, map_sub);
time_sync->registerCallback(std::bind(&Node::read_image, this, _1, _2));
void read_image(const sensor_msgs::msg::Image::ConstSharedPtr & img,
const nav_msgs::msg::OccupancyGrid::ConstSharedPtr & map)
{ // create a new map, copy all the information, update map.data.at(whatever img.pixel) }
Other than the bad performance of having to make essentially 2 maps when you'd like to use 1, this ApproximateTimeSync doesn't work well since I don't have access to the camera publisher, so I can't get a close/exact time stamp of the image to pair with the map.
If it matters, right now I don't care about resizing the map when the robot goes out of frame, so if it becomes really bad I could just make a basic bit map with a std::vector, but I didn't know if there was anything more extensive or reliable.