xxx
This commit is contained in:
parent
3ab78db7f5
commit
b0297bc1f0
@ -69,7 +69,7 @@ void fit_parameter(telemetry* t1, telemetry* t2, telemetry* t3, map* m){
|
|||||||
void radar_dgl(trial* t, timestamp ts){
|
void radar_dgl(trial* t, timestamp ts){
|
||||||
timestamp step = ts- t->sim.tm.ts;
|
timestamp step = ts- t->sim.tm.ts;
|
||||||
if (step > 0){
|
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.tm.ts += step;
|
||||||
t->sim.steps++;
|
t->sim.steps++;
|
||||||
}
|
}
|
||||||
@ -90,6 +90,7 @@ void sim_update(trial* t){
|
|||||||
t->sim.tm.vehicle.y - t->vehicle.y,
|
t->sim.tm.vehicle.y - t->vehicle.y,
|
||||||
t->sim.tm.vehicle.dir - t->vehicle.dir,
|
t->sim.tm.vehicle.dir - t->vehicle.dir,
|
||||||
t->sim.steps);
|
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*/
|
/*update simulation vehicle from telemetry: everything and calculate w*/
|
||||||
t->sim.tm.vehicle = tm->vehicle;
|
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;
|
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);
|
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){
|
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;
|
aw *= (before->w > wsoll) ? -1 : 1;
|
||||||
|
|
||||||
for(i = 0;i<=end;i++){
|
for(i = 0;i<=end;i++){
|
||||||
if(i == end) dt = deltat - (end-1)*dt;
|
if(i == end) dt = deltat - end*dt;
|
||||||
|
|
||||||
/*calculate derivative*/
|
/*calculate derivative*/
|
||||||
diff.x = cos(tmp.dir)*tmp.speed/1000;
|
diff.x = cos(tmp.dir)*tmp.speed/1000;
|
||||||
diff.y = sin(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.w = (tmp.w == wsoll) ? 0 : aw;
|
||||||
diff.dir = tmp.w;
|
diff.dir = tmp.w;
|
||||||
/*Euler Step*/
|
/*Euler Step*/
|
||||||
tmp.x += dt*diff.x;
|
tmp.x += dt*diff.x;
|
||||||
tmp.y += dt*diff.y;
|
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.w += dt*diff.w;
|
||||||
tmp.dir += dt*diff.dir;
|
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.x = tmp.x;
|
||||||
collision.y = tmp.y;
|
collision.y = tmp.y;
|
||||||
collision.collision = 0;
|
collision.collision = 0;
|
||||||
g_hash_table_foreach(t->map.solid_objects,check_coll,&collision);
|
// g_hash_table_foreach(t->map.solid_objects,check_coll,&collision);
|
||||||
if(collision.collision){
|
// if(collision.collision){
|
||||||
return -1;
|
// return -1;
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,9 +33,9 @@ void trial_loop(trial *t) {
|
|||||||
}
|
}
|
||||||
while (t->alive) {
|
while (t->alive) {
|
||||||
radar_dgl(t, getcurts(t) + LATENCY);
|
radar_dgl(t, getcurts(t) + LATENCY);
|
||||||
// goradar(t);
|
goradar(t);
|
||||||
vehicle_break(t);
|
// vehicle_break(t);
|
||||||
vehicle_hard_right(t);
|
// vehicle_hard_right(t);
|
||||||
if (-1 == trial_check_input(t)) return;
|
if (-1 == trial_check_input(t)) return;
|
||||||
// if (-1 == trial_wait_for_input(t)) return;
|
// if (-1 == trial_wait_for_input(t)) return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user