Skip to content

Commit

Permalink
Remove old service and add StorageOptions python integration
Browse files Browse the repository at this point in the history
Signed-off-by: Cameron Miller <[email protected]>
  • Loading branch information
Cameron Miller committed Sep 8, 2021
1 parent 47c028d commit 79b4362
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 17 deletions.
6 changes: 3 additions & 3 deletions docs/design/rosbag2_snapshot_mode.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ $ ros2 bag record --max-cache-size 100000 --snapshot-mode [topics [topics ...]]

Triggering a snapshot via CLI:
```
$ ros2 service call /rosbag2_recorder/snapshot rosbag2_interfaces/TakeSnapshot
$ ros2 service call /rosbag2_recorder/snapshot rosbag2_interfaces/Snapshot
```

Triggering a snapshot with a keyboard shortcut:
Expand All @@ -39,14 +39,14 @@ Triggering a snapshot with a keyboard shortcut:

* Modify `BaseWriterInterface` to include a pure virutal function `take_snapshot` to ensure that all future writers are compatible with snapshot mode.

* Implement the `~/snapshot` service interface as `TakeSnapshot.srv` in `rosbag2_interfaces`. It won’t require any arguments (similar to `Resume.srv`).
* Implement the `~/snapshot` service interface as `Snapshot.srv` in `rosbag2_interfaces`. It won’t require any arguments (similar to `Resume.srv`).


## Implementation Breakdown
The snapshot feature implementation could be broken down into the following PRs:

* Implement `CircularMessageCache` and `MessageCacheCircularBuffer`. Then add corresponding tests.
* Integrate `CircularMessageCache` into `SequentialWriter` and update its tests.
* Create the `~/snapshot` service in the `Recorder` class, add corresponding tests, and create the `TakeSnapshot.srv` service interface.
* Create the `~/snapshot` service in the `Recorder` class, add corresponding tests, and create the `Snapshot.srv` service interface.
* Add `--snapshot-mode` to the `record` verb and update `StorageOptions`
* Add keyboard shortcut for triggering a snapshot in snapshot mode
2 changes: 0 additions & 2 deletions rosbag2_cpp/include/rosbag2_cpp/writers/sequential_writer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,6 @@ class ROSBAG2_CPP_PUBLIC SequentialWriter
std::shared_ptr<rosbag2_cpp::cache::MessageCacheInterface> message_cache_;
std::unique_ptr<rosbag2_cpp::cache::CacheConsumer> cache_consumer_;

std::shared_ptr<rosbag2_cpp::cache::CircularMessageCache> circular_message_cache_;

void switch_to_next_storage();

std::string format_storage_uri(
Expand Down
10 changes: 7 additions & 3 deletions rosbag2_py/src/rosbag2_py/_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,15 @@ PYBIND11_MODULE(_storage, m) {
pybind11::class_<rosbag2_storage::StorageOptions>(m, "StorageOptions")
.def(
pybind11::init<
std::string, std::string, uint64_t, uint64_t, uint64_t, std::string, std::string>(),
std::string, std::string, uint64_t, uint64_t, uint64_t, std::string, std::string, bool>(),
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,
pybind11::arg("storage_preset_profile") = "",
pybind11::arg("storage_config_uri") = "")
pybind11::arg("storage_config_uri") = "",
pybind11::arg("snapshot_mode") = false)
.def_readwrite("uri", &rosbag2_storage::StorageOptions::uri)
.def_readwrite("storage_id", &rosbag2_storage::StorageOptions::storage_id)
.def_readwrite(
Expand All @@ -67,7 +68,10 @@ PYBIND11_MODULE(_storage, m) {
&rosbag2_storage::StorageOptions::storage_preset_profile)
.def_readwrite(
"storage_config_uri",
&rosbag2_storage::StorageOptions::storage_config_uri);
&rosbag2_storage::StorageOptions::storage_config_uri)
.def_readwrite(
"snapshot_mode",
&rosbag2_storage::StorageOptions::snapshot_mode);

pybind11::class_<rosbag2_storage::StorageFilter>(m, "StorageFilter")
.def(
Expand Down
9 changes: 0 additions & 9 deletions rosbag2_transport/src/rosbag2_transport/recorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,6 @@ Recorder::Recorder(
record_options_(record_options),
stop_discovery_(record_options_.is_discovery_disabled)
{
srv_snapshot_ = create_service<rosbag2_interfaces::srv::Snapshot>(
"~/snapshot",
[this](
const std::shared_ptr<rmw_request_id_t>/* request_header */,
const std::shared_ptr<rosbag2_interfaces::srv::Snapshot::Request>/* request */,
const std::shared_ptr<rosbag2_interfaces::srv::Snapshot::Response>/* response */)
{
writer_->take_snapshot();
});
}

Recorder::~Recorder()
Expand Down

0 comments on commit 79b4362

Please sign in to comment.