raulmur / ORB_SLAM2

Real-Time SLAM for Monocular, Stereo and RGB-D Cameras, with Loop Detection and Relocalization Capabilities
Other
9.5k stars 4.71k forks source link

Saving map in realtime #222

Open haythemsgh opened 7 years ago

haythemsgh commented 7 years ago

I am using orbslam2 with ros kinetic and i've managed to run some examples using my webcam. I know that orb slam saves the trajectory in KeyFrameTrajectory.txt. But what I want to do is extracting the coordinates in real time. In other word , is there a way to make orbslam2 node publish the coordinates so that I can use it in other applications.

AlejandroSilvestri commented 7 years ago

Only if you want to write c++ code.

There is only one instance of Map, it contains all MapPoints, you can get them in a vector of MapPoint in main from SLAM.mpMap->GetAllMapPoints() .

vector<MapPoint> mapPoints = SLAM.mpMap->GetAllMapPoints();
Mat position = mapPoints[i].GetWorldPos();

position will be a 3 element Mat, representing the absolute point position in the map.

Remember, scale is arbitrary.