mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-06-30 10:00:36 +08:00
POSIX: use lockstep_scheduler to fake time
This integrates the lockstep_scheduler, so that the system time is set by the mavlink HIL_SENSOR message. This means that the speed factor is removed and the speed is entirely given by the simulator.
This commit is contained in:
@@ -384,19 +384,19 @@ extern "C" {
|
||||
|
||||
// Get the current time
|
||||
struct timespec ts;
|
||||
// FIXME: check if QURT should probably be using CLOCK_MONOTONIC
|
||||
px4_clock_gettime(CLOCK_REALTIME, &ts);
|
||||
// px4_sem_timedwait is implemented using CLOCK_MONOTONIC.
|
||||
px4_clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
|
||||
// Calculate an absolute time in the future
|
||||
const unsigned billion = (1000 * 1000 * 1000);
|
||||
unsigned tdiff = timeout;
|
||||
uint64_t nsecs = ts.tv_nsec + (tdiff * 1000 * 1000);
|
||||
uint64_t nsecs = ts.tv_nsec + (timeout * 1000 * 1000);
|
||||
ts.tv_sec += nsecs / billion;
|
||||
nsecs -= (nsecs / billion) * billion;
|
||||
ts.tv_nsec = nsecs;
|
||||
|
||||
// Execute a blocking wait for that time in the future
|
||||
errno = 0;
|
||||
|
||||
ret = px4_sem_timedwait(&sem, &ts);
|
||||
#ifndef __PX4_DARWIN
|
||||
ret = errno;
|
||||
|
||||
Reference in New Issue
Block a user