AlejandroSilvestri / Osmap-viewer

Viewer for maps from ORB-SLAM2 Osmap
19 stars 8 forks source link

How to compile the code? #3

Open lbrianza opened 1 year ago

lbrianza commented 1 year ago

Hello,

Sorry in advance because this is probably a naive question, but how to compile this package? I am very confused as I see no instructions at all, and no makefile.

I tried for example with g++, which returns several compilation errors, such as: src/main.cpp: In function ‘int main(int, char**)’: src/main.cpp:34:11: error: no matching function for call to ‘ORB_SLAM2::System::System()’ 34 | System system; | ^~~~~~ In file included from include/Osmap.h:45, from src/main.cpp:15: include/System.h:62:5: note: candidate: ‘ORB_SLAM2::System::System(const string&, const string&, ORB_SLAM2::System::eSensor, bool)’ 62 | System(const string &strVocFile, const string &strSettingsFile, const eSensor sensor, const bool bUseViewer = true); | ^~~~~~ include/System.h:62:5: note: candidate expects 4 arguments, 0 provided src/main.cpp:36:36: error: no matching function for call to ‘ORB_SLAM2::KeyFrameDatabase::KeyFrameDatabase()’ 36 | system.mpKeyFrameDatabase = new KeyFrameDatabase; | ^~~~~~~~~~~~~~~~ In file included from include/KeyFrame.h:30, from include/Osmap.h:42, from src/main.cpp:15: include/KeyFrameDatabase.h:46:5: note: candidate: ‘ORB_SLAM2::KeyFrameDatabase::KeyFrameDatabase(const ORBVocabulary&)’ 46 | KeyFrameDatabase(const ORBVocabulary &voc); | ^~~~~~~~~~~~~~~~ include/KeyFrameDatabase.h:46:5: note: candidate expects 1 argument, 0 prov

(Please note that I already installed ORB_SLAM2, and it works fine)

Could you please provide some minimal instructions on how to compile this code? Thank you!

AlejandroSilvestri commented 1 year ago

Hi @lbrianza

First try not to use orb-slam2 with this project, by commenting out these includes (from KeyFrame.h to Tracking.h) https://github.com/AlejandroSilvestri/Osmap-viewer/blob/60e0f2bef3bb5e9f6fdbc9ef2ecb047fdb2c1ecc/include/Osmap.h#L42

You'll need to add libraries to the g++ command line, like OpenCV core and viz3d.

If you have problems, please copy the command line used to compile.

lbrianza commented 1 year ago

Hi @AlejandroSilvestri , thanks for your reply.

I am still a bit confused. If I comment those lines including headers from orb-slam2, I get dozens of errors - and that make sense to me because I see that the code uses some orbslam objects several times, like here: [(https://github.com/AlejandroSilvestri/Osmap-viewer/blob/60e0f2bef3bb5e9f6fdbc9ef2ecb047fdb2c1ecc/include/Osmap.h#L220-L238)]

Am I missing something obvious? (most likely yes)

For reference, I am trying to compile with: g++ -I /usr/local/include/opencv -I /usr/local/include/opencv2 -I include/ src/Osmap.cpp src/main.cpp -o osmap_viewer

Some of the errors that I get: In file included from src/Osmap.cpp:28: include/Osmap.h:57:37: error: expected class-name before ‘{’ token 57 | class OsmapMapPoint: public MapPoint{ | ^ include/Osmap.h:60:21: error: expected ‘)’ before ‘*’ token 60 | OsmapMapPoint(Osmap*); | ~ ^ | ) include/Osmap.h:67:37: error: expected class-name before ‘{’ token 67 | class OsmapKeyFrame: public KeyFrame{ | ^ include/Osmap.h:70:21: error: expected ‘)’ before ‘*’ token 70 | OsmapKeyFrame(Osmap*); | ~ ^ | ) include/Osmap.h:78:27: error: expected class-name before ‘{’ token 78 | class OsmapMap: public Map{ | ^ In file included from src/Osmap.cpp:28: include/Osmap.h:221:3: error: ‘KeyFrameDatabase’ does not name a type 221 | KeyFrameDatabase &keyFrameDatabase; | ^~~~~~~~~~~~~~~~ include/Osmap.h:224:3: error: ‘System’ does not name a type; did you mean ‘system’? 224 | System &system; | ^~~~~~ | system include/Osmap.h:227:3: error: ‘Frame’ does not name a type 227 | Frame &currentFrame; | ^~~~~ include/Osmap.h:238:3: error: ‘KeyFrame’ does not name a type 238 | KeyFrame *pRefKF = NULL; | ^~~~~~~~ include/Osmap.h:273:15: error: expected ‘)’ before ‘&’ token 273 | Osmap(System &_system); | ~ ^~ | ) include/Osmap.h:435:3: error: ‘MapPoint’ does not name a type 435 | MapPoint *getMapPoint(unsigned int id); | ^~~~~~~~ src/Osmap.cpp:38:13: error: expected constructor, destructor, or type conversion before ‘(’ token 38 | Osmap::Osmap(System &_system): | ^

AlejandroSilvestri commented 1 year ago

@lbrianza

So sorry, I haven't used this code in a long time.

I'm trying you to test it with dummy map. You need to set OSMAP_DUMMY_MAP, that will include Dummymap.h and ignore those include you already commented out.

You also need to add the libraries with -l in your g++ command line. There are four you can see here: https://github.com/AlejandroSilvestri/Osmap-viewer/blob/60e0f2bef3bb5e9f6fdbc9ef2ecb047fdb2c1ecc/.cproject#L45

Look for them in /usr/local/lib/opencv4 and /usr/local/lib

I see this project uses protocol buffers version 3006001. Won't work with another version. If you use a different version, you should regenerate headers. proto file is in osmap repository, and this can be cumbersome unless you are familiar with it.