-
Notifications
You must be signed in to change notification settings - Fork 542
Read only parameters #495
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
Read only parameters #495
Changes from 18 commits
73553ec
88a74ff
bc8457d
a6fc8de
7e19756
2597f46
347449d
304ba62
6e5aae9
38c7670
c11654e
b3325aa
189c02e
85b0377
598325d
6b14049
46c207f
8e28200
5273ad9
06ddfc4
04f812c
206ffe3
89018de
9e03b08
ac1b6a6
73b4c28
78a94d9
bf1d149
00da0a6
570c7c2
3ef385d
01362ff
c48db2d
4673ce9
ce9af32
fb78acd
b7e4c0d
efb3f85
4ba4eeb
cb72e58
7e79bba
933ac09
444de25
df7b036
ea3285f
68a4afe
d9ad096
e29cdf1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -258,6 +258,36 @@ class Node : public std::enable_shared_from_this<Node> | |
| const rmw_qos_profile_t & qos_profile = rmw_qos_profile_services_default, | ||
| rclcpp::callback_group::CallbackGroup::SharedPtr group = nullptr); | ||
|
|
||
| /// Declare and initialize a parameter. | ||
| /** | ||
| * This method is used to declare that a parameter exists on this node. | ||
| * If a run-time user has provided an an initial value then it will be set in this method, | ||
| * otherwise the default_value will be set. | ||
| * \param[in] name the name of the parameter | ||
| * \param[in] default_value An initial value to be used if a run-time user did not override it. | ||
| * \param[in] read_only if True then this parameter may not be changed after initialization. | ||
| * \throws std::runtime_error if parameter has already been declared. | ||
| * \throws std::runtime_error if a parameter name is invalid. | ||
| * \throws rclcpp::exceptions::InvalidParameterValueException if initial value fails to be set. | ||
| */ | ||
| RCLCPP_PUBLIC | ||
| void | ||
| declare_parameter( | ||
| const std::string & name, | ||
| const rclcpp::ParameterValue & default_value = rclcpp::ParameterValue(), | ||
| bool read_only = false); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm wondering if we want to make this more generic than just a boolean for read_only. For instance, how would we declare a parameter that is read-only, must be in range 0.0 - 1.0, and that the type must be a double? I'm not suggesting that we need to implement all of that in this PR, but I'd like to understand how the API could allow for things like that.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It will need to either evolve to include more arguments or a structure that defines the meta data for the parameter. I don't know which is better right now, so that's why I didn't change it, and presumably why @sloretz started it this way.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm mostly worried about having to change the API later to add those additional features; if we don't do it now, then it will be an API break later and will be harder to do. Personally, it sounds like there are enough additional features we'd want to add that it would warrant adding a structure here. Thoughts?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought about this at the time, and I couldn't come up with how constraints might work (like must be in this range, or one of these choices, etc.) which put me off from deciding they should all live in a single struct, but I guess no matter what we come up with we can fit it in an options struct or "description"/"descriptor" struct, since that's the matching IDL equivalent ( |
||
|
|
||
| /// Declare and initialize a parameter with a type. | ||
| /** | ||
| * See the non-templated declare_parameter() on this class for details. | ||
| */ | ||
| template<typename ParameterT> | ||
| void | ||
| declare_parameter( | ||
| const std::string & name, | ||
| const ParameterT & default_value, | ||
| bool read_only = false); | ||
|
|
||
| RCLCPP_PUBLIC | ||
| std::vector<rcl_interfaces::msg::SetParametersResult> | ||
| set_parameters(const std::vector<rclcpp::Parameter> & parameters); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.