chore: Update time sync interface

This commit is contained in:
Joe Dong
2024-07-10 15:02:11 +08:00
parent fa520f95d0
commit f483a67ee2
3 changed files with 8 additions and 1 deletions
+2
View File
@@ -33,12 +33,14 @@ ir_exposure: 5000 # 5ms
ir_gain: 40
#left ir params
enable_left_ir: true
left_ir_width: 640
left_ir_height: 480
left_ir_fps: 60
left_ir_format: "Y8"
#right ir params
enable_right_ir: true
right_ir_width: 640
right_ir_height: 480
right_ir_fps: 60
@@ -83,6 +83,7 @@ class OBCameraNodeDriver : public rclcpp::Node {
std::recursive_mutex device_lock_;
int device_num_ = 1;
rclcpp::TimerBase::SharedPtr check_connect_timer_ = nullptr;
rclcpp::TimerBase::SharedPtr sync_host_time_timer_ = nullptr;
std::shared_ptr<std::thread> reset_device_thread_ = nullptr;
std::mutex reset_device_mutex_;
std::condition_variable reset_device_cond_;
+5 -1
View File
@@ -301,7 +301,11 @@ void OBCameraNodeDriver::initializeDevice(const std::shared_ptr<ob::Device> &dev
CHECK_NOTNULL(device_info_.get());
device_unique_id_ = device_info_->uid();
if (!isOpenNIDevice(device_info_->pid())) {
ctx_->enableDeviceClockSync(30000); // every 30s sync time
sync_host_time_timer_ = this->create_wall_timer(std::chrono::milliseconds(30000), [this]() {
if (device_) {
device_->timerSyncWithHost();
}
});
}
RCLCPP_INFO_STREAM(logger_, "Device " << device_info_->name() << " connected");
RCLCPP_INFO_STREAM(logger_, "Serial number: " << device_info_->serialNumber());