Skip to content

ros2 bag play --topics/--services cannot work without extra option before bag file path #1628

Description

@fujitatomoya

Description

--topics and --services option arguments cannot work without having the extra option before the bag file path.

Expected Behavior

it should work even without extra option before bag file path.

root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 bag play --topics chatter rosbag2_2024_04_25-10_55_16/
[INFO] [1714067979.777474156] [rosbag2_player]: Set rate to 1
[INFO] [1714067979.783672709] [rosbag2_player]: Adding keyboard callbacks.
[INFO] [1714067979.783702132] [rosbag2_player]: Press SPACE for Pause/Resume
[INFO] [1714067979.783707171] [rosbag2_player]: Press CURSOR_RIGHT for Play Next Message
[INFO] [1714067979.783712411] [rosbag2_player]: Press CURSOR_UP for Increase Rate 10%
[INFO] [1714067979.783716795] [rosbag2_player]: Press CURSOR_DOWN for Decrease Rate 10%
[INFO] [1714067979.783814715] [rosbag2_player]: Playback until timestamp: -1

Actual Behavior

root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 bag play --topics chatter rosbag2_2024_04_25-10_55_16/
usage: ros2 bag play [-h] [-s {sqlite3,my_test_plugin,mcap,my_read_only_test_plugin}]
                     [--read-ahead-queue-size READ_AHEAD_QUEUE_SIZE] [-r RATE] [--topics topic [topic ...]]
                     [--services service [service ...]] [-e REGEX] [-x EXCLUDE_REGEX] [--exclude-topics topic [topic ...]]
                     [--exclude-services service [service ...]] [--qos-profile-overrides-path QOS_PROFILE_OVERRIDES_PATH]
                     [-l] [--remap REMAP [REMAP ...]] [--storage-config-file STORAGE_CONFIG_FILE] [--clock [CLOCK] |
                     --clock-topics CLOCK_TOPICS [CLOCK_TOPICS ...] | --clock-topics-all] [-d DELAY]
                     [--playback-duration PLAYBACK_DURATION]
                     [--playback-until-sec PLAYBACK_UNTIL_SEC | --playback-until-nsec PLAYBACK_UNTIL_NSEC]
                     [--disable-keyboard-controls] [-p] [--start-offset START_OFFSET] [--wait-for-all-acked TIMEOUT]
                     [--disable-loan-message] [--publish-service-requests]
                     [--service-requests-source {service_introspection,client_introspection}]
                     bag_path
ros2 bag play: error: the following arguments are required: bag_path

To Reproduce

  1. start some publishers.
ros2 topic pub -r 1 /greetings  example_interfaces/msg/String "{data: 'Hello fron greeting topic'}"
ros2 topic pub -r 1 /chatter std_msgs/msg/String "{data: 'Hello on greeting topic'}"
  1. record all topics.
root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 bag record -a
[INFO] [1714067717.014419278] [rosbag2_recorder]: Press SPACE for pausing/resuming
[INFO] [1714067717.018212708] [rosbag2_recorder]: Listening for topics...
[INFO] [1714067717.018257318] [rosbag2_recorder]: Event publisher thread: Starting
[INFO] [1714067717.026120002] [rosbag2_recorder]: Subscribed to topic '/rosout'
[INFO] [1714067717.029323308] [rosbag2_recorder]: Subscribed to topic '/parameter_events'
[INFO] [1714067717.031138205] [rosbag2_recorder]: Subscribed to topic '/events/write_split'
[INFO] [1714067717.031189731] [rosbag2_recorder]: Recording...
[INFO] [1714067721.022214861] [rosbag2_recorder]: Subscribed to topic '/greetings'
[INFO] [1714067724.435570665] [rosbag2_recorder]: Subscribed to topic '/chatter'
[INFO] [1714067736.480997299] [rosbag2_recorder]: Pausing recording.
[INFO] [1714067736.481258938] [rosbag2_cpp]: Writing remaining messages from cache to the bag. It may take a while
[INFO] [1714067736.488452363] [rosbag2_recorder]: Event publisher thread: Exiting
[INFO] [1714067736.488516934] [rosbag2_recorder]: Recording stopped
[INFO] [1714067736.577997951] [rclcpp]: signal_handler(signum=2)
  1. try to replay the topic from the bag file with --topics optional argument.
root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 bag play --topics chatter greetings rosbag2_2024_04_25-10_55_16/
usage: ros2 bag play [-h] [-s {sqlite3,my_test_plugin,mcap,my_read_only_test_plugin}]
                     [--read-ahead-queue-size READ_AHEAD_QUEUE_SIZE] [-r RATE] [--topics topic [topic ...]]
                     [--services service [service ...]] [-e REGEX] [-x EXCLUDE_REGEX] [--exclude-topics topic [topic ...]]
                     [--exclude-services service [service ...]] [--qos-profile-overrides-path QOS_PROFILE_OVERRIDES_PATH]
                     [-l] [--remap REMAP [REMAP ...]] [--storage-config-file STORAGE_CONFIG_FILE] [--clock [CLOCK] |
                     --clock-topics CLOCK_TOPICS [CLOCK_TOPICS ...] | --clock-topics-all] [-d DELAY]
                     [--playback-duration PLAYBACK_DURATION]
                     [--playback-until-sec PLAYBACK_UNTIL_SEC | --playback-until-nsec PLAYBACK_UNTIL_NSEC]
                     [--disable-keyboard-controls] [-p] [--start-offset START_OFFSET] [--wait-for-all-acked TIMEOUT]
                     [--disable-loan-message] [--publish-service-requests]
                     [--service-requests-source {service_introspection,client_introspection}]
                     bag_path
ros2 bag play: error: the following arguments are required: bag_path

System (please complete the following information)

  • OS: Ubuntu 24.04 Nobel
  • ROS 2 Distro: Rolling
  • Install Method: source code
  • Version: ros2/ros2@4d07f58

Additional context

as a work-around, if we have an extra option before the bag file path, it works as expected.

the following example command includes -s mcap before bag file path.

root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 bag play --topics chatter greetings -s mcap rosbag2_2024_04_25-10_55_16/
[INFO] [1714067979.777474156] [rosbag2_player]: Set rate to 1
[INFO] [1714067979.783672709] [rosbag2_player]: Adding keyboard callbacks.
[INFO] [1714067979.783702132] [rosbag2_player]: Press SPACE for Pause/Resume
[INFO] [1714067979.783707171] [rosbag2_player]: Press CURSOR_RIGHT for Play Next Message
[INFO] [1714067979.783712411] [rosbag2_player]: Press CURSOR_UP for Increase Rate 10%
[INFO] [1714067979.783716795] [rosbag2_player]: Press CURSOR_DOWN for Decrease Rate 10%
[INFO] [1714067979.783814715] [rosbag2_player]: Playback until timestamp: -1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions