Fix device disconnection after reboot service call

This commit is contained in:
xiexun
2025-08-13 17:58:38 +08:00
parent 97e7aa524d
commit d91db6b639
4 changed files with 28 additions and 8 deletions
@@ -158,6 +158,13 @@ class OBCameraNode {
void clean() noexcept;
// Safely expose the lock
template <typename Func>
auto withDeviceLock(Func &&func) -> decltype(func()) {
std::lock_guard<std::recursive_mutex> lock(device_lock_);
return func();
}
void rebootDevice();
void startStreams();
@@ -618,7 +625,7 @@ class OBCameraNode {
std::shared_ptr<JPEGDecoder> jpeg_decoder_ = nullptr;
uint8_t* rgb_buffer_ = nullptr;
bool is_color_frame_decoded_ = false;
std::mutex device_lock_;
std::recursive_mutex device_lock_;
// For color
std::queue<std::shared_ptr<ob::FrameSet>> color_frame_queue_;
std::shared_ptr<std::thread> colorFrameThread_ = nullptr;
@@ -118,5 +118,6 @@ class OBCameraNodeDriver : public rclcpp::Node {
std::string extension_path_;
static backward::SignalHandling sh; // for stack trace
std::string upgrade_firmware_;
std::atomic<bool> firmware_update_success_{false};
};
} // namespace orbbec_camera