-
Notifications
You must be signed in to change notification settings - Fork 117
Open
Labels
Description
There are wrappers for getting ROS parameters with the comment
// TODO(anyone): to-be-removed once this functionality becomes supported by the param API directly
control_toolbox/control_toolbox/src/pid_ros.cpp
Lines 132 to 183 in 4a581e3
| bool PidROS::get_boolean_param(const std::string & param_name, bool & value) | |
| { | |
| declare_param(param_name, rclcpp::ParameterValue(value)); | |
| rclcpp::Parameter param; | |
| if (node_params_->has_parameter(param_name)) | |
| { | |
| node_params_->get_parameter(param_name, param); | |
| if (rclcpp::PARAMETER_BOOL != param.get_type()) | |
| { | |
| RCLCPP_ERROR( | |
| node_logging_->get_logger(), "Wrong parameter type '%s', not boolean", param_name.c_str()); | |
| return false; | |
| } | |
| value = param.as_bool(); | |
| return true; | |
| } | |
| else | |
| { | |
| return false; | |
| } | |
| } | |
| // TODO(anyone): to-be-removed once this functionality becomes supported by the param API directly | |
| bool PidROS::get_double_param(const std::string & param_name, double & value) | |
| { | |
| declare_param(param_name, rclcpp::ParameterValue(value)); | |
| rclcpp::Parameter param; | |
| if (node_params_->has_parameter(param_name)) | |
| { | |
| node_params_->get_parameter(param_name, param); | |
| if (rclcpp::PARAMETER_DOUBLE != param.get_type()) | |
| { | |
| RCLCPP_ERROR( | |
| node_logging_->get_logger(), "Wrong parameter type '%s', not double", param_name.c_str()); | |
| return false; | |
| } | |
| value = param.as_double(); | |
| RCLCPP_DEBUG_STREAM( | |
| node_logging_->get_logger(), "parameter '" << param_name << "' in node '" | |
| << node_base_->get_name() << "' value is " << value | |
| << std::endl); | |
| return true; | |
| } | |
| else | |
| { | |
| RCLCPP_ERROR_STREAM( | |
| node_logging_->get_logger(), "parameter '" << param_name << "' in node '" | |
| << node_base_->get_name() << "' does not exists" | |
| << std::endl); | |
| return false; | |
| } | |
| } |
Evaluate, if there is already a cleaner way in the rclcpp API. If not, we should consider using generate_parameter_library here, which is already a dependency of this package.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
No status