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

[ Stable Build ] : Corrects major bugs, and creates buildable repo #798

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

aPR0T0
Copy link

@aPR0T0 aPR0T0 commented Aug 23, 2023

  • C11 to C14 migration
  • Adds Absent ros/orbslam3 from examples
  • OpenCV3 to OpenCV4 migration for old_examples
  • fixes Eigen incompatibility

Don't ask for atomic commits for this

Aah, where to start, It's a very not updated type of repo, to begin with, to be honest, there is so many compatibility issues man!!!

@unicornuniform
Copy link

unicornuniform commented Aug 24, 2023

I wanted to try your fork to see if it fixed the segfault I was getting with the original.

sam@14IAU7:~/lib/ORB_PROTO$ ./Examples/Monocular/mono_euroc ./Vocabulary/ORBvoc.txt ./Examples/Monocular/EuRoC.yaml /home/sam/datasets/EuRoC/MH01 ./Examples/Monocular/EuRoC_TimeStamps/MH01.txt dataset-MH01_mono
num_seq = 1
file name: dataset-MH01_mono
Loading images for sequence 0...LOADED!


ORB-SLAM3 Copyright (C) 2017-2020 Carlos Campos, Richard Elvira, Juan J. Gómez, José M.M. Montiel and Juan D. Tardós, University of Zaragoza.
ORB-SLAM2 Copyright (C) 2014-2016 Raúl Mur-Artal, José M.M. Montiel and Juan D. Tardós, University of Zaragoza.
This program comes with ABSOLUTELY NO WARRANTY;
This is free software, and you are welcome to redistribute it
under certain conditions. See LICENSE.txt.

Input sensor was set to: Monocular
Loading settings from ./Examples/Monocular/EuRoC.yaml
Camera1.k3 optional parameter does not exist...
-Loaded camera 1
-Loaded image info
-Loaded ORB settings
Viewer.imageViewScale optional parameter does not exist...
-Loaded viewer settings
System.LoadAtlasFromFile optional parameter does not exist...
System.SaveAtlasToFile optional parameter does not exist...
-Loaded Atlas settings
System.thFarPoints optional parameter does not exist...
-Loaded misc parameters

SLAM settings:
-Camera 1 parameters (Pinhole): [ 458.65399169921875 457.29598999023438 367.21499633789062 248.375 ]
-Camera 1 distortion parameters: [ -0.28340810537338257 0.073959067463874817 0.00019359000725671649 1.7618711353861727e-05 ]
-Original image size: [ 752 , 480 ]
-Current image size: [ 600 , 350 ]
-Camera 1 parameters after resize: [ 365.94735717773438 333.44500732421875 292.99069213867188 181.10678100585938 ]
-Sequence FPS: 20
-Features per image: 1000
-ORB scale factor: 1.2000000476837158
-ORB number of scales: 8
-Initial FAST threshold: 20
-Min FAST threshold: 7

Loading ORB Vocabulary. This could take a while...
Vocabulary loaded!

Initialization of Atlas from scratch
Creation of new map with id: 0
Creation of new map with last KF id: 0
Seq. Name:
There are 1 cameras in the atlas
Camera 0 is pinhole
First KF:0; Map init KF:0
New Map created with 271 points
Starting the Viewer
Shutdown

Saving trajectory to f_dataset-MH01_mono.txt ...
There are 1 maps in the atlas
Map 0 has 318 KFs

End of saving trajectory to f_dataset-MH01_mono.txt ...

Saving keyframe trajectory to kf_dataset-MH01_mono.txt ...
> Segmentation fault (core dumped)

Any ideas?

@aPR0T0
Copy link
Author

aPR0T0 commented Aug 24, 2023

Can you provide me with the dataset you are using here?

@unicornuniform
Copy link

Can you provide me with the dataset you are using here?

Machine Hall 01
http://robotics.ethz.ch/~asl-datasets/ijrr_euroc_mav_dataset/machine_hall/MH_01_easy/MH_01_easy.zip

@aPR0T0
Copy link
Author

aPR0T0 commented Aug 24, 2023

downloading it, very slow speed it seems

@unicornuniform
Copy link

More here: https://github.com/search?q=repo%3AUZ-SLAMLab%2FORB_SLAM3+Segmentation+fault&type=issues

@prajapatisarvesh
Copy link

@aPR0T0 thanks for this, this solves almost all issues and works flawlessly. Just to add up, for some of our machines, we had this problem where compiler wasn't able to find std::chrono::monotonic_clock, I don't know what's the most efficient way to solve it, but replacing this with std::chrono::steady_clock solves the issues. (Just in case anyone runs into the same issue.)

@chetanpandey1266
Copy link

@aPR0T0 I was able to build successfully but when I am trying to run the example scripts they are showing: libpango_windowing.so: cannot open shared object file: No such file or directory

How are you running the examples? Can you please share the steps

@aPR0T0
Copy link
Author

aPR0T0 commented Aug 30, 2023

@aPR0T0 I was able to build successfully but when I am trying to run the example scripts they are showing: libpango_windowing.so: cannot open shared object file: No such file or directory

How are you running the examples? Can you please share the steps

Did you build the pangolin ?

@aPR0T0
Copy link
Author

aPR0T0 commented Aug 30, 2023

I wanted to try your fork to see if it fixed the segfault I was getting with the original.

sam@14IAU7:~/lib/ORB_PROTO$ ./Examples/Monocular/mono_euroc ./Vocabulary/ORBvoc.txt ./Examples/Monocular/EuRoC.yaml /home/sam/datasets/EuRoC/MH01 ./Examples/Monocular/EuRoC_TimeStamps/MH01.txt dataset-MH01_mono
num_seq = 1
file name: dataset-MH01_mono
Loading images for sequence 0...LOADED!

ORB-SLAM3 Copyright (C) 2017-2020 Carlos Campos, Richard Elvira, Juan J. Gómez, José M.M. Montiel and Juan D. Tardós, University of Zaragoza.
ORB-SLAM2 Copyright (C) 2014-2016 Raúl Mur-Artal, José M.M. Montiel and Juan D. Tardós, University of Zaragoza.
This program comes with ABSOLUTELY NO WARRANTY;
This is free software, and you are welcome to redistribute it
under certain conditions. See LICENSE.txt.

Input sensor was set to: Monocular

Loading settings from ./Examples/Monocular/EuRoC.yaml
Camera1.k3 optional parameter does not exist...
-Loaded camera 1
-Loaded image info
-Loaded ORB settings
Viewer.imageViewScale optional parameter does not exist...
-Loaded viewer settings
System.LoadAtlasFromFile optional parameter does not exist...
System.SaveAtlasToFile optional parameter does not exist...
-Loaded Atlas settings
System.thFarPoints optional parameter does not exist...
-Loaded misc parameters
SLAM settings:
-Camera 1 parameters (Pinhole): [ 458.65399169921875 457.29598999023438 367.21499633789062 248.375 ]
-Camera 1 distortion parameters: [ -0.28340810537338257 0.073959067463874817 0.00019359000725671649 1.7618711353861727e-05 ]
-Original image size: [ 752 , 480 ]
-Current image size: [ 600 , 350 ]
-Camera 1 parameters after resize: [ 365.94735717773438 333.44500732421875 292.99069213867188 181.10678100585938 ]
-Sequence FPS: 20
-Features per image: 1000
-ORB scale factor: 1.2000000476837158
-ORB number of scales: 8
-Initial FAST threshold: 20
-Min FAST threshold: 7
Loading ORB Vocabulary. This could take a while...
Vocabulary loaded!
Initialization of Atlas from scratch
Creation of new map with id: 0
Creation of new map with last KF id: 0
Seq. Name:
There are 1 cameras in the atlas
Camera 0 is pinhole
First KF:0; Map init KF:0
New Map created with 271 points
Starting the Viewer
Shutdown
Saving trajectory to f_dataset-MH01_mono.txt ...
There are 1 maps in the atlas
Map 0 has 318 KFs
End of saving trajectory to f_dataset-MH01_mono.txt ...
Saving keyframe trajectory to kf_dataset-MH01_mono.txt ...
> Segmentation fault (core dumped)

Any ideas?

Hello, I actually downloaded the dataset and tested it on My system it didn't give me segmentation fault.

Camera1.k3 optional parameter does not exist..., this line seems strange to me, please check if the dataset you are using is correct, but then I did the test on your data set only.

you can see my output

Steps I follow:

  • Building Pangolin
  • Building ORB_SLAM3
  • Then just running this
./Examples/Monocular/mono_euroc ./Vocabulary/ORBvoc.txt ./Examples/Monocular/EuRoC.yaml /home/proto/Downloads/ ./Examples/Monocular/EuRoC_TimeStamps/MH01.txt 
num_seq = 1
Loading images for sequence 0...LOADED!

-------

ORB-SLAM3 Copyright (C) 2017-2020 Carlos Campos, Richard Elvira, Juan J. Gómez, José M.M. Montiel and Juan D. Tardós, University of Zaragoza.
ORB-SLAM2 Copyright (C) 2014-2016 Raúl Mur-Artal, José M.M. Montiel and Juan D. Tardós, University of Zaragoza.
This program comes with ABSOLUTELY NO WARRANTY;
This is free software, and you are welcome to redistribute it
under certain conditions. See LICENSE.txt.

Input sensor was set to: Monocular
Loading settings from ./Examples/Monocular/EuRoC.yaml
Camera1.k3 optional parameter does not exist...
	-Loaded camera 1
	-Loaded image info
	-Loaded ORB settings
Viewer.imageViewScale optional parameter does not exist...
	-Loaded viewer settings
System.LoadAtlasFromFile optional parameter does not exist...
System.SaveAtlasToFile optional parameter does not exist...
	-Loaded Atlas settings
System.thFarPoints optional parameter does not exist...
	-Loaded misc parameters
----------------------------------
SLAM settings: 
	-Camera 1 parameters (Pinhole): [ 458.65399169921875 457.29598999023438 367.21499633789062 248.375 ]
	-Camera 1 distortion parameters: [  -0.28340810537338257 0.073959067463874817 0.00019359000725671649 1.7618711353861727e-05 ]
	-Original image size: [ 752 , 480 ]
	-Current image size: [ 600 , 350 ]
	-Camera 1 parameters after resize: [  365.94735717773438 333.44500732421875 292.99069213867188 181.10678100585938 ]
	-Sequence FPS: 20
	-Features per image: 1000
	-ORB scale factor: 1.2000000476837158
	-ORB number of scales: 8
	-Initial FAST threshold: 20
	-Min FAST threshold: 7


Loading ORB Vocabulary. This could take a while...
Vocabulary loaded!

Initialization of Atlas from scratch 
Creation of new map with id: 0
Creation of new map with last KF id: 0
Seq. Name: 
There are 1 cameras in the atlas
Camera 0 is pinhole
First KF:0; Map init KF:0
New Map created with 271 points

Shutdown

Saving trajectory to CameraTrajectory.txt ...
There are 1 maps in the atlas
  Map 0 has 315 KFs

End of saving trajectory to CameraTrajectory.txt ...

Saving keyframe trajectory to KeyFrameTrajectory.txt ...

@geoeo
Copy link

geoeo commented Sep 1, 2023

Thanks a lot for this. It solved all build issues. I hope it gets merged into the main branch

@unicornuniform
Copy link

I don't know what I'm doing wrong. I bought a new laptop, installed Ubuntu 20.04 and compiled your fork + ROS. I'm running:
rosrun ORB_SLAM3 Mono Vocabulary/ORBvoc.txt Examples/Monocular/Webcam.yaml

After I build a map and hit Stop to try and save the Atlas file, I get Segmentation fault (core dumped)

@prajapatisarvesh
Copy link

@unicornuniform Might be something to do with the calibration? Make sure your Examples/Monocular/Webcam.yaml is correct.

@unicornuniform
Copy link

unicornuniform commented Nov 3, 2023

I tried a bunch of different setings. Here is the gdb output:

Thread 4 "mono_webcam" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffe0316700 (LWP 78069)]
__GI___pthread_mutex_lock (mutex=0x7000700040256) at ../nptl/pthread_mutex_lock.c:67
67 ../nptl/pthread_mutex_lock.c: No such file or directory.
(gdb) backtrace
#0 __GI___pthread_mutex_lock (mutex=0x7000700040256)
at ../nptl/pthread_mutex_lock.c:67
#1 0x00007ffff7de1549 in void std::lock<std::unique_lockstd::mutex, std::unique_lockstd::mutex>
(std::unique_lockstd::mutex&, std::unique_lockstd::mutex&) () at /home/sam/libs/ORB_SLAM3/lib/libORB_SLAM3.so
#2 0x00007ffff7ddddec in ORB_SLAM3::MapPoint::isBad() ()
at /home/sam/libs/ORB_SLAM3/lib/libORB_SLAM3.so
#3 0x00007ffff7df4126 in ORB_SLAM3::Map::PreSave(std::set<ORB_SLAM3::GeometricCamera*,
std::less<ORB_SLAM3::GeometricCamera*>, std::allocator<ORB_SLAM3::GeometricCamera*> >&) () at /home/sam
/libs/ORB_SLAM3/lib/libORB_SLAM3.so
#4 0x00007ffff7df19d2 in ORB_SLAM3::Atlas::PreSave() ()
at /home/sam/libs/ORB_SLAM3/lib/libORB_SLAM3.so
#5 0x00007ffff7d47856 in ORB_SLAM3::System::SaveAtlas(int) ()
at /home/sam/libs/ORB_SLAM3/lib/libORB_SLAM3.so
#6 0x00007ffff7d47fb9 in ORB_SLAM3::System::Shutdown() ()
at /home/sam/libs/ORB_SLAM3/lib/libORB_SLAM3.so
#7 0x00007ffff7eb94b4 in ORB_SLAM3::Viewer::Run() ()
at /home/sam/libs/ORB_SLAM3/lib/libORB_SLAM3.so
#8 0x00007ffff4d16df4 in () at /lib/x86_64-linux-gnu/libstdc++.so.6
#9 0x00007ffff42f9609 in start_thread (arg=)
at pthread_create.c:477
#10 0x00007ffff4b52133 in clone ()
at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
(gdb)

It happens when I hit Stop and the map tries to save. I read through the issues and many people seem to have the same problem. Is it possible I'm having a null pointer somewhere in SaveAtlas(), PreSave(), or isBad()? Sorry, I'm not a c/c++ programmer.

@aPR0T0
Copy link
Author

aPR0T0 commented Nov 3, 2023

I tried a bunch of different setings. Here is the gdb output:

Thread 4 "mono_webcam" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffe0316700 (LWP 78069)]
__GI___pthread_mutex_lock (mutex=0x7000700040256) at ../nptl/pthread_mutex_lock.c:67
67 ../nptl/pthread_mutex_lock.c: No such file or directory.
(gdb) backtrace
#0 __GI___pthread_mutex_lock (mutex=0x7000700040256)
at ../nptl/pthread_mutex_lock.c:67
#1 0x00007ffff7de1549 in void std::lock<std::unique_lockstd::mutex, std::unique_lockstd::mutex>
(std::unique_lockstd::mutex&, std::unique_lockstd::mutex&) () at /home/sam/libs/ORB_SLAM3/lib/libORB_SLAM3.so
#2 0x00007ffff7ddddec in ORB_SLAM3::MapPoint::isBad() ()
at /home/sam/libs/ORB_SLAM3/lib/libORB_SLAM3.so
#3 0x00007ffff7df4126 in ORB_SLAM3::Map::PreSave(std::set<ORB_SLAM3::GeometricCamera*,
std::less<ORB_SLAM3::GeometricCamera*>, std::allocator<ORB_SLAM3::GeometricCamera*> >&) () at /home/sam
/libs/ORB_SLAM3/lib/libORB_SLAM3.so
#4 0x00007ffff7df19d2 in ORB_SLAM3::Atlas::PreSave() ()
at /home/sam/libs/ORB_SLAM3/lib/libORB_SLAM3.so
#5 0x00007ffff7d47856 in ORB_SLAM3::System::SaveAtlas(int) ()
at /home/sam/libs/ORB_SLAM3/lib/libORB_SLAM3.so
#6 0x00007ffff7d47fb9 in ORB_SLAM3::System::Shutdown() ()
at /home/sam/libs/ORB_SLAM3/lib/libORB_SLAM3.so
#7 0x00007ffff7eb94b4 in ORB_SLAM3::Viewer::Run() ()
at /home/sam/libs/ORB_SLAM3/lib/libORB_SLAM3.so
#8 0x00007ffff4d16df4 in () at /lib/x86_64-linux-gnu/libstdc++.so.6
#9 0x00007ffff42f9609 in start_thread (arg=)
at pthread_create.c:477
#10 0x00007ffff4b52133 in clone ()
at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
(gdb)

It happens when I hit Stop and the map tries to save. I read through the issues and many people seem to have the same problem. Is it possible I'm having a null pointer somewhere in SaveAtlas(), PreSave(), or isBad()? Sorry, I'm not a c/c++ programmer.

Hello @unicornuniform ,

There is a missing pthread_mutex_lock.c file I think its some library version issue. You can start by understanding why it can't find this file

@unicornuniform
Copy link

I'm going to look into it. Possibly the CMake file is not linking libpthread

@unicornuniform
Copy link

unicornuniform commented Nov 3, 2023

Okay, I'm 99% sure now the problem is in PreSave, and that pthread_mutex_lock.c is a red herring. I'll try again when I get home

@unicornuniform
Copy link

Based on the issue here it seems as if the crash is caused by Map::PreSave deleting items of mspMapPoints while iterating it. I put a cout statement in Map::PreSave() to show this.

void Map::PreSave(std::set<GeometricCamera*> &spCams)
{
    int nMPWithoutObs = 0;
    std::cout << "mspMapPoints.size(): " << mspMapPoints.size() << endl;
    for(MapPoint* pMPi : mspMapPoints)
    {
        if(!pMPi || pMPi->isBad())
            continue;

        if(pMPi->GetObservations().size() == 0)
        {
            nMPWithoutObs++;
        }
        map<KeyFrame*, std::tuple<int,int>> mpObs = pMPi->GetObservations();
        for(map<KeyFrame*, std::tuple<int,int>>::iterator it= mpObs.begin(), end=mpObs.end(); it!=end; ++it)
        {
            if(it->first->GetMap() != this || it->first->isBad())
            {
                pMPi->EraseObservation(it->first);
                std::cout << "\tmspMapPoints.size(): " << mspMapPoints.size() << endl;
            }
        }
    }

So I can do a successful run that looks like this:

mspMapPoints.size(): 184
Starting to write the save binary file
End to write save binary file

But a failed run looks like this:

mspMapPoints.size(): 755
mspMapPoints.size(): 755
mspMapPoints.size(): 755
mspMapPoints.size(): 754
Segmentation fault (core dumped)

After incorporating the changes to Map::PreSave and MapPoint::PreSave I linked to above, I'm no longer getting a segfault.

@aPR0T0
Copy link
Author

aPR0T0 commented Nov 4, 2023

Based on the issue here it seems as if the crash is caused by Map::PreSave deleting items of mspMapPoints while iterating it. I put a cout statement in Map::PreSave() to show this.

void Map::PreSave(std::set<GeometricCamera*> &spCams)
{
    int nMPWithoutObs = 0;
    std::cout << "mspMapPoints.size(): " << mspMapPoints.size() << endl;
    for(MapPoint* pMPi : mspMapPoints)
    {
        if(!pMPi || pMPi->isBad())
            continue;

        if(pMPi->GetObservations().size() == 0)
        {
            nMPWithoutObs++;
        }
        map<KeyFrame*, std::tuple<int,int>> mpObs = pMPi->GetObservations();
        for(map<KeyFrame*, std::tuple<int,int>>::iterator it= mpObs.begin(), end=mpObs.end(); it!=end; ++it)
        {
            if(it->first->GetMap() != this || it->first->isBad())
            {
                pMPi->EraseObservation(it->first);
                std::cout << "\tmspMapPoints.size(): " << mspMapPoints.size() << endl;
            }
        }
    }

So I can do a successful run that looks like this:

mspMapPoints.size(): 184
Starting to write the save binary file
End to write save binary file

But a failed run looks like this:

mspMapPoints.size(): 755
mspMapPoints.size(): 755
mspMapPoints.size(): 755
mspMapPoints.size(): 754
Segmentation fault (core dumped)

After incorporating the changes to Map::PreSave and MapPoint::PreSave I linked to above, I'm no longer getting a segfault.

Did you delete the items after iteration then?

@unicornuniform
Copy link

See the code I linked to above. He keeps the functionality the same but uses a temporary set to copy mspMapPoints into.

@geoeo
Copy link

geoeo commented Nov 8, 2023

@richard-elvira Can someone please merge this branch. It would make a lot of peoples lives a lot easier!

@aPR0T0
Copy link
Author

aPR0T0 commented Nov 8, 2023

I think there are a lot of changes, so if possible someone could verify and suggest some edits so that its a lot cleaner to be merged.

@apurvvarshney
Copy link

Did anyone try Realsense examples on this branch?

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

Successfully merging this pull request may close these issues.

6 participants