Skip to content

Commit

Permalink
Merge branch 'rolling' into nicolaloi/bag-play-progress-bar
Browse files Browse the repository at this point in the history
Signed-off-by: Nicola Loi <[email protected]>
  • Loading branch information
nicolaloi authored Dec 2, 2024
2 parents 0c99597 + 125db50 commit 372b8a2
Show file tree
Hide file tree
Showing 87 changed files with 1,634 additions and 549 deletions.
3 changes: 0 additions & 3 deletions .github/CODEOWNERS

This file was deleted.

2 changes: 0 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ jobs:
rosbag2_test_common
rosbag2_tests
rosbag2_transport
shared_queues_vendor
ament_lint_cpp: # Linters applicable to C++ packages
name: ament_${{ matrix.linter }}
Expand Down Expand Up @@ -62,7 +61,6 @@ jobs:
rosbag2_test_common
rosbag2_tests
rosbag2_transport
shared_queues_vendor
ament_lint_clang_format: # Linters applicable to C++ packages formatted with clang-format
name: ament_${{ matrix.linter }}
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ jobs:
"rosbag2_test_msgdefs",
"rosbag2_tests",
"rosbag2_transport",
"shared_queues_vendor",
"sqlite3_vendor",
"zstd_vendor"
]
Expand All @@ -74,7 +73,6 @@ jobs:
"rosbag2_test_msgdefs",
"rosbag2_tests",
"rosbag2_transport",
"shared_queues_vendor",
"sqlite3_vendor",
"zstd_vendor"
]
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,14 @@ $ ros2 bag play <bag>
The bag argument can be a directory containing `metadata.yaml` and one or more storage files, or to a single storage file such as `.mcap` or `.db3`.
The Player will automatically detect which storage implementation to use for playing.

To play back multiple bags:

```
$ ros2 bag play <bag1> -i <bag2> -i <bag3>
```

Messages from all provided bags will be played in order, based on their original recording reception timestamps.

#### Controlling playback via services

The Rosbag2 player provides the following services for remote control, which can be called via `ros2 service` commandline or from your nodes,
Expand Down
5 changes: 5 additions & 0 deletions liblz4_vendor/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ Changelog for package liblz4_vendor
0.29.0 (2024-09-03)
-------------------

0.30.0 (2024-11-26)
-------------------
* Add in a library prefix for lz4 from conda on Windows. (`#1846 <https://github.com/ros2/rosbag2/issues/1846>`_)
* Contributors: Alejandro Hernández Cordero, Chris Lalancette

0.28.0 (2024-06-17)
-------------------

Expand Down
7 changes: 7 additions & 0 deletions liblz4_vendor/cmake/Modules/Findlz4.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ if(NOT lz4_ROOT_DIR AND DEFINED ENV{lz4_ROOT_DIR})
"lz4 base directory location (optional, used for nonstandard installation paths)")
endif()

# When using lz4 from conda on Windows, and cmake before 3.29.0,
# we need to add the library prefix "lib" so that the library can
# be successfully found.
if(MSVC AND CMAKE_VERSION VERSION_LESS "3.29.0")
set(CMAKE_FIND_LIBRARY_PREFIXES "" "lib")
endif()

# Search path for nonstandard package locations
if(lz4_ROOT_DIR)
set(lz4_INCLUDE_PATH PATHS "${lz4_ROOT_DIR}/include" NO_DEFAULT_PATH)
Expand Down
2 changes: 1 addition & 1 deletion liblz4_vendor/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<?xml-model href="http://download.ros.org/schema/package_format2.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="2">
<name>liblz4_vendor</name>
<version>0.29.0</version>
<version>0.30.0</version>
<description>LZ4 compression vendor package, providing a dependency for LZ4.</description>
<maintainer email="[email protected]">Michael Orlov</maintainer>
<maintainer email="[email protected]">Emerson Knapp</maintainer>
Expand Down
3 changes: 3 additions & 0 deletions mcap_vendor/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
Changelog for package mcap_vendor
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

0.30.0 (2024-11-26)
-------------------

0.29.0 (2024-09-03)
-------------------
* Update mcap (`#1774 <https://github.com/ros2/rosbag2/issues/1774>`_)
Expand Down
2 changes: 1 addition & 1 deletion mcap_vendor/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>mcap_vendor</name>
<version>0.29.0</version>
<version>0.30.0</version>
<description>mcap vendor package</description>
<maintainer email="[email protected]">Foxglove</maintainer>
<maintainer email="[email protected]">Michael Orlov</maintainer>
Expand Down
6 changes: 6 additions & 0 deletions ros2bag/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
Changelog for package ros2bag
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

0.30.0 (2024-11-26)
-------------------
* Rename rclpy.qos.QoS*Policy to rclpy.qos.*Policy (`#1832 <https://github.com/ros2/rosbag2/issues/1832>`_)
* Add "--sort" CLI option to the "ros2 bag info" command (`#1804 <https://github.com/ros2/rosbag2/issues/1804>`_)
* Contributors: Alejandro Hernández Cordero, Christophe Bedard, Nicola Loi, Roman, Sanoronas

0.29.0 (2024-09-03)
-------------------
* Add cli option compression-threads-priority (`#1768 <https://github.com/ros2/rosbag2/issues/1768>`_)
Expand Down
2 changes: 1 addition & 1 deletion ros2bag/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<?xml-model href="http://download.ros.org/schema/package_format2.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="2">
<name>ros2bag</name>
<version>0.29.0</version>
<version>0.30.0</version>
<description>
Entry point for rosbag in ROS 2
</description>
Expand Down
108 changes: 99 additions & 9 deletions ros2bag/ros2bag/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,24 @@
import os
from typing import Any
from typing import Dict
from typing import List
from typing import Optional

from rclpy.duration import Duration
from rclpy.qos import QoSDurabilityPolicy
from rclpy.qos import QoSHistoryPolicy
from rclpy.qos import QoSLivelinessPolicy
from rclpy.qos import DurabilityPolicy
from rclpy.qos import HistoryPolicy
from rclpy.qos import LivelinessPolicy
from rclpy.qos import QoSProfile
from rclpy.qos import QoSReliabilityPolicy
from rclpy.qos import ReliabilityPolicy
from ros2cli.entry_points import get_entry_points
import rosbag2_py

# This map needs to be updated when new policies are introduced
_QOS_POLICY_FROM_SHORT_NAME = {
'history': QoSHistoryPolicy.get_from_short_key,
'reliability': QoSReliabilityPolicy.get_from_short_key,
'durability': QoSDurabilityPolicy.get_from_short_key,
'liveliness': QoSLivelinessPolicy.get_from_short_key
'history': HistoryPolicy.get_from_short_key,
'reliability': ReliabilityPolicy.get_from_short_key,
'durability': DurabilityPolicy.get_from_short_key,
'liveliness': LivelinessPolicy.get_from_short_key
}
_DURATION_KEYS = ['deadline', 'lifespan', 'liveliness_lease_duration']
_VALUE_KEYS = ['depth', 'avoid_ros_namespace_conventions']
Expand Down Expand Up @@ -158,15 +159,104 @@ def check_not_negative_int(arg: str) -> int:


def add_standard_reader_args(parser: ArgumentParser) -> None:
"""
Add arguments for one input bag.
:param parser: the parser
"""
reader_choices = rosbag2_py.get_registered_readers()
parser.add_argument(
'bag_path', type=check_path_exists, help='Bag to open')
'bag_path',
nargs=None,
type=check_path_exists,
help='Bag to open.')
parser.add_argument(
'-s', '--storage', default='', choices=reader_choices,
help='Storage implementation of bag. '
'By default attempts to detect automatically - use this argument to override.')


def add_standard_multi_reader_args(parser: ArgumentParser) -> None:
"""
Add arguments for multiple input bags.
:param parser: the parser
"""
# Let user provide an input bag path using an optional positional arg, but require them to use
# --input to provide an input bag with a specific storage ID
reader_choices = rosbag2_py.get_registered_readers()
parser.add_argument(
'bag_path',
nargs='?',
type=check_path_exists,
help='Bag to open. '
'Use --input instead to provide an input bag with a specific storage ID.')
parser.add_argument(
'-s', '--storage', default='', choices=reader_choices,
help='Storage implementation of bag. '
'By default attempts to detect automatically - use this argument to override.'
' (deprecated: use --input to provide an input bag with a specific storage ID)')
add_multi_bag_input_arg(parser, required=False)


def add_multi_bag_input_arg(parser: ArgumentParser, required: bool = False) -> None:
"""
Add option for list of input bags.
:param parser: the parser
:param required: whether this option should be required
"""
reader_choices = ', '.join(rosbag2_py.get_registered_readers())
parser.add_argument(
'-i', '--input',
required=required,
action='append', nargs='+',
metavar=('uri', 'storage_id'),
help='URI (and optional storage ID) of an input bag. '
'May be provided more than once for multiple input bags. '
f'Storage ID options are: {reader_choices}.')


def input_bag_arg_to_storage_options(
input_arg: List[List[str]],
storage_config_file: Optional[str] = None,
) -> List[rosbag2_py.StorageOptions]:
"""
Convert input bag argument value(s) to list of StorageOptions.
Raises ValueError if validation fails, including:
1. Bag path existence
2. Storage ID
3. Storage config file existence
:param input_arg: the values of the input argument
:param storage_config_file: the storage config file, if any
"""
if storage_config_file and not os.path.exists(storage_config_file):
raise ValueError(f"File '{storage_config_file}' does not exist!")
storage_id_options = rosbag2_py.get_registered_readers()
storage_options = []
for input_bag_info in input_arg:
if len(input_bag_info) > 2:
raise ValueError(
f'--input expects 1 or 2 arguments, {len(input_bag_info)} provided')
bag_path = input_bag_info[0]
if not os.path.exists(bag_path):
raise ValueError(f"Bag path '{bag_path}' does not exist!")
storage_id = input_bag_info[1] if len(input_bag_info) > 1 else ''
if storage_id and storage_id not in storage_id_options:
raise ValueError(
f"Unknown storage ID '{storage_id}', options are: {', '.join(storage_id_options)}")
options = rosbag2_py.StorageOptions(
uri=bag_path,
storage_id=storage_id,
)
if storage_config_file:
options.storage_config_uri = storage_config_file
storage_options.append(options)
return storage_options


def _parse_cli_storage_plugin():
plugin_choices = set(rosbag2_py.get_registered_writers())
default_storage = rosbag2_py.get_default_storage_id()
Expand Down
22 changes: 4 additions & 18 deletions ros2bag/ros2bag/verb/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import argparse

from ros2bag.api import add_multi_bag_input_arg
from ros2bag.api import input_bag_arg_to_storage_options
from ros2bag.verb import VerbExtension
from rosbag2_py import bag_rewrite
from rosbag2_py import StorageOptions


class ConvertVerb(VerbExtension):
"""Given an input bag, write out a new bag with different settings."""

def add_arguments(self, parser, cli_name):
parser.add_argument(
'-i', '--input',
required=True,
action='append', nargs='+',
metavar=('uri', 'storage_id'),
help='URI (and optional storage ID) of an input bag. May be provided more than once')
add_multi_bag_input_arg(parser, required=True)
parser.add_argument(
'-o', '--output-options',
type=str, required=True,
Expand All @@ -37,14 +31,6 @@ def add_arguments(self, parser, cli_name):
'objects. See README.md for some examples.')

def main(self, *, args):
input_options = []
for input_bag in args.input:
if len(input_bag) > 2:
raise argparse.ArgumentTypeError(
f'--input expects 1 or 2 arguments, {len(input_bag)} provided')
storage_options = StorageOptions(uri=input_bag[0])
if len(input_bag) > 1:
storage_options.storage_id = input_bag[1]
input_options.append(storage_options)
input_options = input_bag_arg_to_storage_options(args.input)

bag_rewrite(input_options, args.output_options)
11 changes: 8 additions & 3 deletions ros2bag/ros2bag/verb/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,21 @@ def add_arguments(self, parser, cli_name): # noqa: D102
'-v', '--verbose', action='store_true',
help='Display request/response information for services'
)
available_sorting_methods = Info().get_sorting_methods()
parser.add_argument(
'--sort', default='name', choices=available_sorting_methods,
help='Configuration for sorting of output. '
'By default sorts by topic name - use this argument to override.')

def main(self, *, args): # noqa: D102
if args.topic_name and args.verbose:
print("Warning! You have set both the '-t' and '-v' parameters. The '-t' parameter "
'will be ignored.')
m = Info().read_metadata(args.bag_path, args.storage)
if args.verbose:
Info().print_output_verbose(args.bag_path, m)
Info().print_output_verbose(args.bag_path, m, args.sort)
else:
if args.topic_name:
Info().print_output_topic_name_only(m)
Info().print_output_topic_name_only(m, args.sort)
else:
Info().print_output(m)
Info().print_output(m, args.sort)
Loading

0 comments on commit 372b8a2

Please sign in to comment.