00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "GT2005KickLogger.h"
00010 #include <stdio.h>
00011
00012 GT2005KickLogger::GT2005KickLogger()
00013 {
00014 }
00015
00016 void GT2005KickLogger::addResult(GT2005KickRecord& r)
00017 {
00018 std::list<GT2005KickRecord>::iterator i=findInsertPos(r.direction);
00019
00020 GT2005KickRecord item=r;
00021 item.count=1;
00022
00023 if ((i!=list.end()) || (i->direction<r.direction)){
00024 list.insert(i,item);
00025 } else {
00026 list.push_back(item);
00027 }
00028 }
00029
00030
00031 std::list<GT2005KickRecord>::iterator GT2005KickLogger::findInsertPos(int direction)
00032 {
00033 std::list<GT2005KickRecord>::iterator i;
00034 i=list.begin();
00035
00036 while ((i!=list.end()) && (i->direction < direction)){
00037 i++;
00038 }
00039 return i;
00040 }
00041
00042 void GT2005KickLogger::loadLatest(){
00043
00044 }
00045 void GT2005KickLogger::save(){
00046 FILE * pFile;
00047 pFile = fopen ("/MS/kicklog.txt","wt");
00048
00049 if (pFile!=NULL)
00050 {
00051 std::list<GT2005KickRecord>::iterator i;
00052 i=list.begin();
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071 fprintf(pFile,"Direction ; Distance ; whi_ball_rel.x ; whi_ball_rel.y ; Kick ; bef_ball_tra.x ; bef_ball_tra.y ; bef_rob_tra.x ; bef_rob_tra.y ; bef_rob_rot ; whi_ball_tra.x ; whi_ball_tra.y ; whi_rob_tra.x ; whi_rob_tra.y ; whi_rob_rot ; whi_rob_speed.x ; whi_rob_speed.y ; whi_rob_speed.r ; aft_ball_tra.x ; aft_ball_tra.y ; aft_rob_tra.x ; aft_rob_tra.y ; aft_rob_rot ; trigger.x ; trigger.y ; count\n");
00072 while (i!=list.end()){
00073
00074
00075 fprintf(pFile,"%i; %i; %i; %i; %s; %i; %i; %i; %i; %i; %i; %i; %i; %i; %i; %i; %i; %i; %i; %i; %i; %i; %i; %i; %i; %i\n",
00076 i->direction,
00077 i->distance,
00078 i->while_ball_relative_translation.x,
00079 i->while_ball_relative_translation.y,
00080 i->kick,
00081 i->before_ball_translation.x,
00082 i->before_ball_translation.y,
00083 i->before_robot_translation.x,
00084 i->before_robot_translation.y,
00085 i->before_robot_rotation,
00086 i->while_ball_translation.x,
00087 i->while_ball_translation.y,
00088 i->while_robot_translation.x,
00089 i->while_robot_translation.y,
00090 i->while_robot_rotation,
00091 i->while_robot_speed.x,
00092 i->while_robot_speed.y,
00093 i->while_robot_speed.z,
00094 i->after_ball_translation.x,
00095 i->after_ball_translation.y,
00096 i->after_robot_translation.x,
00097 i->after_robot_translation.y,
00098 i->after_robot_rotation,
00099 i->trigger_relative.x,
00100 i->trigger_relative.y,
00101 i->count);
00102 i++;
00103 }
00104 fclose (pFile);
00105 }
00106 }
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123