This commit is contained in:
Stefan Bühler 2008-07-13 23:36:04 +02:00
parent 3ab78db7f5
commit b0297bc1f0
2 changed files with 15 additions and 11 deletions

View File

@ -69,7 +69,7 @@ void fit_parameter(telemetry* t1, telemetry* t2, telemetry* t3, map* m){
void radar_dgl(trial* t, timestamp ts){
timestamp step = ts- t->sim.tm.ts;
if (step > 0){
dgl(t,&t->sim.tm.vehicle,&t->sim.tm.vehicle,step,1);
dgl(t,&t->sim.tm.vehicle,&t->sim.tm.vehicle,1,step);
t->sim.tm.ts += step;
t->sim.steps++;
}
@ -90,6 +90,7 @@ void sim_update(trial* t){
t->sim.tm.vehicle.y - t->vehicle.y,
t->sim.tm.vehicle.dir - t->vehicle.dir,
t->sim.steps);
// fprintf(stderr, "w = %f, dir = %f\n", t->sim.tm.vehicle.w, t->sim.tm.vehicle.dir);
/*update simulation vehicle from telemetry: everything and calculate w*/
t->sim.tm.vehicle = tm->vehicle;
@ -100,6 +101,7 @@ void sim_update(trial* t){
tmp = (telemetry*) g_queue_peek_tail_link(&t->telemetry)->prev->data;
t->sim.tm.vehicle.w = (tm->vehicle.dir - tmp->vehicle.dir)/(tm->ts - tmp->ts);
}
// fprintf(stderr, "w = %f, dir = %f\n", t->sim.tm.vehicle.w, t->sim.tm.vehicle.dir);
}
int dgl(trial* t, vehicle* after, vehicle* before, timestamp h, timestamp deltat){
@ -122,18 +124,20 @@ int dgl(trial* t, vehicle* after, vehicle* before, timestamp h, timestamp deltat
aw *= (before->w > wsoll) ? -1 : 1;
for(i = 0;i<=end;i++){
if(i == end) dt = deltat - (end-1)*dt;
if(i == end) dt = deltat - end*dt;
/*calculate derivative*/
diff.x = cos(tmp.dir)*tmp.speed/1000;
diff.y = sin(tmp.dir)*tmp.speed/1000;
diff.speed = fmax(-tmp.speed,a - k*tmp.speed*tmp.speed*1e-6);
diff.speed = a - k*tmp.speed*tmp.speed*1e-6;
// diff.speed = fmax(-tmp.speed/1000,a - k*tmp.speed*tmp.speed*1e-6);
diff.w = (tmp.w == wsoll) ? 0 : aw;
diff.dir = tmp.w;
/*Euler Step*/
tmp.x += dt*diff.x;
tmp.y += dt*diff.y;
tmp.speed += (tmp.speed > 0) ? dt*diff.speed : 0;
// tmp.speed += (tmp.speed > 0) ? 1000*dt*diff.speed : 0;
tmp.speed = fmax(0, tmp.speed + dt*1000*diff.speed);
tmp.w += dt*diff.w;
tmp.dir += dt*diff.dir;
@ -141,10 +145,10 @@ int dgl(trial* t, vehicle* after, vehicle* before, timestamp h, timestamp deltat
collision.x = tmp.x;
collision.y = tmp.y;
collision.collision = 0;
g_hash_table_foreach(t->map.solid_objects,check_coll,&collision);
if(collision.collision){
return -1;
}
// g_hash_table_foreach(t->map.solid_objects,check_coll,&collision);
// if(collision.collision){
// return -1;
// }
}

View File

@ -33,9 +33,9 @@ void trial_loop(trial *t) {
}
while (t->alive) {
radar_dgl(t, getcurts(t) + LATENCY);
// goradar(t);
vehicle_break(t);
vehicle_hard_right(t);
goradar(t);
// vehicle_break(t);
// vehicle_hard_right(t);
if (-1 == trial_check_input(t)) return;
// if (-1 == trial_wait_for_input(t)) return;
}