Skip to content

(WIP) Jump in time implementation for PlayerClock class#718

Closed
MichaelOrlov wants to merge 3 commits intoros2:emersonknapp/player-clock-pause-resumefrom
MichaelOrlov:michaelorlov/player_clock-jump-impl
Closed

(WIP) Jump in time implementation for PlayerClock class#718
MichaelOrlov wants to merge 3 commits intoros2:emersonknapp/player-clock-pause-resumefrom
MichaelOrlov:michaelorlov/player_clock-jump-impl

Conversation

@MichaelOrlov
Copy link
Copy Markdown
Contributor

Part of #696
Depends on #704

This is initial implementation for jump functionality in PlayerClock.

  • Added jump(ROSTimePoint time_point) with calling registered callbacks before and after jump
  • Added PlayerClock::JumpHandler::SharedPtr create_jump_handler( const JumpHandler::pre_callback_t & pre_callback, const JumpHandler::post_callback_t & post_callback, const rcl_jump_threshold_t & threshold)
  • Added void add_jump_calbacks(PlayerClock::JumpHandler::SharedPtr handler)
  • Added void remove_jump_callbacks(PlayerClock::JumpHandler::SharedPtr handler)

@MichaelOrlov MichaelOrlov force-pushed the michaelorlov/player_clock-jump-impl branch from a9258a4 to d78d9b4 Compare April 6, 2021 23:36
@MichaelOrlov
Copy link
Copy Markdown
Contributor Author

@emersonknapp I've made initial implementation for the jump functionality with registering callbacks.
However I haven't added any unit tests for it yet.
Could you please take a look on my implementation and comment if you have any concerns or suggestions?

@emersonknapp emersonknapp force-pushed the emersonknapp/player-clock-pause-resume branch from e921b13 to 77161c8 Compare April 6, 2021 23:43
@emersonknapp
Copy link
Copy Markdown
Collaborator

Overall the approach to jump handlers looks fine - is it mostly copied from rclcpp::Clock?

One thing I have realized, is that:
jump should trigger the callbacks for arbitrary time jumps, and bust the queue in the Player. This probably needs new functionality in the Reader API to seek as well. However, "play_next while paused" shouldn't actually need all of that.

I know that "play_next" feature was a priority of yours, let me know if you have a less heavy approach you want to implement first - maybe jump(callbacks=false), so that we don't have to incur all that overhead for just fast-forwarding to the next message timestamp.

@MichaelOrlov
Copy link
Copy Markdown
Contributor Author

@emersonknapp I wouldn't say that it's mostly copied from rclcpp, but rather have similar approach and design.
I've looked on the implementation of such callbacks mechanism in rclcpp and it turns out it's over complicated. It's diving deep on rcl layer and most of the code written on "C". I adopted some data types from rclcpp and made my own lightweight implementation which should better satisfy our needs and to be more clear for understanding.

WRT to the new reader API for arbitrary seek. Yes it would be nice to have such extension. Although I thought about that it would make sense to implement this feature for sequential reader first. Not sure yet how we will advance in time. May be just reading out messages and skipping them until we will found required timestamp. It could be just straight forward temporary workaround without adding new API to the reader.

And I agree that it make sense to implement this feature with multiple iterations and PRs by adding some essential functionality to unblock development for another features as "Play next in pause".

I think that current API and implementation should cover dependencies for "Play next in pause" feature.

@emersonknapp
Copy link
Copy Markdown
Collaborator

Not sure yet how we will advance in time. May be just reading out messages and skipping them until we will found required timestamp. It could be just straight forward temporary workaround without adding new API to the reader.

Yes, I think this would be a good first implementation. For "go backward in time" - maybe "reopen the bag at the beginning and read messages until the required timestamp". I have a feeling that this will run into performance problems quickly - but at least it would get the feature in front of people to complain about the performance :)

I think that current API and implementation should cover dependencies for "Play next in pause" feature.

OK! I just wanted to make sure you didn't feel like this feature was blocking you from getting to the one you really wanted to do.

@emersonknapp emersonknapp force-pushed the emersonknapp/player-clock-pause-resume branch 4 times, most recently from 01901fe to 20c2131 Compare April 8, 2021 00:54
Expose it on Player class as well

Signed-off-by: Emerson Knapp <eknapp@amazon.com>
@emersonknapp emersonknapp force-pushed the emersonknapp/player-clock-pause-resume branch from 20c2131 to df78227 Compare April 8, 2021 21:41
@MichaelOrlov MichaelOrlov force-pushed the michaelorlov/player_clock-jump-impl branch 2 times, most recently from 3b9c405 to ce4af48 Compare April 9, 2021 07:41
Signed-off-by: Michael Orlov <morlovmr@gmail.com>
@MichaelOrlov MichaelOrlov force-pushed the michaelorlov/player_clock-jump-impl branch from ce4af48 to 346f63c Compare April 9, 2021 07:48
…_const_playback_rate_no_callbacks unit tests

Signed-off-by: Michael Orlov <morlovmr@gmail.com>
@emersonknapp emersonknapp force-pushed the emersonknapp/player-clock-pause-resume branch 2 times, most recently from 3a52671 to 98079dc Compare April 9, 2021 19:49
@delete-merged-branch delete-merged-branch bot deleted the branch ros2:emersonknapp/player-clock-pause-resume April 12, 2021 18:39
@MichaelOrlov
Copy link
Copy Markdown
Contributor Author

Closing this PR as wouldn't merge since we've split implementation on #754 and #775

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.

2 participants