Delete specific nodes

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

Delete specific nodes

dschnabel
This post was updated on .
Is it possible to delete specific nodes from the database, preferably through a UI (e.g. Graph View in database viewer)?

Let's say I have a huge map and only want to redo a certain area of the map, I could continue adding new nodes but AFAIK adding new nodes in an area won't delete old nodes so the database will keep growing. Or am I mistaken?

It could be really useful to manually select and delete nodes that are considered outdated.
Reply | Threaded
Open this post in threaded view
|

Re: Delete specific nodes

dschnabel
After studying the code/comments more it's probably not possible to delete specific nodes (area) without corrupting the database.

But as a workaround what I will do is to record and store different areas in multiple maps and create one big map by merging all the small ones. This way I can easily redo a certain area only and re-create the big map by using the updated small maps.
Reply | Threaded
Open this post in threaded view
|

Re: Delete specific nodes

Alan
I'm not sure if this will have the intended effect, but you could record the map in small sessions, as you say, and when you combine you could try using a node filtering radius to only add a single node within a user specified radius.
Reply | Threaded
Open this post in threaded view
|

Re: Delete specific nodes

Alan
Also if you use the DB editor and erase the depth image associated with a node, it will sometimes have the same effect as deleting the node altogether. At least it does for my purposes.
Reply | Threaded
Open this post in threaded view
|

Re: Delete specific nodes

matlabbe
Administrator
This post was updated on .
Hi,

Option 1:
In DatabaseViewer, it is possible to remove links from the graph to cut out some part of the map. In Graph View, mouse over the links you want to remove, then in Constraints View, browse to that link and click on Reject. Note that the data is still kept in the database, but won't be assembled in the global map.

Option 2:
With sqlitebrowser or directly by command line, to remove a node completely from the database, we should be careful to remove all its links and to clear optimized poses to force rtabmap re-optimize with the new graph afterwards. Assuming we want to remove nodes 10 to 24:
# remove links
sqlite3 rtabmap.db "Delete from Link where (from_id>=10 and from_id<=24) or (to_id>=10 and to_id<=24)" 

# remove nodes
sqlite3 rtabmap.db "Delete from Node where id>=10 and id<=24" 

# remove data
sqlite3 rtabmap.db "Delete from Data where id>=10 and id<=24" 
sqlite3 rtabmap.db "Delete from Feature where node_id>=10 and node_id<=24"

# the following one may not exist with older databases, can be skipped also if global descriptors are not used
sqlite3 rtabmap.db "Delete from GlobalDescriptor where id>=10 and id<=24"

# clear optimzed graph to force rtabmap to re-create it the next time
sqlite3 rtabmap.db "Update Admin set opt_ids = null, opt_poses = null"

# remove any statistics saved with the nodes removed (optional, but may be required if the last node is removed to avoid issues with duplicate ids)
sqlite3 rtabmap.db "Delete from Statistics where id>=10 and id<=24" 

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

Re: Delete specific nodes

dschnabel
Thanks Alan and Mathieu!

The sqlite3 option seems to be the best and cleanest solution. And it's easy to write a script that does all the steps for you. Awesome!
Reply | Threaded
Open this post in threaded view
|

Re: Delete specific nodes

matlabbe
Administrator
Hi,

I added another line in the example above to update also Statistics table. I didn't tested it, but the case of removing the last nodes of the graph may cause issues when updating Statistics table afterwards. How we know which ID we should set to next node added to map is by looking at the last one in the database (Nodes table). If we remove the last one, the new ID will be the same than the one we removed, thus re-adding a Statistics with same ID than one possibly still in database.

cheers,
Mathieu