-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add SplitBagfile recording service. (#1115)
* feat(rosbag2_cpp): Add SplitBagfile recording service. Fixes #1087 Tested from the command line and verified that below command closed one log file and opened another. ros2 service call /rosbag2_recorder/split_bagfile rosbag2_interfaces/srv/SplitBagfile Signed-off-by: Rick Shanor rshanor <[email protected]> * feat(rosbag2_cpp): Add unit tests for SplitBagfile feature. Also address PR comments from @MichaelOrlov and deal with rebase merge conflicts. Signed-off-by: Rick Shanor rshanor <[email protected]> * fix(rosbag2_cpp): Remove unnecessary ManualSplitSequentialWriter. After making split_bagfile public, this class was no longer necessary. Signed-off-by: Rick Shanor rshanor <[email protected]> * ci(rosbag2_transport): Mark test_record_services as xfail. Signed-off-by: Rick Shanor rshanor <[email protected]> Signed-off-by: Rick Shanor rshanor <[email protected]> (cherry picked from commit e6f7fd7) # Conflicts: # rosbag2_cpp/src/rosbag2_cpp/writer.cpp # rosbag2_cpp/test/rosbag2_cpp/fake_data.cpp # rosbag2_cpp/test/rosbag2_cpp/fake_data.hpp # rosbag2_interfaces/CMakeLists.txt # rosbag2_transport/CMakeLists.txt
- Loading branch information
1 parent
b71944a
commit b69b5ff
Showing
13 changed files
with
196 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright 2022, Foxglove Technologies. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include <memory> | ||
#include <string> | ||
#include <utility> | ||
#include <vector> | ||
|
||
#include "fake_data.hpp" | ||
|
||
#include "rosbag2_storage/ros_helper.hpp" | ||
|
||
void write_sample_split_bag( | ||
const rosbag2_storage::StorageOptions & storage_options, | ||
const std::vector<std::pair<rcutils_time_point_value_t, uint32_t>> & fake_messages, | ||
size_t split_every) | ||
{ | ||
std::string topic_name = "testtopic"; | ||
|
||
rosbag2_cpp::writers::SequentialWriter writer{}; | ||
writer.open(storage_options, rosbag2_cpp::ConverterOptions{}); | ||
writer.create_topic( | ||
{ | ||
topic_name, | ||
"test_msgs/ByteMultiArray", | ||
"cdr", | ||
"" | ||
}); | ||
for (size_t i = 0; i < fake_messages.size(); i++) { | ||
if (i > 0 && (i % split_every == 0)) { | ||
writer.split_bagfile(); | ||
} | ||
|
||
const auto message = fake_messages[i]; | ||
rcutils_time_point_value_t time_stamp = message.first; | ||
uint32_t value = message.second; | ||
|
||
auto msg = std::make_shared<rosbag2_storage::SerializedBagMessage>(); | ||
msg->serialized_data = rosbag2_storage::make_serialized_message(&value, sizeof(value)); | ||
msg->time_stamp = time_stamp; | ||
msg->topic_name = topic_name; | ||
writer.write(msg); | ||
} | ||
writer.close(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright 2022, Foxglove Technologies. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#ifndef ROSBAG2_CPP__FAKE_DATA_HPP_ | ||
#define ROSBAG2_CPP__FAKE_DATA_HPP_ | ||
|
||
#include <utility> | ||
#include <vector> | ||
|
||
#include "rosbag2_cpp/writers/sequential_writer.hpp" | ||
|
||
// Write vector of <timestamp, uint32_data_value> pairs to bag files, splitting every N messages | ||
void write_sample_split_bag( | ||
const rosbag2_storage::StorageOptions & storage_options, | ||
const std::vector<std::pair<rcutils_time_point_value_t, uint32_t>> & fake_messages, | ||
size_t split_every); | ||
|
||
#endif // ROSBAG2_CPP__FAKE_DATA_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters