Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

# Modules/BehaviorControl/GT2005BehaviorControl/GT2005KickLogger/GT2005KickLogger.cpp

Go to the documentation of this file.

    00001 /**
    00002 * @file GT2005KickLogger.cpp
    00003 *
    00004 * Implementation of class GT2005KickLogger.
    00005 *
    00006 * @author Carsten Schumann
    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 void GT2005KickLogger::addResult(Vector2<int> before_ball_translation,
    00056 Vector2<int> before_robot_translation,
    00057 double before_robot_rotation,
    00058 Vector2<int> while_ball_translation,
    00059 Vector3<int> while_robot_speed,
    00060 Vector2<int> while_robot_translation,
    00061 double while_robot_rotation,
    00062 Vector2<int> while_ball_relative_translation,
    00063 Vector2<int> trigger_relative,
    00064 Vector2<int> after_robot_translation,
    00065 double after_robot_rotation,
    00066 Vector2<int> after_ball_translation,
    00067 const char* kick,
    00068 int direction,
    00069 int distance)
    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       //Format: Direction, Distance, Kick, bx, by, exbx, exby, sx, sy, sz, count
    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 /*  int upperBound=list.size()-1;
    00110   int lowerBound=0;
    00111
    00112   while (upperBound<lowerBound)
    00113   {
    00114     int middle=(upperBound+lowerBound)/2;
    00115     if (direction>list[middle] && (middle != lowerBound)){
    00116       lowerBound=middle;
    00117     } else {
    00118       upperBound=middle;
    00119     }
    00120   }
    00121   return loweBound; // ==upperBound==middle
    00122 }
    00123 */