#include "control.h" #include #define LATENCY 20 static double fixdir(double a) { if (a < 0) a += 360; else if (a > 360) a -= 360; return a; } void simulate(trial *t) { double move, angle; timestamp now = getcurts(t) + LATENCY, diff = now - t->sim.ts; if (diff < 20) return; /* move = t->sim.vehicle.speed / 1000 * diff; angle = t->sim.vehicle.dir*M_PI/180; t->sim.vehicle.x += cos(angle)*move; t->sim.vehicle.y += sin(angle)*move;*/ /* switch (t->sim.vehicle.turn) { case TURN_HARD_LEFT : t->sim.vehicle.dir = fixdir(t->sim.vehicle.dir + t->map.max_hard_turn); break; case TURN_LEFT : t->sim.vehicle.dir = fixdir(t->sim.vehicle.dir + t->map.max_turn); break; case TURN_STRAIGHT : break; case TURN_RIGHT : t->sim.vehicle.dir = fixdir(t->sim.vehicle.dir - t->map.max_turn); break; case TURN_HARD_RIGHT: t->sim.vehicle.dir = fixdir(t->sim.vehicle.dir - t->map.max_hard_turn); break; } t->sim.vehicle.accel = t->vehicle.accel; t->sim.vehicle.turn = t->vehicle.turn;*/ }