pr0n!
This commit is contained in:
parent
b835ace69f
commit
66d5b5f065
@ -133,6 +133,8 @@ INLINE void vehicle_right(trial *t);
|
|||||||
INLINE void vehicle_hard_right(trial *t);
|
INLINE void vehicle_hard_right(trial *t);
|
||||||
|
|
||||||
INLINE timestamp getcurts(trial *t);
|
INLINE timestamp getcurts(trial *t);
|
||||||
|
INLINE double fixangle(double a);
|
||||||
|
INLINE double fixdirection(double a);
|
||||||
|
|
||||||
/* needed by parser */
|
/* needed by parser */
|
||||||
telemetry* telemetry_new();
|
telemetry* telemetry_new();
|
||||||
@ -229,4 +231,16 @@ INLINE timestamp getcurts(trial *t) {
|
|||||||
return ts;
|
return ts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
INLINE double fixangle(double a) {
|
||||||
|
while (a < -180) a += 360;
|
||||||
|
while (a > 180) a -= 360;
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
INLINE double fixdirection(double a) {
|
||||||
|
while (a < 0) a += 360;
|
||||||
|
while (a > 360) a -= 360;
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -49,8 +49,8 @@ void fit_parameter(telemetry* t1, telemetry* t2, telemetry* t3, map* m){
|
|||||||
dt1 = (t2->ts - t1->ts);
|
dt1 = (t2->ts - t1->ts);
|
||||||
dt2 = (t3->ts - t2->ts);
|
dt2 = (t3->ts - t2->ts);
|
||||||
|
|
||||||
a1 = (v2->speed - v1->speed)/dt1;
|
a1 = 1000*(v2->speed - v1->speed)/dt1;
|
||||||
a2 = (v3->speed - v2->speed)/dt2;
|
a2 = 1000*(v3->speed - v2->speed)/dt2;
|
||||||
|
|
||||||
if(a1/a2 > 1.1 || a1/a2 < 0.9){
|
if(a1/a2 > 1.1 || a1/a2 < 0.9){
|
||||||
fprintf(stderr,"Inconsistent accelerations: a1: %f a2: %f. inaccurate results possible\n",a1,a2);
|
fprintf(stderr,"Inconsistent accelerations: a1: %f a2: %f. inaccurate results possible\n",a1,a2);
|
||||||
@ -91,6 +91,7 @@ void sim_update(trial* t){
|
|||||||
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);
|
// fprintf(stderr, "w = %f, dir = %f\n", t->sim.tm.vehicle.w, t->sim.tm.vehicle.dir);
|
||||||
|
fprintf(stderr, "speed = %f\n", t->sim.tm.vehicle.speed);
|
||||||
|
|
||||||
/*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;
|
||||||
@ -102,6 +103,7 @@ void sim_update(trial* t){
|
|||||||
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);
|
// fprintf(stderr, "w = %f, dir = %f\n", t->sim.tm.vehicle.w, t->sim.tm.vehicle.dir);
|
||||||
|
fprintf(stderr, "speed = %f\n", t->sim.tm.vehicle.speed);
|
||||||
}
|
}
|
||||||
|
|
||||||
int dgl(trial* t, vehicle* after, vehicle* before, timestamp h, timestamp deltat){
|
int dgl(trial* t, vehicle* after, vehicle* before, timestamp h, timestamp deltat){
|
||||||
@ -118,18 +120,17 @@ int dgl(trial* t, vehicle* after, vehicle* before, timestamp h, timestamp deltat
|
|||||||
|
|
||||||
a = t->map.a;
|
a = t->map.a;
|
||||||
k = t->map.k;
|
k = t->map.k;
|
||||||
aw = t->map.aw;
|
|
||||||
|
|
||||||
wsoll = turn2w(t,before->turn);
|
wsoll = turn2w(t,before->turn);
|
||||||
aw *= (before->w > wsoll) ? -1 : 1;
|
|
||||||
|
|
||||||
for(i = 0;i<=end;i++){
|
for(i = 0;i<=end;i++){
|
||||||
if(i == end) dt = deltat - end*dt;
|
if(i == end) dt = deltat - end*dt;
|
||||||
|
aw = t->map.aw * ((before->w > wsoll) ? -1 : 1);
|
||||||
|
|
||||||
/*calculate derivative*/
|
/*calculate derivative*/
|
||||||
diff.x = cos(tmp.dir)*tmp.speed/1000;
|
diff.x = cos(tmp.dir*M_PI/180)*tmp.speed/1000;
|
||||||
diff.y = sin(tmp.dir)*tmp.speed/1000;
|
diff.y = sin(tmp.dir*M_PI/180)*tmp.speed/1000;
|
||||||
diff.speed = a - k*tmp.speed*tmp.speed*1e-6;
|
diff.speed = a - k*tmp.speed*tmp.speed;
|
||||||
// diff.speed = fmax(-tmp.speed/1000,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;
|
||||||
@ -137,7 +138,7 @@ int dgl(trial* t, vehicle* after, vehicle* before, timestamp h, timestamp deltat
|
|||||||
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) ? 1000*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.speed = fmax(0, tmp.speed + dt*diff.speed);
|
||||||
tmp.w += dt*diff.w;
|
tmp.w += dt*diff.w;
|
||||||
tmp.dir += dt*diff.dir;
|
tmp.dir += dt*diff.dir;
|
||||||
|
|
||||||
@ -157,7 +158,7 @@ int dgl(trial* t, vehicle* after, vehicle* before, timestamp h, timestamp deltat
|
|||||||
after->y = tmp.y;
|
after->y = tmp.y;
|
||||||
after->speed = tmp.speed;
|
after->speed = tmp.speed;
|
||||||
after->w = tmp.w;
|
after->w = tmp.w;
|
||||||
after->dir = tmp.dir;
|
after->dir = fixdirection(tmp.dir);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,12 +27,6 @@ angle* angle_new(double a, int c) {
|
|||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
static double fixangle(double a) {
|
|
||||||
while (a < -180) a += 360;
|
|
||||||
while (a > 180) a -= 360;
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
|
|
||||||
int distance_weight(double distance) {
|
int distance_weight(double distance) {
|
||||||
if (distance > 50) {
|
if (distance > 50) {
|
||||||
if (distance > 150) return 0;
|
if (distance > 150) return 0;
|
||||||
|
@ -33,7 +33,6 @@ void trial_loop(trial *t) {
|
|||||||
(telemetry*) g_queue_peek_nth(&t->telemetry,4),
|
(telemetry*) g_queue_peek_nth(&t->telemetry,4),
|
||||||
&t->map);
|
&t->map);
|
||||||
fprintf(stderr,"Fitparameter: a: %f aw: %f k: %f\n",t->map.a,t->map.aw,t->map.k);
|
fprintf(stderr,"Fitparameter: a: %f aw: %f k: %f\n",t->map.a,t->map.aw,t->map.k);
|
||||||
|
|
||||||
}
|
}
|
||||||
while (t->alive) {
|
while (t->alive) {
|
||||||
radar_dgl(t, getcurts(t) + LATENCY);
|
radar_dgl(t, getcurts(t) + LATENCY);
|
||||||
|
Loading…
Reference in New Issue
Block a user