zhouquan1103
OAK4 currently uses E2E over UDP/IPv4.
Please ensure that the lidar and PTP grandmaster are configured for the same PTP domain and E2E UDP transport.
There is currently no direct DepthAI C++ variable that reports the PTP lock state.
With PTP_SYNC_SYSTEM_CLOCK=true, you can read the PTP-synchronized system timestamp from each frame:
auto timestamp = frame->getTimestampSystem();
if(timestamp.has_value()) {
auto nanoseconds =
std::chrono::duration_cast<std::chrono::nanoseconds>(
timestamp->time_since_epoch()
).count();
std::cout << "Timestamp: " << nanoseconds << " ns" << std::endl;
}
getTimestampSystem() returns the device system-clock timestamp, which can be synchronized by PTP. You can compare it with the timestamp from your lidar or GPS/PTP system to verify synchronization.
For frame synchronization, the C++ example checks the timestamp difference between devices and considers them synchronized when the difference is below the configured threshold:
https://github.com/luxonis/depthai-core/blob/main/examples/cpp/Misc/MultiDevice/multi_device_frame_sync.cpp
The relevant logic reads the frame timestamps, calculates the maximum timestamp difference, and reports whether the frames are in sync.
Please use DepthAI 3.8.0 or newer and Luxonis OS 1.35.0 or newer for the latest OAK4 PTP support.
Thank you,
Sašo