00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef ARSICKLOGGER_H
00028 #define ARSICKLOGGER_H
00029
00030 #include <stdio.h>
00031
00032 #include "ariaUtil.h"
00033 #include "ArFunctor.h"
00034
00035 class ArSick;
00036 class ArRobot;
00037 class ArJoyHandler;
00038 class ArRobotPacket;
00039
00041
00053 class ArSickLogger
00054 {
00055 public:
00057 ArSickLogger(ArRobot *robot, ArSick *sick, double distDiff,
00058 double degDiff, const char *fileName,
00059 bool addGoals = false,
00060 ArJoyHandler *joyHandler = NULL,
00061 const char *baseDirectory = NULL);
00063 virtual ~ArSickLogger();
00064 #ifndef SWIG
00065
00066 void addTagToLog(const char *str, ...);
00067 #endif
00068
00069 void addTagToLogPlain(const char *str);
00070 #ifndef SWIG
00071
00072 void addInfoToLog(const char *str, ...);
00073 #endif
00074
00075 void addInfoToLogPlain(const char *str);
00077 void setDistDiff(double distDiff) { myDistDiff = ArMath::fabs(distDiff); }
00079 double getDistDiff(void) { return myDistDiff; }
00081 void setDegDiff(double degDiff) { myDistDiff = ArMath::fabs(degDiff); }
00083 double getDegDiff(void) { return myDegDiff; }
00085 void takeReading(void) { myTakeReadingExplicit = true; }
00087 void addGoal(void) { myAddGoalExplicit = true; }
00089 bool wasFileOpenedSuccessfully(void)
00090 { if (myFile != NULL) return true; else return false; }
00092 bool takingOldReadings(void) { return myOldReadings; }
00094 void takeOldReadings(bool takeOld) { myOldReadings = takeOld; }
00096 bool takingNewReadings(void) { return myNewReadings; }
00098 void takeNewReadings(bool takeNew) { myNewReadings = takeNew; }
00100 void robotTask(void);
00101
00102 protected:
00103
00104 bool myOldReadings;
00105
00106 bool myNewReadings;
00107
00108 void internalAddGoal(void);
00109
00110 void internalWriteTags(void);
00111
00112 void internalTakeReading(void);
00113
00114 void internalPrintPos(ArPose poseTaken);
00115
00116 bool loopPacketHandler(ArRobotPacket *packet);
00117 std::list<std::string> myTags;
00118 std::list<std::string> myInfos;
00119 bool myWrote;
00120 ArRobot *myRobot;
00121 ArSick *mySick;
00122 bool myAddGoals;
00123 ArJoyHandler *myJoyHandler;
00124 std::string myFileName;
00125 std::string myBaseDirectory;
00126 FILE *myFile;
00127 bool myFirstTaken;
00128 ArPose myLast;
00129 double myLastVel;
00130 double myDistDiff;
00131 double myDegDiff;
00132 ArSectors mySectors;
00133 ArFunctorC<ArSickLogger> myTaskCB;
00134 int myScanNumber;
00135 ArTime myStartTime;
00136 bool myTakeReadingExplicit;
00137 bool myAddGoalExplicit;
00138 bool myAddGoalKeyboard;
00139 bool myFirstGoalTaken;
00140 int myNumGoal;
00141 ArPose myLastGoalTakenPose;
00142 ArTime myLastGoalTakenTime;
00143 void goalKeyCallback(void);
00144 unsigned char myLastLoops;
00145 ArFunctorC<ArSickLogger> myGoalKeyCB;
00146 ArRetFunctor1C<bool, ArSickLogger, ArRobotPacket *> myLoopPacketHandlerCB;
00147 };
00148
00149 #endif // ARSICKLOGGER_H