Skip to content
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

mcap ros1 message play back in rust #6

Closed
lucasw opened this issue Aug 24, 2024 · 8 comments
Closed

mcap ros1 message play back in rust #6

lucasw opened this issue Aug 24, 2024 · 8 comments

Comments

@lucasw
Copy link
Owner

lucasw commented Aug 24, 2024

Duplicate rosbag play features, eventually --clock.

The md5sum is needed, but mcaps don't store it, this python can get it from the message definition so need a rust version:
https://github.com/lucasw/mcap_tools/blob/main/mcap_tools/scripts/msg_def_md5.py

lucasw/ros_one2z#4

A python implementation of mcap playback: https://github.com/lucasw/ros_one2z/blob/main/one2z/scripts/ros1_play_mcap.py

RosLibRust/roslibrust#194

@lucasw lucasw changed the title mcap ros1 message play back mcap ros1 message play back in rust Aug 24, 2024
@lucasw
Copy link
Owner Author

lucasw commented Aug 30, 2024

ROS_PACKAGE_PATH=`rospack find std_msgs`:`rospack find geometry_msgs`:`rospack find sensor_msgs`:`rospack find std_srvs` cargo build --features ros1 --release -p roslibrust

test

ROS_PACKAGE_PATH=`rospack find std_msgs`:`rospack find geometry_msgs`:`rospack find sensor_msgs`:`rospack find std_srvs` cargo test -p roslibrust_codegen --release msg_def_to_md5  -- --show-output

@lucasw
Copy link
Owner Author

lucasw commented Aug 31, 2024

This is apparently the md5sum of nothing, I'm getting it for two different strings but they must not be making in, maybe due to size limits?

d41d8cd98f00b204e9800998ecf8427e

-> no the strings were getting sent in with r#" wrappers so escaped newlines \n were getting interpreted as back slash 'n' instead of newlines, so the entire message appeared to be on one line and the first line started with a # so got filtered out.

@lucasw
Copy link
Owner Author

lucasw commented Sep 1, 2024

This is working with lucasw/roslibrust@04bb108 in this roslibrust branch https://github.com/lucasw/roslibrust/commits/subscribe_any/

@lucasw
Copy link
Owner Author

lucasw commented Sep 1, 2024

Next feature is to be able to play back multiple mcaps properly interleaved.

First load all of them and get the start times of the first messages, and take the earliest time of those.

Then tokio spawn a player for each of them with that earliest message time and a wallclock start time (could be slightly in the future to allow everything to initialize), each will independently publish and sleep in order to keep in time relative to the start time, but don't need to talk to each other (there will be duplicate publishers across them, but they'll all have their own node handles). Then wait for all to complete before looping or exiting.

A more advanced version of that would have each receive message clock time via a channel, and the main thread sends that to each and can pause or jump forward or change the rate of playback.

@lucasw
Copy link
Owner Author

lucasw commented Sep 3, 2024

Broadcast the wall start time with tokio broadcast https://docs.rs/tokio/latest/tokio/sync/broadcast/index.html

@lucasw
Copy link
Owner Author

lucasw commented Sep 5, 2024

Play/pause mostly works, but the timing is off when resuming sometimes- maybe need to future date the playback a little and not play back anything until it's time?

@lucasw
Copy link
Owner Author

lucasw commented Sep 9, 2024

Need to aggregate tf_static messages into one message as in ros1_play_mcap.py- it would be easier if mcap convert did that (mcap_record could as well), but can't depend on that so need to handle it on playback.

Every tf_static TFMessage in an mcap needs to be added to a mutable vector, and the tf_static publisher needs to be set to latch.

(How is latching handled in other cases for mcap, where would the information be stored? How is it handled in bags?

https://robotics.stackexchange.com/questions/98040/is-it-possible-to-know-if-a-topic-is-latched-on-subscriber-side-in-cpp
)

@lucasw
Copy link
Owner Author

lucasw commented Sep 30, 2024

Completed by #10, but there are still some playback issues to resolve- looping with multiple bags can take up increasing amounts of memory is one.

@lucasw lucasw closed this as completed Sep 30, 2024
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

No branches or pull requests

1 participant