mirror of
https://github.com/orbbec/OrbbecSDK_ROS2.git
synced 2026-10-10 06:29:50 +08:00
fix: avoid host time sync on unsupported devices
This commit is contained in:
@@ -151,6 +151,8 @@ rmw_qos_profile_t getRMWQosProfileFromString(const std::string& str_qos);
|
||||
|
||||
bool isOpenNIDevice(int pid);
|
||||
|
||||
bool isHostTimeSyncSupported(int pid);
|
||||
|
||||
OB_DEPTH_PRECISION_LEVEL depthPrecisionLevelFromString(
|
||||
const std::string& depth_precision_level_str);
|
||||
|
||||
|
||||
@@ -435,7 +435,7 @@ void OBCameraNodeDriver::initializeDevice(const std::shared_ptr<ob::Device> &dev
|
||||
serial_number_ = device_info_->serialNumber();
|
||||
CHECK_NOTNULL(device_info_.get());
|
||||
device_unique_id_ = device_info_->uid();
|
||||
if (enable_sync_host_time_ && !isOpenNIDevice(device_info_->pid())) {
|
||||
if (enable_sync_host_time_ && isHostTimeSyncSupported(device_info_->pid())) {
|
||||
TRY_EXECUTE_BLOCK(device_->timerSyncWithHost());
|
||||
sync_host_time_timer_ = this->create_wall_timer(std::chrono::milliseconds(30000), [this]() {
|
||||
if (device_) {
|
||||
|
||||
@@ -471,6 +471,16 @@ bool isOpenNIDevice(int pid) {
|
||||
[pid](int pid_openni) { return pid == pid_openni; });
|
||||
}
|
||||
|
||||
bool isHostTimeSyncSupported(int pid) {
|
||||
static const std::vector<int> UNSUPPORTED_DEVICE_PIDS = {0x069d};
|
||||
|
||||
if (isOpenNIDevice(pid)) {
|
||||
return false;
|
||||
}
|
||||
return std::none_of(UNSUPPORTED_DEVICE_PIDS.begin(), UNSUPPORTED_DEVICE_PIDS.end(),
|
||||
[pid](int unsupported_pid) { return pid == unsupported_pid; });
|
||||
}
|
||||
|
||||
OB_DEPTH_PRECISION_LEVEL depthPrecisionLevelFromString(
|
||||
const std::string &depth_precision_level_str) {
|
||||
if (depth_precision_level_str == "1mm") {
|
||||
|
||||
Reference in New Issue
Block a user