Skip to content

Commit

Permalink
significantly improve the reliability of the time_source tests
Browse files Browse the repository at this point in the history
Signed-off-by: William Woodall <william@osrfoundation.org>
  • Loading branch information
wjwwood committed Apr 18, 2019
1 parent 570c7c2 commit 3ef385d
Show file tree
Hide file tree
Showing 2 changed files with 167 additions and 79 deletions.
14 changes: 10 additions & 4 deletions rclcpp/src/rclcpp/time_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,16 @@ void TimeSource::attachNode(

// 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.
auto use_sim_time_param = node_parameters_->declare_parameter(
"use_sim_time",
rclcpp::ParameterValue(false),
rcl_interfaces::msg::ParameterDescriptor());
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;
Expand Down
Loading

0 comments on commit 3ef385d

Please sign in to comment.