-
Notifications
You must be signed in to change notification settings - Fork 481
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Feature request
Feature description
Regarding TimeSource's use of the use_sim_time parameter, as per @ivanpauno's comment on #799:
...now that we allow registering multiple parameter callbacks, we should use a
on_parameter_setcallback for rejecting wronguse_sim_timevalues, instead of logging an error...
Implementation considerations
Relevant sources can be found here:
rclcpp/rclcpp/src/rclcpp/time_source.cpp
Lines 82 to 105 in 9be3e08
| // Though this defaults to false, it can be overridden by initial parameter values for the node, | |
| // which may be given by the user at the node's construction or even by command-line arguments. | |
| rclcpp::ParameterValue use_sim_time_param; | |
| const char * use_sim_time_name = "use_sim_time"; | |
| if (!node_parameters_->has_parameter(use_sim_time_name)) { | |
| use_sim_time_param = node_parameters_->declare_parameter( | |
| use_sim_time_name, | |
| rclcpp::ParameterValue(false), | |
| rcl_interfaces::msg::ParameterDescriptor()); | |
| } else { | |
| use_sim_time_param = node_parameters_->get_parameter(use_sim_time_name).get_parameter_value(); | |
| } | |
| if (use_sim_time_param.get_type() == rclcpp::PARAMETER_BOOL) { | |
| if (use_sim_time_param.get<bool>()) { | |
| parameter_state_ = SET_TRUE; | |
| enable_ros_time(); | |
| create_clock_sub(); | |
| } | |
| } else { | |
| // TODO(wjwwood): use set_on_parameters_set_callback to catch the type mismatch, | |
| // before the use_sim_time parameter can ever be set to an invalid value | |
| RCLCPP_ERROR(logger_, "Invalid type '%s' for parameter 'use_sim_time', should be 'bool'", | |
| rclcpp::to_string(use_sim_time_param.get_type()).c_str()); | |
| } |
and here:
rclcpp/rclcpp/src/rclcpp/time_source.cpp
Lines 232 to 235 in 9be3e08
| if (it.second->value.type != ParameterType::PARAMETER_BOOL) { | |
| RCLCPP_ERROR(logger_, "use_sim_time parameter cannot be set to anything but a bool"); | |
| continue; | |
| } |
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request