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

ArSickLogger.h

00001 /*
00002 ActivMedia Robotics Interface for Applications (ARIA)
00003 Copyright (C) 2004,2005 ActivMedia Robotics, LLC
00004 
00005 
00006      This program is free software; you can redistribute it and/or modify
00007      it under the terms of the GNU General Public License as published by
00008      the Free Software Foundation; either version 2 of the License, or
00009      (at your option) any later version.
00010 
00011      This program is distributed in the hope that it will be useful,
00012      but WITHOUT ANY WARRANTY; without even the implied warranty of
00013      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014      GNU General Public License for more details.
00015 
00016      You should have received a copy of the GNU General Public License
00017      along with this program; if not, write to the Free Software
00018      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 
00020 If you wish to redistribute ARIA under different terms, contact 
00021 ActivMedia Robotics for information about a commercial version of ARIA at 
00022 robots@activmedia.com or 
00023 ActivMedia Robotics, 19 Columbia Drive, Amherst, NH 03031; 800-639-9481
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   // what type of readings we are taking
00104   bool myOldReadings;
00105   // what type of readings we are taking
00106   bool myNewReadings;
00107   // internal function that adds goals if needed (and specified)
00108   void internalAddGoal(void);
00109   // internal function that writes tags
00110   void internalWriteTags(void);
00111   // internal function that takes a reading
00112   void internalTakeReading(void);
00113   // internal function that prints the position
00114   void internalPrintPos(ArPose poseTaken);
00115   // internal packet for handling the loop packets
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

Generated on Wed Oct 19 12:56:37 2005 for Aria by  doxygen 1.4.0