`operator+` and `operator-` for `builtin_interfaces::msg::Time` and `rclcpp::Duration`
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 805
- Forks
- 564
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 27
Description
Feature request
I wonder if rclcpp could support add/minus time with msg::Time on the left as caller.
In the current delivery,
std_msgs::msg::Header header;
header.stamp = rclcpp::Duration::from_seconds(1) + header.stamp; // OK, unintuitive
header.stamp = rclcpp::Time(header.stamp) + rclcpp::Duration::from_seconds(1); // OK, with conversion and implicit conversion
header.stamp = header.stamp + rclcpp::Duration::from_seconds(1); // CE
header.stamp += rclcpp::Duration::from_seconds(1); // CE
It is more intuitive for the user to choose the third (furthermore, fourth) option instead of the first two.
I think the operators +, -, +=, -= can be implemented in duration.hpp and duration.cpp without any backward incompatiblity.
Furthermore, aside from rclcpp::Time containing a clock, rclcpp::Duration only contains nanoseconds which makes this task simpler.
Also in a higher level view, "a time" can always add "a duration" and conclude another "time."
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading rclcpp/include/rclcpp/duration.hpp and rclcpp/src/rclcpp/duration.cpp, especially the existing time and duration operator overloads. Confirm how builtin_interfaces::msg::Time is represented and determine the declarations and definitions needed for +, -, +=, and -=. Done means the examples using a message timestamp on the left compile and have the expected time arithmetic behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- robotics
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100