sensor_params.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright 2023 RealSense, Inc. All Rights Reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #pragma once
  15. #include <librealsense2/rs.hpp>
  16. #include "ros_node_base.h"
  17. #include <dynamic_params.h>
  18. namespace realsense2_camera
  19. {
  20. class SensorParams
  21. {
  22. public:
  23. SensorParams(std::shared_ptr<Parameters> parameters, rclcpp::Logger logger):
  24. _logger(logger),
  25. _parameters(parameters) {};
  26. ~SensorParams();
  27. void registerDynamicOptions(rs2::options sensor, const std::string& module_name);
  28. void clearParameters();
  29. std::shared_ptr<Parameters> getParameters() {return _parameters;};
  30. public:
  31. rclcpp::Logger _logger;
  32. private:
  33. double float_to_double(float val, rs2::option_range option_range);
  34. template<class T>
  35. rcl_interfaces::msg::ParameterDescriptor get_parameter_descriptor(const std::string& option_name, rs2::option_range option_range,
  36. T option_value, const std::string& option_description, const std::string& description_addition);
  37. template<class T>
  38. void set_parameter(rs2::options sensor, rs2_option option, const std::string& module_name, const std::string& description_addition="");
  39. private:
  40. std::shared_ptr<Parameters> _parameters;
  41. std::vector<std::string> _parameters_names;
  42. };
  43. }