Skip to content

Conversation

matemat13
Copy link

Description

Fixes #2898

Is this user-facing behavior change?

Yes. Trying to set a floating-point parameter with a configured range to a value outside this range that is either inf, -inf, or nan will now correctly fail.

Did you use Generative AI?

No.

Additional Information

Nothing that comes to mind.

{
const rclcpp::Parameter new_parameter = rclcpp::Parameter(
"double_parameter",
std::numeric_limits<double>::infinity()
Copy link
Contributor

Choose a reason for hiding this comment

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

include <limits>

Copy link
Contributor

@ahcorde ahcorde left a comment

Choose a reason for hiding this comment

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

Copy link
Collaborator

@fujitatomoya fujitatomoya left a comment

Choose a reason for hiding this comment

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

@matemat13 thanks for creating PR.

can you retarget this fix to rolling branch? that is where we develop the code 1st. btw, code base is bit different from jazzy and rolling around this area.

if ((v < fp_range.from_value) || (v > fp_range.to_value)) {
const double v = value.get<double>();
const auto& fp_range = descriptor.floating_point_range.at(0);
const bool within_range = (v >= fp_range.from_value) && (v <= fp_range.to_value);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This removed the epsilon, shouldn't it be

Suggested change
const bool within_range = (v >= fp_range.from_value) && (v <= fp_range.to_value);
const bool within_range = (v >= fp_range.from_value - std::numeric_limits<double>::epsilon() ) && (v <= fp_range.to_value + + std::numeric_limits<double>::epsilon() );

Also, if the __are_doubles_equal function is obviously broken, why was it not removed ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants