From 926427bda5e353777a792110842dcf7d54e00b2d Mon Sep 17 00:00:00 2001 From: Johannes Reinhardt Date: Sat, 12 Jul 2008 11:32:41 +0200 Subject: [PATCH] added a matlab writer for trial history --- src/control.c | 21 +++++++++++++++++++++ src/control.h | 1 + src/main.c | 1 + 3 files changed, 23 insertions(+) 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 f13185a..b878ac5 100644 --- a/src/main.c +++ b/src/main.c @@ -32,6 +32,7 @@ int main(int argc, char **argv) { } trial_loop(t); + trial_matlab(t); trial_free(t);