-
Notifications
You must be signed in to change notification settings - Fork 262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PlayerClock initial implementation - Player functionally unchanged #689
Conversation
ef47e0e
to
06398ad
Compare
06398ad
to
3049f1a
Compare
Fixes #99 Design: #675 Depends on #689 Depends on #693 to expose to the CLI Add a `rosgraph_msgs/Clock` publisher to the `Player` - that uses `PlayerClock::now()` to publish current time. Signed-off-by: Emerson Knapp <[email protected]>
6fe7642
to
c5a0c06
Compare
Cross-platform sanity check Gist: https://gist.githubusercontent.com/emersonknapp/56fa49315468fd07d734740da7975b4a/raw/b85678a7e3040cb2fef7dbccb3e6133c1431ee56/ros2.repos Note: |
261fd11
to
f06836e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the documentation, diagrams, and test cases!
Fixes #99 Design: #675 Depends on #689 Depends on #693 to expose to the CLI Add a `rosgraph_msgs/Clock` publisher to the `Player` - that uses `PlayerClock::now()` to publish current time. Signed-off-by: Emerson Knapp <[email protected]>
f06836e
to
bc24c53
Compare
Gist: https://gist.githubusercontent.com/emersonknapp/6fb38f4384ee9db70d518f601711591a/raw/e3aa6275de0ca40c21d1a6860083e814c486933c/ros2.repos |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API looks good. my main question is how scenerio 3 from the design would be set up using this class.
da412e2
to
5e1012c
Compare
Create new PlayerClock class with `now()`, `sleep_until()`, and rate handling, with tests. Removes time handling from `Player` in favor of using this new class. Signed-off-by: Emerson Knapp <[email protected]>
Signed-off-by: Emerson Knapp <[email protected]>
Signed-off-by: Emerson Knapp <[email protected]>
…lper functions to match design Signed-off-by: Emerson Knapp <[email protected]>
…nts to clock setup and move some logic out into helper function Signed-off-by: Emerson Knapp <[email protected]>
…implement - makes it obvious how SimTimeClock will be implemented Signed-off-by: Emerson Knapp <[email protected]>
Signed-off-by: Emerson Knapp <[email protected]>
5e1012c
to
20f37f3
Compare
Signed-off-by: Emerson Knapp <[email protected]>
05e2252
to
3173b87
Compare
…nings Signed-off-by: Emerson Knapp <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally lgtm, but I am finding the typedefs a bit wild. I'd actually stick to their original types if we don't plan on evolving them further into their own structs.
rosbag2_storage/include/rosbag2_storage/serialized_bag_message.hpp
Outdated
Show resolved
Hide resolved
550d432
to
08e530d
Compare
* Remove time point typedefs in favor of using the types directly. * Use condition_variable for waiting * Minor formatting updates Signed-off-by: Emerson Knapp <[email protected]>
08e530d
to
daadf5b
Compare
@Karsten1987 thanks for the feedback - I think it put a nice finishing touch on this diff. Now, fingers crossed for a green result :) |
Signed-off-by: Emerson Knapp <[email protected]>
Fixed float->double conversion warning ^ Green - cmake warning is eclipse-cyclonedds/cyclonedds#741 |
return reference.steady + std::chrono::nanoseconds(diff_nanos); | ||
} | ||
|
||
std::mutex mutex; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is bad practice to use names reserved in C++. It would be more safe if rename variable mutex
.
Maybe ref_rate_mutex
or time_control_mutex
?
|
||
std::mutex mutex; | ||
std::condition_variable cv; | ||
PlayerClock::NowFunction now_fn RCPPUTILS_TSA_GUARDED_BY(mutex); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I am understand correctly we are going to assign now_fn
only in constructor. In this case strict requirement to lock mutex
is extra and not required.
return std::chrono::duration_cast<std::chrono::nanoseconds>(duration).count(); | ||
} | ||
|
||
rcutils_time_point_value_t steady_to_ros(std::chrono::steady_clock::time_point steady_time) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@emersonknapp It would be nice to add REQUIRES(mutex)
attribute to steady_to_ros
function.
https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#getting-started
However I am not sure if it possible to do with rclcpp
abstraction layer.
} | ||
|
||
std::chrono::steady_clock::time_point ros_to_steady(rcutils_time_point_value_t ros_time) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar. It would be nice to add REQUIRES(mutex)
attribute to ros_to_steady
function.
…os2#689) * Initial PlayerClock integration - functionality unchanged * Create PlayerClock, a pure virtual interface with `now()`, and `sleep_until()` for Player to use to control timing of message playback * TimeControllerClock implementation of PlayerClock * Removes time handling from `Player` in favor of using this new class Signed-off-by: Emerson Knapp <[email protected]>
…os2#689) * Initial PlayerClock integration - functionality unchanged * Create PlayerClock, a pure virtual interface with `now()`, and `sleep_until()` for Player to use to control timing of message playback * TimeControllerClock implementation of PlayerClock * Removes time handling from `Player` in favor of using this new class Signed-off-by: Emerson Knapp <[email protected]>
* Design for rosbag2 handling of clock/simtime (ros2#675) * Add a design dock for rosbag2 handling of clock/simtime Signed-off-by: Emerson Knapp <[email protected]> * PlayerClock initial implementation - Player functionally unchanged (ros2#689) * Initial PlayerClock integration - functionality unchanged * Create PlayerClock, a pure virtual interface with `now()`, and `sleep_until()` for Player to use to control timing of message playback * TimeControllerClock implementation of PlayerClock * Removes time handling from `Player` in favor of using this new class Signed-off-by: Emerson Knapp <[email protected]> * /clock publisher in Player (ros2#695) * Add /clock publishing to Player Signed-off-by: Emerson Knapp <[email protected]> * fix for foxy abi Signed-off-by: mitsudome-r <[email protected]> * fix bug Signed-off-by: mitsudome-r <[email protected]> Co-authored-by: Emerson Knapp <[email protected]>
Related Issues
Description
PlayerClock
withnow()
andsleep_until()
with simple rate handling.Player
in favor of configuring and usingPlayerClock