00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include <string>
00032 #include <vector>
00033
00034 #include <realsense_camera/f200_nodelet.h>
00035
00036 PLUGINLIB_EXPORT_CLASS(realsense_camera::F200Nodelet, nodelet::Nodelet)
00037
00038 namespace realsense_camera
00039 {
00040
00041
00042
00043 void F200Nodelet::onInit()
00044 {
00045 format_[RS_STREAM_COLOR] = RS_FORMAT_RGB8;
00046 encoding_[RS_STREAM_COLOR] = sensor_msgs::image_encodings::RGB8;
00047 cv_type_[RS_STREAM_COLOR] = CV_8UC3;
00048 unit_step_size_[RS_STREAM_COLOR] = sizeof(unsigned char) * 3;
00049
00050 format_[RS_STREAM_DEPTH] = RS_FORMAT_Z16;
00051 encoding_[RS_STREAM_DEPTH] = sensor_msgs::image_encodings::TYPE_16UC1;
00052 cv_type_[RS_STREAM_DEPTH] = CV_16UC1;
00053 unit_step_size_[RS_STREAM_DEPTH] = sizeof(uint16_t);
00054
00055 format_[RS_STREAM_INFRARED] = RS_FORMAT_Y8;
00056 encoding_[RS_STREAM_INFRARED] = sensor_msgs::image_encodings::TYPE_8UC1;
00057 cv_type_[RS_STREAM_INFRARED] = CV_8UC1;
00058 unit_step_size_[RS_STREAM_INFRARED] = sizeof(unsigned char);
00059
00060 max_z_ = F200_MAX_Z;
00061
00062 SyncNodelet::onInit();
00063 }
00064
00065
00066
00067
00068 void F200Nodelet::setStreams()
00069 {
00070
00071 BaseNodelet::setStreams();
00072
00073
00074 fastest_stream_ = RS_STREAM_DEPTH;
00075
00076 if (fps_[RS_STREAM_COLOR] > fps_[RS_STREAM_DEPTH])
00077 {
00078 if (enable_[RS_STREAM_COLOR])
00079 {
00080 fastest_stream_ = RS_STREAM_COLOR;
00081 }
00082 }
00083 }
00084
00085
00086
00087
00088 std::vector<std::string> F200Nodelet::setDynamicReconfServer()
00089 {
00090 dynamic_reconf_server_.reset(new dynamic_reconfigure::Server<realsense_camera::f200_paramsConfig>(pnh_));
00091
00092
00093 realsense_camera::f200_paramsConfig params_config;
00094 dynamic_reconf_server_->getConfigDefault(params_config);
00095 std::vector<realsense_camera::f200_paramsConfig::AbstractParamDescriptionConstPtr> param_desc =
00096 params_config.__getParamDescriptions__();
00097 std::vector<std::string> dynamic_params;
00098 for (realsense_camera::f200_paramsConfig::AbstractParamDescriptionConstPtr param_desc_ptr : param_desc)
00099 {
00100 dynamic_params.push_back((* param_desc_ptr).name);
00101 }
00102
00103 return dynamic_params;
00104 }
00105
00106
00107
00108
00109 void F200Nodelet::startDynamicReconfCallback()
00110 {
00111 dynamic_reconf_server_->setCallback(boost::bind(&F200Nodelet::configCallback, this, _1, _2));
00112 }
00113
00114
00115
00116
00117 void F200Nodelet::configCallback(realsense_camera::f200_paramsConfig &config, uint32_t level)
00118 {
00119 ROS_INFO_STREAM(nodelet_name_ << " - Setting dynamic camera options");
00120
00121
00122 BaseNodelet::setDepthEnable(config.enable_depth);
00123
00124
00125 rs_set_device_option(rs_device_, RS_OPTION_COLOR_BACKLIGHT_COMPENSATION, config.color_backlight_compensation, 0);
00126 rs_set_device_option(rs_device_, RS_OPTION_COLOR_BRIGHTNESS, config.color_brightness, 0);
00127 rs_set_device_option(rs_device_, RS_OPTION_COLOR_CONTRAST, config.color_contrast, 0);
00128 rs_set_device_option(rs_device_, RS_OPTION_COLOR_GAIN, config.color_gain, 0);
00129 rs_set_device_option(rs_device_, RS_OPTION_COLOR_GAMMA, config.color_gamma, 0);
00130 rs_set_device_option(rs_device_, RS_OPTION_COLOR_HUE, config.color_hue, 0);
00131 rs_set_device_option(rs_device_, RS_OPTION_COLOR_SATURATION, config.color_saturation, 0);
00132 rs_set_device_option(rs_device_, RS_OPTION_COLOR_SHARPNESS, config.color_sharpness, 0);
00133 rs_set_device_option(rs_device_, RS_OPTION_COLOR_ENABLE_AUTO_EXPOSURE,
00134 config.color_enable_auto_exposure, 0);
00135 if (config.color_enable_auto_exposure == 0)
00136 {
00137 rs_set_device_option(rs_device_, RS_OPTION_COLOR_EXPOSURE, config.color_exposure, 0);
00138 }
00139 rs_set_device_option(rs_device_, RS_OPTION_COLOR_ENABLE_AUTO_WHITE_BALANCE,
00140 config.color_enable_auto_white_balance, 0);
00141 if (config.color_enable_auto_white_balance == 0)
00142 {
00143 rs_set_device_option(rs_device_, RS_OPTION_COLOR_WHITE_BALANCE, config.color_white_balance, 0);
00144 }
00145
00146
00147 rs_set_device_option(rs_device_, RS_OPTION_F200_LASER_POWER, config.f200_laser_power, 0);
00148 rs_set_device_option(rs_device_, RS_OPTION_F200_ACCURACY, config.f200_accuracy, 0);
00149 rs_set_device_option(rs_device_, RS_OPTION_F200_MOTION_RANGE, config.f200_motion_range, 0);
00150 rs_set_device_option(rs_device_, RS_OPTION_F200_FILTER_OPTION, config.f200_filter_option, 0);
00151 rs_set_device_option(rs_device_, RS_OPTION_F200_CONFIDENCE_THRESHOLD, config.f200_confidence_threshold, 0);
00152 }
00153 }