This commit is contained in:
Stefan Bühler 2008-07-12 10:49:48 +02:00
parent 641ab17995
commit 9ae5931db7
4 changed files with 7 additions and 4 deletions

View File

@ -6,6 +6,7 @@
#include <unistd.h> #include <unistd.h>
#include <sys/time.h> #include <sys/time.h>
#include <glib.h> #include <glib.h>
#include <stdio.h>
#define INLINE static inline #define INLINE static inline
#define UNUSED(x) ((void)(x)) #define UNUSED(x) ((void)(x))
@ -192,7 +193,9 @@ INLINE void vehicle_hard_right(trial *t) {
INLINE timestamp getcurts(trial *t) { INLINE timestamp getcurts(trial *t) {
struct timeval tv; struct timeval tv;
gettimeofday(&tv, NULL); gettimeofday(&tv, NULL);
return (tv.tv_sec - t->started.tv_sec) * 1000 + (tv.tv_usec - t->started.tv_sec) / 1000; timestamp ts = (tv.tv_sec - t->started.tv_sec) * 1000 + (tv.tv_usec - t->started.tv_usec) / 1000;
printf("Timestamp: %u\n", ts);
return ts;
} }
#endif #endif

View File

@ -387,9 +387,9 @@ _match:
if (!t->alive) { if (!t->alive) {
t->vehicle.accel = ctx->tm->vehicle.accel; t->vehicle.accel = ctx->tm->vehicle.accel;
t->vehicle.turn = ctx->tm->vehicle.turn; t->vehicle.turn = ctx->tm->vehicle.turn;
gettimeofday(&t->started, NULL);
} }
t->last_ts = ctx->tm->ts; t->last_ts = ctx->tm->ts;
gettimeofday(&t->started, NULL);
ctx->tm = NULL; ctx->tm = NULL;
t->alive = 1; t->alive = 1;
} }

View File

@ -39,9 +39,9 @@ static timestamp extract_ts(context *ctx, char *fpc) {
if (!t->alive) { if (!t->alive) {
t->vehicle.accel = ctx->tm->vehicle.accel; t->vehicle.accel = ctx->tm->vehicle.accel;
t->vehicle.turn = ctx->tm->vehicle.turn; t->vehicle.turn = ctx->tm->vehicle.turn;
gettimeofday(&t->started, NULL);
} }
t->last_ts = ctx->tm->ts; t->last_ts = ctx->tm->ts;
gettimeofday(&t->started, NULL);
ctx->tm = NULL; ctx->tm = NULL;
t->alive = 1; t->alive = 1;
} }

View File

@ -59,7 +59,7 @@ void path_execute(trial* t,path* p){
return; return;
} }
now = timestamp_get_curts(t); now = getcurts(t);
/*fprintf(stderr,"Now: %d TS: %d\n",now,clock());*/ /*fprintf(stderr,"Now: %d TS: %d\n",now,clock());*/
/*magic number for latency, send messages that much earlier*/ /*magic number for latency, send messages that much earlier*/
while(tmp != NULL && now - 20 > tmp->ts){ while(tmp != NULL && now - 20 > tmp->ts){