Skip to content

Commit

Permalink
Exclude recorded /clock topic when --clock option is specified (#1646)
Browse files Browse the repository at this point in the history
* Fix double clock publish

Signed-off-by: kosuke55 <kosuke.tnp@gmail.com>

* add option help

Signed-off-by: kosuke55 <kosuke.tnp@gmail.com>

---------

Signed-off-by: kosuke55 <kosuke.tnp@gmail.com>
  • Loading branch information
kosuke55 committed Jun 12, 2024
1 parent fbb08d0 commit e7e6005
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions ros2bag/ros2bag/verb/play.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ def add_arguments(self, parser, cli_name): # noqa: D102
clock_args_group.add_argument(
'--clock', type=positive_float, nargs='?', const=40, default=0,
help='Publish to /clock at a specific frequency in Hz, to act as a ROS Time Source. '
'Value must be positive. Defaults to not publishing.')
'Value must be positive. Defaults to not publishing.'
'If specified, /clock topic in the bag file is excluded to publish.')
clock_args_group.add_argument(
'--clock-topics', type=str, default=[], nargs='+',
help='List of topics separated by spaces that will trigger a /clock update '
Expand Down Expand Up @@ -212,15 +213,17 @@ def main(self, *, args): # noqa: D102

play_options.exclude_regex_to_filter = args.exclude_regex

play_options.exclude_topics_to_filter = args.exclude_topics if args.exclude_topics else []

play_options.exclude_service_events_to_filter = \
convert_service_to_service_event_topic(args.exclude_services)

play_options.topic_qos_profile_overrides = qos_profile_overrides
play_options.loop = args.loop
play_options.topic_remapping_options = topic_remapping
play_options.clock_publish_frequency = args.clock
exclude_topics = args.exclude_topics if args.exclude_topics else []
if play_options.clock_publish_frequency > 0:
exclude_topics.append('/clock')
play_options.exclude_topics_to_filter = exclude_topics
if args.clock_topics_all or len(args.clock_topics) > 0:
play_options.clock_publish_on_topic_publish = True
play_options.clock_topics = args.clock_topics
Expand Down

0 comments on commit e7e6005

Please sign in to comment.