diff --git a/src/control.c b/src/control.c index e485e56..ddd0698 100644 --- a/src/control.c +++ b/src/control.c @@ -172,7 +172,28 @@ void trial_print(trial *t){ /*perhaps add map_print and vehicle_print*/ } +void telemetry_matlab(gpointer tele, gpointer file){ + FILE* outfile; + telemetry* t; + vehicle * v; + + outfile = (FILE*) file; + t = (telemetry*) tele; + v = &t->vehicle; + fprintf(outfile,"v(end+1,:) = [%d %f, %f, %f, %f];\n",t->ts,v->x,v->y,v->dir,v->speed); +} + +/*prints coordinate history to matlab compatible file*/ +void trial_matlab(trial *t){ + FILE* outfile; + + outfile = fopen("velocity.m","w"); + fprintf(outfile,"v = [];\n"); + g_queue_foreach(&t->telemetry,telemetry_matlab,outfile); + fclose(outfile); +} + /* debugging stuff */ void object_print(object *o){ diff --git a/src/control.h b/src/control.h index 44edc4c..b8ae078 100644 --- a/src/control.h +++ b/src/control.h @@ -91,6 +91,7 @@ void object_print(object *o); void vehicle_print(vehicle *v); void telemetry_print(telemetry *t); void trial_print(trial *t); +void trial_matlab(trial *t); void map_print(map *m); diff --git a/src/main.c b/src/main.c index 56b937c..18d484d 100644 --- a/src/main.c +++ b/src/main.c @@ -33,6 +33,7 @@ int main(int argc, char **argv) { } trial_loop(t); + trial_matlab(t); trial_free(t);