ros2 bag play - start/pause play next interaction#680
ros2 bag play - start/pause play next interaction#680MichaelOrlov wants to merge 14 commits intoros2:masterfrom
Conversation
Signed-off-by: Michael Orlov <michael.orlov@apex.ai>
Signed-off-by: Michael Orlov <michael.orlov@apex.ai>
…f playback. Without delay publishers could be destroyed before they will sent last message on wire. Signed-off-by: Michael Orlov <michael.orlov@apex.ai>
Signed-off-by: Michael Orlov <michael.orlov@apex.ai>
Signed-off-by: Michael Orlov <michael.orlov@apex.ai>
Signed-off-by: Michael Orlov <michael.orlov@apex.ai>
Signed-off-by: Michael Orlov <michael.orlov@apex.ai>
Signed-off-by: Michael Orlov <michael.orlov@apex.ai>
Signed-off-by: Michael Orlov <michael.orlov@apex.ai>
Signed-off-by: Michael Orlov <michael.orlov@apex.ai>
Signed-off-by: Michael Orlov <michael.orlov@apex.ai>
Signed-off-by: Michael Orlov <michael.orlov@apex.ai>
…lay next Bloc Signed-off-by: Michael Orlov <michael.orlov@apex.ai>
773eb49 to
4465b39
Compare
…ming to play. Signed-off-by: Michael Orlov <michael.orlov@apex.ai>
f467933 to
dd24609
Compare
|
thanks @MichaelOrlov for the PR. While I appreciate to have such a feature-rich PR, I believe we should break these down in individual PRs. It's great that you've found a bug for the publisher clean up, I believe this should be contributed anyhow independent from the pause/resume feature. We've discussed on #443 (comment) that at least the keyboard handling shall be dealt with external to the player. Ideally, in the ros2bag python package to ease the cross-platform keyboard handling. Can you elaborate why the player API has to be public? You mentioned you wanted to use this in other applications. What are these applications? |
|
Hi @Karsten1987. As regards to the small bugfix/workaround with delay at the end of playback. It's literally one line of code and one line of comment to it with explanation why. I can do a separate PR for it if you want. Please let me know. As regards to the proposal to moving keyboard handling outside of the player in python script. In theory it looks reasonable and easy way. On practice we have extra layer Rosbag2Transport::play() which we are calling from python script. Keyboard handling imply interaction with 2 threads running in parallel doing this from python will require to use Player class directly without As regards to the idea of featuring a rclcpp_lifecycle Node, which implicitly provides services and further command line tools integration for handling a start/stop functionality.
After resuming, unplayed messages shall start playing with 2x speed i.e. 50 mSec interval and time spend in pause should be taken in to account to avoid playing messages without required interval. The complication arise that you can't just simply sleep for 50 mSec in playback routine. Because it will cause accumulation of errors in time delay. Need to respect start time and time at what time particular message was recorded relative to the start of the recording and time spend in pause and also different playback speed. As regards to your question:
We are at Apex.AI considering to use it in Rosbag Coordinator application to be able deterministically replay complicated scenarios with high bandwidth from multiple nodes and perhaps in future port of rosbag rqt. |
You've listed 5 independent changes in your PR description - this sounds like 5 PRs. EDIT: actually, based on point 1 - which says "play/pause, change playback ratio, and play next" - this itself could even be 3 PRs introducing the features one at a time. I'd also like to find out how this approach works with the proposal in #675 . It is an important feature set, I think we need to have a consensus on the design before just merging new code
One single line of code may look small, but it needs independent verification, and one wrong line is all it takes to make a program work incorrectly. If it is in a separate PR/commit - there is a chain of review and |
|
Hi @emersonknapp and @Karsten1987 as per initial issue (feature request) initiated by you ros2 bag play - start/pause interaction #55
You listed "play/pause, play next, and keyboard handling" in this feature and we already have had interface for change playback ratio on start. I only implemented runtime API for it to be able to changed it from keyboard. I've implemented everything what you have been asking for in this feature. Perhaps I will be able to split keyboard handling and bugfix with delay to the separate PRs. As a consequences they will have dependencies in the order of merging them. When I was developing/upstreaming this feature I came across to the situation that I can't proceed without those bugfix and I have to add it on the early stage. Then I found out that I can't proceed without refactoring testing code. Otherwise it would be even more spaghetti-sh. I made it and it became backed in changes with dependencies in this PR. As regards to the
Long story short: Ok. A little bit longer story and details about #675.
We mostly concern about item 3. " Though we are going to change how time flowing on low level. My implementation will live above it and will not know that something got changed. If someone will change slow down time flow twice. My playback rate will be relative to it. All logic will be valid and will be working as nothing got changed. Even pause-resume will be working the same way. And here are the reasons for this:
And proposal:
Is till a valid good to go plan with addition that it will need to use To summarize: One more factor to consider is that my approach is ready to be used now. Approach from #675 is only planing to be implemented and have some dependencies and have high uncertainty when it will be ready (may be year(s) after). @emersonknapp and @Karsten1987 Giving that details above I would like to ask you to take a look on my changes and give concrete proposals what need to change and how to split them on different PRs. Hope on understanding. |
No. #675 considers that as just one of the cases being handled, but it's not the primary concern of the design. That design is concerned with gracefully handling all three cases. But it is largely focused on the "rosbag2 controls time" scenario of cases 1 and 2 - determining how "pause and resume time", "change rate of playback", and "seek to a specific time" work. In case 3, I am proposing that the user cannot do time control on the rosbag2 playback. The ROS Time Source is external, so the playback is completely driven by the ROS Time Source. There may be other features that can happen in this case, such as "mute playback" - where messages are not published until rosbag2 is "un-muted", but this is not the same feature as "pause/resume".
Based on what I have said above, I don't see this to be the case. I think you're right that implementing this functionality in the Perhaps I am missing some use cases as to why these features would need to exist side by side, please let me know if that's the case (and that is useful input to a design document). The only thing I see from these features living side by side is this: "Gazebo controls time, but rosbag2 wants to play back in sync, but at a different rate. For example, Gazebo is simulating at 2x speed, and we want rosbag2 to play back at double the simulation speed (effectively 4x, but looks like 2x) - pausing and resuming when the simulation does so." And even on considering the above, the |
|
Hi @emersonknapp Thank you for expressing your opinion and decision in timely manner. |
|
Closing this PR as wouldn't merge, since the same functionality will be implemented in the scope of the time control feature #696 |
Key press handling implemented for POSIX compatible OS like Linux.
play/pause = "
space bar", increase playback speed = "cursor up", decrease playback speed = "cursor down", play next message = "cursor forward".Special consideration and pay attention was made to keep original performance and deterministic playback in runtime i.e. avoiding locking mutexes and busy loops in runtime phase of the playback. Also keeping original concept for avoiding accumulation of errors in playback time.