Populate Range Constraints in Parameter Descriptors from Validation Functions #103
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR resolves Issue 96.
This uses the
declare_parameter
anddeclare_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
, andlt
validation functions by using std::numerical_limits library to populate the correspondingto_value
orfrom_value
that's not defined with eithermax()
orlowest()
for that parameter cpp type.To assist in Unit Tests, a
get_descriptors
method was also added in theparameter_library_header
template.Finally, a Unit Test was created in the
example
directory and should run whencolcon test
is run.