rclcpp
rclcpp copied to clipboard
Check for negative time in rclcpp::Time(int64_t nanoseconds, ...) constructor
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 https://github.com/ros2/rclcpp/issues/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 therclcpp::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 https://github.com/ros2/rclcpp/issues/2507.