generate_parameter_library icon indicating copy to clipboard operation
generate_parameter_library copied to clipboard

Undeclaring a parameter throws an unexpected error.

Open pac48 opened this issue 3 years ago • 0 comments
trafficstars

According to the ROS 2 documentation, the undeclare_parameter(const std::string & name) method of rclcpp::node_interfaces::NodeParametersInterface should only throw two types of exceptions:

  1. rclcpp::exceptions::ParameterNotDeclaredException: if the parameter has not been declared.
  2. rclcpp::exceptions::ParameterImmutableException: if the parameter was create as read_only (immutable).

I get the following exception when I try to undeclare a parameter.

terminate called after throwing an instance of 'rclcpp::exceptions::InvalidParameterTypeException'
  what():  parameter 'pid.elbow_joint.p' has invalid type: cannot undeclare an statically typed parameter

This occurs when setting the parameter like this:

double val = 1.5;
auto parameter = rclcpp::ParameterValue(val);
rcl_interfaces::msg::ParameterDescriptor descriptor;
descriptor.description = "my  parameter";
parameters_interface_->declare_parameter("pid.elbow_joint.p", parameter, descriptor);

pac48 avatar Jul 27 '22 03:07 pac48