Orb_slam2: Reset ORB-SLAM

Created on 16 Jan 2019  路  10Comments  路  Source: raulmur/ORB_SLAM2

Hi,

From the viewer it is possible to Reset() ORB-SLAM.
However, I would like to know if it was possible to just remove the points, the keyframes but still keeping the initialisation made at the beginning ?

In the reset function, it is reseting localMapper, loopClosing, KeyframeDB and the Map. What should I keep and remove to keep the initialisation but clear the map ?

Thanks

Most helpful comment

@AlejandroSilvestri
Alright ! Thank you very much !
It's clear and I understand better how it works!
I will try to do something

All 10 comments

The initialization consists in creating the map, with the first two keyframes and many mappoints. There's no way to erase all keyframes and mappoints and preserve initialization.

I believe you want to eliminate most of the map and return to the "just initialized map".

Many worked on saving and loading maps in ORB-SLAM2. Using these tools (not provided by ORB-SLAM2) you can initialize and save the map. Any time you want to return to that map, you load it.

You can search in this "issues/forum" for such tools. I myself have one, but it is on a groped code version of orb-slam2, reduced to monocular only, and it doesn't work perfect.

Right now I'm developing orb-slam2 map serialization with protocol buffers. No ready yet.

@AlejandroSilvestri
Yes, it's exactly what I would like to do -> return to the just initialized map.
Actually, I can already save and load a map using this pull request.

In fact, the idea of my work is focused on two parts:

  • Map an entire building,
  • Locate the position into the building.

What I though was to create many maps of the different rooms and corridors of the building to avoid the overlapping.
So far, from this pull request I can save and load map. I modify it in order to save a map in live and not after shutting down ORB-SLAM. Thus, I avoid to restart the ORB-SLAM each time I save a map and I can continue to discover the building without interruption. However, after that, I need to remove all points and keyframes to have a clean map to save. This is why I asked this question to "Reset ORB-SLAM".

And then, my second problem is about locate the position into the building from all the maps. Indeed, my idea was to switch between all the maps saved each 5 seconds while ORB-SLAM running to find the position. For this, I need to know if it's possible to change a map while ORB-SLAM running. Indeed, during the initialization, the map is created and used for the tracker, the mapDrawer, the frameDrawer,... and then the viewer uses the tracker to initiliaze. So if I change the map, I am afraid the tracker, the mapDrawer or the viewer will not work anymore.

@PierBJX

I believe you are loading the map on starting orb-slam2.

I have a mapLoad method to open a file. You load the map in this sequence:

  • Pause threads, to ensure nobody try to access the map while it is loading
  • Clear the actual map
  • Load de new map on existing Map object
  • Restart threads
  • Take the tracker to LOST state

@PierBJX ,

One idea.

Relocalization uses KeyFrameDatabase to fast searching. You can think of a big database indexing not only de keyframes of the current map, but the keyframes of the whole building. When relocalization find one keyframe, you load the map that has it.

@PierBJX

I believe you are loading the map on starting orb-slam2.

I have a mapLoad method to open a file. You load the map in this sequence:

* Pause threads, to ensure nobody try to access the map while it is loading

* Clear the actual map

* Load de new map on existing Map object

* Restart threads

* [Take the tracker to LOST state](https://github.com/AlejandroSilvestri/os1/blob/179e42d8f940530989bae24086e6a339e62f8321/src/main.cc#L175)

I succeeded to do it following your sequence except that I finish the threads instead of pause them.

@PierBJX ,

One idea.

Relocalization uses KeyFrameDatabase to fast searching. You can think of a big database indexing not only de keyframes of the current map, but the keyframes of the whole building. When relocalization find one keyframe, you load the map that has it.

It means that I should have an extra variable, called FullKeyFrameDatabase, with two elements: vector of keyframes with a variable which is the index of one map. The method will consist to add all the keyframes from the KeyFrameDatabase of the current map with the index of the current map to the variable FullKeyFrameDatabase each time I save the map. Then, when the whole building is finished to be mapped I save the variable FullKeyFrameDatabase. Like this I will have the whole KeyFrameDatabase. Am I right ?

But then, how can I initialized the system at the beginning ?
Indeed, I need to load the Map but if I only have the variable FullKeyFrameDatabase how is it feasible ?

@PierBJX

"I succeeded to do it following your sequence except that I finish the threads instead of pause them."

I don't know if you want to finish the threads or it is an unwanted side effect. All I can say is that the code in the sequence I showed you is working just fine. RequestStop pause the threads, Release() unpause then.

About KeyFrameDatabase, I can think of many ways to do this, all of them implying a lot of work. KeyFrameDatabase can point you to candidate keyframes for relocalization. This candidates could be in other maps (modifying the code, of course). You must load those maps to do the final pose test to come out with the winning keyframe.

About KeyFrameDatabase, I can think of many ways to do this, all of them implying a lot of work. KeyFrameDatabase can point you to candidate keyframes for relocalization. This candidates could be in other maps (modifying the code, of course). You must load those maps to do the final pose test to come out with the winning keyframe.

@AlejandroSilvestri , I am not sure to get this

@PierBJX ,
Well, it's a bit complex.
BRIEF descriptors are classified and reduced to an int, a "word", so every close descriptor will be classified as the same word.
KeyFrameDatabase is a list of all possible words (one million words), and for each word this database has a list of KeyFrames that has that word. Meaning those keyframes has at least one descriptor classified as that word.

On relocalization, orb-slam2 takes the words from each keypoint of the relocalizing frame, and look for keyframes that has each of those words. Candidates keyframes are those who share a minimum number of words with the relocalizing frame.

Here is when, may be, you can know what map to open. The next step requires the map already loaded: orb-slam2 do a geometric test on each candidate keyframe to see which one suits better.

@AlejandroSilvestri
Alright ! Thank you very much !
It's clear and I understand better how it works!
I will try to do something

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pulkitver1991 picture pulkitver1991  路  4Comments

ank700 picture ank700  路  3Comments

ColeHoff7 picture ColeHoff7  路  4Comments

jinfagang picture jinfagang  路  4Comments

akashshar picture akashshar  路  4Comments