RGBDNode.cc
Go to the documentation of this file.
1 #include "RGBDNode.h"
2 
3 int main(int argc, char **argv)
4 {
5  ros::init(argc, argv, "RGBD");
6  ros::start();
7 
8  if(argc > 1) {
9  ROS_WARN ("Arguments supplied via command line are neglected.");
10  }
11 
12  ros::NodeHandle node_handle;
13 
14  // Create SLAM system. It initializes all system threads and gets ready to process frames.
16 
17  RGBDNode node (ORB_SLAM2::System::RGBD, node_handle, image_transport);
18 
19  node.Init();
20 
21  ros::spin();
22 
23  ros::shutdown();
24 
25  return 0;
26 }
27 
28 
29 RGBDNode::RGBDNode (const ORB_SLAM2::System::eSensor sensor, ros::NodeHandle &node_handle, image_transport::ImageTransport &image_transport) : Node (sensor, node_handle, image_transport) {
30  rgb_subscriber_ = new message_filters::Subscriber<sensor_msgs::Image> (node_handle, "/camera/rgb/image_raw", 1);
31  depth_subscriber_ = new message_filters::Subscriber<sensor_msgs::Image> (node_handle, "/camera/depth_registered/image_raw", 1);
32  camera_info_topic_ = "/camera/rgb/camera_info";
33 
35  sync_->registerCallback(boost::bind(&RGBDNode::ImageCallback, this, _1, _2));
36 }
37 
38 
40  delete rgb_subscriber_;
41  delete depth_subscriber_;
42  delete sync_;
43 }
44 
45 
46 void RGBDNode::ImageCallback (const sensor_msgs::ImageConstPtr& msgRGB, const sensor_msgs::ImageConstPtr& msgD) {
47  // Copy the ros image message to cv::Mat.
49  try {
50  cv_ptrRGB = cv_bridge::toCvShare(msgRGB);
51  } catch (cv_bridge::Exception& e) {
52  ROS_ERROR("cv_bridge exception: %s", e.what());
53  return;
54  }
55 
57  try {
58  cv_ptrD = cv_bridge::toCvShare(msgD);
59  } catch (cv_bridge::Exception& e) {
60  ROS_ERROR("cv_bridge exception: %s", e.what());
61  return;
62  }
63 
64  current_frame_time_ = msgRGB->header.stamp;
65 
66  orb_slam_->TrackRGBD(cv_ptrRGB->image,cv_ptrD->image,cv_ptrRGB->header.stamp.toSec());
67 
68  Update ();
69 }
CvImageConstPtr toCvShare(const sensor_msgs::ImageConstPtr &source, const std::string &encoding=std::string())
std::string camera_info_topic_
Definition: Node.h:66
ROSCPP_DECL void start()
Definition: Node.h:54
void ImageCallback(const sensor_msgs::ImageConstPtr &msgRGB, const sensor_msgs::ImageConstPtr &msgD)
Definition: RGBDNode.cc:46
message_filters::Subscriber< sensor_msgs::Image > * rgb_subscriber_
Definition: RGBDNode.h:52
~RGBDNode()
Definition: RGBDNode.cc:39
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
ORB_SLAM2::System * orb_slam_
Definition: Node.h:63
RGBDNode(const ORB_SLAM2::System::eSensor sensor, ros::NodeHandle &node_handle, image_transport::ImageTransport &image_transport)
Definition: RGBDNode.cc:29
#define ROS_WARN(...)
ROSCPP_DECL void spin(Spinner &spinner)
void TrackRGBD(const cv::Mat &im, const cv::Mat &depthmap, const double &timestamp)
Definition: System.cc:176
ros::Time current_frame_time_
Definition: Node.h:64
void Init()
Definition: Node.cc:23
message_filters::Subscriber< sensor_msgs::Image > * depth_subscriber_
Definition: RGBDNode.h:53
message_filters::sync_policies::ApproximateTime< sensor_msgs::Image, sensor_msgs::Image > sync_pol
Definition: RGBDNode.h:51
ROSCPP_DECL void shutdown()
int main(int argc, char **argv)
Definition: RGBDNode.cc:3
void Update()
Definition: Node.cc:66
message_filters::Synchronizer< sync_pol > * sync_
Definition: RGBDNode.h:54
#define ROS_ERROR(...)


orb_slam2_ros
Author(s):
autogenerated on Wed Apr 21 2021 02:53:05