fp
Functional Programming extensions to C++ for ROS projects.
|
The fp
library contains some functions to validate values. These validation functions are useful for tasks such as validating ROS parameters.
fp::validate_in
can be used to validate a value is within a set of values.
This this example will generate this result:
fp::validate_range
is a struct that can be used to validate numbers are within a range defined by these struct member variables.
Variable | Default | Description |
---|---|---|
from | -inf | The minimum |
to | +inf | The maximum |
step | nothing | The step |
step_threshold | 1e-3 | The threshold to use when evaluating if value is at step |
An example of using this if you have c++20 to test if a value is in the [-2,inf,3].
If you instead only have C++17 you can use it like this:
You can combine these functions with the fp::maybe_error
function to validate a set of values. This is useful when validating a struct of ROS parameters.
In this tutorial you learned about the functions in fp
for validating values and how to combine them into a function that validates a set of values.