Skip to content

diagnostic_aggregator: accept integer-typed values for floating point parameters - #683

Open
fujitatomoya wants to merge 1 commit into
ros:ros2from
fujitatomoya:fix/accept-integer-double-params
Open

fujitatomoya wants to merge 1 commit into
ros:ros2from
fujitatomoya:fix/accept-integer-double-params

Conversation

@fujitatomoya

Copy link
Copy Markdown

Description

pub_rate: 2 or timeout: 5 in a parameter file are typed INTEGER by rclcpp, and rclcpp::Parameter::as_double() throws ParameterTypeException on them, which terminates the aggregator during initialization. Users had to know to write 5.0 even though these are conceptually floating point values.

This was noticed while reviewing #680 (#680 (comment)) and split out so the pre-existing problem can be fixed and backported on its own.

Changes

  • Add getDoubleParam() in status_item.hpp, which converts integer-typed parameters to double and otherwise falls back to as_double().
  • Use it for the aggregator pub_rate and the GenericAnalyzer timeout.
  • Add test_integer_parameters.py, a launch test that starts the aggregator with integer-valued pub_rate and timeout and checks that it produces output. Without the fix the aggregator dies with ParameterTypeException and the test fails.

Backport

This is a small, self-contained robustness fix with no behaviour change for existing float-valued configurations. Please add the backport label so it reaches ros2-humble, ros2-jazzy, ros2-kilted and ros2-lyrical; I do not have permission to set labels on this repository.

🤖 Generated with Claude Code

… parameters

"pub_rate: 2" or "timeout: 5" in a parameter file are typed INTEGER by
rclcpp, and rclcpp::Parameter::as_double() throws ParameterTypeException on
them, which terminates the aggregator during initialization. Users had to
know to write "5.0" even though these are conceptually floating point
values.

Add getDoubleParam(), which converts integer-typed parameters to double and
otherwise falls back to as_double(), and use it for pub_rate and the
GenericAnalyzer timeout. Add a launch test that starts the aggregator with
integer-valued pub_rate and timeout and checks that it produces output; it
fails with ParameterTypeException without the fix.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: Tomoya Fujita <fujita.tomoya@triorb.co.jp>

@fujitatomoya fujitatomoya left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor fix, most of them are just test codes.

@ct2034 can you take a look?

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