Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

map save/load #19

Open
dannyway03 opened this issue Feb 7, 2016 · 127 comments
Open

map save/load #19

dannyway03 opened this issue Feb 7, 2016 · 127 comments

Comments

@dannyway03
Copy link

Hi Raul!

first of all thank you for sharing such a great piece of software!
I was thinking it would be nice to have some map save/load functionality.
This could enable some interesting functionalities, like the reconstruction of large scale environments in an incremental fashion (i.e., create and save and initial map, which is loaded and extended iteratively).

Do you plan to deliver such functionality?
(i saw there are some commented functions in system.h)
If not, do you have any advice to enable it?

thanks,
danny

@marcelinomalmeidan
Copy link

Hey, check the Pull Request "Add getter for map in System. #14". Seems like its exactly what you are asking about!

@dannyway03
Copy link
Author

Hi,
that is quite not the same thing. The map "getter" of #14 does not allow storing/reloading the map, and re-use it.
What I meant is to have a way to store the WHOLE map/system configuration. In this way it would be possible to load a pre-calculated environment map (and all the related information), and carry out e.g., only the camera localization (or keep on the tracking and extend the map)

@poine
Copy link

poine commented Feb 19, 2016

@dannyway03: I am working on load/save. I don't know if/when i will have it finished.

@poine
Copy link

poine commented Feb 26, 2016

Request for comments:
I have been working on map saving/loading for a while and am starting to get the first results. I am able to run ORBSLAM2 on kitti0 monocular and save the resulting map. Subsequently, I am able to restart ORBSLAM2, load the map and run in localization only mode. A typical resulting map for kitti0 (100.000 MapPoints and 1700 KeyFrames) weights about 200mB, takes 2.5s to store and 10s to load.

In order to achieve this result, I have had to butcher ORBSLAM2's code quite a bit and before releasing a patch, I would like to gain a better understanding and refactor quite a bit too, hence that first request for comments (for now i shoved most everything in Map.cc and added accessors in other classes where needed).

In my understanding, at the moment, the camera calibration is parsed by Tracking. The calibration, and computed by-products, are then stored in Frames and KeyFrames, partly as class variables and partly as instance variables. Tracking has a ChangeCalibration methods which triggers the update of the Frames class variables but leaves existing instances as is. My question is about the use case of ChangeCalibration. How is this functionality intended? I would like to avoid having to store a calibration along each KeyFrame. I could store the different calibrations and have each Keyframe linked to its own one but that also sounds a bit complicated.
I guess my question is: do we want to have the possibility of having several calibrations coexisting in one map? or was ChangeCalibration intended to be used in conjunction with a map reset and we can assume that all the Frames in a map use the same camera and the same calibration?

Oh... and once again, thank you so much Raul for your awesome work and your code. I learned so much by reading it, you are my hero!

@ghost
Copy link

ghost commented Mar 2, 2016

@poine thats great news and great work, can you give an estimate on when you can release a patch?

@poine
Copy link

poine commented Mar 2, 2016

Depends on what kind of patch you want. As I said, I butchered orbslam2
quite a bit. For example, I made camera-related stuff common to all frames,
which allowed me to not store anything camera-related in the map. Is that
what we want?
My first patch, related to the dictionary, did not get accepted (nor
rejected) so I am not sure what to do nor where to start from.
As I said before, I am a noob at C++, vision and git. I need guidance.
On Mar 2, 2016 2:06 PM, "khedd" notifications@github.com wrote:

@poine https://github.com/poine thats great news and great work, can
you give an estimate on when you can release a patch?


Reply to this email directly or view it on GitHub
#19 (comment).

@ghost
Copy link

ghost commented Mar 4, 2016

Any kind of patch will work for me.

However I do not know why your first patch did not get accepted, I see that
you have you own repository. Was you first patch about speeding up the
loading time? If so I can see that in https://github.com/poine/ORB_SLAM2.

2016-03-02 23:38 GMT+02:00 poine notifications@github.com:

Depends on what kind of patch you want. As I said, I butchered orbslam2
quite a bit. For example, I made camera-related stuff common to all frames,
which allowed me to not store anything camera-related in the map. Is that
what we want?
My first patch, related to the dictionary, did not get accepted (nor
rejected) so I am not sure what to do nor where to start from.
As I said before, I am a noob at C++, vision and git. I need guidance.
On Mar 2, 2016 2:06 PM, "khedd" notifications@github.com wrote:

@poine https://github.com/poine thats great news and great work, can
you give an estimate on when you can release a patch?


Reply to this email directly or view it on GitHub
#19 (comment).


Reply to this email directly or view it on GitHub
#19 (comment).

@MathewDenny
Copy link

@poine i tried serializing and deserializing the ORB map and i have a couple of questions to ask you.
I am storing the list of mappoints and keyframes in the Map class and I just store the ids of the observations ,the parentKFs , the spanning tree etc for each item. During loading, after loading the saved lists, im searching and the list of ids in the original lists of mappoints and keyframes and then referencing them.

In this way , I found there are non corresponding KF and Mappoint ids during crossreferencing. I can circumvent by checking for nonexistant KFs / Map points at multiple locations during run time.I am able to run in localization or mapping mode with the loaded map but fails during the instance of a loop closure.
Could you advise if i would need to serialize other elements like the Local Graph or just identify and save the missing elements also. Have you faced this situation?

@poine
Copy link

poine commented Mar 27, 2016

@denny
I am on vacations away from my computer. I'll answer in a few days.

On Fri, Mar 25, 2016 at 5:04 AM, Denny notifications@github.com wrote:

@poine https://github.com/poine i tried serializing and deserializing
the ORB map and i have a couple of questions to ask you.
I am storing the list of mappoints and keyframes in the Map class and I
just store the ids of the observations ,the parentKFs , the spanning tree
etc for each item. During loading, after loading the saved lists, im
searching and the list of ids in the original lists of mappoints and
keyframes and then referencing them.

In this way , I found there are non corresponding KF and Mappoint ids
during crossreferencing. I can circumvent by checking for nonexistant KFs /
Map points at multiple locations during run time.I am able to run in
localization or mapping mode with the loaded map but fails during the
instance of a loop closure.
Could you advise if i would need to serialize other elements like the
Local Graph or just identify and save the missing elements also. Have you
faced this situation?


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#19 (comment)

@shomin
Copy link

shomin commented Apr 6, 2016

@poine To answer your request for comments:
I don't see the function ChangeCalibration actually getting called anywhere. I think it's a very safe to assume a constant calibration throughout a map. If you're willing to commit what you have to your fork, I'd be happy to take a look at it.

@poine
Copy link

poine commented Apr 7, 2016

@michael: i am not comfortable with git and a bit short in time at the
moment to remedy it. I've uploaded an archive of my current tree here:
http://recherche.enac.fr/~drouin/slam/orbslam2/poine_orbslam2_04_07_16.tgz

The code for loading/saving maps is in Map.cc .It's kind of ugly at the
moment, but it's good enough for my needs. I have assumed a common camera
calibration for all frames and stored it with the map.

If you (or someone else) is willing to use that code, I am willing to take
the time to polish it and publish it on github.

hth

Poine

On Wed, Apr 6, 2016 at 10:56 PM, Michael Shomin notifications@github.com
wrote:

@poine https://github.com/poine To answer your request for comments:
I don't see the function ChangeCalibration actually getting called
anywhere. I think it's a very safe to assume a constant calibration
throughout a map. If you're willing to commit what you have to your fork,
I'd be happy to take a look at it.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#19 (comment)

@shomin
Copy link

shomin commented Apr 7, 2016

@poine I'll look over the code and give it a try. Your link appears to be broken though.

@poine
Copy link

poine commented Apr 7, 2016

@michael: sorry for the broken link. Should be fixed now

On Thu, Apr 7, 2016 at 7:29 PM, Michael Shomin notifications@github.com
wrote:

@poine https://github.com/poine I'll look over the code and give it a
try. Your link appears to be broken though.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#19 (comment)

@riematrix
Copy link

@poine Looking forward to see this feature been published, but maybe the link is still broken.

@bhack
Copy link

bhack commented Apr 8, 2016

@poine I hope that you can push your code on github soon. Would be very helpful.

@zsy372901
Copy link

@poine I'm glad your code released, but the link may broken...anyway, thanks for your efforts

@poine
Copy link

poine commented Apr 8, 2016

@zsy372901
The link seems to be working from my side (it was broken last night). Can
you check and let me know ?

@bhack

I'll try to free some time and look again at git oddities next week

On Fri, Apr 8, 2016 at 10:16 AM, zsy372901 notifications@github.com wrote:

@poine https://github.com/poine I'm glad your code released, but the
link may broken...anyway, thanks for your efforts


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#19 (comment)

@zsy372901
Copy link

@poine aha, it is worked:D thanks a lot!

@shomin
Copy link

shomin commented Apr 10, 2016

@poine Wow, I just gave myself a headache... There seems to be a bug in your PublishCurrentCamera function used in rgbd. I added the save subscriber from ros_mono and was trying it on a bag, but I was getting an exception after about 20 seconds of running. Very strange. I'll look into it later, but for now, the save functionality seems to be working. I'll add the loading to System.cc and try it through ros.

@shomin
Copy link

shomin commented Apr 12, 2016

@poine Would you like me to package up the save/load functionality into commits and make a pull request, or do you plan to? Also, nice work!

@poine
Copy link

poine commented Apr 12, 2016

@michael: Sure, whatever... i'm not fluent with git, so it would take me a
long time figure it. Also the code is not really finished. It only works
for monocular and i vaguely recall very inefficiently storing an array of
pointers which were mostly null.
But for now, it fills my need which was to have a georeferenced slam.

On Tue, Apr 12, 2016 at 4:39 AM, Michael Shomin notifications@github.com
wrote:

@poine https://github.com/poine Would you like me to package up the
save/load functionality into commits and make a pull request, or do you
plan to?


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#19 (comment)

@highlightz
Copy link

@poine Thanks for your great work! I have downloaded your codes and see that in Map.cc, you implemented a function called _ReadKeyFrame. And there is a comment 'mono only for now'. I have been running ORB-SLAM2 with a bumblebee2 stereo camera, that is, I need to save map in stereo mode. So could you tell me whether I can reuse your codes on my stereo camera. Thanks again.

@skylook
Copy link

skylook commented Apr 26, 2016

Thanks @poine for the great job. But I still have an issue:
If I just save map and next time load map, it loaded well but does not work on tracking stage.

It crashes on this line:

    mlRelativeFramePoses.push_back(mlRelativeFramePoses.back());<=== Crash Error: EXC_BAD_ACCESS
    mlpReferences.push_back(mlpReferences.back());
    mlFrameTimes.push_back(mlFrameTimes.back());
    mlbLost.push_back(mState==LOST);

because mlRelativeFramePoses is empty.
Any ideas on how to fix this or did I miss something?
Thanks.

@poine
Copy link

poine commented Apr 26, 2016

@skylook: the code i use to restart orbslam2 after loading a map is
here: ORB_SLAM2/test/restart_slam_on_images.cc

On Tue, Apr 26, 2016 at 11:32 AM, skylook notifications@github.com wrote:

Thanks @poine https://github.com/poine for the great job. But I still
have an issue of how to use map load function?
If I just save map and next time load map, it loaded well but does not
work on tracking because the value of mState is still NOT_INITIALIZED and
some other parameters are not set.
Any body can give a working example of Save&Load.
Thanks!


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#19 (comment)

@skylook
Copy link

skylook commented Apr 27, 2016

Thanks for your reply @poine , I already tried what you did in restart_slam_on_images.cc, it still crashes on the following line in Tracking.cc:

mlRelativeFramePoses.push_back(mlRelativeFramePoses.back());

This line is touched when it is failed tracking on the first frame (mCurrentFrame.mTcw.empty()). When it runs without an initial map, it always has a mlRelativeFramePoses, but when it runs with a initial map, it is empty.

I go through your code but I haven't catch the point on how to fix this. Any idea? Thanks so much :)

@highlightz
Copy link

@dannyway03 Have you realized your goal of reusing the slam map?

@skylook
Copy link

skylook commented May 18, 2016

I have found a problem of map load function. Because mspMapPoints is stored in std::set which means when using
std::vector<MapPoint*> amp = GetAllMapPoints();
the return vector is not always in the same order (set is ordered by the pointer address). That makes _ReadKeyFrame() function gets a wrong result. @poine

@Severn-Vergil
Copy link

@poine Thanks for your great job! Could I ask about the modification of your package comparing with the original ORB-SLAM? For example, the map save/load in map.cc and the example codes. So nice of you to help me learn more about SLAM.

@dannyway03
Copy link
Author

@highlightz not so much time for this lately...anyway, i have been trying with serialization, somehow inspired by @MathewDenny..

@chwimmer
Copy link

@poine
2 Questions:

  1. Are you able to switch back from the Localisation Mode to the SLAM Mode after loading the Map?
  2. Are you able to reset the System after loading the Map?

I'm also currently writing my code to save and load the map and it works fine, but still got problems with this 2 issues.

@Alkaid-Benetnash
Copy link

@stevenyslin
Please read the readme first.
I think how to use this functionality is explained clearly there.

@stevenyslins
Copy link

Dear @Alkaid-Benetnash ,
Sorry, my fault, because in ROS environment, my command is this :
"rosrun ORB_SLAM2 Mono /home/ubuntu/ros_build/ORB_SLAM2/Vocabulary/ORBvoc.txt /home/ubuntu/ros_build/ORB_SLAM2/Examples/Monocular/TUM1.yaml"

So if I want to save map, it can modify System.h, and set is_save_map_ as true,
although it is temporarily solution, but I can save the map and load it now.

Really thank you for your help, and have a great day.

@deveshjain94
Copy link

deveshjain94 commented Sep 13, 2017

Hi all, I was playing around with @MathewDenny 's code for map save/load. (Thanks for such an amazing work, it mostly worked out of the box). However, apart from missing MPs and KFs, I also noticed a bug which later resultant in a crash when relocalization tried to access the Parent KF of a reference KF which was non-null and pointing to garbage (this is only valid for the 1st KF ever added as it won't have a parent)

Solution would be to set mpParent to NULL (in the KF's default constructor). I don't know if anybody else faced this problem, but just putting it out there in case it helps somebody.

@FConteMarza
Copy link

FConteMarza commented Nov 10, 2017

Hello, i was using the save function and i have an issue when the algorithm detects a loop. In first place when a loop is detected and then the execution is stopped to create the text files, it takes quite a long time to the program to end, and then save the files. when a second loop is detected the program never ends therefore there is no text file saved.

I think that the problem is that the second LoopClosing process never ends, that is why the execution is not finished and the files not saved. If someone could help me with this issue it would be great.

Many thanks in advance.

@rimital
Copy link

rimital commented Nov 17, 2017

How to publish a string to the topic ORB_SLAM2/save_map for saving the map. I am new to ROS, Should I have to write a separate publisher node for publishing string in this topic?????

@wendaoyuchen
Copy link

Hi, @poine ,thanks for your work. But I met some problems when run make in the /ORB_SLAM2/build,
it reports:
../lib/libORB_SLAM2.so: undefined reference to `ORB_SLAM2::Frame::InitializeScaleLevels()'
collect2: error: ld returned 1 exit status
CMakeFiles/restart_slam_on_images.dir/build.make:161: recipe for target '../test/restart_slam_on_images' failed
make[2]: *** [../test/restart_slam_on_images] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/restart_slam_on_images.dir/all' failed
make[1]: *** [CMakeFiles/restart_slam_on_images.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

but when I change the "inlier void Frame::InitializeScaleLevels() " to " void Frame::InitializeScaleLevels()"in the file "Frame.cc", it can make well, I don't know why it works and what problems it can bring?

@wendaoyuchen
Copy link

Hi, Is there anyone know how to run in the ROS-kinetic? This ROS version supports OpenCV3, so when I rosrun the mono, it can't work .

@ADDDDD
Copy link

ADDDDD commented Jan 4, 2018

Hi, @Alkaid-Benetnash ,thanks for your code. It works fine, except missing MPs and KFs. In my case, the map I saved has 56 KFs and 2600+ MPs, but when I load map, there are only 29 KFs and 1600+ MPs. I tried other datasets, and seems to be the same result. Wonder where is the problem?
Thanks a lot!

@Alkaid-Benetnash
Copy link

Hi @ADDDDD
Have you suffered from any segment fault when localizing or updating the map?
I guess the reason may be KeyFrame::mbBad and MapPoint::mbBad.
According to here, bad MPs are still resident in memory and in my opinion KFs behave similarly. However, these bad objects may be deleted from internal structure and consequently inaccessible (memory leak?). In my code, only accessible KFs and MPs, whether bad or not, will be saved.

@ADDDDD
Copy link

ADDDDD commented Jan 4, 2018

Hi @Alkaid-Benetnash
I have confirmed I didn't get any segment fault.
I got KFs and MPs by Map::GetAllKeyFrames and Map::GetAllMapPoints, I have checked bad flags by using KeyFrame::isbad() and MapPoint::isbad() before output KFs and MPs numbers. The result is the same as I see in the viewer. Just like below:
image
image
image
When I load map, the viewer shows like this:
image

@Alkaid-Benetnash
Copy link

@ADDDDD
Please help me reproduce the problem. I can't reproduce it.
I tested with rgbd_dataset_freiburg1_desk, rgbd_dataset_freiburg1_rpy and rgbd_dataset_freiburg1_xyz in the TUM dataset. Which dataset are you using?
I check the mpMap->GetAllKeyFrames().size() and mpMap->GetAllMapPoints().size() in the System::LoadMap and System::SaveMap. Where did you check those numbers?

@ADDDDD
Copy link

ADDDDD commented Jan 4, 2018

@Alkaid-Benetnash
I use my own dataset and I check those numbers in another method wrote by myself, it is called just before SLAM::shutdown.
I will try some common datasets, and I will let you know if I find something new.
Thanks again!

@ADDDDD
Copy link

ADDDDD commented Jan 4, 2018

@Alkaid-Benetnash
Sorry, It's my fault. I made a KeyFrame Filter before save map, which changes KFs and MPs.
So sorry for bothering you !

@hesamira
Copy link

hesamira commented Feb 24, 2018

Hello world,
@MathewDenny , thanks for your code.
I have used @MathewDenny 's code.I have faced this error:
sami@sami-Vostro-1520:~/MathewDenn/src/ORB_SLAM2$ ./build.sh
./build.sh: line 35: ./tools/bin_vocabulary: No such file or directory

I have used Ubuntu 14.4, ROS indigo and OpenCV 2.4.13.
Please guide me.
Thanks.

@MathewDenny
Copy link

MathewDenny commented Feb 24, 2018 via email

@hesamira
Copy link

hesamira commented Mar 16, 2018

Dear @stevenyslin,
Hi,
How can you save map and load the data in ROS environment via Alkaid-Benetnash 's code ?
Can you share your code? I have need to save map and load the data in ROS environment.
I could run Alkaid-Benetnash 's code, but I could not save map and load the data in ROS environment.
Your answer is really important to me.
Please, guide me.
Thanks.

@morgiazzi
Copy link

Hi everyone !

I have downloaded the @poine ORBSLAM2 version with the possibility of save and load a map theoretically but I can execute ./build.sh . Indeed I have this problem :


martinorgiazzi@martinorgiazzi-ThinkPad-T540p:~/Documents/stereoCameraNavigation/orbslam2v2trial/ORB_SLAM2$ ./build.sh
Configuring and building Thirdparty/DBoW2 ...
mkdir: cannot create directory ‘build’: File exists
CMake Error: The current CMakeCache.txt directory /home/martinorgiazzi/Documents/stereoCameraNavigation/orbslam2v2trial/ORB_SLAM2/Thirdparty/DBoW2/build/CMakeCache.txt is different than the directory /home/poine/work/simone/trunk/ORB_SLAM2/Thirdparty/DBoW2/build where CMakeCache.txt was created. This may result in binaries being created in the wrong place. If you are not sure, reedit the CMakeCache.txt
CMake Error: The source "/home/martinorgiazzi/Documents/stereoCameraNavigation/orbslam2v2trial/ORB_SLAM2/Thirdparty/DBoW2/CMakeLists.txt" does not match the source "/home/poine/work/simone/trunk/ORB_SLAM2/Thirdparty/DBoW2/CMakeLists.txt" used to generate cache. Re-run cmake with a different source directory.
CMake Error: The source directory "/home/poine/work/simone/trunk/ORB_SLAM2/Thirdparty/DBoW2" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.
Makefile:296: recipe for target 'cmake_check_build_system' failed
make: *** [cmake_check_build_system] Error 1
Configuring and building Thirdparty/g2o ...
mkdir: cannot create directory ‘build’: File exists
CMake Error: The current CMakeCache.txt directory /home/martinorgiazzi/Documents/stereoCameraNavigation/orbslam2v2trial/ORB_SLAM2/Thirdparty/g2o/build/CMakeCache.txt is different than the directory /home/poine/work/simone/trunk/ORB_SLAM2/Thirdparty/g2o/build where CMakeCache.txt was created. This may result in binaries being created in the wrong place. If you are not sure, reedit the CMakeCache.txt
CMake Error: The source "/home/martinorgiazzi/Documents/stereoCameraNavigation/orbslam2v2trial/ORB_SLAM2/Thirdparty/g2o/CMakeLists.txt" does not match the source "/home/poine/work/simone/trunk/ORB_SLAM2/Thirdparty/g2o/CMakeLists.txt" used to generate cache. Re-run cmake with a different source directory.
CMake Error: The source directory "/home/poine/work/simone/trunk/ORB_SLAM2/Thirdparty/g2o" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.
Makefile:917: recipe for target 'cmake_check_build_system' failed
make: *** [cmake_check_build_system] Error 1
Uncompress vocabulary ...
Configuring and building ORB_SLAM2 ...
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
Build type: Release
-- Performing Test COMPILER_SUPPORTS_CXX11
-- Performing Test COMPILER_SUPPORTS_CXX11 - Success
-- Performing Test COMPILER_SUPPORTS_CXX0X
-- Performing Test COMPILER_SUPPORTS_CXX0X - Success
-- Using flag -std=c++11.
-- Found Eigen3: /usr/include/eigen3 (Required is at least version "3.1.0")
-- Boost version: 1.58.0
-- Found the following Boost libraries:
-- regex
-- system
-- filesystem
-- Configuring done
-- Generating done
-- Build files have been written to: /home/martinorgiazzi/Documents/stereoCameraNavigation/orbslam2v2trial/ORB_SLAM2/build
Scanning dependencies of target ORB_SLAM2
[ 1%] Building CXX object CMakeFiles/ORB_SLAM2.dir/src/Camera.cc.o
[ 3%] Building CXX object CMakeFiles/ORB_SLAM2.dir/src/System.cc.o
[ 5%] Building CXX object CMakeFiles/ORB_SLAM2.dir/src/Tracking.cc.o
[ 7%] Building CXX object CMakeFiles/ORB_SLAM2.dir/src/LocalMapping.cc.o
[ 9%] Building CXX object CMakeFiles/ORB_SLAM2.dir/src/LoopClosing.cc.o
[ 11%] Building CXX object CMakeFiles/ORB_SLAM2.dir/src/ORBextractor.cc.o
/home/martinorgiazzi/Documents/stereoCameraNavigation/orbslam2v2trial/ORB_SLAM2/src/ORBextractor.cc: In member function ‘void ORB_SLAM2::ORBextractor::ComputeKeyPointsOctTree(std::vector<std::vectorcv::KeyPoint >&)’:
/home/martinorgiazzi/Documents/stereoCameraNavigation/orbslam2v2trial/ORB_SLAM2/src/ORBextractor.cc:808:46: error: ‘FAST’ was not declared in this scope
vKeysCell,iniThFAST,true);
^
/home/martinorgiazzi/Documents/stereoCameraNavigation/orbslam2v2trial/ORB_SLAM2/src/ORBextractor.cc: In member function ‘void ORB_SLAM2::ORBextractor::ComputeKeyPointsOld(std::vector<std::vectorcv::KeyPoint >&)’:
/home/martinorgiazzi/Documents/stereoCameraNavigation/orbslam2v2trial/ORB_SLAM2/src/ORBextractor.cc:933:66: error: ‘FAST’ was not declared in this scope
FAST(cellImage,cellKeyPoints[i][j],iniThFAST,true);
^
/home/martinorgiazzi/Documents/stereoCameraNavigation/orbslam2v2trial/ORB_SLAM2/src/ORBextractor.cc:1004:17: error: ‘KeyPointsFilter’ has not been declared
KeyPointsFilter::retainBest(keysCell,nToRetain[i][j]);
^
/home/martinorgiazzi/Documents/stereoCameraNavigation/orbslam2v2trial/ORB_SLAM2/src/ORBextractor.cc:1022:13: error: ‘KeyPointsFilter’ has not been declared
KeyPointsFilter::retainBest(keypoints,nDesiredFeatures);
^
/home/martinorgiazzi/Documents/stereoCameraNavigation/orbslam2v2trial/ORB_SLAM2/src/ORBextractor.cc: In member function ‘void ORB_SLAM2::ORBextractor::operator()(cv::InputArray, cv::InputArray, std::vectorcv::KeyPoint&, cv::OutputArray)’:
/home/martinorgiazzi/Documents/stereoCameraNavigation/orbslam2v2trial/ORB_SLAM2/src/ORBextractor.cc:1084:82: error: ‘GaussianBlur’ was not declared in this scope
GaussianBlur(workingMat, workingMat, Size(7, 7), 2, 2, BORDER_REFLECT_101);
^
/home/martinorgiazzi/Documents/stereoCameraNavigation/orbslam2v2trial/ORB_SLAM2/src/ORBextractor.cc: In member function ‘void ORB_SLAM2::ORBextractor::ComputePyramid(cv::Mat)’:
/home/martinorgiazzi/Documents/stereoCameraNavigation/orbslam2v2trial/ORB_SLAM2/src/ORBextractor.cc:1118:78: error: ‘INTER_LINEAR’ was not declared in this scope
resize(mvImagePyramid[level-1], mvImagePyramid[level], sz, 0, 0, INTER_LINEA
^
/home/martinorgiazzi/Documents/stereoCameraNavigation/orbslam2v2trial/ORB_SLAM2/src/ORBextractor.cc:1118:90: error: ‘resize’ was not declared in this scope
resize(mvImagePyramid[level-1], mvImagePyramid[level], sz, 0, 0, INTER_LINEAR);
^
CMakeFiles/ORB_SLAM2.dir/build.make:182: recipe for target 'CMakeFiles/ORB_SLAM2.dir/src/ORBextractor.cc.o' failed
make[2]: *** [CMakeFiles/ORB_SLAM2.dir/src/ORBextractor.cc.o] Error 1
CMakeFiles/Makefile2:474: recipe for target 'CMakeFiles/ORB_SLAM2.dir/all' failed
make[1]: *** [CMakeFiles/ORB_SLAM2.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2


Someone had the same building issue or has an idea to solve it ?

Thank you in advance !

@amitfishy
Copy link

amitfishy commented Jun 6, 2018

Hi @Alkaid-Benetnash
I tried out your repo, map saving and loading works pretty well. However I have noticed that when I try to map slightly larger areas I am able to save the map, but I get the following error when I try to load it again:

Loading Mapfile: map.bin
terminate called after throwing an instance of 'boost::archive::archive_exception'
  what():  input stream error
Aborted (core dumped)

In this way I have been able to load maps up to roughly 550MB successfully, but if I create a larger map of >600MB, I get the aforementioned error. Any idea how to fix this?

EDIT: It seems like this error occurs when the video is very large even if the map created is small. I was able to load a map once I shortened the video (even though its size was 610MB).

Thanks

@Alkaid-Benetnash
Copy link

@amitfishy
I guess the map isn't saved properly. As you have noticed, the size of map doesn't grow according to the video length (it should in most cases).

Can you confirm everything works fine when saving the map?

Besides, finphin encountered problems when saving large maps, you can take a look at his comment.

@amitfishy
Copy link

amitfishy commented Jun 18, 2018

I think there might be a problem with the original repo itself, seeing as how I sometimes get Seg faults with it. Some people have suggested using a different version of Pangolin which helps to some extent but you still get occasional Seg faults. Possibly the repo does not scale too well with larger maps or I might be using a newer version of a dependency that the original repo was built on.
These errors like the QObject:Timers error sometimes occur on exiting the program, so I'm thinking the same issues have crept into your fork. Apart from this everything in your repo seemed to work perfectly.

I'll try out what was mentioned in the other post. Thank you!

@ksivakumar
Copy link

@amitfishy Did you have any luck in solving this issue? I tried the solution in the other post by increasing stack size but I am still getting a malloc(): memory corruption error with larger maps.

@amitfishy
Copy link

@ksivakumar
Sorry, I didn't really follow up on this. Partly I felt map sizes were too large for small clips and going over the same area again would add on a significant overhead(about 50-70% extra memory for retracing a path). I didn't really think getting this working was worth it. Maybe have a look at maplab which has its own problems, but infrastructure-wise, it's pretty solid and bug free.

@RahmanMifta
Copy link

@ywj447
As you can see in this Line the Map is saved in a binary format with the ending ".bin"
You cant visualize it with a pcl_viewer.
You are only able to save and load it with ORB SLAM.

When you want to visualize it otherwise you have to convert every Mappoint and Keyframe Pose in a PCL Datatype. Thats not implemented yet.

Tank you for you suggestion. I am a newbie in ORB-SLAM2. I have map.bin file. Can you please guide me little more elaborately how to get pointcloud from map.bin file?

@Shubhamvithalani
Copy link

@poine @MathewDenny I was able to save and load map using serialisation. I tried to relocalise on a pre-loaded map and was able to do it successfully. Now if I want the re-localised position with respect to the Global Map. Can you suggest any methods. My aim is to to travel from a point A to point B inside the map using SLAM. Thus I need to establish global position of A,B

@AlejandroSilvestri
Copy link

Hey guys,

If you are still looking for a way to save maps, I have this project working fine:
https://github.com/AlejandroSilvestri/osmap

It uses Google's protocol buffers, so the protocol used in serialization is well documented, and you can modify it without losing compatibility. Plus an example code show you how to access keyframes, mappoints and so directly in the map files, without the need of compiling all ORB-SLAM2.

@kadn
Copy link

kadn commented Jun 26, 2019

@poine Hi, I found some bugs in your code http://recherche.enac.fr/~drouin/slam/orbslam2/poine_orbslam2_04_07_16.tgz

  1. Frame.cc has an illegal inline in front of ORB_SLAM2::Frame::InitializeScaleLevels()
  2. void Tracking::Track() : I change the code
mlRelativeFramePoses.push_back(mlRelativeFramePoses.back());

into this

        if(mlRelativeFramePoses.size()==0)
            mlRelativeFramePoses.push_back(cv::Mat());
        else
            mlRelativeFramePoses.push_back(mlRelativeFramePoses.back());
  1. a bug in g2o/g2o/solvers/linear_solver_eigen.h
    After change:
class LinearSolverEigen: public LinearSolver<MatrixType>
{
  public:
    typedef Eigen::SparseMatrix<double, Eigen::ColMajor> SparseMatrix;
    typedef Eigen::Triplet<double> Triplet;
    typedef Eigen::PermutationMatrix<Eigen::Dynamic, Eigen::Dynamic, int> PermutationMatrix;
  1. I think LoopClosing thread should be hang up, but there is no such function. So I changewhile(1) to while(0).

Your work is really awesome !!
After these operations, I succeed in saving and loading, and I get a good result that looks nice!

@Shame-fight
Copy link

Hey guys,

If you are still looking for a way to save maps, I have this project working fine:
https://github.com/AlejandroSilvestri/osmap

It uses Google's protocol buffers, so the protocol used in serialization is well documented, and you can modify it without losing compatibility. Plus an example code show you how to access keyframes, mappoints and so directly in the map files, without the need of compiling all ORB-SLAM2.

I have two questions about 'How to bundle with ORB-SLAM2'

  1. The second step '2- Add Osmap files to ORB-SLAM2 project.', I only have osmap.pb.h and no osmap.h. Do these two files refer to the same.
  2. Step 4: 'Write the code to call save and load, usually attached to UI. As an example, in Orb-Slam2's main.cc'. I can't find which folder main.cc is in, I've searched The entire folder. I only have main.cpp under the pangolin folder. Can you tell me where the main.cc file is?

@AlejandroSilvestri
Copy link

@Shame-fight

Answers:

1- Osmap.h is into include folder. Osmap.cc is into src folder.
2- Readme fixed. There's no main.cc. You must locate main() in orb-slam2. There are many in Example folder.

Let me know if it works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests