mirror of
https://github.com/orbbec/OrbbecSDK_ROS2.git
synced 2026-10-10 06:29:50 +08:00
fix: restart playback streams on loop
This commit is contained in:
@@ -192,6 +192,8 @@ class OBCameraNode {
|
|||||||
|
|
||||||
void startIMU();
|
void startIMU();
|
||||||
|
|
||||||
|
void restartPlaybackStreams();
|
||||||
|
|
||||||
int openSocSyncPwmTrigger(uint16_t fps);
|
int openSocSyncPwmTrigger(uint16_t fps);
|
||||||
int closeSocSyncPwmTrigger();
|
int closeSocSyncPwmTrigger();
|
||||||
void startGmslTrigger();
|
void startGmslTrigger();
|
||||||
|
|||||||
@@ -3303,6 +3303,26 @@ void OBCameraNode::startIMU() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OBCameraNode::restartPlaybackStreams() {
|
||||||
|
if (!is_playback_device_ || !is_running_.load()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
stopStreams();
|
||||||
|
startStreams();
|
||||||
|
stopIMU();
|
||||||
|
startIMU();
|
||||||
|
} catch (const ob::Error &e) {
|
||||||
|
RCLCPP_WARN_STREAM(logger_, "Failed to restart playback streams: "
|
||||||
|
<< orbbec_camera::formatObErrorWithStatus(e));
|
||||||
|
} catch (const std::exception &e) {
|
||||||
|
RCLCPP_WARN_STREAM(logger_, "Failed to restart playback streams: " << e.what());
|
||||||
|
} catch (...) {
|
||||||
|
RCLCPP_WARN_STREAM(logger_, "Failed to restart playback streams");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void OBCameraNode::stopStreams() {
|
void OBCameraNode::stopStreams() {
|
||||||
std::lock_guard<decltype(device_lock_)> lock(device_lock_);
|
std::lock_guard<decltype(device_lock_)> lock(device_lock_);
|
||||||
|
|
||||||
|
|||||||
@@ -1023,7 +1023,7 @@ void OBCameraNodeDriver::initializeBagPlayback() {
|
|||||||
try {
|
try {
|
||||||
playback_device_->seek(0);
|
playback_device_->seek(0);
|
||||||
if (ob_camera_node_) {
|
if (ob_camera_node_) {
|
||||||
ob_camera_node_->startStreams();
|
ob_camera_node_->restartPlaybackStreams();
|
||||||
}
|
}
|
||||||
} catch (const ob::Error &e) {
|
} catch (const ob::Error &e) {
|
||||||
RCLCPP_WARN_STREAM(logger_, "Failed to restart bag playback: "
|
RCLCPP_WARN_STREAM(logger_, "Failed to restart bag playback: "
|
||||||
|
|||||||
Reference in New Issue
Block a user