diff --git a/realsense2_camera/include/ros_sensor.h b/realsense2_camera/include/ros_sensor.h index c4430bfd4f..57d224300e 100644 --- a/realsense2_camera/include/ros_sensor.h +++ b/realsense2_camera/include/ros_sensor.h @@ -105,6 +105,7 @@ namespace realsense2_camera void set_sensor_auto_exposure_roi(); void registerAutoExposureROIOptions(); void UpdateSequenceIdCallback(); + template void set_sensor_parameter_to_ros(rs2_option option); private: diff --git a/realsense2_camera/src/ros_sensor.cpp b/realsense2_camera/src/ros_sensor.cpp index 635424d8c5..a7a341dacb 100644 --- a/realsense2_camera/src/ros_sensor.cpp +++ b/realsense2_camera/src/ros_sensor.cpp @@ -136,8 +136,8 @@ void RosSensor::UpdateSequenceIdCallback() { set_option(RS2_OPTION_SEQUENCE_ID, parameter.get_value()); std::vector > funcs; - funcs.push_back([this](){set_sensor_parameter_to_ros(RS2_OPTION_GAIN);}); - funcs.push_back([this](){set_sensor_parameter_to_ros(RS2_OPTION_EXPOSURE);}); + funcs.push_back([this](){set_sensor_parameter_to_ros(RS2_OPTION_GAIN);}); + funcs.push_back([this](){set_sensor_parameter_to_ros(RS2_OPTION_EXPOSURE);}); _params.getParameters()->pushUpdateFunctions(funcs); }); } @@ -149,11 +149,12 @@ void RosSensor::UpdateSequenceIdCallback() } +template void RosSensor::set_sensor_parameter_to_ros(rs2_option option) { std::string module_name = create_graph_resource_name(rs2_to_ros(get_info(RS2_CAMERA_INFO_NAME))); const std::string option_name(module_name + "." + create_graph_resource_name(rs2_option_to_string(option))); - float value = get_option(option); + auto value = static_cast(get_option(option)); _params.getParameters()->setRosParamValue(option_name, &value); }