Skip to content
This repository has been archived by the owner on Jun 10, 2021. It is now read-only.

Added publish period attribute as a parameter #71

Closed

Conversation

ahcorde
Copy link
Contributor

@ahcorde ahcorde commented Jan 15, 2020

By default the publish rate is hardcoded to 1 minute

This PR allows to change this value using ROS 2 parameters

@thomas-moulard
Copy link
Member

Thank you for the pull request! Would you need this parameter to not be read-only?

For something like a publishing period, maybe it would be preferable to declare the parameter as read-only (see https://github.com/ros2/rcl_interfaces/blob/master/rcl_interfaces/msg/ParameterDescriptor.msg and declare_parameter signature). This would alleviate the possibility of bug when the parameter value is changed dynamically.

@ahcorde
Copy link
Contributor Author

ahcorde commented Jan 15, 2020

Sure,

where I should document the meaning and units of this parameter?

Copy link

@zmichaels11 zmichaels11 left a comment

Choose a reason for hiding this comment

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

The parameter along with its default value should be documented within the README.
Otherwise this LGTM. Thanks for your contribution!

descriptor.read_only = true;
declare_parameter("publish_period", publish_period_.count(), descriptor);
if (get_parameter("publish_period", publish_period_param)) {
publish_period_ = std::chrono::milliseconds(publish_period_param);

Choose a reason for hiding this comment

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

Suggested change
publish_period_ = std::chrono::milliseconds(publish_period_param);
publish_period_ = std::chrono::milliseconds{publish_period_param};

int publish_period_param = 0;
rcl_interfaces::msg::ParameterDescriptor descriptor;
descriptor.read_only = true;
declare_parameter("publish_period", publish_period_.count(), descriptor);
Copy link

Choose a reason for hiding this comment

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

Nit: It might be useful to extract "publish_period" into a constant

@mm318
Copy link
Member

mm318 commented Jan 15, 2020

We're working on making all the node constructors use rclcpp::NodeOptions, which will most likely supersede all the changes in this pull request.

@dabonnie
Copy link
Contributor

We're working on making all the node constructors use rclcpp::NodeOptions, which will most likely supersede all the changes in this pull request.

Not sure if you're planning on it, but it would be great to have those changes in a separate PR :-)

@thomas-moulard
Copy link
Member

thomas-moulard commented Jan 15, 2020

@ahcorde I think it would be good to document the parameter in the ParameterDescriptor directly.
https://github.com/ros2/rcl_interfaces/blob/master/rcl_interfaces/msg/ParameterDescriptor.msg

See the field description. i would also set the range if it supports half-open intervals (not sure)

@ahcorde
Copy link
Contributor Author

ahcorde commented Jan 16, 2020

closing this PR, this other PR #73 is more complete

@ahcorde ahcorde closed this Jan 16, 2020
@ahcorde ahcorde deleted the ahcorde/param_publish_rate branch January 16, 2020 07:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants