From: petr Date: Mon, 7 May 2012 21:48:20 +0000 (+0200) Subject: Odometry autocalibration X-Git-Url: http://rtime.felk.cvut.cz/gitweb/eurobot/public.git/commitdiff_plain/4c7554fa70022b7a485a6dad66564394b84da159?hp=b6d168ef35f00341799d5ed63b1d25633031ff17 Odometry autocalibration Updated saving calibration data for better reading. Left column for left odometry wheel and right for right odometry wheel. --- diff --git a/src/robofsm/common-states.cc b/src/robofsm/common-states.cc index 8914ecfe..7556727b 100644 --- a/src/robofsm/common-states.cc +++ b/src/robofsm/common-states.cc @@ -451,7 +451,7 @@ FSM_STATE(go_back_for_cal) file = fopen ("odometry_cal_data","a+"); sprintf(buffer, "%4.4f", -1/x1); fputs (buffer,file); - fputs ("\n", file); + fputs (" ", file); sprintf(buffer, "%4.4f", -1/y1); fputs (buffer,file); fputs ("\n", file); diff --git a/src/robofsm/robot.c b/src/robofsm/robot.c index c4fc0346..57e690a8 100644 --- a/src/robofsm/robot.c +++ b/src/robofsm/robot.c @@ -300,14 +300,14 @@ void robot_calibrate_odometry() fprintf(stderr, "File not found. \n\n"); return; } - char line [10]; + char line [15]; float a = 0; float b = 0; int num = 0; - while (fgets (line, 10 , file)) { - a += atof(line); - fgets (line, 10 , file); - b += atof(line); + while (fgets (line, 15 , file)) { + a += atof(strtok(line," ")); + fgets (line, 15 , file); + b += atof(strtok(NULL," ")); num ++; } fclose (file);