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

Add TIME_MAX and DURATION_MAX functions #538

Merged
merged 10 commits into from
Aug 27, 2018
Merged

Add TIME_MAX and DURATION_MAX functions #538

merged 10 commits into from
Aug 27, 2018

Conversation

sagniknitr
Copy link
Contributor

Related to issue #524 .

-> I am not sure about the tests which I added to validate the functions.Would require some help in them.
-> I have done the linting checks locally in my workstation.

@tfoote tfoote added the in review Waiting for review (Kanban column) label Aug 20, 2018
@dirk-thomas
Copy link
Member

The PR currently has merge conflicts. After resolving them please also run the tests of the package and address any linter warnings.

Duration
Duration::DURATION_MAX()
{
Duration duration_max(std::numeric_limits<int32_t>::max(), 999999999);
Copy link
Contributor

Choose a reason for hiding this comment

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

@tfoote This PR and #524 say a duration is limited by the max value that can be given to the constructor accepting seconds and nanoseconds, but there is another constructor taking nanoseconds directly, and that seems to accept a number of nanoseconds as large as the 64bit rcutils type. Should this instead be std::numeric_limits<rcl_duration_value_t>::max()? Alternatively, should the nanoseconds constructor restrict the maximum size to int32_t seconds + 999999999 nanoseconds?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that the nanoseconds constructor should limit it to this representation. Otherwise we'll overflow the message datastructure.

tfoote
tfoote previously requested changes Aug 22, 2018
Copy link
Contributor

@tfoote tfoote 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 request for simplification.

Time
TIME_MAX()
{
Time time_max(std::numeric_limits<int32_t>::max(), 999999999);
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems like it would be easier to read as a one line function. No need to name the temporary variable, it could just be returned.

Duration
Duration::DURATION_MAX()
{
Duration duration_max(std::numeric_limits<int32_t>::max(), 999999999);
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems like it would be easier to read as a one line function. No need to name the temporary variable, it could just be returned.

@@ -89,6 +89,10 @@ class Duration
Duration
operator-(const rclcpp::Duration & rhs) const;

RCLCPP_PUBLIC
static Duration
DURATION_MAX();
Copy link
Member

Choose a reason for hiding this comment

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

Please rename the method to use lowercase (as per code style). Also since it is defined in the class Duration I don't think it needs to be part of the name. So I would suggest just calling it max() which will be used as Duration::max().

Same for time below.

@dirk-thomas
Copy link
Member

Thank you for the patch and for iterating on it.

@dirk-thomas dirk-thomas merged commit 18ad26e into ros2:master Aug 27, 2018
@dirk-thomas dirk-thomas removed the in review Waiting for review (Kanban column) label Aug 27, 2018
nnmm pushed a commit to ApexAI/rclcpp that referenced this pull request Jul 9, 2022
I've exposed the existing function as public API and added documentation and unit tests.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
DensoADAS pushed a commit to DensoADAS/rclcpp that referenced this pull request Aug 5, 2022
…nfo (ros2#538)

Signed-off-by: Ivan Santiago Paunovic <ivanpauno@ekumenlabs.com>
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.

None yet

4 participants