camera.h
Go to the documentation of this file.
1 
34 #ifndef MULTISENSE_ROS_CAMERA_H
35 #define MULTISENSE_ROS_CAMERA_H
36 
37 #include <boost/shared_ptr.hpp>
38 #include <boost/thread.hpp>
39 #include <ros/ros.h>
40 #include <multisense_ros/RawCamData.h>
41 #include <sensor_msgs/PointCloud2.h>
42 #include <stereo_msgs/DisparityImage.h>
47 
48 
49 #include <multisense_lib/MultiSenseChannel.hh>
50 
51 namespace multisense_ros {
52 
53 class Camera {
54 public:
56  const std::string& tf_prefix);
57  ~Camera();
58 
60 
62  void rectCallback(const crl::multisense::image::Header& header);
70 
71  void borderClipChanged(int borderClipType, double borderClipValue);
72 
73 private:
74 
75  //
76  // Device stream control
77 
80  void stop();
81 
82  //
83  // Query sensor status and calibration
84 
85  void queryConfig();
86 
87  //
88  // Update a specific camera info topic. This is used once the camera resolution has changed.
89  // Scale factors in x and y are applied to M and P camera matrices. M and P
90  // matrices are assumed to be full resolution
91 
92  void updateCameraInfo(sensor_msgs::CameraInfo& cameraInfo,
93  const float M[3][3],
94  const float R[3][3],
95  const float P[3][4],
96  const float D[8],
97  double xScale=1,
98  double yScale=1);
99 
100  //
101  // Republish camera info messages by publishing the current messages
102  // Used whenever the resolution of the camera changes
103 
104  void publishAllCameraInfo();
105 
106  //
107  // Generate border clips for point clouds
108 
109  void generateBorderClip(int borderClipType, double borderClipValue, uint32_t width, uint32_t height);
110 
111 
112  //
113  // CRL sensor API
114 
116 
117  //
118  // Driver nodes
119 
123 
124  //
125  // Image transports
126 
138 
139  //
140  // Data publishers
141 
142  sensor_msgs::CameraInfo left_mono_cam_info_;
143  sensor_msgs::CameraInfo right_mono_cam_info_;
144  sensor_msgs::CameraInfo left_rect_cam_info_;
145  sensor_msgs::CameraInfo right_rect_cam_info_;
146  sensor_msgs::CameraInfo left_rgb_rect_cam_info_;
147  sensor_msgs::CameraInfo left_disp_cam_info_;
148  sensor_msgs::CameraInfo right_disp_cam_info_;
149  sensor_msgs::CameraInfo left_cost_cam_info_;
150  sensor_msgs::CameraInfo left_rgb_cam_info_;
151  sensor_msgs::CameraInfo depth_cam_info_;
152 
158  image_transport::Publisher ni_depth_cam_pub_; // publish depth infomation in the openNI format
161 
172 
175 
178 
182 
185 
186  //
187  // Raw data publishers
188 
194 
195  //
196  // Store outgoing messages for efficiency
197 
198  sensor_msgs::Image left_mono_image_;
199  sensor_msgs::Image right_mono_image_;
200  sensor_msgs::Image left_rect_image_;
201  sensor_msgs::Image right_rect_image_;
202  sensor_msgs::Image depth_image_;
203  sensor_msgs::Image ni_depth_image_;
204  sensor_msgs::PointCloud2 luma_point_cloud_;
205  sensor_msgs::PointCloud2 color_point_cloud_;
206  sensor_msgs::PointCloud2 luma_organized_point_cloud_;
207  sensor_msgs::PointCloud2 color_organized_point_cloud_;
208 
209  sensor_msgs::Image left_luma_image_;
210  sensor_msgs::Image left_rgb_image_;
211  sensor_msgs::Image left_rgb_rect_image_;
212 
213  sensor_msgs::Image left_disparity_image_;
214  sensor_msgs::Image left_disparity_cost_image_;
215  sensor_msgs::Image right_disparity_image_;
216 
217  stereo_msgs::DisparityImage left_stereo_disparity_;
218  stereo_msgs::DisparityImage right_stereo_disparity_;
219 
229  multisense_ros::RawCamData raw_cam_data_;
230 
231  //
232  // Calibration from sensor
233 
238 
239  //
240  // For local rectification of color images
241 
242  boost::mutex cal_lock_;
245 
246  //
247  // The frame IDs
248 
249  std::string frame_id_left_;
250  std::string frame_id_right_;
251 
252  //
253  // For pointcloud generation
254 
255  std::vector<float> disparity_buff_;
256  std::vector<cv::Vec3f> points_buff_;
258  cv::Mat_<double> q_matrix_;
261 
262 
263  //
264  // Current maximum number of disparities
265 
266  uint32_t disparities_;
267 
268  //
269  // Stream subscriptions
270 
271  typedef std::map<crl::multisense::DataSource, int32_t> StreamMapType;
272  boost::mutex stream_lock_;
273  StreamMapType stream_map_;
274 
275  //
276  // Histogram tracking
277 
278  int64_t last_frame_id_;
279 
280  //
281  // Luma Color Depth
282 
284 
285  //
286  // If the color pointcloud data should be written packed. If false
287  // it will be static_cast to a flat and interpreted literally
288 
290 
291  //
292  // Enum to determine border clipping types
293 
295 
298 
299  //
300  // The mask used to perform the border clipping of the disparity image
301 
302  cv::Mat_<uint8_t> border_clip_mask_;
303 
304  boost::mutex border_clip_lock_;
305 };
306 
307 }
308 
309 #endif
ros::Publisher left_rgb_cam_info_pub_
Definition: camera.h:169
image_transport::Publisher right_disparity_pub_
Definition: camera.h:180
ros::Publisher luma_organized_point_cloud_pub_
Definition: camera.h:176
void pointCloudCallback(const crl::multisense::image::Header &header)
Definition: camera.cpp:1485
void rawCamDataCallback(const crl::multisense::image::Header &header)
Definition: camera.cpp:1625
image_transport::ImageTransport disparity_cost_transport_
Definition: camera.h:137
image_transport::Publisher left_mono_cam_pub_
Definition: camera.h:153
sensor_msgs::Image right_rect_image_
Definition: camera.h:201
void disparityImageCallback(const crl::multisense::image::Header &header)
Definition: camera.cpp:979
ros::NodeHandle device_nh_
Definition: camera.h:120
uint8_t luma_color_depth_
Definition: camera.h:283
crl::multisense::image::Calibration image_calibration_
Definition: camera.h:237
ros::Publisher right_stereo_disparity_pub_
Definition: camera.h:184
ros::Publisher right_rect_cam_info_pub_
Definition: camera.h:165
void colorImageCallback(const crl::multisense::image::Header &header)
Definition: camera.cpp:1676
image_transport::ImageTransport left_rect_transport_
Definition: camera.h:129
sensor_msgs::Image ni_depth_image_
Definition: camera.h:203
sensor_msgs::PointCloud2 luma_organized_point_cloud_
Definition: camera.h:206
sensor_msgs::PointCloud2 luma_point_cloud_
Definition: camera.h:204
void monoCallback(const crl::multisense::image::Header &header)
Definition: camera.cpp:1161
image_transport::Publisher left_disparity_cost_pub_
Definition: camera.h:181
sensor_msgs::CameraInfo left_mono_cam_info_
Definition: camera.h:142
sensor_msgs::PointCloud2 color_point_cloud_
Definition: camera.h:205
ros::Publisher left_stereo_disparity_pub_
Definition: camera.h:183
ros::Publisher luma_point_cloud_pub_
Definition: camera.h:173
ros::Publisher depth_cam_info_pub_
Definition: camera.h:171
boost::mutex border_clip_lock_
Definition: camera.h:304
ros::Publisher histogram_pub_
Definition: camera.h:193
ros::Publisher left_mono_cam_info_pub_
Definition: camera.h:162
Camera(crl::multisense::Channel *driver, const std::string &tf_prefix)
Definition: camera.cpp:324
sensor_msgs::Image right_disparity_image_
Definition: camera.h:215
void borderClipChanged(int borderClipType, double borderClipValue)
Definition: camera.cpp:2114
double border_clip_value_
Definition: camera.h:297
sensor_msgs::Image depth_image_
Definition: camera.h:202
void disconnectStream(crl::multisense::DataSource disableMask)
Definition: camera.cpp:2221
std::string frame_id_right_
Definition: camera.h:250
void depthCallback(const crl::multisense::image::Header &header)
Definition: camera.cpp:1360
void connectStream(crl::multisense::DataSource enableMask)
Definition: camera.cpp:2202
ros::Publisher raw_cam_config_pub_
Definition: camera.h:190
sensor_msgs::Image left_disparity_cost_image_
Definition: camera.h:214
sensor_msgs::CameraInfo right_rect_cam_info_
Definition: camera.h:145
int64_t left_luma_frame_id_
Definition: camera.h:222
image_transport::ImageTransport right_mono_transport_
Definition: camera.h:128
image_transport::ImageTransport left_rgb_transport_
Definition: camera.h:131
std::vector< cv::Vec3f > points_buff_
Definition: camera.h:256
uint32_t disparities_
Definition: camera.h:266
sensor_msgs::CameraInfo left_cost_cam_info_
Definition: camera.h:149
ros::Publisher right_mono_cam_info_pub_
Definition: camera.h:163
stereo_msgs::DisparityImage left_stereo_disparity_
Definition: camera.h:217
std::string frame_id_left_
Definition: camera.h:249
image_transport::Publisher right_mono_cam_pub_
Definition: camera.h:154
StreamMapType stream_map_
Definition: camera.h:273
crl::multisense::system::DeviceInfo device_info_
Definition: camera.h:235
int64_t luma_point_cloud_frame_id_
Definition: camera.h:225
void generateBorderClip(int borderClipType, double borderClipValue, uint32_t width, uint32_t height)
Definition: camera.cpp:2124
sensor_msgs::Image left_mono_image_
Definition: camera.h:198
image_transport::Publisher ni_depth_cam_pub_
Definition: camera.h:158
void rectCallback(const crl::multisense::image::Header &header)
Definition: camera.cpp:1238
image_transport::Publisher left_disparity_pub_
Definition: camera.h:179
ros::Publisher raw_cam_data_pub_
Definition: camera.h:189
image_transport::CameraPublisher left_rgb_rect_cam_pub_
Definition: camera.h:160
ros::Publisher left_disp_cam_info_pub_
Definition: camera.h:166
image_transport::Publisher depth_cam_pub_
Definition: camera.h:157
crl::multisense::image::Config image_config_
Definition: camera.h:236
std::map< crl::multisense::DataSource, int32_t > StreamMapType
Definition: camera.h:271
std::vector< float > disparity_buff_
Definition: camera.h:255
ros::NodeHandle right_nh_
Definition: camera.h:122
image_transport::CameraPublisher right_rect_cam_pub_
Definition: camera.h:156
image_transport::ImageTransport left_mono_transport_
Definition: camera.h:127
ros::Publisher raw_cam_cal_pub_
Definition: camera.h:191
sensor_msgs::CameraInfo depth_cam_info_
Definition: camera.h:151
image_transport::CameraPublisher left_rect_cam_pub_
Definition: camera.h:155
sensor_msgs::Image left_rect_image_
Definition: camera.h:200
ros::Publisher right_disp_cam_info_pub_
Definition: camera.h:167
crl::multisense::Channel * driver_
Definition: camera.h:115
sensor_msgs::Image left_luma_image_
Definition: camera.h:209
void resolutionChanged()
Definition: camera.h:59
ros::Publisher device_info_pub_
Definition: camera.h:192
image_transport::Publisher left_rgb_cam_pub_
Definition: camera.h:159
image_transport::ImageTransport left_rgb_rect_transport_
Definition: camera.h:132
sensor_msgs::CameraInfo left_rect_cam_info_
Definition: camera.h:144
bool write_pc_color_packed_
Definition: camera.h:289
int64_t color_organized_point_cloud_frame_id_
Definition: camera.h:228
sensor_msgs::Image left_rgb_image_
Definition: camera.h:210
sensor_msgs::Image right_mono_image_
Definition: camera.h:199
image_transport::ImageTransport depth_transport_
Definition: camera.h:133
ros::Publisher left_rgb_rect_cam_info_pub_
Definition: camera.h:170
void histogramCallback(const crl::multisense::image::Header &header)
Definition: camera.cpp:863
stereo_msgs::DisparityImage right_stereo_disparity_
Definition: camera.h:218
CvMat * calibration_map_left_2_
Definition: camera.h:244
int64_t points_buff_frame_id_
Definition: camera.h:257
sensor_msgs::CameraInfo left_disp_cam_info_
Definition: camera.h:147
uint32_t DataSource
ros::NodeHandle left_nh_
Definition: camera.h:121
int64_t color_point_cloud_frame_id_
Definition: camera.h:227
image_transport::ImageTransport right_rect_transport_
Definition: camera.h:130
ros::Publisher left_cost_cam_info_pub_
Definition: camera.h:168
sensor_msgs::CameraInfo right_disp_cam_info_
Definition: camera.h:148
boost::mutex stream_lock_
Definition: camera.h:272
int64_t left_rect_frame_id_
Definition: camera.h:223
int64_t luma_organized_point_cloud_frame_id_
Definition: camera.h:226
CvMat * calibration_map_left_1_
Definition: camera.h:243
sensor_msgs::CameraInfo left_rgb_cam_info_
Definition: camera.h:150
image_transport::ImageTransport ni_depth_transport_
Definition: camera.h:134
image_transport::ImageTransport disparity_right_transport_
Definition: camera.h:136
ros::Publisher left_rect_cam_info_pub_
Definition: camera.h:164
sensor_msgs::CameraInfo right_mono_cam_info_
Definition: camera.h:143
void jpegImageCallback(const crl::multisense::image::Header &header)
Definition: camera.cpp:899
sensor_msgs::Image left_disparity_image_
Definition: camera.h:213
ros::Publisher color_organized_point_cloud_pub_
Definition: camera.h:177
const std::string header
image_transport::ImageTransport disparity_left_transport_
Definition: camera.h:135
sensor_msgs::PointCloud2 color_organized_point_cloud_
Definition: camera.h:207
crl::multisense::system::VersionInfo version_info_
Definition: camera.h:234
cv::Mat_< double > q_matrix_
Definition: camera.h:258
sensor_msgs::CameraInfo left_rgb_rect_cam_info_
Definition: camera.h:146
int64_t left_rgb_rect_frame_id_
Definition: camera.h:224
sensor_msgs::Image left_rgb_rect_image_
Definition: camera.h:211
multisense_ros::RawCamData raw_cam_data_
Definition: camera.h:229
ros::Publisher color_point_cloud_pub_
Definition: camera.h:174
cv::Mat_< uint8_t > border_clip_mask_
Definition: camera.h:302
int64_t last_frame_id_
Definition: camera.h:278
boost::mutex cal_lock_
Definition: camera.h:242
void updateCameraInfo(sensor_msgs::CameraInfo &cameraInfo, const float M[3][3], const float R[3][3], const float P[3][4], const float D[8], double xScale=1, double yScale=1)
Definition: camera.cpp:2015


multisense_ros
Author(s):
autogenerated on Sat Apr 6 2019 02:16:53