45 void R200Nodelet::onInit()
69 SyncNodelet::onInit();
75 void R200Nodelet::getParameters()
77 BaseNodelet::getParameters();
80 pnh_.param(
"enable_ir2", enable_[RS_STREAM_INFRARED2],
ENABLE_IR2);
91 void R200Nodelet::advertiseTopics()
93 BaseNodelet::advertiseTopics();
102 std::vector<std::string> R200Nodelet::setDynamicReconfServer()
104 dynamic_reconf_server_.reset(
new dynamic_reconfigure::Server<realsense_camera::r200_paramsConfig>(pnh_));
107 realsense_camera::r200_paramsConfig params_config;
108 dynamic_reconf_server_->getConfigDefault(params_config);
109 std::vector<realsense_camera::r200_paramsConfig::AbstractParamDescriptionConstPtr> param_desc =
110 params_config.__getParamDescriptions__();
111 std::vector<std::string> dynamic_params;
112 for (realsense_camera::r200_paramsConfig::AbstractParamDescriptionConstPtr param_desc_ptr : param_desc)
114 dynamic_params.push_back((* param_desc_ptr).name);
117 return dynamic_params;
123 void R200Nodelet::startDynamicReconfCallback()
125 dynamic_reconf_server_->setCallback(boost::bind(&R200Nodelet::configCallback,
this, _1, _2));
131 void R200Nodelet::setDynamicReconfigDepthControlPreset(
int preset)
136 std::vector<std::string> argv;
137 argv.push_back(
"rosrun");
138 argv.push_back(
"dynamic_reconfigure");
139 argv.push_back(
"dynparam");
140 argv.push_back(
"set");
141 argv.push_back(nodelet_name_);
142 argv.push_back(
"r200_dc_preset");
143 argv.push_back(std::to_string(preset));
153 std::string R200Nodelet::setDynamicReconfigDepthControlIndividuals()
155 std::string current_param;
156 std::string current_dc;
157 std::string option_value;
162 std::vector<std::string> argv;
163 argv.push_back(
"rosrun");
164 argv.push_back(
"dynamic_reconfigure");
165 argv.push_back(
"dynparam");
166 argv.push_back(
"set");
167 argv.push_back(nodelet_name_);
174 current_param +=
"'r200_dc_estimate_median_decrement':" + option_value +
", ";
175 current_dc += option_value +
":";
180 current_param +=
"'r200_dc_estimate_median_increment':" + option_value +
", ";
181 current_dc += option_value +
":";
186 current_param +=
"'r200_dc_median_threshold':" + option_value +
", ";
187 current_dc += option_value +
":";
192 current_param +=
"'r200_dc_score_minimum_threshold':" + option_value +
", ";
193 current_dc += option_value +
":";
198 current_param +=
"'r200_dc_score_maximum_threshold':" + option_value +
", ";
199 current_dc += option_value +
":";
204 current_param +=
"'r200_dc_texture_count_threshold':" + option_value +
", ";
205 current_dc += option_value +
":";
210 current_param +=
"'r200_dc_texture_difference_threshold':" + option_value +
", ";
211 current_dc += option_value +
":";
216 current_param +=
"'r200_dc_second_peak_threshold':" + option_value +
", ";
217 current_dc += option_value +
":";
222 current_param +=
"'r200_dc_neighbor_threshold':" + option_value +
", ";
223 current_dc += option_value +
":";
228 current_param +=
"'r200_dc_lr_threshold':" + option_value +
"}";
229 current_dc += option_value;
233 argv.push_back(current_param);
243 void R200Nodelet::configCallback(realsense_camera::r200_paramsConfig &config, uint32_t
level)
246 static int dc_preset = -2;
247 int previous_dc_preset = dc_preset;
249 static std::string last_dc;
252 std::bitset<32> bit_level{level};
254 if (bit_level.test(6))
256 ROS_INFO_STREAM(nodelet_name_ <<
" - Setting dynamic camera options" <<
257 " (r200_dc_preset=" << config.r200_dc_preset <<
")");
265 BaseNodelet::setDepthEnable(config.enable_depth);
277 config.color_enable_auto_exposure, 0);
278 if (config.color_enable_auto_exposure == 0)
283 config.color_enable_auto_white_balance, 0);
284 if (config.color_enable_auto_white_balance == 0)
291 if (config.r200_lr_auto_exposure_enabled == 0)
297 if (config.r200_lr_auto_exposure_enabled == 1)
301 config.r200_auto_exposure_top_edge = height_[RS_STREAM_DEPTH] - 1;
303 if (config.r200_auto_exposure_bottom_edge >= height_[RS_STREAM_DEPTH])
305 config.r200_auto_exposure_bottom_edge = height_[RS_STREAM_DEPTH] - 1;
307 if (config.r200_auto_exposure_left_edge >= width_[RS_STREAM_DEPTH])
309 config.r200_auto_exposure_left_edge = width_[RS_STREAM_DEPTH] - 1;
311 if (config.r200_auto_exposure_right_edge >= width_[RS_STREAM_DEPTH])
313 config.r200_auto_exposure_right_edge = width_[RS_STREAM_DEPTH] - 1;
315 double edge_values_[4];
316 edge_values_[0] = config.r200_auto_exposure_left_edge;
317 edge_values_[1] = config.r200_auto_exposure_top_edge;
318 edge_values_[2] = config.r200_auto_exposure_right_edge;
319 edge_values_[3] = config.r200_auto_exposure_bottom_edge;
327 if (bit_level.test(5))
329 std::string current_dc;
334 config.r200_dc_estimate_median_decrement, 0);
335 current_dc += std::to_string(static_cast<uint32_t>(config.r200_dc_estimate_median_decrement)) +
":";
337 config.r200_dc_estimate_median_increment, 0);
338 current_dc += std::to_string(static_cast<uint32_t>(config.r200_dc_estimate_median_increment)) +
":";
340 config.r200_dc_median_threshold, 0);
341 current_dc += std::to_string(static_cast<uint32_t>(config.r200_dc_median_threshold)) +
":";
343 config.r200_dc_score_minimum_threshold, 0);
344 current_dc += std::to_string(static_cast<uint32_t>(config.r200_dc_score_minimum_threshold)) +
":";
346 config.r200_dc_score_maximum_threshold, 0);
347 current_dc += std::to_string(static_cast<uint32_t>(config.r200_dc_score_maximum_threshold)) +
":";
349 config.r200_dc_texture_count_threshold, 0);
350 current_dc += std::to_string(static_cast<uint32_t>(config.r200_dc_texture_count_threshold)) +
":";
352 config.r200_dc_texture_difference_threshold, 0);
353 current_dc += std::to_string(static_cast<uint32_t>(config.r200_dc_texture_difference_threshold)) +
":";
355 config.r200_dc_second_peak_threshold, 0);
356 current_dc += std::to_string(static_cast<uint32_t>(config.r200_dc_second_peak_threshold)) +
":";
358 config.r200_dc_neighbor_threshold, 0);
359 current_dc += std::to_string(static_cast<uint32_t>(config.r200_dc_neighbor_threshold)) +
":";
361 config.r200_dc_lr_threshold, 0);
362 current_dc += std::to_string(static_cast<uint32_t>(config.r200_dc_lr_threshold));
367 if (bit_level.test(6))
369 dc_preset = config.r200_dc_preset;
371 if (previous_dc_preset != -2)
375 if (dc_preset != -1 && current_dc != last_dc)
377 ROS_DEBUG_STREAM(nodelet_name_ <<
" - Forcing Depth Control Preset to Unused");
378 setDynamicReconfigDepthControlPreset(-1);
389 ROS_INFO_STREAM(nodelet_name_ <<
" - Initializing Depth Control Preset to " << dc_preset);
390 ROS_DEBUG_STREAM(nodelet_name_ <<
" - NOTICE: Individual Depth Control values " <<
391 "set by params will be ignored; set r200_dc_preset=-1 to override.");
392 rs_apply_depth_control_preset(rs_device_, dc_preset);
395 last_dc = setDynamicReconfigDepthControlIndividuals();
403 if (dc_preset != -1 && current_dc != last_dc)
405 ROS_DEBUG_STREAM(nodelet_name_ <<
" - Forcing Depth Control Preset to Unused");
406 setDynamicReconfigDepthControlPreset(-1);
412 if (bit_level.test(6))
414 dc_preset = config.r200_dc_preset;
418 ROS_DEBUG_STREAM(nodelet_name_ <<
" - Set Depth Control Preset to " << dc_preset);
419 rs_apply_depth_control_preset(rs_device_, dc_preset);
422 last_dc = setDynamicReconfigDepthControlIndividuals();
431 void R200Nodelet::getCameraExtrinsics()
433 BaseNodelet::getCameraExtrinsics();
447 void R200Nodelet::publishStaticTransforms()
449 BaseNodelet::publishStaticTransforms();
452 geometry_msgs::TransformStamped b2i_msg;
453 geometry_msgs::TransformStamped i2io_msg;
456 b2i_msg.header.stamp = transform_ts_;
457 b2i_msg.header.frame_id = base_frame_id_;
459 b2i_msg.transform.translation.x = color2ir2_extrinsic_.translation[2];
460 b2i_msg.transform.translation.y = -color2ir2_extrinsic_.translation[0];
461 b2i_msg.transform.translation.z = -color2ir2_extrinsic_.translation[1];
462 b2i_msg.transform.rotation.x = 0;
463 b2i_msg.transform.rotation.y = 0;
464 b2i_msg.transform.rotation.z = 0;
465 b2i_msg.transform.rotation.w = 1;
466 static_tf_broadcaster_.sendTransform(b2i_msg);
469 q_i2io.
setRPY(-M_PI/2, 0.0, -M_PI/2);
470 i2io_msg.header.stamp = transform_ts_;
473 i2io_msg.transform.translation.x = 0;
474 i2io_msg.transform.translation.y = 0;
475 i2io_msg.transform.translation.z = 0;
476 i2io_msg.transform.rotation.x = q_i2io.getX();
477 i2io_msg.transform.rotation.y = q_i2io.getY();
478 i2io_msg.transform.rotation.z = q_i2io.getZ();
479 i2io_msg.transform.rotation.w = q_i2io.
getW();
480 static_tf_broadcaster_.sendTransform(i2io_msg);
486 void R200Nodelet::publishDynamicTransforms()
491 BaseNodelet::publishDynamicTransforms();
495 color2ir2_extrinsic_.translation[2],
496 -color2ir2_extrinsic_.translation[0],
497 -color2ir2_extrinsic_.translation[1]));
504 q.
setRPY(-M_PI/2, 0.0, -M_PI/2);
507 frame_id_[RS_STREAM_INFRARED2], optical_frame_id_[RS_STREAM_INFRARED2]));
RS_OPTION_R200_LR_AUTO_EXPOSURE_ENABLED
RS_OPTION_COLOR_ENABLE_AUTO_EXPOSURE
void rs_set_device_option(rs_device *device, rs_option option, double value, rs_error **error)
RS_OPTION_COLOR_BACKLIGHT_COMPENSATION
RS_OPTION_COLOR_ENABLE_AUTO_WHITE_BALANCE
RS_OPTION_R200_DEPTH_CONTROL_SECOND_PEAK_THRESHOLD
RS_OPTION_R200_LR_EXPOSURE
PLUGINLIB_EXPORT_CLASS(depth_image_proc::ConvertMetricNodelet, nodelet::Nodelet)
RS_OPTION_R200_DEPTH_CONTROL_ESTIMATE_MEDIAN_INCREMENT
const std::string TYPE_8UC1
TFSIMD_FORCE_INLINE const tfScalar & getW() const
void rs_set_device_options(rs_device *device, const rs_option options[], unsigned int count, const double values[], rs_error **error)
RS_OPTION_R200_DEPTH_CONTROL_SCORE_MINIMUM_THRESHOLD
RS_OPTION_R200_DEPTH_CONTROL_SCORE_MAXIMUM_THRESHOLD
RS_OPTION_COLOR_WHITE_BALANCE
const std::string IR2_TOPIC
CameraPublisher advertiseCamera(const std::string &base_topic, uint32_t queue_size, bool latch=false)
RS_OPTION_COLOR_SHARPNESS
void setRPY(const tfScalar &roll, const tfScalar &pitch, const tfScalar &yaw)
const std::string IR2_NAMESPACE
RS_OPTION_R200_DEPTH_CONTROL_ESTIMATE_MEDIAN_DECREMENT
double rs_get_device_option(rs_device *device, rs_option option, rs_error **error)
const std::string TYPE_16UC1
RS_OPTION_R200_DEPTH_CONTROL_NEIGHBOR_THRESHOLD
RS_OPTION_R200_EMITTER_ENABLED
void rs_get_device_extrinsics(const rs_device *device, rs_stream from, rs_stream to, rs_extrinsics *extrin, rs_error **error)
#define ROS_DEBUG_STREAM(args)
RS_OPTION_R200_DEPTH_CONTROL_MEDIAN_THRESHOLD
RS_OPTION_R200_DEPTH_CONTROL_TEXTURE_DIFFERENCE_THRESHOLD
#define ROS_INFO_STREAM(args)
const std::string DEFAULT_IR2_FRAME_ID
const std::string DEFAULT_IR2_OPTICAL_FRAME_ID
RS_OPTION_COLOR_SATURATION
GLdouble GLdouble GLdouble GLdouble q
#define ROS_ERROR_STREAM(args)
RS_OPTION_R200_DEPTH_CONTROL_LR_THRESHOLD
RS_OPTION_R200_DEPTH_CONTROL_TEXTURE_COUNT_THRESHOLD
RS_OPTION_COLOR_BRIGHTNESS