Skip to content

Fix start_type_description_service param handling (backport #2897) #2909

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 17, 2025

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Jul 16, 2025

Closes #2892 by using the same exact strategy for declaring use_sim_time.

rclcpp::ParameterValue use_sim_time_param;
const std::string 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));
} 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;
clocks_state_.enable_ros_time();
create_clock_sub();
}
} else {
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());
throw std::invalid_argument("Invalid type for parameter 'use_sim_time', should be 'bool'");
}

Tested (you can try to define start_type_description_service like so, and pass it to Nav2 bt_navigator or diagnostic_aggregator):

/**:
  ros__parameters:
    use_sim_time: false
    start_type_description_service: false

whithout the patch, it crashes like ros/diagnostics#519.

  • Add test

Did you use Generative AI?

No


This is an automatic backport of pull request #2897 done by Mergify.

* Fix `start_type_description_service` param handling

Signed-off-by: Patrick Roncagliolo <[email protected]>

* Add test

Signed-off-by: Patrick Roncagliolo <[email protected]>

* Demonstrate different exceptions depending on node options

Signed-off-by: Patrick Roncagliolo <[email protected]>

* Same exact exception and `what()` message in both cases

Signed-off-by: Patrick Roncagliolo <[email protected]>

* Uncrustify

Signed-off-by: Patrick Roncagliolo <[email protected]>

---------

Signed-off-by: Patrick Roncagliolo <[email protected]>
(cherry picked from commit 4fb558a)
@fujitatomoya
Copy link
Collaborator

Pulls: #2909
Gist: https://gist.githubusercontent.com/fujitatomoya/da08f6083dcc62564b8edd80a60aa9ff/raw/b82e7ce0ae942e1e5dde8cb2ea389a18de288671/ros2.repos
BUILD args: --packages-above-and-dependencies rclcpp
TEST args: --packages-above rclcpp
ROS Distro: jazzy
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/16509

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

@fujitatomoya fujitatomoya merged commit ebdaf1f into jazzy Jul 17, 2025
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants