Skip to content

Enforcing parameter ranges.#357

Merged
jubeira merged 3 commits intomasterfrom
jubeira/parameter_ranges
May 28, 2019
Merged

Enforcing parameter ranges.#357
jubeira merged 3 commits intomasterfrom
jubeira/parameter_ranges

Conversation

@jubeira
Copy link
Copy Markdown

@jubeira jubeira commented May 23, 2019

Closes #350.

See ros2/rclcpp#728 for details and related discussion.

Signed-off-by: Juan Ignacio Ubeira <jubeira@ekumenlabs.com>
@jubeira jubeira requested a review from wjwwood May 23, 2019 16:56
@jubeira jubeira self-assigned this May 23, 2019
@dirk-thomas dirk-thomas added the in review Waiting for review (Kanban column) label May 23, 2019
@jubeira
Copy link
Copy Markdown
Author

jubeira commented May 24, 2019

Partial CI:

  • Linux: Build Status.

Running remaining jobs now.

@jubeira
Copy link
Copy Markdown
Author

jubeira commented May 24, 2019

Full CI:

  • Linux: Build Status
  • Linux-aarch64: Build Status
  • Mac OS: Build Status
  • Windows: Build Status

Copy link
Copy Markdown
Member

@ivanpauno ivanpauno left a comment

Choose a reason for hiding this comment

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

LGTM! I let some minor comments.

('from_value', 0.0, ParameterDescriptor(floating_point_range=[fp_range])),
('to_value', 10.0, ParameterDescriptor(floating_point_range=[fp_range])),
('in_range', 4.5, ParameterDescriptor(floating_point_range=[fp_range])),
('str_value', 'I am no integer', ParameterDescriptor(floating_point_range=[fp_range])),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am not integer -> I am not float

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks; addressed in 7381f62.

Signed-off-by: Juan Ignacio Ubeira <jubeira@ekumenlabs.com>
@jacobperron jacobperron self-requested a review May 28, 2019 17:23
@jubeira
Copy link
Copy Markdown
Author

jubeira commented May 28, 2019

CI after comments:

  • Linux: Build Status
  • Linux-aarch64: Build Status
  • Mac OS: Build Status
  • Windows: Build Status

Copy link
Copy Markdown
Member

@jacobperron jacobperron left a comment

Choose a reason for hiding this comment

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

A couple nitpicks, otherwise LGTM.

In the future, it might be nice to define an interface for constraint checking, so the node doesn't have to contain the logic for all possible constraints. Since we only have two types of constraints for now, I think it's fine to leave it as-is.

self.assertEqual(self.node.get_parameter('in_range').value, 4.5)

# Change in_range parameter to int; ranges will not apply.
result = self.node.set_parameters([Parameter('in_range', value=12)])
Copy link
Copy Markdown
Member

@jacobperron jacobperron May 28, 2019

Choose a reason for hiding this comment

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

That's subtle. I hope users don't forget (or accidentally add) a decimal point in their code, otherwise they may experience unexpected behavior. I guess this is a case for type constraints.

This is just an observation; nothing to be done.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Indeed.
Note that in this case I'm making the Parameter guess the type; using the old API where the type had to be explicitly given to the parameter you wouldn't have this problem.

In any case, I also think the solution is eventually enforcing the types (now for Dashing, or later for a patch release).

…with Windows.

Signed-off-by: Juan Ignacio Ubeira <jubeira@ekumenlabs.com>
@jubeira
Copy link
Copy Markdown
Author

jubeira commented May 28, 2019

Thanks for the thoughtful comments @jacobperron!
They should be addressed now; I'll run CI once more.

Copy link
Copy Markdown
Member

@jacobperron jacobperron left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@jubeira
Copy link
Copy Markdown
Author

jubeira commented May 28, 2019

CI:

  • Linux: Build Status
  • Linux-aarch64: Build Status
  • Mac OS: Build Status
  • Windows: Build Status

@jubeira
Copy link
Copy Markdown
Author

jubeira commented May 28, 2019

Failure on Windows seems to be unrelated; merging now!

@jubeira jubeira merged commit 2cc3e33 into master May 28, 2019
@delete-merged-branch delete-merged-branch bot deleted the jubeira/parameter_ranges branch May 28, 2019 22:56
@nuclearsandwich
Copy link
Copy Markdown
Member

The Windows CI failure has appeared before and is in test_rclcpp. When Build Status runs it should tell is whether we made the right call.

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

Labels

in review Waiting for review (Kanban column)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Range support for parameters

5 participants