Go to the documentation of this file.00001
00002
00003
00004 #pragma once
00005
00006 #include <pluginlib/class_list_macros.h>
00007 #include <nodelet/nodelet.h>
00008 #include <image_transport/image_transport.h>
00009 #include <ros/ros.h>
00010 #include <ros/package.h>
00011 #include <librealsense2/rs.hpp>
00012 #include <librealsense2/rsutil.h>
00013 #include <librealsense2/hpp/rs_processing.hpp>
00014 #include <librealsense2/rs_advanced_mode.hpp>
00015 #include <cv_bridge/cv_bridge.h>
00016 #include <constants.h>
00017 #include <realsense2_camera/Extrinsics.h>
00018 #include <realsense2_camera/IMUInfo.h>
00019 #include <csignal>
00020 #include <eigen3/Eigen/Geometry>
00021 #include <fstream>
00022 #include <thread>
00023
00024 namespace realsense2_camera
00025 {
00026 const stream_index_pair COLOR{RS2_STREAM_COLOR, 0};
00027 const stream_index_pair DEPTH{RS2_STREAM_DEPTH, 0};
00028 const stream_index_pair INFRA1{RS2_STREAM_INFRARED, 1};
00029 const stream_index_pair INFRA2{RS2_STREAM_INFRARED, 2};
00030 const stream_index_pair FISHEYE{RS2_STREAM_FISHEYE, 0};
00031 const stream_index_pair FISHEYE1{RS2_STREAM_FISHEYE, 1};
00032 const stream_index_pair FISHEYE2{RS2_STREAM_FISHEYE, 2};
00033 const stream_index_pair GYRO{RS2_STREAM_GYRO, 0};
00034 const stream_index_pair ACCEL{RS2_STREAM_ACCEL, 0};
00035 const stream_index_pair POSE{RS2_STREAM_POSE, 0};
00036
00037
00038 const std::vector<stream_index_pair> IMAGE_STREAMS = {DEPTH, INFRA1, INFRA2,
00039 COLOR,
00040 FISHEYE,
00041 FISHEYE1, FISHEYE2};
00042
00043 const std::vector<stream_index_pair> HID_STREAMS = {GYRO, ACCEL, POSE};
00044
00045 class InterfaceRealSenseNode
00046 {
00047 public:
00048 virtual void publishTopics() = 0;
00049 virtual void registerDynamicReconfigCb(ros::NodeHandle& nh) = 0;
00050 virtual ~InterfaceRealSenseNode() = default;
00051 };
00052
00053 class RealSenseNodeFactory : public nodelet::Nodelet
00054 {
00055 public:
00056 RealSenseNodeFactory();
00057 virtual ~RealSenseNodeFactory();
00058
00059 private:
00060 void closeDevice();
00061 void StartDevice();
00062 void change_device_callback(rs2::event_information& info);
00063 void getDevice(rs2::device_list list);
00064 virtual void onInit() override;
00065 void tryGetLogSeverity(rs2_log_severity& severity) const;
00066
00067 rs2::device _device;
00068 std::unique_ptr<InterfaceRealSenseNode> _realSenseNode;
00069 rs2::context _ctx;
00070 std::string _serial_no;
00071 bool _initial_reset;
00072 std::thread _query_thread;
00073
00074 };
00075 }