mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-09-25 15:36:01 +08:00
gz: set realtime clock at startup (#24530)
This commit is contained in:
@@ -182,7 +182,16 @@ void GZBridge::clockCallback(const gz::msgs::Clock &msg)
|
||||
struct timespec ts;
|
||||
ts.tv_sec = msg.sim().sec();
|
||||
ts.tv_nsec = msg.sim().nsec();
|
||||
px4_clock_settime(CLOCK_MONOTONIC, &ts);
|
||||
|
||||
if (!_realtime_clock_set) {
|
||||
// Set initial real time clock at startup
|
||||
px4_clock_settime(CLOCK_REALTIME, &ts);
|
||||
_realtime_clock_set = true;
|
||||
|
||||
} else {
|
||||
// Keep monotonic clock synchronized
|
||||
px4_clock_settime(CLOCK_MONOTONIC, &ts);
|
||||
}
|
||||
}
|
||||
|
||||
void GZBridge::opticalFlowCallback(const px4::msgs::OpticalFlow &msg)
|
||||
|
||||
@@ -162,6 +162,7 @@ private:
|
||||
|
||||
float _temperature{288.15}; // 15 degrees
|
||||
|
||||
bool _realtime_clock_set{false};
|
||||
gz::transport::Node _node;
|
||||
|
||||
// GPS noise model
|
||||
|
||||
Reference in New Issue
Block a user