timespec_substract function slightly changed value in start time structure,
(it puts negative value in start time nsec variable) which causes problem when WAIT macro (clock_nanosleep function) was called again.
float robot_current_time()
{
- struct timespec now, diff;
+ struct timespec now, diff, start_local;
+ start_local = start;
clock_gettime(CLOCK_MONOTONIC, &now);
- timespec_subtract(&diff, &now, &start);
+ timespec_subtract(&diff, &now, &start_local);
return diff.tv_sec + diff.tv_nsec/1000000000.0;
}