Fix crash by improving lock handling

This commit is contained in:
xiexun
2025-08-26 15:05:20 +08:00
parent 052b6c35eb
commit 755ac394d7
5 changed files with 179 additions and 15 deletions
@@ -42,5 +42,9 @@ class D2CViewer {
sensor_msgs::msg::Image>;
std::shared_ptr<message_filters::Synchronizer<MySyncPolicy>> sync_;
rclcpp::Publisher<sensor_msgs::msg::Image>::SharedPtr d2c_viewer_pub_;
// Add thread safety
std::mutex callback_mutex_;
std::atomic<bool> is_active_{true};
};
} // namespace orbbec_camera
@@ -87,6 +87,7 @@ class OBCameraNodeDriver : public rclcpp::Node {
std::shared_ptr<ob::DeviceInfo> device_info_ = nullptr;
std::atomic_bool is_alive_{false};
std::atomic_bool device_connected_{false};
std::atomic_bool device_connecting_{false};
std::string serial_number_;
std::string device_unique_id_;
std::string usb_port_;