forked from alsora/ros2-ORB_SLAM2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added stereo node; cleaned other nodes
- Loading branch information
Showing
13 changed files
with
424 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
# | ||
# @author Alberto Soragna (alberto dot soragna at gmail dot com) | ||
# @2018 | ||
|
||
XSOCK=/tmp/.X11-unix | ||
|
||
# --runtime=nvidia \ | ||
docker run -it --rm \ | ||
-e DISPLAY=$DISPLAY \ | ||
-v $XSOCK:$XSOCK \ | ||
-v $HOME/.Xauthority:/root/.Xauthority \ | ||
-v $PWD/..:/root/VOLUME_ros2-ORB_SLAM2 \ | ||
--privileged \ | ||
--net=host \ | ||
ros2_orbslam2 "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#include "rgbd-slam-node.hpp" | ||
|
||
#include<opencv2/core/core.hpp> | ||
|
||
|
||
using ImageMsg = sensor_msgs::msg::Image; | ||
|
||
using namespace std; | ||
|
||
using std::placeholders::_1; | ||
|
||
RgbdSlamNode::RgbdSlamNode(ORB_SLAM2::System* pSLAM, const string &strVocFile, const string &strSettingsFile) | ||
: Node("orbslam") | ||
,m_SLAM(pSLAM) | ||
{ | ||
|
||
rgb_sub = std::make_shared<message_filters::Subscriber<ImageMsg> >(shared_ptr<rclcpp::Node>(this), "camera/rgb"); | ||
depth_sub = std::make_shared<message_filters::Subscriber<ImageMsg> >(shared_ptr<rclcpp::Node>(this), "camera/depth"); | ||
|
||
syncApproximate = std::make_shared<message_filters::Synchronizer<approximate_sync_policy> >(approximate_sync_policy(10), *rgb_sub, *depth_sub); | ||
syncApproximate->registerCallback(&RgbdSlamNode::GrabRGBD, this); | ||
|
||
} | ||
|
||
|
||
RgbdSlamNode::~RgbdSlamNode() | ||
{ | ||
// Stop all threads | ||
m_SLAM->Shutdown(); | ||
|
||
// Save camera trajectory | ||
m_SLAM->SaveKeyFrameTrajectoryTUM("KeyFrameTrajectory.txt"); | ||
|
||
} | ||
|
||
|
||
void RgbdSlamNode::GrabRGBD(const ImageMsg::SharedPtr msgRGB, const ImageMsg::SharedPtr msgD) | ||
{ | ||
|
||
// Copy the ros rgb image message to cv::Mat. | ||
try | ||
{ | ||
cv_ptrRGB = cv_bridge::toCvShare(msgRGB); | ||
} | ||
catch (cv_bridge::Exception& e) | ||
{ | ||
RCLCPP_ERROR(this->get_logger(), "cv_bridge exception: %s", e.what()); | ||
return; | ||
} | ||
|
||
// Copy the ros depth image message to cv::Mat. | ||
try | ||
{ | ||
cv_ptrD = cv_bridge::toCvShare(msgD); | ||
} | ||
catch (cv_bridge::Exception& e) | ||
{ | ||
RCLCPP_ERROR(this->get_logger(), "cv_bridge exception: %s", e.what()); | ||
return; | ||
} | ||
|
||
|
||
cv::Mat Tcw = m_SLAM->TrackRGBD(cv_ptrRGB->image, cv_ptrD->image, msgRGB->header.stamp.sec); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
|
||
#ifndef __RGBD_SLAM_NODE_HPP__ | ||
#define __RGBD_SLAM_NODE_HPP__ | ||
|
||
|
||
#include<iostream> | ||
#include<algorithm> | ||
#include<fstream> | ||
#include<chrono> | ||
|
||
#include "rclcpp/rclcpp.hpp" | ||
#include "sensor_msgs/msg/image.hpp" | ||
|
||
#include "message_filters/subscriber.h" | ||
#include "message_filters/synchronizer.h" | ||
#include "message_filters/sync_policies/approximate_time.h" | ||
|
||
#include <cv_bridge/cv_bridge.h> | ||
|
||
#include"System.h" | ||
#include"Frame.h" | ||
#include "Map.h" | ||
#include "Tracking.h" | ||
|
||
|
||
typedef message_filters::sync_policies::ApproximateTime<sensor_msgs::msg::Image, sensor_msgs::msg::Image> approximate_sync_policy; | ||
|
||
|
||
class RgbdSlamNode : public rclcpp::Node | ||
{ | ||
|
||
public: | ||
|
||
RgbdSlamNode(ORB_SLAM2::System* pSLAM, const string &strVocFile, const string &strSettingsFile); | ||
|
||
|
||
~RgbdSlamNode(); | ||
|
||
|
||
private: | ||
|
||
|
||
void GrabRGBD(const sensor_msgs::msg::Image::SharedPtr msgRGB, const sensor_msgs::msg::Image::SharedPtr msgD); | ||
|
||
ORB_SLAM2::System* m_SLAM; | ||
|
||
cv_bridge::CvImageConstPtr cv_ptrRGB; | ||
cv_bridge::CvImageConstPtr cv_ptrD; | ||
|
||
std::shared_ptr<message_filters::Subscriber<sensor_msgs::msg::Image> > rgb_sub; | ||
std::shared_ptr<message_filters::Subscriber<sensor_msgs::msg::Image> > depth_sub; | ||
|
||
std::shared_ptr<message_filters::Synchronizer<approximate_sync_policy> > syncApproximate; | ||
}; | ||
|
||
|
||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.