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

ArSickLogger.h

00001 /*
00002 MobileRobots Advanced Robotics Interface for Applications (ARIA)
00003 Copyright (C) 2004, 2005 ActivMedia Robotics LLC
00004 Copyright (C) 2006, 2007 MobileRobots Inc.
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 MobileRobots for information about a commercial version of ARIA at 
00022 robots@mobilerobots.com or 
00023 MobileRobots Inc, 19 Columbia Drive, Amherst, NH 03031; 800-639-9481
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   // what type of readings we are taking
00110   bool myOldReadings;
00111   // what type of readings we are taking
00112   bool myNewReadings;
00113   // if we're taking reflector values too
00114   bool myUseReflectorValues;
00115   // internal function that adds goals if needed (and specified)
00116   void internalAddGoal(void);
00117   // internal function that writes tags
00118   void internalWriteTags(void);
00119   // internal function that takes a reading
00120   void internalTakeReading(void);
00121   // internal function that prints the position
00122   void internalPrintPos(ArPose poseTaken);
00123   // internal packet for handling the loop packets
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

Generated on Tue Feb 20 10:51:41 2007 for Aria by  doxygen 1.4.0