added a matlab writer for trial history

This commit is contained in:
Johannes Reinhardt 2008-07-12 11:32:41 +02:00
parent ac2574fe2a
commit 926427bda5
3 changed files with 23 additions and 0 deletions

View File

@ -172,7 +172,28 @@ void trial_print(trial *t){
/*perhaps add map_print and vehicle_print*/ /*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 */ /* debugging stuff */
void object_print(object *o){ void object_print(object *o){

View File

@ -91,6 +91,7 @@ void object_print(object *o);
void vehicle_print(vehicle *v); void vehicle_print(vehicle *v);
void telemetry_print(telemetry *t); void telemetry_print(telemetry *t);
void trial_print(trial *t); void trial_print(trial *t);
void trial_matlab(trial *t);
void map_print(map *m); void map_print(map *m);

View File

@ -32,6 +32,7 @@ int main(int argc, char **argv) {
} }
trial_loop(t); trial_loop(t);
trial_matlab(t);
trial_free(t); trial_free(t);