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 ARTCM2_H
00028 #define ARTCM2_H
00029 
00030 #include "ariaUtil.h"
00031 #include "ArFunctor.h"
00032 #include "ArRobot.h"
00033 
00035 
00041 class ArTCM2
00042 {
00043 public:
00044 
00046   ArTCM2(ArRobot *robot);
00048   virtual ~ArTCM2();
00050   double getCompass(void) const { return myCompass; }
00052   double getPitch(void) const { return myPitch; }
00054   double getRoll(void) const { return myRoll; }
00056   double getXMagnetic(void) const { return myXMag; }
00058   double getYMagnetic(void) const { return myYMag; }
00060   double getZMagnetic(void) const { return myZMag; }
00062   double getTemperature(void) const { return myTemperature; }
00063   
00064   int getError(void) const { return myError; }
00066   double getCalibrationH(void) const { return myCalibrationH; }
00068   double getCalibrationV(void) const { return myCalibrationV; }
00070   double getCalibrationM(void) const { return myCalibrationM; }
00072   void commandOff(void) { myRobot->comInt(ArCommands::TCM2, 0); }
00074   void commandJustCompass(void) { myRobot->comInt(ArCommands::TCM2, 1); }
00076   void commandOnePacket(void) { myRobot->comInt(ArCommands::TCM2, 2); }
00078   void commandContinuousPackets(void) { myRobot->comInt(ArCommands::TCM2, 3); }
00080   void commandUserCalibration(void) { myRobot->comInt(ArCommands::TCM2, 4); }
00082   void commandAutoCalibration(void) { myRobot->comInt(ArCommands::TCM2, 5); }
00084   void commandStopCalibration(void) { myRobot->comInt(ArCommands::TCM2, 6); }
00086   void commandSoftReset(void) { myRobot->comInt(ArCommands::TCM2, 7); }
00088   int getPacCount(void);
00090   bool packetHandler(ArRobotPacket *packet);
00091 protected:  
00092   ArRobot *myRobot;
00093 
00094   double myCompass;
00095   double myPitch;
00096   double myRoll;
00097   double myXMag;
00098   double myYMag;
00099   double myZMag;
00100   double myTemperature;
00101   int myError;
00102   double myCalibrationH;
00103   double myCalibrationV;
00104   double myCalibrationM;
00105 
00106   
00107   time_t myTimeLastPacket;
00108   int myPacCurrentCount;
00109   int myPacCount;               
00110   ArRetFunctor1C<bool, ArTCM2, ArRobotPacket *> myPacketHandlerCB;
00111   
00112 };
00113 
00114 #endif // ARTCM2_H