astra_driver.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013, Willow Garage, Inc.
3  * Copyright (c) 2016, Orbbec Ltd.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  * * Neither the name of the Willow Garage, Inc. nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28  * POSSIBILITY OF SUCH DAMAGE.
29  *
30  * Author: Tim Liu (liuhua@orbbec.com)
31  */
32 
33 #ifndef ASTRA_DRIVER_H
34 #define ASTRA_DRIVER_H
35 
36 #include <boost/shared_ptr.hpp>
37 #include <boost/cstdint.hpp>
38 #include <boost/bind.hpp>
39 #include <boost/function.hpp>
40 
41 #include <sensor_msgs/Image.h>
42 
43 #include <dynamic_reconfigure/server.h>
44 #include <astra_camera/AstraConfig.h>
45 
48 
49 #include <string>
50 #include <vector>
51 
55 #include "astra_camera/GetSerial.h"
56 #include "astra_camera/GetDeviceType.h"
57 #include "astra_camera/GetIRGain.h"
58 #include "astra_camera/SetIRGain.h"
59 #include "astra_camera/GetIRExposure.h"
60 #include "astra_camera/SetIRExposure.h"
61 #include "astra_camera/SetLaser.h"
62 #include "astra_camera/SetLDP.h"
63 #include "astra_camera/ResetIRGain.h"
64 #include "astra_camera/ResetIRExposure.h"
65 #include "astra_camera/GetCameraInfo.h"
66 #include "astra_camera/SetIRFlood.h"
67 #include "astra_camera/SwitchIRCamera.h"
69 
70 #include <ros/ros.h>
71 
72 namespace astra_wrapper
73 {
74 
76 {
77 public:
79  ~AstraDriver();
80 
81 private:
82  typedef astra_camera::AstraConfig Config;
83  typedef dynamic_reconfigure::Server<Config> ReconfigureServer;
84 
85  void newIRFrameCallback(sensor_msgs::ImagePtr image);
86  void newColorFrameCallback(sensor_msgs::ImagePtr image);
87  void newDepthFrameCallback(sensor_msgs::ImagePtr image);
88 
89  // Methods to get calibration parameters for the various cameras
90  sensor_msgs::CameraInfoPtr getDefaultCameraInfo(int width, int height, double f) const;
91  sensor_msgs::CameraInfoPtr getColorCameraInfo(int width, int height, ros::Time time) const;
92  sensor_msgs::CameraInfoPtr getIRCameraInfo(int width, int height, ros::Time time) const;
93  sensor_msgs::CameraInfoPtr getDepthCameraInfo(int width, int height, ros::Time time) const;
94  sensor_msgs::CameraInfoPtr getProjectorCameraInfo(int width, int height, ros::Time time) const;
95  sensor_msgs::CameraInfo convertAstraCameraInfo(OBCameraParams p, ros::Time time) const;
96 
98 
99  // resolves non-URI device IDs to URIs, e.g. '#1' is resolved to the URI of the first device
100  std::string resolveDeviceURI(const std::string& device_id);
101  void initDevice();
102 
103  void advertiseROSTopics();
104 
105  void imageConnectCb();
106  void depthConnectCb();
107 
108  bool getSerialCb(astra_camera::GetSerialRequest& req, astra_camera::GetSerialResponse& res);
109  bool getDeviceTypeCb(astra_camera::GetDeviceTypeRequest& req, astra_camera::GetDeviceTypeResponse& res);
110  bool getIRGainCb(astra_camera::GetIRGainRequest& req, astra_camera::GetIRGainResponse& res);
111  bool setIRGainCb(astra_camera::SetIRGainRequest& req, astra_camera::SetIRGainResponse& res);
112  bool getIRExposureCb(astra_camera::GetIRExposureRequest& req, astra_camera::GetIRExposureResponse& res);
113  bool setIRExposureCb(astra_camera::SetIRExposureRequest& req, astra_camera::SetIRExposureResponse& res);
114  bool setLaserCb(astra_camera::SetLaserRequest& req, astra_camera::SetLaserResponse& res);
115  bool resetIRGainCb(astra_camera::ResetIRGainRequest& req, astra_camera::ResetIRGainResponse& res);
116  bool resetIRExposureCb(astra_camera::ResetIRExposureRequest& req, astra_camera::ResetIRExposureResponse& res);
117  bool getCameraInfoCb(astra_camera::GetCameraInfoRequest& req, astra_camera::GetCameraInfoResponse& res);
118  bool setIRFloodCb(astra_camera::SetIRFloodRequest& req, astra_camera::SetIRFloodResponse& res);
119  bool switchIRCameraCb(astra_camera::SwitchIRCameraRequest& req, astra_camera::SwitchIRCameraResponse& res);
120  bool setLDPCb(astra_camera::SetLDPRequest& req, astra_camera::SetLDPResponse& res);
121 
122  void configCb(Config &config, uint32_t level);
123 
125 
126  void genVideoModeTableMap();
127  int lookupVideoModeFromDynConfig(int mode_nr, AstraVideoMode& video_mode);
128 
129  sensor_msgs::ImageConstPtr rawToFloatingPointConversion(sensor_msgs::ImageConstPtr raw_image);
130 
131  void setIRVideoMode(const AstraVideoMode& ir_video_mode);
132  void setColorVideoMode(const AstraVideoMode& color_video_mode);
133  void setDepthVideoMode(const AstraVideoMode& depth_video_mode);
134 
137 
140 
141  std::string device_id_;
142 
157 
161 
162  std::set<std::string> alreadyOpen;
163  boost::mutex connect_mutex_;
164  // published topics
170 
173 
177 
178  std::string ir_frame_id_;
179  std::string color_frame_id_;
180  std::string depth_frame_id_ ;
181 
183 
186 
187  std::map<int, AstraVideoMode> video_modes_lookup_;
188 
189  // dynamic reconfigure config
193  double z_scaling_;
194 
198 
200 
204 
206 
209 
215 
217 
218  Config old_config_;
220 };
221 
222 }
223 
224 #endif
ros::ServiceServer set_ir_exposure_server
Definition: astra_driver.h:150
void setDepthVideoMode(const AstraVideoMode &depth_video_mode)
sensor_msgs::CameraInfoPtr getColorCameraInfo(int width, int height, ros::Time time) const
std::string resolveDeviceURI(const std::string &device_id)
ros::ServiceServer get_camera_info
get_serial server
Definition: astra_driver.h:144
bool getIRGainCb(astra_camera::GetIRGainRequest &req, astra_camera::GetIRGainResponse &res)
sensor_msgs::CameraInfoPtr getProjectorCameraInfo(int width, int height, ros::Time time) const
boost::shared_ptr< ReconfigureServer > reconfigure_server_
reconfigure server
Definition: astra_driver.h:159
ros::NodeHandle & nh_
Definition: astra_driver.h:135
bool setIRExposureCb(astra_camera::SetIRExposureRequest &req, astra_camera::SetIRExposureResponse &res)
image_transport::CameraPublisher pub_depth_raw_
Definition: astra_driver.h:167
image_transport::CameraPublisher pub_depth_
Definition: astra_driver.h:166
ros::ServiceServer set_laser_server
Definition: astra_driver.h:152
image_transport::CameraPublisher pub_color_
Definition: astra_driver.h:165
ros::ServiceServer reset_ir_gain_server
Definition: astra_driver.h:154
sensor_msgs::ImageConstPtr rawToFloatingPointConversion(sensor_msgs::ImageConstPtr raw_image)
ros::Duration ir_time_offset_
Definition: astra_driver.h:195
AstraVideoMode color_video_mode_
Definition: astra_driver.h:175
sensor_msgs::CameraInfoPtr getIRCameraInfo(int width, int height, ros::Time time) const
ros::NodeHandle & pnh_
Definition: astra_driver.h:136
ros::ServiceServer get_serial_server
Definition: astra_driver.h:145
ros::Duration depth_time_offset_
Definition: astra_driver.h:197
sensor_msgs::CameraInfoPtr getDefaultCameraInfo(int width, int height, double f) const
ros::Publisher pub_projector_info_
Definition: astra_driver.h:169
bool getDeviceTypeCb(astra_camera::GetDeviceTypeRequest &req, astra_camera::GetDeviceTypeResponse &res)
bool getCameraInfoCb(astra_camera::GetCameraInfoRequest &req, astra_camera::GetCameraInfoResponse &res)
int lookupVideoModeFromDynConfig(int mode_nr, AstraVideoMode &video_mode)
boost::shared_ptr< camera_info_manager::CameraInfoManager > color_info_manager_
Camera info manager objects.
Definition: astra_driver.h:172
boost::shared_ptr< AstraDevice > device_
Definition: astra_driver.h:139
bool getIRExposureCb(astra_camera::GetIRExposureRequest &req, astra_camera::GetIRExposureResponse &res)
bool setIRGainCb(astra_camera::SetIRGainRequest &req, astra_camera::SetIRGainResponse &res)
void newColorFrameCallback(sensor_msgs::ImagePtr image)
AstraVideoMode depth_video_mode_
Definition: astra_driver.h:176
sensor_msgs::CameraInfo convertAstraCameraInfo(OBCameraParams p, ros::Time time) const
boost::shared_ptr< camera_info_manager::CameraInfoManager > ir_info_manager_
Definition: astra_driver.h:172
void newIRFrameCallback(sensor_msgs::ImagePtr image)
ros::Duration color_time_offset_
Definition: astra_driver.h:196
ros::ServiceServer set_ir_gain_server
Definition: astra_driver.h:148
void configCb(Config &config, uint32_t level)
void newDepthFrameCallback(sensor_msgs::ImagePtr image)
dynamic_reconfigure::Server< Config > ReconfigureServer
Definition: astra_driver.h:83
void setColorVideoMode(const AstraVideoMode &color_video_mode)
ros::ServiceServer set_ir_flood_server
Definition: astra_driver.h:151
ros::ServiceServer get_device_type_server
Definition: astra_driver.h:146
void setIRVideoMode(const AstraVideoMode &ir_video_mode)
ros::ServiceServer get_ir_exposure_server
Definition: astra_driver.h:149
std::set< std::string > alreadyOpen
Definition: astra_driver.h:162
std::map< int, AstraVideoMode > video_modes_lookup_
Definition: astra_driver.h:187
ros::ServiceServer switch_ir_camera
Definition: astra_driver.h:156
astra_camera::AstraConfig Config
Definition: astra_driver.h:82
ros::ServiceServer set_ldp_server
Definition: astra_driver.h:153
ros::ServiceServer get_ir_gain_server
Definition: astra_driver.h:147
unsigned int uint32_t
bool setLDPCb(astra_camera::SetLDPRequest &req, astra_camera::SetLDPResponse &res)
AstraDriver(ros::NodeHandle &n, ros::NodeHandle &pnh)
bool setIRFloodCb(astra_camera::SetIRFloodRequest &req, astra_camera::SetIRFloodResponse &res)
bool resetIRGainCb(astra_camera::ResetIRGainRequest &req, astra_camera::ResetIRGainResponse &res)
bool getSerialCb(astra_camera::GetSerialRequest &req, astra_camera::GetSerialResponse &res)
image_transport::CameraPublisher pub_ir_
Definition: astra_driver.h:168
sensor_msgs::CameraInfoPtr getDepthCameraInfo(int width, int height, ros::Time time) const
bool setLaserCb(astra_camera::SetLaserRequest &req, astra_camera::SetLaserResponse &res)
bool resetIRExposureCb(astra_camera::ResetIRExposureRequest &req, astra_camera::ResetIRExposureResponse &res)
ros::ServiceServer reset_ir_exposure_server
Definition: astra_driver.h:155
AstraVideoMode ir_video_mode_
Definition: astra_driver.h:174
boost::shared_ptr< AstraDeviceManager > device_manager_
Definition: astra_driver.h:138
bool switchIRCameraCb(astra_camera::SwitchIRCameraRequest &req, astra_camera::SwitchIRCameraResponse &res)


astra_camera
Author(s): Tim Liu
autogenerated on Wed Dec 16 2020 03:54:34