Add TwistStamped support via TwistPublisher and TwistSubscriber#3775
Add TwistStamped support via TwistPublisher and TwistSubscriber#3775Ryanf55 wants to merge 35 commits intoros-navigation:mainfrom
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #3775 +/- ##
==========================================
+ Coverage 90.15% 90.31% +0.15%
==========================================
Files 415 417 +2
Lines 18593 18646 +53
==========================================
+ Hits 16763 16840 +77
+ Misses 1830 1806 -24 ☔ View full report in Codecov by Sentry. |
SteveMacenski
left a comment
There was a problem hiding this comment.
Generally LGTM other than missing test coverage + documentation updates on the new param / feature
|
I think just unit testing is the main blocker here |
What would you like to see as far as testing goes?
|
|
Add unit tests for this new object to make sure its working properly e.g.
^ the last 2 are obvious, but we don't know how its going to be modified over time. Also, its dereferencing pointers that will crash if the logic is ever wrong since the other publisher isn't allocated. So exercising the code in CI promises it won't crash applications later. Just basic tests with gtest like the other utils - nothing nuts. System testing with a full bringup is unnecessary since its being used in the controller server which then would be tested by the system tests suite |
Sounds good, can do! |
|
I've added much more comprehensive testing. Currently, CI is failing a test: I'm currently looking to see if my PR causes that failure. I also did a rebase since you had mentioned fixing some flaky tests recently and I branched before that. As far as all the other uses of Twist in NAV2, I;ve learned some nodes subscribe and republish Twist such as the velocity smoother. In order to have this backward-compatible support for TwistStamped in the entire stack, I expect I'll need to create a mirrored |
dc3eac7 to
5aa592c
Compare
|
I think this PR so that we have a clean migration over to it. Just merging this alone could break users that enable that param and don't have the ability to enable that new param with the velocity smoother and collision monitor. I looked over the codecov results and the code and this is good to me now, so consider the publisher approved! |
|
@Ryanf55, your PR has failed to build. Please check CI outputs and resolve issues. |
|
I was curious if you had any ideas on the TwistStamped subscribers how to deal with the callbacks needing to have a certain signature. For example: My thought is to add overrides for all node callbacks to also work with TwistStamped, and convert all internal variables to TwistStamped typed. Then, once the ecosystem (gazebo, etc) is moved over to TwistStamped, the pure Twist callbacks can be deprected on |
That sample is pretty easy: the twist subscriber has some Others may be more complex. You may want to enumerate them and we can discuss them individually so you don't waste time
I don't fully follow. Like have both a stamped and non-stamped callbacks, each registered, and the stamped just passes the |
33406e4 to
a2aee78
Compare
Goal: Only subscribe with either Twist or TwistStamped, not both to eliminate overhead. Based on your feedback, it's leading me to have the TwistSubscriber class constructor take in both signatures (Twist and TwistStamped) of the subscriber callback. It will bind whichever the node is configured for. The problem with that approach, assuming the callbacks are overrides is that the template arg deduction in bind fails. For now, I'll just name the callbacks differently (easy) or switch to lambdas (harder). |
|
This pull request is in conflict. Could you fix it @Ryanf55? |
772b95e to
bfaeb1e
Compare
|
Hi @SteveMacenski, I've gotten all the features working. I'd like to start iterating on getting to 100% code coverage, or at least no decrease in code coverage such that you will be happy merging. I know that CI runs a tool that shows you a diff of your PR against the target branch, colorizing with respect to changes in code coverage. Is there any way to use it locally so I can iterate faster than waiting for the build and test workflow in CI to run? |
|
Looks like the latest build has flake8 failures in CI are totally unrelated to my changes. I do not know what I should do to resolve those: |
fe1997a to
dd3ff24
Compare
SteveMacenski
left a comment
There was a problem hiding this comment.
Overall, LGTM. One thing I'd ask is to review the README files of changed packages + Nav2 documentation to update the use of Twist or TwistStamped. I know its annoying to do docs, but you should be able to get through skimming each of the pages and updating that within 15 minutes and would do a world to help users down the line if they didn't know about this to have hints in the docs easily
|
This pull request is in conflict. Could you fix it @Ryanf55? |
|
I fixed the merge conflict |
| nav2_util::LifecycleNode::SharedPtr node, | ||
| const std::string & topic, | ||
| const rclcpp::QoS & qos, | ||
| TwistCallbackT && TwistCallback, |
There was a problem hiding this comment.
You lost me a bit with the 2 callbacks. I suppose previous-me reviewing this didn't catch the reason why I thought having the getMsg() functions might be nice.
What do you do if there is a mismatch? Or what if there is no Stamped callback? It seems weird to force a user to define both when they only want to implement one or the other.
Thought 1: TwistStampedCallback has a default argument so that it doesn't need to be defined. Then we have a default twist stamped callback that just strips the stamp and calls the Twist callback so that a Twist user can subscribe to Twist/TwistStamped and get the same result.
Thought 2: Have a second constructor if TwistStamped is the only valid option, so that you don't have to define a bogus Twist callback that won't be used. Or, we could do a similar thing with default argument that results in a default callback for Twist that just throws an exception as unimplemented for that use-case.
The desire I have is not to have to define 2 callbacks, when I only need / want 1, and the other is bogus just to fit the API. There may be applications where both are acceptable, so having a constructor such as this makes sense -- but I think we should have the other options to specify one or the other alone (or even still the same constructor but default arguments so not required to implement)
There was a problem hiding this comment.
I've implemented the support for the Thought 2 with a second constructor.
Signed-off-by: Ryan Friedman <ryanfriedman5410+github@gmail.com>
|
Any update here? |
Yea: I got the TwistSubscriber alternative constructor (TwistStamped only) as we discussed working, and tested. Converting back to std::move everywhere has compilation errors about trying to call a deleted function. I spent a while chasing the ROS 2 design docs, older github issues regarding std::move and the API, but was not successful. I could use help on that. If you have time to work with me today, that would be excellent. Otherwise, I just need to move the markdown docs to |
There was a problem hiding this comment.
All of the open requests from the last review are also still relevant (but all small). I'll handle the re-pointer-ification once everything else is handled.
The least of it, but CI is complaining about a small number of linting issues. Usual bits on configuration guide for new parameter + migration guide for capability documentation
|
This pull request is in conflict. Could you fix it @Ryanf55? |
|
I handled the conflict |
Signed-off-by: Ryan Friedman <ryanfriedman5410+github@gmail.com>
Signed-off-by: Ryan Friedman <ryanfriedman5410+github@gmail.com>
Signed-off-by: Ryan Friedman <ryanfriedman5410+github@gmail.com>
Signed-off-by: Ryan Friedman <ryanfriedman5410+github@gmail.com>
* Implement behavior in the stamped callback * Unstamped callback calls the stamped callback * Switch to unique pointer for publisher Signed-off-by: Ryan Friedman <ryanfriedman5410+github@gmail.com>
* Use incoming twistStamped timestamp if available * Convert all internal representations to use TwistStamped Signed-off-by: Ryan Friedman <ryanfriedman5410+github@gmail.com>
6b11068 to
50cc292
Compare
Signed-off-by: Ryan Friedman <ryanfriedman5410+github@gmail.com>
Thanks. Almost ready. Just working on the docs now in Here's the resources on publishing unique_ptr I tried following. Sadly, none of them led me to a resolution with std::move. If you need to reproduce the failure: According to the ROS design docs, this should work: void publish(std::unique_ptr<geometry_msgs::msg::TwistStamped> velocity)However, I get this compilation error: |
Signed-off-by: Ryan Friedman <ryanfriedman5410+github@gmail.com>
Signed-off-by: Ryan Friedman <ryanfriedman5410+github@gmail.com>
|
@Ryanf55, your PR has failed to build. Please check CI outputs and resolve issues. |
* This makes it easier to switch to std::move instead of dereference on publish Signed-off-by: Ryan Friedman <ryanfriedman5410+github@gmail.com>
1ff04b8 to
03ec283
Compare
|
@Ryanf55 I will follow up in a few moments with a PR to supersede this one with some changes. Please review :-) |
|
Feel free to re-open this one. I just pushed a fix that @srmainwaring uncovered during testing and also cherry-pickd your changes in from #4031. |

Basic Info
Description of contribution in a few bullet points
TwistPublisherTwistSubscriberBut, I suppose we could make a velocity publisher wrapper in nav2_util that deals with that parameterization outside of the application code (and in a way we can remove the non-stamped support more gradually).Description of documentation updates required from your changes
Future work that may be required in bullet points
Test Instructions
Quick iteration
For Maintainers: