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

Progress-bar for ros2 bag play #1836

Open
wants to merge 17 commits into
base: rolling
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/design/rosbag2_record_replay_service.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ Added or changed parameters:

Rename from `--exclude`. Exclude topics and services containing provided regular expression.

- `--progress-bar [ProgressBarFrequency]`

Print a progress bar of the playback player at a specific frequency in Hz. Negative values mark an update for every published message, while a zero value disables the progress bar. Default to a positive low value.

`-e REGEX, --regex REGEX` affects both topics and services.

## Implementation Staging
Expand Down
8 changes: 8 additions & 0 deletions ros2bag/ros2bag/verb/play.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,13 @@ def add_arguments(self, parser, cli_name): # noqa: D102
'--log-level', type=str, default='info',
choices=['debug', 'info', 'warn', 'error', 'fatal'],
help='Logging level.')
parser.add_argument(
'--progress-bar', type=float, default=3.0,
help='Print a progress bar of the playback player at a specific frequency in Hz. '
'Default is %(default)d. '
'Negative values mark an update for every published message, while '
' a zero value disables the progress bar.',
metavar='PROGRESS_BAR_FREQUENCY')

def get_playback_until_from_arg_group(self, playback_until_sec, playback_until_nsec) -> int:
nano_scale = 1000 * 1000 * 1000
Expand Down Expand Up @@ -275,6 +282,7 @@ def main(self, *, args): # noqa: D102
play_options.service_requests_source = ServiceRequestsSource.SERVICE_INTROSPECTION
else:
play_options.service_requests_source = ServiceRequestsSource.CLIENT_INTROSPECTION
play_options.progress_bar_print_frequency = args.progress_bar

player = Player(args.log_level)
try:
Expand Down
1 change: 1 addition & 0 deletions rosbag2_py/rosbag2_py/_transport.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class PlayOptions:
node_prefix: str
playback_duration: float
playback_until_timestamp: int
progress_bar_print_frequency: float
publish_service_requests: bool
rate: float
read_ahead_queue_size: int
Expand Down
1 change: 1 addition & 0 deletions rosbag2_py/src/rosbag2_py/_transport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@ PYBIND11_MODULE(_transport, m) {
"playback_until_timestamp",
&PlayOptions::getPlaybackUntilTimestamp,
&PlayOptions::setPlaybackUntilTimestamp)
.def_readwrite("progress_bar_print_frequency", &PlayOptions::progress_bar_print_frequency)
.def_readwrite("wait_acked_timeout", &PlayOptions::wait_acked_timeout)
.def_readwrite("disable_loan_message", &PlayOptions::disable_loan_message)
.def_readwrite("publish_service_requests", &PlayOptions::publish_service_requests)
Expand Down
3 changes: 3 additions & 0 deletions rosbag2_transport/include/rosbag2_transport/play_options.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ struct PlayOptions

// The source of the service request
ServiceRequestsSource service_requests_source = ServiceRequestsSource::SERVICE_INTROSPECTION;

// Rate in Hz at which to print progress bar.
double progress_bar_print_frequency = 3.0;
};

} // namespace rosbag2_transport
Expand Down
5 changes: 5 additions & 0 deletions rosbag2_transport/src/rosbag2_transport/play_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ Node convert<rosbag2_transport::PlayOptions>::encode(

node["disable_loan_message"] = play_options.disable_loan_message;

node["progress_bar_print_frequency"] = play_options.progress_bar_print_frequency;

return node;
}

Expand Down Expand Up @@ -114,6 +116,9 @@ bool convert<rosbag2_transport::PlayOptions>::decode(

optional_assign<bool>(node, "disable_loan_message", play_options.disable_loan_message);

optional_assign<double>(
node, "progress_bar_print_frequency", play_options.progress_bar_print_frequency);

return true;
}

Expand Down
Loading
Loading