diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 9356e28c9e..7c7691e784 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -11,7 +11,7 @@ jobs: image: rostooling/setup-ros-docker:ubuntu-focal-ros-foxy-ros-base-testing-latest steps: - uses: actions/checkout@v2 - - uses: ros-tooling/action-ros-lint@0.0.6 + - uses: ros-tooling/action-ros-lint@v0.1 with: linter: copyright distribution: foxy @@ -32,7 +32,7 @@ jobs: image: rostooling/setup-ros-docker:ubuntu-focal-ros-foxy-ros-base-testing-latest steps: - uses: actions/checkout@v2 - - uses: ros-tooling/action-ros-lint@0.0.6 + - uses: ros-tooling/action-ros-lint@v0.1 with: linter: xmllint distribution: foxy @@ -59,7 +59,7 @@ jobs: image: rostooling/setup-ros-docker:ubuntu-focal-ros-foxy-ros-base-testing-latest steps: - uses: actions/checkout@v2 - - uses: ros-tooling/action-ros-lint@0.0.6 + - uses: ros-tooling/action-ros-lint@v0.1 with: linter: ${{ matrix.linter }} distribution: foxy @@ -83,7 +83,7 @@ jobs: linter: [pep257, flake8] steps: - uses: actions/checkout@v2 - - uses: ros-tooling/action-ros-lint@0.0.6 + - uses: ros-tooling/action-ros-lint@v0.1 with: linter: ${{ matrix.linter }} distribution: foxy diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f9f81d059b..c38afb621d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,32 +3,36 @@ on: pull_request: push: branches: - - master - schedule: - # Run every hour. This helps detect flakiness, - # and broken external dependencies. - - cron: '0 * * * *' + - foxy-future + # NOTE: build schedules are only supported for the default branch - this wouldn't work anyways + # schedule: + # # Run every hour. This helps detect flakiness, + # # and broken external dependencies. + # - cron: '0 * * * *' jobs: build_and_test: runs-on: ubuntu-latest container: - image: rostooling/setup-ros-docker:ubuntu-focal-latest + # Use the ros-base container, so that the rosbag2 binaries are already installed + image: rostooling/setup-ros-docker:ubuntu-focal-ros-foxy-ros-base-latest steps: - - uses: ros-tooling/action-ros-ci@0.1.0 + - uses: ros-tooling/action-ros-ci@v0.2 with: package-name: | ros2bag rosbag2_compression + rosbag2_compression_zstd rosbag2_cpp rosbag2_storage rosbag2_storage_default_plugins + rosbag2_test_common + rosbag2_tests rosbag2_transport shared_queues_vendor sqlite3_vendor - rosbag2_test_common - rosbag2_tests - target-ros2-distro: rolling + zstd_vendor + target-ros2-distro: foxy - uses: actions/upload-artifact@v1 with: name: colcon-logs diff --git a/README.md b/README.md index 939d3bdb0b..084a79d44f 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,28 @@ +# Foxy Improvement Backport Branch + +This branch contains a special-purpose version of rosbag2 that is intended to be used in a Foxy application. + +It contains performance improvements and new features from Galactic development up to March 23, 2021 - with minor tweaks to maintain build and test compatibility against the stable Foxy distribution. + +The popularly-requested improvements in this branch were not possible to backport to Foxy in an API/ABI-maintaining way. Instead, this "Foxy Future" branch is provided for users to build from source and get the performance benefits from nearly a year of development after Foxy. + +For more context on this conversation, see https://discourse.ros.org/t/fast-forward-merging-rosbag2-master-api-to-foxy/18927 or reach out to the ros-tooling Working Group. + +## Usage instructions + +* Check out this branch `foxy-future` from the repository `github.com/ros2/rosbag2` into your ROS workspace (or an overlay workspace) +* Build like the other ROS packages you use + +This branch of rosbag2 will mask the binary-released version, allowing to you to enjoy this very improved version. + +NOTE: Any code that built against the rosbag2 C++ API may not build out of the box against this version, the main reason for the branch is that the APIs changed in some ways that could not be fixed into a backport. + # rosbag2 ![License](https://img.shields.io/github/license/ros2/rosbag2) [![GitHub Action Status](https://github.com/ros2/rosbag2/workflows/Test%20rosbag2/badge.svg)](https://github.com/ros2/rosbag2/actions) Repository for implementing rosbag2 as described in its corresponding [design article](https://github.com/ros2/design/blob/f69fbbd11848e3dd6866b71a158a1902e31e92f1/articles/rosbags.md). -## Foxy Backport Release - -NOTE: this branch will contain the sources for the package `ros-foxy-rosbag2-future`, an updated package containing new performance improvements and features that could not be safely backported to `ros-foxy-rosbag2` in the Foxy Fitzroy distribution without breaking API/ABI. This branch is NOT YET STABLE and will be force-pushed during the release process. - -This to-do list will be removed as the updates are made to this branch: -* [ ] Rename all `package.xml`s with `-future` package name suffix and `` tag -* [ ] Update this README to ensure correct installation and usage instructions -* [ ] Finalize the `master` commit that this will be based on - ## Installation instructions ## Debian packages diff --git a/ros2bag/ros2bag/command/bag.py b/ros2bag/ros2bag/command/bag.py index 0690c951e3..55772a7c27 100644 --- a/ros2bag/ros2bag/command/bag.py +++ b/ros2bag/ros2bag/command/bag.py @@ -19,6 +19,8 @@ class BagCommand(CommandExtension): """Various rosbag related sub-commands.""" + FUTURE_NOTICE = 'Running rosbag2 "futurized" source release, not the official Foxy binary version.' # NOQA + def add_arguments(self, parser, cli_name): self._subparser = parser @@ -27,6 +29,8 @@ def add_arguments(self, parser, cli_name): parser, cli_name, '_verb', 'ros2bag.verb', required=False) def main(self, *, parser, args): + print(self.FUTURE_NOTICE) + print() if not hasattr(args, '_verb'): # in case no verb was passed self._subparser.print_help() diff --git a/rosbag2_compression/CMakeLists.txt b/rosbag2_compression/CMakeLists.txt index 0fdfdbb637..db65af80e8 100644 --- a/rosbag2_compression/CMakeLists.txt +++ b/rosbag2_compression/CMakeLists.txt @@ -75,6 +75,8 @@ if(BUILD_TESTING) test/rosbag2_compression/fake_compressor.cpp test/rosbag2_compression/fake_decompressor.cpp) target_link_libraries(fake_plugin ${PROJECT_NAME}) + # Needs to be removed/revised after https://github.com/ros2/ros2/issues/1150 gets fixed + ament_target_dependencies(fake_plugin rosbag2_cpp rosbag2_storage) install( TARGETS fake_plugin ARCHIVE DESTINATION lib @@ -86,22 +88,28 @@ if(BUILD_TESTING) ament_add_gmock(test_compression_factory test/rosbag2_compression/test_compression_factory.cpp) target_link_libraries(test_compression_factory ${PROJECT_NAME}) + # Needs to be removed/revised after https://github.com/ros2/ros2/issues/1150 gets fixed + ament_target_dependencies(test_compression_factory rosbag2_cpp rosbag2_storage) ament_add_gmock(test_compression_options test/rosbag2_compression/test_compression_options.cpp) target_include_directories(test_compression_options PUBLIC include) target_link_libraries(test_compression_options ${PROJECT_NAME}) + # Needs to be removed/revised after https://github.com/ros2/ros2/issues/1150 gets fixed + ament_target_dependencies(test_compression_options rosbag2_cpp rosbag2_storage) ament_add_gmock(test_sequential_compression_reader test/rosbag2_compression/test_sequential_compression_reader.cpp) target_include_directories(test_sequential_compression_reader PUBLIC include) target_link_libraries(test_sequential_compression_reader ${PROJECT_NAME}) + # Needs to be removed/revised after https://github.com/ros2/ros2/issues/1150 gets fixed ament_target_dependencies(test_sequential_compression_reader rosbag2_cpp rosbag2_storage) ament_add_gmock(test_sequential_compression_writer test/rosbag2_compression/test_sequential_compression_writer.cpp) target_include_directories(test_sequential_compression_writer PUBLIC include) target_link_libraries(test_sequential_compression_writer ${PROJECT_NAME}) + # Needs to be removed/revised after https://github.com/ros2/ros2/issues/1150 gets fixed ament_target_dependencies(test_sequential_compression_writer rosbag2_cpp rosbag2_storage) endif() diff --git a/rosbag2_compression/src/rosbag2_compression/sequential_compression_reader.cpp b/rosbag2_compression/src/rosbag2_compression/sequential_compression_reader.cpp index 0070322f44..e004bddea9 100644 --- a/rosbag2_compression/src/rosbag2_compression/sequential_compression_reader.cpp +++ b/rosbag2_compression/src/rosbag2_compression/sequential_compression_reader.cpp @@ -67,7 +67,8 @@ void SequentialCompressionReader::preprocess_current_file() * Because we have no way to check whether the bag was written correctly, * check for the existence of the prefixed file as a fallback. */ - const rcpputils::fs::path base{base_folder_}; + // Foxy compatibility. Adapts for https://github.com/ros2/rcpputils/pull/119 + rcpputils::fs::path base{base_folder_}; const rcpputils::fs::path relative{get_current_file()}; const auto resolved = base / relative; if (!resolved.exists()) { diff --git a/rosbag2_compression_zstd/CMakeLists.txt b/rosbag2_compression_zstd/CMakeLists.txt index d985c201ae..ea6f677d3a 100644 --- a/rosbag2_compression_zstd/CMakeLists.txt +++ b/rosbag2_compression_zstd/CMakeLists.txt @@ -38,7 +38,10 @@ target_include_directories(${PROJECT_NAME} ament_target_dependencies(${PROJECT_NAME} rcpputils rosbag2_compression - zstd) + zstd + # Needs to be removed/revised after https://github.com/ros2/ros2/issues/1150 gets fixed + rosbag2_cpp + rosbag2_storage) target_compile_definitions(${PROJECT_NAME} PRIVATE ROSBAG2_COMPRESSION_ZSTD_BUILDING_DLL) pluginlib_export_plugin_description_file(rosbag2_compression plugin_description.xml) @@ -69,9 +72,11 @@ if(BUILD_TESTING) ament_add_gmock(test_zstd_compressor test/rosbag2_compression_zstd/test_zstd_compressor.cpp) - target_include_directories(test_zstd_compressor PUBLIC include) target_link_libraries(test_zstd_compressor ${PROJECT_NAME}) - ament_target_dependencies(test_zstd_compressor rclcpp rosbag2_test_common) + + ament_target_dependencies(test_zstd_compressor rclcpp rosbag2_test_common + # Needs to be removed/revised after https://github.com/ros2/ros2/issues/1150 gets fixed + rosbag2_cpp rosbag2_storage zstd rosbag2_compression) endif() ament_package() diff --git a/rosbag2_cpp/CMakeLists.txt b/rosbag2_cpp/CMakeLists.txt index 208cd1bf00..f93b486ac0 100644 --- a/rosbag2_cpp/CMakeLists.txt +++ b/rosbag2_cpp/CMakeLists.txt @@ -140,8 +140,9 @@ if(BUILD_TESTING) ament_add_gmock(test_converter_factory test/rosbag2_cpp/test_converter_factory.cpp) if(TARGET test_converter_factory) - target_include_directories(test_converter_factory PRIVATE include) target_link_libraries(test_converter_factory ${PROJECT_NAME}) + # Needs to be removed/revised after https://github.com/ros2/ros2/issues/1150 gets fixed + ament_target_dependencies(test_converter_factory rosbag2_storage) endif() ament_add_gmock(test_typesupport_helpers @@ -149,6 +150,8 @@ if(BUILD_TESTING) WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) if(TARGET test_typesupport_helpers) target_link_libraries(test_typesupport_helpers ${PROJECT_NAME}) + # Needs to be removed/revised after https://github.com/ros2/ros2/issues/1150 gets fixed + ament_target_dependencies(test_typesupport_helpers rosbag2_storage rosbag2_test_common) endif() ament_add_gmock(test_info @@ -156,27 +159,33 @@ if(BUILD_TESTING) WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) if(TARGET test_info) target_link_libraries(test_info ${PROJECT_NAME}) - ament_target_dependencies(test_info rosbag2_test_common) + ament_target_dependencies(test_info rosbag2_test_common + # Needs to be removed/revised after https://github.com/ros2/ros2/issues/1150 gets fixed + rosbag2_storage) endif() ament_add_gmock(test_sequential_reader test/rosbag2_cpp/test_sequential_reader.cpp) if(TARGET test_sequential_reader) - ament_target_dependencies(test_sequential_reader rosbag2_storage) target_link_libraries(test_sequential_reader ${PROJECT_NAME}) + # Needs to be removed/revised after https://github.com/ros2/ros2/issues/1150 gets fixed + ament_target_dependencies(test_sequential_reader rosbag2_storage) endif() ament_add_gmock(test_storage_without_metadata_file test/rosbag2_cpp/test_storage_without_metadata_file.cpp) if(TARGET test_storage_without_metadata_file) - ament_target_dependencies(test_storage_without_metadata_file rosbag2_storage) target_link_libraries(test_storage_without_metadata_file ${PROJECT_NAME}) + # Needs to be removed/revised after https://github.com/ros2/ros2/issues/1150 gets fixed + ament_target_dependencies(test_storage_without_metadata_file rosbag2_storage) endif() ament_add_gmock(test_message_cache test/rosbag2_cpp/test_message_cache.cpp) if(TARGET test_message_cache) target_link_libraries(test_message_cache ${PROJECT_NAME}) + # Needs to be removed/revised after https://github.com/ros2/ros2/issues/1150 gets fixed + ament_target_dependencies(test_message_cache rosbag2_storage) endif() # If compiling with gcc, run this test with sanitizers enabled @@ -207,15 +216,17 @@ if(BUILD_TESTING) ament_add_gmock(test_sequential_writer test/rosbag2_cpp/test_sequential_writer.cpp) if(TARGET test_sequential_writer) - ament_target_dependencies(test_sequential_writer rosbag2_storage) target_link_libraries(test_sequential_writer ${PROJECT_NAME}) + # Needs to be removed/revised after https://github.com/ros2/ros2/issues/1150 gets fixed + ament_target_dependencies(test_sequential_writer rosbag2_storage) endif() ament_add_gmock(test_multifile_reader test/rosbag2_cpp/test_multifile_reader.cpp) if(TARGET test_multifile_reader) - ament_target_dependencies(test_multifile_reader rosbag2_storage) target_link_libraries(test_multifile_reader ${PROJECT_NAME}) + # Needs to be removed/revised after https://github.com/ros2/ros2/issues/1150 gets fixed + ament_target_dependencies(test_multifile_reader rosbag2_storage) endif() endif() diff --git a/rosbag2_cpp/src/rosbag2_cpp/writers/sequential_writer.cpp b/rosbag2_cpp/src/rosbag2_cpp/writers/sequential_writer.cpp index 6e09ea8580..1ad428bed9 100644 --- a/rosbag2_cpp/src/rosbag2_cpp/writers/sequential_writer.cpp +++ b/rosbag2_cpp/src/rosbag2_cpp/writers/sequential_writer.cpp @@ -110,6 +110,8 @@ void SequentialWriter::open( } bool dir_created = rcpputils::fs::create_directories(db_path); + // Foxy compatibility. Adapts for https://github.com/ros2/rcpputils/pull/98 + dir_created &= db_path.is_directory(); if (!dir_created) { std::stringstream error; error << "Failed to create database directory (" << db_path.string() << ")."; diff --git a/rosbag2_py/CMakeLists.txt b/rosbag2_py/CMakeLists.txt index dd41c29bf9..d354a97044 100644 --- a/rosbag2_py/CMakeLists.txt +++ b/rosbag2_py/CMakeLists.txt @@ -65,42 +65,61 @@ function(clean_windows_flags target) endif() endfunction() +function(reorder_pybind_include_directories _target) + # Hack to fix overlay workspace include directories order + # Needs to be removed/revised after https://github.com/ros2/ros2/issues/1150 gets fixed + # Needs to be called instead of ament_target_dependencies for all targets created via pybind11_add_module + # + # Ros uses its own pybind11 library. It is installed to /opt/ros/foxy folder, so INCLUDE_DIRECTORIES property + # of target created via pybind11_add_module is polluted with /opt/ros/foxy/include + # All includes found in that directory are used instead of local workspace + + # Get all values from INCLUDE_DIRECTORIES property + get_property(_pybind_include_directories TARGET ${_target} PROPERTY INCLUDE_DIRECTORIES) + # Clear all values from INCLUDE_DIRECTORIES property + set_property(TARGET ${_target} PROPERTY INCLUDE_DIRECTORIES "") + # Add ament dependencies + ament_target_dependencies(${_target} PUBLIC ${ARGN}) + # Restore INCLUDE_DIRECTORIES property + set_property(TARGET ${_target} APPEND PROPERTY INCLUDE_DIRECTORIES ${_pybind_include_directories}) +endfunction() + ament_python_install_package(${PROJECT_NAME}) -pybind11_add_module(_reader SHARED +pybind11_add_module(_reader SHARED SYSTEM src/rosbag2_py/_reader.cpp ) -ament_target_dependencies(_reader PUBLIC +reorder_pybind_include_directories(_reader "rosbag2_compression" "rosbag2_cpp" "rosbag2_storage" ) clean_windows_flags(_reader) -pybind11_add_module(_storage SHARED +pybind11_add_module(_storage SHARED SYSTEM src/rosbag2_py/_storage.cpp src/rosbag2_py/format_bag_metadata.cpp ) -ament_target_dependencies(_storage PUBLIC +reorder_pybind_include_directories(_storage "rosbag2_cpp" "rosbag2_storage" ) clean_windows_flags(_storage) -pybind11_add_module(_writer SHARED +pybind11_add_module(_writer SHARED SYSTEM src/rosbag2_py/_writer.cpp ) -ament_target_dependencies(_writer PUBLIC +reorder_pybind_include_directories(_writer "rosbag2_compression" "rosbag2_cpp" "rosbag2_storage" ) clean_windows_flags(_writer) -pybind11_add_module(_info SHARED +pybind11_add_module(_info SHARED SYSTEM src/rosbag2_py/_info.cpp ) -ament_target_dependencies(_info PUBLIC +reorder_pybind_include_directories(_info "rosbag2_cpp" "rosbag2_storage" ) diff --git a/rosbag2_storage/src/rosbag2_storage/metadata_io.cpp b/rosbag2_storage/src/rosbag2_storage/metadata_io.cpp index aa81b78fb9..ee2de60d47 100644 --- a/rosbag2_storage/src/rosbag2_storage/metadata_io.cpp +++ b/rosbag2_storage/src/rosbag2_storage/metadata_io.cpp @@ -232,12 +232,8 @@ BagMetadata MetadataIo::read_metadata(const std::string & uri) YAML::Node yaml_file = YAML::LoadFile(get_metadata_file_name(uri)); auto metadata = yaml_file["rosbag2_bagfile_information"].as(); rcutils_allocator_t allocator = rcutils_get_default_allocator(); - if (RCUTILS_RET_OK != - rcutils_calculate_directory_size(uri.c_str(), &metadata.bag_size, allocator)) - { - throw std::runtime_error( - std::string("Exception on calculating the size of directory :") + uri); - } + // Foxy compatibility. Adapts for https://github.com/ros2/rcutils/pull/306 + metadata.bag_size = rcutils_calculate_directory_size(uri.c_str(), allocator); return metadata; } catch (const YAML::Exception & ex) { throw std::runtime_error(std::string("Exception on parsing info file: ") + ex.what()); diff --git a/rosbag2_test_common/include/rosbag2_test_common/temporary_directory_fixture.hpp b/rosbag2_test_common/include/rosbag2_test_common/temporary_directory_fixture.hpp index 97bce584e4..d46aae89aa 100644 --- a/rosbag2_test_common/include/rosbag2_test_common/temporary_directory_fixture.hpp +++ b/rosbag2_test_common/include/rosbag2_test_common/temporary_directory_fixture.hpp @@ -31,7 +31,18 @@ class TemporaryDirectoryFixture : public Test public: TemporaryDirectoryFixture() { - temporary_dir_path_ = rcpputils::fs::create_temp_directory("tmp_test_dir_").string(); + // Foxy compatibility. Adapt for lack of https://github.com/ros2/rcpputils/pull/126 + char template_char[] = "tmp_test_dir.XXXXXX"; + #ifdef _WIN32 + char temp_path[255]; + GetTempPathA(255, temp_path); + _mktemp_s(template_char, strnlen(template_char, 20) + 1); + temporary_dir_path_ = std::string(temp_path) + std::string(template_char); + _mkdir(temporary_dir_path_.c_str()); + #else + char * dir_name = mkdtemp(template_char); + temporary_dir_path_ = dir_name; + #endif } ~TemporaryDirectoryFixture() override diff --git a/rosbag2_tests/CMakeLists.txt b/rosbag2_tests/CMakeLists.txt index 833ddeb6f5..3f31e8e378 100644 --- a/rosbag2_tests/CMakeLists.txt +++ b/rosbag2_tests/CMakeLists.txt @@ -40,19 +40,23 @@ if(BUILD_TESTING) find_package(rosbag2_test_common REQUIRED) find_package(std_msgs REQUIRED) find_package(test_msgs REQUIRED) + find_package(zstd_vendor REQUIRED) ament_add_gmock(test_rosbag2_record_end_to_end test/rosbag2_tests/test_rosbag2_record_end_to_end.cpp WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) if(TARGET test_rosbag2_record_end_to_end) + # Needs to be removed/revised after https://github.com/ros2/ros2/issues/1150 gets fixed ament_target_dependencies(test_rosbag2_record_end_to_end rclcpp + rosbag2_cpp rosbag2_compression rosbag2_compression_zstd rosbag2_storage rosbag2_storage_default_plugins rosbag2_test_common - test_msgs) + test_msgs + zstd_vendor) ament_add_test_label(test_rosbag2_record_end_to_end xfail) endif() @@ -60,6 +64,7 @@ if(BUILD_TESTING) test/rosbag2_tests/test_rosbag2_play_end_to_end.cpp WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) if(TARGET test_rosbag2_play_end_to_end) + # Needs to be removed/revised after https://github.com/ros2/ros2/issues/1150 gets fixed ament_target_dependencies(test_rosbag2_play_end_to_end rclcpp rosbag2_storage @@ -73,6 +78,7 @@ if(BUILD_TESTING) test/rosbag2_tests/test_rosbag2_info_end_to_end.cpp WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) if(TARGET test_rosbag2_info_end_to_end) + # Needs to be removed/revised after https://github.com/ros2/ros2/issues/1150 gets fixed ament_target_dependencies(test_rosbag2_info_end_to_end rosbag2_storage rosbag2_test_common) @@ -83,16 +89,19 @@ if(BUILD_TESTING) test/rosbag2_tests/test_converter.cpp WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) if(TARGET test_converter) + # Needs to be removed/revised after https://github.com/ros2/ros2/issues/1150 gets fixed ament_target_dependencies(test_converter rosbag2_cpp rosbag2_test_common - test_msgs) + test_msgs + rosbag2_storage) endif() ament_add_gmock(test_rosbag2_cpp_api test/rosbag2_tests/test_rosbag2_cpp_api.cpp WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) if(TARGET test_rosbag2_cpp_api) + # Needs to be removed/revised after https://github.com/ros2/ros2/issues/1150 gets fixed ament_target_dependencies(test_rosbag2_cpp_api rclcpp rosbag2_cpp diff --git a/rosbag2_transport/CMakeLists.txt b/rosbag2_transport/CMakeLists.txt index f67c855c22..df066a5398 100644 --- a/rosbag2_transport/CMakeLists.txt +++ b/rosbag2_transport/CMakeLists.txt @@ -68,6 +68,7 @@ ament_target_dependencies(rosbag2_transport_py rosbag2_cpp rosbag2_storage rmw + shared_queues_vendor ) # Causes the visibility macros to use dllexport rather than dllimport, # which is appropriate when building the dll but not consuming it. @@ -94,17 +95,20 @@ function(create_tests_for_rmw_implementation) rosbag2_transport_add_gmock(test_record_all test/rosbag2_transport/test_record_all.cpp LINK_LIBS rosbag2_transport - AMENT_DEPS rosbag2_cpp rosbag2_storage test_msgs rosbag2_test_common) + # Needs to be removed/revised after https://github.com/ros2/ros2/issues/1150 gets fixed + AMENT_DEPS rosbag2_cpp rosbag2_storage test_msgs rosbag2_test_common rosbag2_compression shared_queues_vendor) rosbag2_transport_add_gmock(test_record_all_no_discovery test/rosbag2_transport/test_record_all_no_discovery.cpp LINK_LIBS rosbag2_transport - AMENT_DEPS rosbag2_cpp rosbag2_storage test_msgs rosbag2_test_common) + # Needs to be removed/revised after https://github.com/ros2/ros2/issues/1150 gets fixed + AMENT_DEPS rosbag2_cpp rosbag2_storage test_msgs rosbag2_test_common rosbag2_compression shared_queues_vendor) rosbag2_transport_add_gmock(test_play_timing test/rosbag2_transport/test_play_timing.cpp LINK_LIBS rosbag2_transport - AMENT_DEPS rosbag2_cpp rosbag2_storage test_msgs rosbag2_test_common) + # Needs to be removed/revised after https://github.com/ros2/ros2/issues/1150 gets fixed + AMENT_DEPS rosbag2_cpp rosbag2_storage test_msgs rosbag2_test_common rosbag2_compression shared_queues_vendor) rosbag2_transport_add_gmock(test_rosbag2_node src/rosbag2_transport/generic_publisher.cpp @@ -118,6 +122,7 @@ function(create_tests_for_rmw_implementation) $ $ $ + # Needs to be removed/revised after https://github.com/ros2/ros2/issues/1150 gets fixed AMENT_DEPS ament_index_cpp rclcpp @@ -125,7 +130,9 @@ function(create_tests_for_rmw_implementation) rosbag2_storage rosbag2_test_common test_msgs - yaml_cpp_vendor) + yaml_cpp_vendor + rosbag2_compression + shared_queues_vendor) rosbag2_transport_add_gmock(test_qos src/rosbag2_transport/qos.cpp @@ -133,6 +140,7 @@ function(create_tests_for_rmw_implementation) INCLUDE_DIRS $ $ + # Needs to be removed/revised after https://github.com/ros2/ros2/issues/1150 gets fixed AMENT_DEPS rclcpp rosbag2_test_common @@ -147,7 +155,8 @@ function(create_tests_for_rmw_implementation) rosbag2_transport_add_gmock(test_record test/rosbag2_transport/test_record.cpp - AMENT_DEPS rosbag2_cpp rosbag2_storage test_msgs rosbag2_test_common + # Needs to be removed/revised after https://github.com/ros2/ros2/issues/1150 gets fixed + AMENT_DEPS rosbag2_cpp rosbag2_storage test_msgs rosbag2_test_common rosbag2_compression shared_queues_vendor INCLUDE_DIRS $ LINK_LIBS rosbag2_transport ${SKIP_TEST}) @@ -155,7 +164,8 @@ function(create_tests_for_rmw_implementation) rosbag2_transport_add_gmock(test_record_regex test/rosbag2_transport/test_record_regex.cpp LINK_LIBS rosbag2_transport - AMENT_DEPS test_msgs rosbag2_test_common + # Needs to be removed/revised after https://github.com/ros2/ros2/issues/1150 gets fixed + AMENT_DEPS test_msgs rosbag2_test_common rosbag2_compression shared_queues_vendor rosbag2_cpp rosbag2_storage ${SKIP_TEST}) rosbag2_transport_add_gmock(test_play @@ -163,20 +173,23 @@ function(create_tests_for_rmw_implementation) test/rosbag2_transport/test_play.cpp INCLUDE_DIRS $ LINK_LIBS rosbag2_transport - AMENT_DEPS rosbag2_cpp rosbag2_storage test_msgs rosbag2_test_common + # Needs to be removed/revised after https://github.com/ros2/ros2/issues/1150 gets fixed + AMENT_DEPS rosbag2_cpp rosbag2_storage test_msgs rosbag2_test_common rosbag2_compression shared_queues_vendor ${SKIP_TEST}) rosbag2_transport_add_gmock(test_play_loop test/rosbag2_transport/test_play_loop.cpp ${SKIP_TEST} LINK_LIBS rosbag2_transport - AMENT_DEPS rosbag2_cpp rosbag2_storage test_msgs rosbag2_test_common) + # Needs to be removed/revised after https://github.com/ros2/ros2/issues/1150 gets fixed + AMENT_DEPS rosbag2_cpp rosbag2_storage test_msgs rosbag2_test_common rosbag2_compression shared_queues_vendor) rosbag2_transport_add_gmock(test_play_topic_remap test/rosbag2_transport/test_play_topic_remap.cpp ${SKIP_TEST} LINK_LIBS rosbag2_transport - AMENT_DEPS rosbag2_cpp rosbag2_storage test_msgs rosbag2_test_common) + # Needs to be removed/revised after https://github.com/ros2/ros2/issues/1150 gets fixed + AMENT_DEPS rosbag2_cpp rosbag2_storage test_msgs rosbag2_test_common rosbag2_compression shared_queues_vendor) endfunction() if(BUILD_TESTING) diff --git a/rosbag2_transport/src/rosbag2_transport/qos.cpp b/rosbag2_transport/src/rosbag2_transport/qos.cpp index 980e712e6b..4a4c888439 100644 --- a/rosbag2_transport/src/rosbag2_transport/qos.cpp +++ b/rosbag2_transport/src/rosbag2_transport/qos.cpp @@ -21,6 +21,52 @@ namespace { + +// Foxy compatibility - copied from Galactic version of rmw/time.c +// Introuced in https://github.com/ros2/rmw/pull/301 +using rmw_duration_t = rcutils_duration_value_t; +// we can't use the Galactic version of this constant because Foxy RMWs won't understand it +const rmw_time_t RMW_DURATION_INFINITE {0LL, 0LL}; + + +rmw_duration_t +rmw_time_total_nsec(const rmw_time_t time) +{ + static const uint64_t max_sec = INT64_MAX / RCUTILS_S_TO_NS(1); + if (time.sec > max_sec) { + // Seconds not representable in nanoseconds + return INT64_MAX; + } + + const int64_t sec_as_nsec = RCUTILS_S_TO_NS(time.sec); + if (time.nsec > (uint64_t)(INT64_MAX - sec_as_nsec)) { + // overflow + return INT64_MAX; + } + return sec_as_nsec + time.nsec; +} + +bool +rmw_time_equal(const rmw_time_t left, const rmw_time_t right) +{ + return rmw_time_total_nsec(left) == rmw_time_total_nsec(right); +} + +rmw_time_t +rmw_time_from_nsec(const rmw_duration_t nanoseconds) +{ + if (nanoseconds < 0) { + return (rmw_time_t)RMW_DURATION_INFINITE; + } + + // Avoid typing the 1 billion constant + rmw_time_t time; + time.sec = RCUTILS_NS_TO_S(nanoseconds); + time.nsec = nanoseconds % RCUTILS_S_TO_NS(1); + return time; +} +/// End Foxy compatibility section + /** * The following constants were the "Inifinity" value returned by RMW implementations before * the introduction of RMW_DURATION_INFINITE and associated RMW fixes diff --git a/rosbag2_transport/test/rosbag2_transport/test_qos.cpp b/rosbag2_transport/test/rosbag2_transport/test_qos.cpp index ab9125083b..03f3cb4128 100644 --- a/rosbag2_transport/test/rosbag2_transport/test_qos.cpp +++ b/rosbag2_transport/test/rosbag2_transport/test_qos.cpp @@ -21,6 +21,55 @@ #include "qos.hpp" + +namespace +{ +// Foxy compatibility - copied from Galactic version of rmw/time.c +// Introuced in https://github.com/ros2/rmw/pull/301 +using rmw_duration_t = rcutils_duration_value_t; +// we can't use the Galactic version of this constant because Foxy RMWs won't understand it +const rmw_time_t RMW_DURATION_INFINITE {0LL, 0LL}; + + +rmw_duration_t +rmw_time_total_nsec(const rmw_time_t time) +{ + static const uint64_t max_sec = INT64_MAX / RCUTILS_S_TO_NS(1); + if (time.sec > max_sec) { + // Seconds not representable in nanoseconds + return INT64_MAX; + } + + const int64_t sec_as_nsec = RCUTILS_S_TO_NS(time.sec); + if (time.nsec > (uint64_t)(INT64_MAX - sec_as_nsec)) { + // overflow + return INT64_MAX; + } + return sec_as_nsec + time.nsec; +} + +bool +rmw_time_equal(const rmw_time_t left, const rmw_time_t right) +{ + return rmw_time_total_nsec(left) == rmw_time_total_nsec(right); +} + +rmw_time_t +rmw_time_from_nsec(const rmw_duration_t nanoseconds) +{ + if (nanoseconds < 0) { + return (rmw_time_t)RMW_DURATION_INFINITE; + } + + // Avoid typing the 1 billion constant + rmw_time_t time; + time.sec = RCUTILS_NS_TO_S(nanoseconds); + time.nsec = nanoseconds % RCUTILS_S_TO_NS(1); + return time; +} +/// End Foxy compatibility section +} // namespace + TEST(TestQoS, serialization) { rosbag2_transport::Rosbag2QoS expected_qos;