astra_ros
RosDevice.hpp
1 #ifndef _ASTRA_ROS_ROS_DEVICE_HPP_
2 #define _ASTRA_ROS_ROS_DEVICE_HPP_
3 
4 #include <ros/ros.h>
5 
6 #include <image_transport/image_transport.h>
7 #include <dynamic_reconfigure/server.h>
8 #include <tf2_ros/transform_broadcaster.h>
9 
10 #include "astra_ros/DeviceConfig.h"
11 
12 #include "astra_ros/BodyFrame.h"
13 
14 #include "astra_ros/GetChipId.h"
15 #include "astra_ros/GetDepthRegistration.h"
16 #include "astra_ros/GetImageStreamMode.h"
17 #include "astra_ros/GetImageStreamModes.h"
18 #include "astra_ros/GetIrExposure.h"
19 #include "astra_ros/GetIrGain.h"
20 #include "astra_ros/GetMirrored.h"
21 #include "astra_ros/GetRunning.h"
22 #include "astra_ros/GetSerial.h"
23 #include "astra_ros/GetUsbInfo.h"
24 #include "astra_ros/SetDepthRegistration.h"
25 #include "astra_ros/SetImageStreamMode.h"
26 #include "astra_ros/SetIrExposure.h"
27 #include "astra_ros/SetIrGain.h"
28 #include "astra_ros/SetMirrored.h"
29 #include "astra_ros/SetRunning.h"
30 
31 #include "Device.hpp"
32 
33 namespace astra_ros
34 {
35  class RosDevice
36  {
37  public:
45  RosDevice(const std::string &name, ros::NodeHandle &nh, ros::NodeHandle &pnh);
46 
50  const std::string &getName() const noexcept;
51 
56  void update();
57 
58  private:
59  static Device::Configuration getConfiguration(ros::NodeHandle &nh);
60 
61  void onFrame(const Device::Frame &frame);
62  void onDynamicReconfigure(DeviceConfig &config, uint32_t level);
63 
64  bool onGetChipId(GetChipId::Request &req, GetChipId::Response &res);
65  bool onGetDepthRegistration(GetDepthRegistration::Request &req, GetDepthRegistration::Response &res);
66  bool onGetColorImageStreamMode(GetImageStreamMode::Request &req, GetImageStreamMode::Response &res);
67  bool onGetDepthImageStreamMode(GetImageStreamMode::Request &req, GetImageStreamMode::Response &res);
68  bool onGetIrImageStreamMode(GetImageStreamMode::Request &req, GetImageStreamMode::Response &res);
69  bool onGetColorImageStreamModes(GetImageStreamModes::Request &req, GetImageStreamModes::Response &res);
70  bool onGetDepthImageStreamModes(GetImageStreamModes::Request &req, GetImageStreamModes::Response &res);
71  bool onGetIrImageStreamModes(GetImageStreamModes::Request &req, GetImageStreamModes::Response &res);
72  bool onGetIrExposure(GetIrExposure::Request &req, GetIrExposure::Response &res);
73  bool onGetIrGain(GetIrGain::Request &req, GetIrGain::Response &res);
74  bool onGetColorMirrored(GetMirrored::Request &req, GetMirrored::Response &res);
75  bool onGetDepthMirrored(GetMirrored::Request &req, GetMirrored::Response &res);
76  bool onGetIrMirrored(GetMirrored::Request &req, GetMirrored::Response &res);
77  bool onGetColorRunning(GetRunning::Request &req, GetRunning::Response &res);
78  bool onGetDepthRunning(GetRunning::Request &req, GetRunning::Response &res);
79  bool onGetIrRunning(GetRunning::Request &req, GetRunning::Response &res);
80  bool onGetSerial(GetSerial::Request &req, GetSerial::Response &res);
81  bool onGetColorUsbInfo(GetUsbInfo::Request &req, GetUsbInfo::Response &res);
82  bool onGetDepthUsbInfo(GetUsbInfo::Request &req, GetUsbInfo::Response &res);
83  bool onGetIrUsbInfo(GetUsbInfo::Request &req, GetUsbInfo::Response &res);
84  bool onSetDepthRegistration(SetDepthRegistration::Request &req, SetDepthRegistration::Response &res);
85  bool onSetColorImageStreamMode(SetImageStreamMode::Request &req, SetImageStreamMode::Response &res);
86  bool onSetDepthImageStreamMode(SetImageStreamMode::Request &req, SetImageStreamMode::Response &res);
87  bool onSetIrImageStreamMode(SetImageStreamMode::Request &req, SetImageStreamMode::Response &res);
88  bool onSetIrExposure(SetIrExposure::Request &req, SetIrExposure::Response &res);
89  bool onSetIrGain(SetIrGain::Request &req, SetIrGain::Response &res);
90  bool onSetColorMirrored(SetMirrored::Request &req, SetMirrored::Response &res);
91  bool onSetDepthMirrored(SetMirrored::Request &req, SetMirrored::Response &res);
92  bool onSetIrMirrored(SetMirrored::Request &req, SetMirrored::Response &res);
93  bool onSetColorRunning(SetRunning::Request &req, SetRunning::Response &res);
94  bool onSetDepthRunning(SetRunning::Request &req, SetRunning::Response &res);
95  bool onSetIrRunning(SetRunning::Request &req, SetRunning::Response &res);
96 
97  std::string name_;
98  ros::NodeHandle &nh_;
99  ros::NodeHandle device_nh_;
100  ros::NodeHandle &pnh_;
101 
102  image_transport::ImageTransport image_transport_;
103 
104  typedef dynamic_reconfigure::Server<DeviceConfig> DeviceConfigServer;
105 
106  // DeviceConfigServer isn't movable (w.r.t. move semantics), so we wrap it in a unique_ptr
107  std::unique_ptr<boost::recursive_mutex> mut_;
108  std::unique_ptr<DeviceConfigServer> dynamic_reconfigure_server_;
109 
110  std::unique_ptr<tf2_ros::TransformBroadcaster> tf_broadcaster_;
111 
112  bool publish_body_markers;
113  bool publish_body_mask;
114  bool publish_floor_mask;
115  std::string body_frame_id;
116 
117  Device::Ptr device_;
118 
119  orbbec_camera_params camera_parameters_;
120 
121  ros::Publisher color_camera_info_pub_;
122  ros::Publisher depth_camera_info_pub_;
123 
124  image_transport::Publisher color_image_pub_;
125  image_transport::Publisher ir_image_pub_;
126  image_transport::Publisher depth_image_pub_;
127  image_transport::Publisher body_mask_image_pub_;
128  image_transport::Publisher floor_mask_image_pub_;
129  image_transport::Publisher colorized_body_image_pub_;
130  image_transport::Publisher masked_color_image_pub_;
131 
132  ros::Publisher body_frame_pub_;
133  ros::Publisher body_markers_pub_;
134  ros::Publisher point_cloud_pub_;
135 
136 
137  ros::ServiceServer get_chip_id_svc_;
138  ros::ServiceServer get_depth_registration_svc_;
139  ros::ServiceServer get_color_image_stream_mode_svc_;
140  ros::ServiceServer get_depth_image_stream_mode_svc_;
141  ros::ServiceServer get_ir_image_stream_mode_svc_;
142  ros::ServiceServer get_color_image_stream_modes_svc_;
143  ros::ServiceServer get_depth_image_stream_modes_svc_;
144  ros::ServiceServer get_ir_image_stream_modes_svc_;
145  ros::ServiceServer get_ir_exposure_svc_;
146  ros::ServiceServer get_ir_gain_svc_;
147  ros::ServiceServer get_color_mirrored_svc_;
148  ros::ServiceServer get_depth_mirrored_svc_;
149  ros::ServiceServer get_ir_mirrored_svc_;
150  ros::ServiceServer get_color_running_svc_;
151  ros::ServiceServer get_depth_running_svc_;
152  ros::ServiceServer get_ir_running_svc_;
153  ros::ServiceServer get_serial_svc_;
154  ros::ServiceServer get_color_usb_info_svc_;
155  ros::ServiceServer get_depth_usb_info_svc_;
156  ros::ServiceServer get_ir_usb_info_svc_;
157  ros::ServiceServer set_depth_registration_svc_;
158  ros::ServiceServer set_color_image_stream_mode_svc_;
159  ros::ServiceServer set_depth_image_stream_mode_svc_;
160  ros::ServiceServer set_ir_image_stream_mode_svc_;
161  ros::ServiceServer set_ir_exposure_svc_;
162  ros::ServiceServer set_ir_gain_svc_;
163  ros::ServiceServer set_color_mirrored_svc_;
164  ros::ServiceServer set_depth_mirrored_svc_;
165  ros::ServiceServer set_ir_mirrored_svc_;
166  ros::ServiceServer set_color_running_svc_;
167  ros::ServiceServer set_depth_running_svc_;
168  ros::ServiceServer set_ir_running_svc_;
169  };
170 
171  extern const std::string DEVICE_NAMESPACE;
172 }
173 
174 #endif
astra_ros::RosDevice::update
void update()
astra_ros::RosDevice::getName
const std::string & getName() const noexcept
astra_ros::RosDevice
Definition: RosDevice.hpp:36
astra_ros::RosDevice::RosDevice
RosDevice(const std::string &name, ros::NodeHandle &nh, ros::NodeHandle &pnh)
astra_ros::Device
An agnostic C++ wrapper for the C Astra SDK. This object is wrapped by RosDevice.
Definition: Device.hpp:22