Skip to content

Check for negative time in rclcpp::Time(int64_t nanoseconds, ...) constructor#2510

Merged
ahcorde merged 5 commits intoros2:rollingfrom
sharminramli:check_for_negative_time_nanoseconds
Apr 23, 2024
Merged

Check for negative time in rclcpp::Time(int64_t nanoseconds, ...) constructor#2510
ahcorde merged 5 commits intoros2:rollingfrom
sharminramli:check_for_negative_time_nanoseconds

Conversation

@sharminramli
Copy link
Copy Markdown
Contributor

rclcpp::Time currently allows a negative time when constructing with int64_t nanoseconds (but not with int32_t seconds even though both can possibly hold a negative value). For a more uniform interface and based off of #525 where time cannot be negative:

  • Added the negative time check and throw from the rclcpp::Time(int32_t seconds, uint32_t nanoseconds, ...) constructor to the rclcpp::Time(int64_t nanoseconds, ...) constructor
  • Added a test to check that it throws with negative time
  • Removed the tests which allowed for negative time (the cases should already be covered by the other tests?)

Closes #2507.

Signed-off-by: Nursharmin Ramli <nursharminramli@gmail.com>
Signed-off-by: Nursharmin Ramli <nursharminramli@gmail.com>
Copy link
Copy Markdown
Collaborator

@fujitatomoya fujitatomoya left a comment

Choose a reason for hiding this comment

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

i think this is right thing to do.

@clalancette @wjwwood what do you think?

Signed-off-by: Nursharmin Ramli <nursharminramli@gmail.com>
Signed-off-by: Nursharmin Ramli <nursharminramli@gmail.com>
Signed-off-by: Nursharmin Ramli <nursharminramli@gmail.com>
Copy link
Copy Markdown
Contributor

@clalancette clalancette left a comment

Choose a reason for hiding this comment

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

This looks reasonable to me with green CI.

Let's put this on the queue to merge once Rolling is unfrozen.

@ahcorde
Copy link
Copy Markdown
Contributor

ahcorde commented Apr 23, 2024

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

@ahcorde
Copy link
Copy Markdown
Contributor

ahcorde commented Apr 23, 2024

@clalancette can we backport this to jazzy ? or we should wait the frozen period?

@clalancette
Copy link
Copy Markdown
Contributor

@clalancette can we backport this to jazzy ? or we should wait the frozen period?

We are open for backports now. My only question is whether we should actually backport it to Jazzy or not. We are not allowing new features into Jazzy, but we are allowing bugfixes. The other thing we want to avoid at this point is too much breakage to downstream packages.

What do you think @ahcorde ? Do you consider this a bugfix or a feature, and what do you think the downstream impact is going to be?

@fujitatomoya
Copy link
Copy Markdown
Collaborator

@clalancette @ahcorde IMO, this could possibly break the user application. so i would not backport this to released distros...

@ahcorde ahcorde merged commit de666d2 into ros2:rolling Apr 23, 2024
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.

rclcpp::Time(int64_t nanoseconds, ...) should check for negative time

5 participants