Skip to content

Fix start_type_description_service param handling (backport #2897)#2908

Merged
fujitatomoya merged 1 commit intokiltedfrom
mergify/bp/kilted/pr-2897
Jul 17, 2025
Merged

Fix start_type_description_service param handling (backport #2897)#2908
fujitatomoya merged 1 commit intokiltedfrom
mergify/bp/kilted/pr-2897

Conversation

@mergify
Copy link
Copy Markdown
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 <ronca.pat@gmail.com>

* Add test

Signed-off-by: Patrick Roncagliolo <ronca.pat@gmail.com>

* Demonstrate different exceptions depending on node options

Signed-off-by: Patrick Roncagliolo <ronca.pat@gmail.com>

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

Signed-off-by: Patrick Roncagliolo <ronca.pat@gmail.com>

* Uncrustify

Signed-off-by: Patrick Roncagliolo <ronca.pat@gmail.com>

---------

Signed-off-by: Patrick Roncagliolo <ronca.pat@gmail.com>
(cherry picked from commit 4fb558a)
@fujitatomoya
Copy link
Copy Markdown
Collaborator

fujitatomoya commented Jul 16, 2025

Pulls: #2908
Gist: https://gist.githubusercontent.com/fujitatomoya/8d1063d36d9ce23d536b97145550c4e6/raw/d13db0b14f13a62cadbc40f7ae398f8e8a1919ba/ros2.repos
BUILD args: --packages-above-and-dependencies rclcpp
TEST args: --packages-above rclcpp
ROS Distro: kilted
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/16508

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

@fujitatomoya fujitatomoya merged commit a709d81 into kilted 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