Removing oldest keyframes

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Removing oldest keyframes

kgeebelen
Dear Mathieu,

I have a use case where I have a robot driving both indoor and outdoor in an industrial environment (outdoor area next to the factory). For indoor, we have a working localization system. For outdoor, the robot is equiped with both a RTK GNSS receiver and a stereo camera. However, when we go from indoor to outdoor, the GNSS receiver needs a considerable amount of time (20 seconds up to 1 minute) to get an RTK-fix. Our idea is to use the stereo camera and GNSS together with RTAB-Map to get an accurate, drift-free map of the environment, which we can then use to localize within when there is no GNSS signal, and still achieve sufficient accuracy. We could already create a proof-of-concept of this with the current functionalities of RTAB-Map.

However, the outdoor environment is changing drastically from day to day, so we need to constantly update the map with GNSS. If we keep RTAB-Map in mapping modus all the time however, the map just grows unbounded. In this application, it would be perfectly fine to just throw away the oldest keyframes from the map, and only keep the most recent ones in order to constrain the size of the map (e.g. only keep keyframes from the last 10 hours, and remove anything older than that).

Is this something that is either already possible with RTAB-Map, or could (easily) be added? If so, could you give some pointers on how to approach this?

Thanks,
Best regards,
Kurt
Reply | Threaded
Open this post in threaded view
|

Re: Removing oldest keyframes

matlabbe
Administrator
Hi,

If you indeed input the GPS to rtabmap (feeding /gps/fix topic, with Optimizer/PriorsIgnored=false), that can make it easier to remove old nodes in the map while keeping the map in same origin (based on the GPS). Ideally, if you can clean the map offline, it would be easier. You can use "rtabmap-reprocess" CLI tool to extract nodes up to past 10 hours, with this option :
-start #    Start from this node ID.
To know from which ID to start from, you can do a sqlite3 query on the database:
ID=$(sqlite3 rtabmap.db "select min(id) from Node where time_enter > '2024-09-29 19:45:15'")

rtabmap-reprocess -start #ID rtabmap.db output.db

cheers,
Mathieu
Reply | Threaded
Open this post in threaded view
|

Re: Removing oldest keyframes

kgeebelen
Thanks, I will give that a try.

Do you also see an option to limit the size in 'runtime'? Perhaps not based on time (last 10 hours), but on the maximum number of nodes in the map?
Reply | Threaded
Open this post in threaded view
|

Re: Removing oldest keyframes

matlabbe
Administrator
This post was updated on .
Hi,

You could enable Memory Management with Rtabmap/MemoryThr (maximum number of nodes kept in Working Memory). Then to only keep the latest nodes in Working Memory, you can set Mem/RehearsalSimilarity=1 to simulate a FIFO.

Note that doing this way could simplify removing old nodes afterwards, like a sqlite3 request like:
# cleanup Node
DELETE FROM Node AS n WHERE n.time_enter < (SELECT MAX(time_enter) FROM Info)

# cleanup Word
DELETE FROM Word AS w WHERE w.time_enter < (SELECT MAX(time_enter) FROM Info)
Other requests could be done to cleanup Features, Link amd Data tables if their corresponding node id are gone. Backup your database before editing the database like this.

To reduce database file size after the cleanup, there is a VACUUM request that can be done.

cheers,
Mathieu