Skip to content

Commit

Permalink
Merge pull request UZ-SLAMLab#44 from ccamposm/master
Browse files Browse the repository at this point in the history
ROS support and fix minor bugs
  • Loading branch information
richard-elvira authored Aug 10, 2020
2 parents 9ddba33 + b4ff9c6 commit adc4062
Show file tree
Hide file tree
Showing 19 changed files with 641 additions and 244 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ Examples/Stereo-Inertial/stereo_inertial_euroc
Examples/Stereo-Inertial/stereo_inertial_tum_vi

Examples/ROS/ORB_SLAM3/Mono
Examples/ROS/ORB_SLAM3/Mono_Inertial
Examples/ROS/ORB_SLAM3/MonoAR
Examples/ROS/ORB_SLAM3/RGBD
Examples/ROS/ORB_SLAM3/Stereo
Examples/ROS/ORB_SLAM3/Stereo_Inertial

Examples/ROS/ORB_SLAM3/CMakeLists.txt.user
Examples/ROS/ORB_SLAM3/build/
Expand Down
2 changes: 1 addition & 1 deletion Examples/RGB-D/TUM1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Camera.RGB: 1
ThDepth: 40.0

# Deptmap values factor
DepthMapFactor: 5000.0
DepthMapFactor: 5000.0 # 1.0 for ROS_bag

#--------------------------------------------------------------------------------------------
# ORB Parameters
Expand Down
19 changes: 19 additions & 0 deletions Examples/ROS/ORB_SLAM3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ include_directories(
${PROJECT_SOURCE_DIR}
${PROJECT_SOURCE_DIR}/../../../
${PROJECT_SOURCE_DIR}/../../../include
${PROJECT_SOURCE_DIR}/../../../include/CameraModels
${Pangolin_INCLUDE_DIRS}
)

Expand All @@ -55,6 +56,7 @@ ${Pangolin_LIBRARIES}
${PROJECT_SOURCE_DIR}/../../../Thirdparty/DBoW2/lib/libDBoW2.so
${PROJECT_SOURCE_DIR}/../../../Thirdparty/g2o/lib/libg2o.so
${PROJECT_SOURCE_DIR}/../../../lib/libORB_SLAM3.so
-lboost_system
)

# Node for monocular camera
Expand Down Expand Up @@ -95,3 +97,20 @@ target_link_libraries(RGBD
${LIBS}
)

# Node for monocular-inertial camera
rosbuild_add_executable(Mono_Inertial
src/ros_mono_inertial.cc
)

target_link_libraries(Mono_Inertial
${LIBS}
)

# Node for stereo-inertial camera
rosbuild_add_executable(Stereo_Inertial
src/ros_stereo_inertial.cc
)

target_link_libraries(Stereo_Inertial
${LIBS}
)
10 changes: 3 additions & 7 deletions Examples/ROS/ORB_SLAM3/manifest.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
<package>
<description brief="ORB_SLAM2">

ORB_SLAM2

<description brief="ORB_SLAM3">
ORB_SLAM3
</description>
<author>Raul Mur-Artal</author>
<author>Carlos Campos, Richard Elvira, Juan J. Gomez, Jose M.M. Montiel, Juan D. Tardos</author>
<license>GPLv3</license>
<depend package="roscpp"/>
<depend package="tf"/>
<depend package="sensor_msgs"/>
<depend package="image_transport"/>
<depend package="cv_bridge"/>


</package>


Expand Down
4 changes: 2 additions & 2 deletions Examples/ROS/ORB_SLAM3/src/AR/ViewerAR.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

using namespace std;

namespace ORB_SLAM2
namespace ORB_SLAM3
{

const float eps = 1e-4;
Expand Down Expand Up @@ -233,7 +233,7 @@ void ViewerAR::Run()

}

void ViewerAR::SetImagePose(const cv::Mat &im, const cv::Mat &Tcw, const int &status, const vector<cv::KeyPoint> &vKeys, const vector<ORB_SLAM2::MapPoint*> &vMPs)
void ViewerAR::SetImagePose(const cv::Mat &im, const cv::Mat &Tcw, const int &status, const vector<cv::KeyPoint> &vKeys, const vector<ORB_SLAM3::MapPoint*> &vMPs)
{
unique_lock<mutex> lock(mMutexPoseImage);
mImage = im.clone();
Expand Down
6 changes: 3 additions & 3 deletions Examples/ROS/ORB_SLAM3/src/AR/ViewerAR.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <string>
#include"../../../include/System.h"

namespace ORB_SLAM2
namespace ORB_SLAM3
{

class Plane
Expand Down Expand Up @@ -62,7 +62,7 @@ class ViewerAR
mT=1e3/fps;
}

void SetSLAM(ORB_SLAM2::System* pSystem){
void SetSLAM(ORB_SLAM3::System* pSystem){
mpSystem = pSystem;
}

Expand All @@ -82,7 +82,7 @@ class ViewerAR
private:

//SLAM
ORB_SLAM2::System* mpSystem;
ORB_SLAM3::System* mpSystem;

void PrintStatus(const int &status, const bool &bLocMode, cv::Mat &im);
void AddTextToImage(const std::string &s, cv::Mat &im, const int r=0, const int g=0, const int b=0);
Expand Down
14 changes: 7 additions & 7 deletions Examples/ROS/ORB_SLAM3/src/AR/ros_mono_ar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
using namespace std;


ORB_SLAM2::ViewerAR viewerAR;
ORB_SLAM3::ViewerAR viewerAR;
bool bRGB = true;

cv::Mat K;
Expand All @@ -45,11 +45,11 @@ cv::Mat DistCoef;
class ImageGrabber
{
public:
ImageGrabber(ORB_SLAM2::System* pSLAM):mpSLAM(pSLAM){}
ImageGrabber(ORB_SLAM3::System* pSLAM):mpSLAM(pSLAM){}

void GrabImage(const sensor_msgs::ImageConstPtr& msg);

ORB_SLAM2::System* mpSLAM;
ORB_SLAM3::System* mpSLAM;
};

int main(int argc, char **argv)
Expand All @@ -59,13 +59,13 @@ int main(int argc, char **argv)

if(argc != 3)
{
cerr << endl << "Usage: rosrun ORB_SLAM2 Mono path_to_vocabulary path_to_settings" << endl;
cerr << endl << "Usage: rosrun ORB_SLAM3 Mono path_to_vocabulary path_to_settings" << endl;
ros::shutdown();
return 1;
}

// Create SLAM system. It initializes all system threads and gets ready to process frames.
ORB_SLAM2::System SLAM(argv[1],argv[2],ORB_SLAM2::System::MONOCULAR,false);
ORB_SLAM3::System SLAM(argv[1],argv[2],ORB_SLAM3::System::MONOCULAR,false);


cout << endl << endl;
Expand Down Expand Up @@ -118,7 +118,7 @@ int main(int argc, char **argv)
DistCoef.at<float>(4) = k3;
}

thread tViewer = thread(&ORB_SLAM2::ViewerAR::Run,&viewerAR);
thread tViewer = thread(&ORB_SLAM3::ViewerAR::Run,&viewerAR);

ros::spin();

Expand Down Expand Up @@ -150,7 +150,7 @@ void ImageGrabber::GrabImage(const sensor_msgs::ImageConstPtr& msg)
cv::Mat imu;
cv::Mat Tcw = mpSLAM->TrackMonocular(cv_ptr->image,cv_ptr->header.stamp.toSec());
int state = mpSLAM->GetTrackingState();
vector<ORB_SLAM2::MapPoint*> vMPs = mpSLAM->GetTrackedMapPoints();
vector<ORB_SLAM3::MapPoint*> vMPs = mpSLAM->GetTrackedMapPoints();
vector<cv::KeyPoint> vKeys = mpSLAM->GetTrackedKeyPointsUn();

cv::undistort(im,imu,K,DistCoef);
Expand Down
10 changes: 5 additions & 5 deletions Examples/ROS/ORB_SLAM3/src/ros_mono.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ using namespace std;
class ImageGrabber
{
public:
ImageGrabber(ORB_SLAM2::System* pSLAM):mpSLAM(pSLAM){}
ImageGrabber(ORB_SLAM3::System* pSLAM):mpSLAM(pSLAM){}

void GrabImage(const sensor_msgs::ImageConstPtr& msg);

ORB_SLAM2::System* mpSLAM;
ORB_SLAM3::System* mpSLAM;
};

int main(int argc, char **argv)
Expand All @@ -48,18 +48,18 @@ int main(int argc, char **argv)

if(argc != 3)
{
cerr << endl << "Usage: rosrun ORB_SLAM2 Mono path_to_vocabulary path_to_settings" << endl;
cerr << endl << "Usage: rosrun ORB_SLAM3 Mono path_to_vocabulary path_to_settings" << endl;
ros::shutdown();
return 1;
}

// Create SLAM system. It initializes all system threads and gets ready to process frames.
ORB_SLAM2::System SLAM(argv[1],argv[2],ORB_SLAM2::System::MONOCULAR,true);
ORB_SLAM3::System SLAM(argv[1],argv[2],ORB_SLAM3::System::MONOCULAR,true);

ImageGrabber igb(&SLAM);

ros::NodeHandle nodeHandler;
ros::Subscriber sub = nodeHandler.subscribe("/camera/image_raw", 1, &ImageGrabber::GrabImage,&igb);
ros::Subscriber sub = nodeHandler.subscribe("/camera/image_raw", 100, &ImageGrabber::GrabImage,&igb);

ros::spin();

Expand Down
Loading

0 comments on commit adc4062

Please sign in to comment.