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:
Julian Oes
2018-10-15 15:00:29 +02:00
parent f0ce300744
commit 3e6e1f5c2b
5 changed files with 74 additions and 125 deletions
+4 -4
View File
@@ -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;