Skip to content

Commit

Permalink
Foxy compatibility - README update for usage - and notice in the CLI …
Browse files Browse the repository at this point in the history
…tool

Signed-off-by: Emerson Knapp <[email protected]>
  • Loading branch information
emersonknapp committed Jun 10, 2021
1 parent 1aba66f commit 94798b4
Show file tree
Hide file tree
Showing 9 changed files with 141 additions and 21 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,23 @@ jobs:
container:
image: rostooling/setup-ros-docker:ubuntu-focal-latest
steps:
- uses: ros-tooling/action-ros-ci@0.1.0
- uses: ros-tooling/action-ros-ci@v0.1
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
vcs-repo-file-url: ""
- uses: actions/upload-artifact@v1
with:
name: colcon-logs
Expand Down
28 changes: 19 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

## 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 `<conflicts>` 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
Expand Down
4 changes: 4 additions & 0 deletions ros2bag/ros2bag/command/bag.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
class BagCommand(CommandExtension):
"""Various rosbag related sub-commands."""

FUTURE_NOTICE = 'NOTE: Running rosbag2 "futurized" source release, not the official Foxy binary version.' # NOQA

def add_arguments(self, parser, cli_name):
self._subparser = parser

Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
2 changes: 2 additions & 0 deletions rosbag2_cpp/src/rosbag2_cpp/writers/sequential_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() << ").";
Expand Down
8 changes: 2 additions & 6 deletions rosbag2_storage/src/rosbag2_storage/metadata_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<rosbag2_storage::BagMetadata>();
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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
45 changes: 45 additions & 0 deletions rosbag2_transport/src/rosbag2_transport/qos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,51 @@

namespace
{

// Foxy compatibility - copied from Galactic version of rmw/time.c
typedef rcutils_duration_value_t rmw_duration_t;
// we can't use the Galactic version of this constant because Foxy RMWs won't understand it
static 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
Expand Down
48 changes: 48 additions & 0 deletions rosbag2_transport/test/rosbag2_transport/test_qos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,54 @@

#include "qos.hpp"


namespace
{
// Foxy compatibility - copied from Galactic version of rmw/time.c
typedef rcutils_duration_value_t rmw_duration_t;
// we can't use the Galactic version of this constant because Foxy RMWs won't understand it
static 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;
Expand Down

0 comments on commit 94798b4

Please sign in to comment.