-
Notifications
You must be signed in to change notification settings - Fork 466
Fixed range checking for floating-type parameters #2904
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
base: jazzy
Are you sure you want to change the base?
Conversation
{ | ||
const rclcpp::Parameter new_parameter = rclcpp::Parameter( | ||
"double_parameter", | ||
std::numeric_limits<double>::infinity() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
include <limits>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this 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); |
There was a problem hiding this comment.
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
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 ?
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
, ornan
will now correctly fail.Did you use Generative AI?
No.
Additional Information
Nothing that comes to mind.