Skip to content

Instantly share code, notes, and snippets.

@nistath
Last active July 12, 2022 12:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nistath/0d0a1926941b235552aa46f4fdfd4491 to your computer and use it in GitHub Desktop.
Save nistath/0d0a1926941b235552aa46f4fdfd4491 to your computer and use it in GitHub Desktop.
Backport rosbag2_py to ROS2 Foxy
diff --git a/rosbag2_py/src/rosbag2_py/_reader.cpp b/rosbag2_py/src/rosbag2_py/_reader.cpp
index 731e627..51fa640 100644
--- a/rosbag2_py/src/rosbag2_py/_reader.cpp
+++ b/rosbag2_py/src/rosbag2_py/_reader.cpp
@@ -21,7 +21,7 @@
#include "rosbag2_cpp/readers/sequential_reader.hpp"
#include "rosbag2_cpp/reader.hpp"
#include "rosbag2_storage/storage_filter.hpp"
-#include "rosbag2_storage/storage_options.hpp"
+#include "rosbag2_cpp/storage_options.hpp"
#include "rosbag2_storage/topic_metadata.hpp"
#include "./pybind11.hpp"
@@ -39,7 +39,7 @@ public:
}
void open(
- rosbag2_storage::StorageOptions & storage_options,
+ rosbag2_cpp::StorageOptions & storage_options,
rosbag2_cpp::ConverterOptions & converter_options)
{
reader_->open(storage_options, converter_options);
diff --git a/rosbag2_py/src/rosbag2_py/_storage.cpp b/rosbag2_py/src/rosbag2_py/_storage.cpp
index 016dc05..bfe338b 100644
--- a/rosbag2_py/src/rosbag2_py/_storage.cpp
+++ b/rosbag2_py/src/rosbag2_py/_storage.cpp
@@ -17,7 +17,7 @@
#include "rosbag2_cpp/converter_options.hpp"
#include "rosbag2_storage/storage_filter.hpp"
-#include "rosbag2_storage/storage_options.hpp"
+#include "rosbag2_cpp/storage_options.hpp"
#include "rosbag2_storage/topic_metadata.hpp"
#include "./pybind11.hpp"
@@ -37,25 +37,21 @@ PYBIND11_MODULE(_storage, m) {
"output_serialization_format",
&rosbag2_cpp::ConverterOptions::output_serialization_format);
- pybind11::class_<rosbag2_storage::StorageOptions>(m, "StorageOptions")
+ pybind11::class_<rosbag2_cpp::StorageOptions>(m, "StorageOptions")
.def(
- pybind11::init<std::string, std::string, uint64_t, uint64_t, uint64_t>(),
+ pybind11::init<std::string, std::string, uint64_t, uint64_t>(),
pybind11::arg("uri"),
pybind11::arg("storage_id"),
pybind11::arg("max_bagfile_size") = 0,
- pybind11::arg("max_bagfile_duration") = 0,
pybind11::arg("max_cache_size") = 0)
- .def_readwrite("uri", &rosbag2_storage::StorageOptions::uri)
- .def_readwrite("storage_id", &rosbag2_storage::StorageOptions::storage_id)
+ .def_readwrite("uri", &rosbag2_cpp::StorageOptions::uri)
+ .def_readwrite("storage_id", &rosbag2_cpp::StorageOptions::storage_id)
.def_readwrite(
"max_bagfile_size",
- &rosbag2_storage::StorageOptions::max_bagfile_size)
- .def_readwrite(
- "max_bagfile_duration",
- &rosbag2_storage::StorageOptions::max_bagfile_duration)
+ &rosbag2_cpp::StorageOptions::max_bagfile_size)
.def_readwrite(
"max_cache_size",
- &rosbag2_storage::StorageOptions::max_cache_size);
+ &rosbag2_cpp::StorageOptions::max_cache_size);
pybind11::class_<rosbag2_storage::StorageFilter>(m, "StorageFilter")
.def(
diff --git a/rosbag2_py/src/rosbag2_py/_writer.cpp b/rosbag2_py/src/rosbag2_py/_writer.cpp
index fb1b7e7..10a3930 100644
--- a/rosbag2_py/src/rosbag2_py/_writer.cpp
+++ b/rosbag2_py/src/rosbag2_py/_writer.cpp
@@ -21,7 +21,7 @@
#include "rosbag2_cpp/writers/sequential_writer.hpp"
#include "rosbag2_storage/ros_helper.hpp"
#include "rosbag2_storage/storage_filter.hpp"
-#include "rosbag2_storage/storage_options.hpp"
+#include "rosbag2_cpp/storage_options.hpp"
#include "rosbag2_storage/topic_metadata.hpp"
#include "./pybind11.hpp"
@@ -39,7 +39,7 @@ public:
}
void open(
- rosbag2_storage::StorageOptions & storage_options,
+ rosbag2_cpp::StorageOptions & storage_options,
rosbag2_cpp::ConverterOptions & converter_options)
{
writer_->open(storage_options, converter_options);
#!/bin/bash
set -ex
mkdir -p rosbag_ws/src
cd rosbag_ws/src
# Get rosbag2 for foxy
git clone https://github.com/ros2/rosbag2.git -b foxy
# Backport rosbag2_py
cd rosbag2
git checkout 4bcb631e674d7c0e3e7c55eb6b4915ff74f9cd8c -- rosbag2_py
curl https://gist.githubusercontent.com/nistath/0d0a1926941b235552aa46f4fdfd4491/raw/backport_rosbag2_py.patch | git apply
cd -
# Install dependencies
sudo apt-get install ros-foxy-test-msgs python3-pybind11
git clone https://github.com/ros2/pybind11_vendor.git
# Build
colcon build --merge-install
@Jenifen
Copy link

Jenifen commented Jul 12, 2022

you have to install sudo apt install ros-foxy-example-interfaces

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment