diff --git a/src/control.c b/src/control.c index ab14c3e..6dff617 100644 --- a/src/control.c +++ b/src/control.c @@ -207,15 +207,13 @@ void trial_print(trial *t){ } void telemetry_matlab(gpointer tele, gpointer file){ - FILE* outfile; telemetry* t; - vehicle * v; - - outfile = (FILE*) file; t = (telemetry*) tele; - v = &t->vehicle; + vehicle_matlab((FILE*) file,t->ts,&t->vehicle); +} - fprintf(outfile,"v(end+1,:) = [%d %f, %f, %f, %f];\n",t->ts,v->x,v->y,v->dir,v->speed); +void vehicle_matlab(FILE* out, timestamp ts, vehicle* v){ + fprintf(out,"v(end+1,:) = [%d %f, %f, %f, %f];\n",ts,v->x,v->y,v->dir,v->speed); } /*prints coordinate history to matlab compatible file*/ diff --git a/src/control.h b/src/control.h index 6a03530..8b9ec30 100644 --- a/src/control.h +++ b/src/control.h @@ -115,6 +115,7 @@ object* object_new(object_t type, double x, double y, double rad, double dir, do /* debugging stuff */ void object_print(object *o); void vehicle_print(vehicle *v); +void vehicle_matlab(FILE* out,timestamp ts, vehicle* v); void telemetry_print(telemetry *t); void trial_print(trial *t); void trial_matlab(trial *t); diff --git a/src/radar_main.c b/src/radar_main.c index 8484dbb..104f8c6 100644 --- a/src/radar_main.c +++ b/src/radar_main.c @@ -7,7 +7,11 @@ #define LATENCY 2 void trial_loop(trial *t) { + FILE* sim; + char name[80]; do { + sprintf(name,"simulation%d.m",t->runcnt); + sim = fopen(name,"w"); if (-1 == trial_wait_for_start(t)) return; if (t->finished) break; if (t->runcnt == 0) { @@ -33,6 +37,7 @@ void trial_loop(trial *t) { } while (t->alive) { radar_dgl(t, getcurts(t) + LATENCY); + vehicle_matlab(sim,t->sim.tm.ts,&t->sim.tm.vehicle); // goradar(t); vehicle_break(t); vehicle_hard_right(t); @@ -40,6 +45,7 @@ void trial_loop(trial *t) { // if (-1 == trial_wait_for_input(t)) return; } trial_reset_run(t); + fclose(sim); } while (!t->finished); }