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 #ifndef ARSICKLOGGER_H
00027 #define ARSICKLOGGER_H
00028
00029 #include <stdio.h>
00030
00031 #include "ariaUtil.h"
00032 #include "ArFunctor.h"
00033
00034 class ArSick;
00035 class ArRobot;
00036 class ArJoyHandler;
00037 class ArRobotJoyHandler;
00038 class ArRobotPacket;
00039
00041
00053 class ArSickLogger
00054 {
00055 public:
00057 AREXPORT 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,
00062 bool useReflectorValues = false,
00063 ArRobotJoyHandler *robotJoyHandler = NULL);
00065 AREXPORT virtual ~ArSickLogger();
00066 #ifndef SWIG
00067
00070 AREXPORT void addTagToLog(const char *str, ...);
00071 #endif
00072
00073 AREXPORT void addTagToLogPlain(const char *str);
00074 #ifndef SWIG
00075
00078 AREXPORT void addInfoToLog(const char *str, ...);
00079 #endif
00080
00081 AREXPORT void addInfoToLogPlain(const char *str);
00083 void setDistDiff(double distDiff) { myDistDiff = ArMath::fabs(distDiff); }
00085 double getDistDiff(void) { return myDistDiff; }
00087 void setDegDiff(double degDiff) { myDistDiff = ArMath::fabs(degDiff); }
00089 double getDegDiff(void) { return myDegDiff; }
00091 void takeReading(void) { myTakeReadingExplicit = true; }
00093 void addGoal(void) { myAddGoalExplicit = true; }
00095 bool wasFileOpenedSuccessfully(void)
00096 { if (myFile != NULL) return true; else return false; }
00098 bool takingOldReadings(void) { return myOldReadings; }
00100 void takeOldReadings(bool takeOld) { myOldReadings = takeOld; }
00102 bool takingNewReadings(void) { return myNewReadings; }
00104 void takeNewReadings(bool takeNew) { myNewReadings = takeNew; }
00106 AREXPORT void robotTask(void);
00107
00108 protected:
00109
00110 bool myOldReadings;
00111
00112 bool myNewReadings;
00113
00114 bool myUseReflectorValues;
00115
00116 void internalAddGoal(void);
00117
00118 void internalWriteTags(void);
00119
00120 void internalTakeReading(void);
00121
00122 void internalPrintPos(ArPose poseTaken);
00123
00124 AREXPORT bool loopPacketHandler(ArRobotPacket *packet);
00125 std::list<std::string> myTags;
00126 std::list<std::string> myInfos;
00127 bool myWrote;
00128 ArRobot *myRobot;
00129 ArSick *mySick;
00130 bool myAddGoals;
00131 ArJoyHandler *myJoyHandler;
00132 ArRobotJoyHandler *myRobotJoyHandler;
00133 std::string myFileName;
00134 std::string myBaseDirectory;
00135 FILE *myFile;
00136 bool myFirstTaken;
00137 ArPose myLast;
00138 double myLastVel;
00139 double myDistDiff;
00140 double myDegDiff;
00141 ArSectors mySectors;
00142 ArFunctorC<ArSickLogger> myTaskCB;
00143 int myScanNumber;
00144 ArTime myStartTime;
00145 bool myTakeReadingExplicit;
00146 bool myAddGoalExplicit;
00147 bool myAddGoalKeyboard;
00148 bool myLastAddGoalKeyboard;
00149 bool myLastJoyButton;
00150 bool myLastRobotJoyButton;
00151 bool myFirstGoalTaken;
00152 int myNumGoal;
00153 ArPose myLastGoalTakenPose;
00154 ArTime myLastGoalTakenTime;
00155 void goalKeyCallback(void);
00156 unsigned char myLastLoops;
00157 ArFunctorC<ArSickLogger> myGoalKeyCB;
00158 ArRetFunctor1C<bool, ArSickLogger, ArRobotPacket *> myLoopPacketHandlerCB;
00159 };
00160
00161 #endif // ARSICKLOGGER_H