Cleanup + fixes

This commit is contained in:
Stefan Bühler 2008-07-13 22:05:06 +02:00
parent e6f30c948c
commit 61a094fed5
3 changed files with 19 additions and 5 deletions

View File

@ -1,17 +1,18 @@
#include "control.h"
#include "lookahead.h"
#include <stdio.h>
#include <math.h>
double turn2w(trial* t, turn_t turn){
double turn2w(trial* t, turn_t turn) {
switch(turn){
case(TURN_HARD_LEFT): return t->map.max_hard_turn/1000.0;
case(TURN_LEFT): return t->map.max_turn/1000.0;
case(TURN_STRAIGHT): return 0;
case(TURN_RIGHT): return -t->map.max_turn/1000.0;
case(TURN_HARD_RIGHT): return -t->map.max_hard_turn/1000.0;
fprintf(stderr,"Unknown turn state in turn2w\n");
return 0;
default:
fprintf(stderr,"Unknown turn state in turn2w\n");
return 0;
}
}
@ -24,6 +25,8 @@ void check_coll(gpointer key, gpointer value, gpointer ud){
struct collcheck* coll;
object* ob;
UNUSED(key);
coll = (struct collcheck*) ud;
ob = (object*) value;

10
src/lookahead.h Normal file
View File

@ -0,0 +1,10 @@
#ifndef _LOOKAHEAD_H
#define _LOOKAHEAD_H
#include "control.h"
double turn2w(trial* t, turn_t turn);
void fit_parameter(telemetry* t1, telemetry* t2, telemetry* t3, map* m);
int dgl(trial* t, vehicle* after, vehicle* before, timestamp h, timestamp deltat);
#endif

View File

@ -1,5 +1,6 @@
#include "control.h"
#include "lookahead.h"
#include <stdio.h>
@ -33,7 +34,7 @@ void trial_loop(trial *t) {
while (t->alive) {
timestamp step=getcurts(t) + LATENCY - t->sim.tm.ts;
t->sim.tm.vehicle.w = turn2w(t->sim.tm.vehicle.turn);
t->sim.tm.vehicle.w = turn2w(t, t->sim.tm.vehicle.turn);
dgl(t,&t->sim.tm.vehicle,&t->sim.tm.vehicle,step,step);
t->sim.steps++;