Skip to content
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

Populate Range Constraints in Parameter Descriptors from Validation Functions #103

Merged

Conversation

chancecardona
Copy link
Contributor

This PR resolves Issue 96.

This uses the declare_parameter and declare_runtime_parameter templates to populate the parameter descriptor.
For this, some string checking on the validation function was added to see if it was appropriate to populate the Descriptor range constraints. In the jinja templates I simply check against the string name of the validation function and the number of arguments. This should work in all cases here, but strange things may happen if another validation function with a substring of "gt" or "lt" with 1 argument, or "bounds" with 2 args is either created in RSL or in a user defined validation function. For this purpose I figure this is acceptable.

This also may not allow setting of the descriptors dynamically (only in the declaration) but that can be a future work (unless it's a simple change) if it's a desired feature.

This should work for the RSL validation functions: bounds, element_bounds, lower_bounds, upper_bounds, gt_eq, lt_eq, gt, and lt validation functions by using std::numerical_limits library to populate the corresponding to_value or from_value that's not defined with either max() or lowest() for that parameter cpp type.

To assist in Unit Tests, a get_descriptors method was also added in the parameter_library_header template.
Finally, a Unit Test was created in the example directory and should run when colcon test is run.

Copy link
Contributor

@tylerjw tylerjw left a comment

Choose a reason for hiding this comment

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

One small comment, otherwise, this looks good. Thank you for this nice feature 🍾

@tylerjw tylerjw merged commit cea78d7 into PickNikRobotics:main Apr 12, 2023
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.

Specify range constraint in parameter descriptor when bounds<> validator is present
2 participants