mirror of
https://github.com/orbbec/OrbbecSDK_ROS2.git
synced 2026-09-13 03:30:18 +08:00
load bag preset JSON during playback
This commit is contained in:
@@ -1108,10 +1108,22 @@ void OBCameraNodeDriver::exportBagPresetJson(const std::string &bag_path) {
|
||||
void OBCameraNodeDriver::initializeBagPlayback() {
|
||||
RCLCPP_INFO_STREAM(logger_, "Starting bag file playback: " << bag_filename_);
|
||||
try {
|
||||
playback_device_ = std::make_shared<ob::PlaybackDevice>(bag_filename_);
|
||||
auto preset_path = std::filesystem::path(bag_filename_);
|
||||
if (preset_path.extension() == ".bag") {
|
||||
preset_path.replace_extension(".json");
|
||||
} else {
|
||||
preset_path += ".json";
|
||||
}
|
||||
|
||||
std::string preset_path_str;
|
||||
if (std::filesystem::is_regular_file(preset_path)) {
|
||||
preset_path_str = preset_path.string();
|
||||
RCLCPP_INFO_STREAM(logger_, "Loading bag preset JSON: " << preset_path_str);
|
||||
}
|
||||
playback_device_ = std::make_shared<ob::PlaybackDevice>(bag_filename_, preset_path_str);
|
||||
} catch (const ob::Error &e) {
|
||||
RCLCPP_ERROR_STREAM(logger_,
|
||||
"Failed to open bag file: " << orbbec_camera::formatObErrorWithStatus(e));
|
||||
RCLCPP_ERROR_STREAM(logger_, "Failed to initialize bag playback: "
|
||||
<< orbbec_camera::formatObErrorWithStatus(e));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user