Main Page   Modules   Class Hierarchy   Compound List   File List   Compound Members  

SfSystem.h

00001 //
00002 // SfSystem.h
00003 //
00004 // Saphira system definitions
00005 
00006 //
00007 // Copyright 2001 by Kurt Konolige
00008 //
00009 // The author hereby grants to SRI permission to use this software.
00010 // The author also grants to SRI permission to distribute this software
00011 // to schools for non-commercial educational use only.
00012 //
00013 // The author hereby grants to other individuals or organizations
00014 // permission to use this software for non-commercial
00015 // educational use only.  This software may not be distributed to others
00016 // except by SRI, under the conditions above.
00017 //
00018 // Other than these cases, no part of this software may be used or
00019 // distributed without written permission of the author.
00020 //
00021 // Neither the author nor SRI make any representations about the 
00022 // suitability of this software for any purpose.  It is provided 
00023 // "as is" without express or implied warranty.
00024 //
00025 // Kurt Konolige
00026 // Senior Computer Scientist
00027 // SRI International
00028 // 333 Ravenswood Avenue
00029 // Menlo Park, CA 94025
00030 // E-mail:  konolige@ai.sri.com
00031 
00032 
00033 #ifndef SFSYSTEM_H
00034 #define SFSYSTEM_H
00035 
00036 #undef SFEXPORT
00037 #if defined(MS_WINDOWS) && !defined(SF_STATIC)
00038 #ifdef MAKE_LIBRARY
00039 #define _declspec( dllexport )
00040 #else
00041 #define _declspec( dllimport )
00042 #endif
00043 #else
00044 #define SFEXPORT
00045 #endif
00046 
00047 
00049 
00059 class Sf
00060 {
00061   Sf() {}; // no constructor!
00062 
00063 public:
00064 
00065 
00068   static void init();   
00071   static SfRobot *robot() { return ourRobot; }; 
00073   static SfSonarDevice *sonar() { return ourSonar; }
00075   static SfLaserDevice *laser() { return ourLaser; }
00077   static SfIrrfDevice *irrf() { return ourIrrf; }
00079   static SfArtifactList *artList;     // artifact list
00081   static SfColbertStream *ourColbert; // console Colbert stream
00082 
00083   // values for the current robot
00084 
00086   static double getX() { return ourRobot->getX(); }; // in mm
00088   static double getY() { return ourRobot->getY(); }; // in mm;
00090   static double getTh() { return ourRobot->getTh(); }; // in deg
00092   static ArPose getRwPose() { return ourRobot->getPose(); }; // robot's pose
00093 
00094   // connections
00095   static ArTcpConnection *tcpCon; 
00096   static ArSerialConnection *serialCon; 
00097   static ArLogFileConnection *logCon; 
00098 
00100   static SfFr *frame;
00101   static bool isExited;         // true when we have an exit request
00102 
00103   // internal, use the accessor... laser device, currently just a single one
00104   static SfLaserDevice *ourLaser;
00105   // internal, use the accessor... IR rangefinder device, currently just a single one
00106   static SfIrrfDevice *ourIrrf;
00107   // internal, use the accessor, the current robot
00108   static SfRobot *ourRobot;
00109 
00110 private:
00111   // sonar device, most robots have this...
00112   static SfSonarDevice *ourSonar;
00113 
00114 
00115   // parsing stream handler
00116 
00117   static void parser();
00118 };
00119 
00120 //
00121 // Global macros
00122 //
00123 
00125 #define SfROBOT Sf::robot()
00126 
00127 #define SfSELFTASK  SfActRegister::currentTask
00128 
00129 
00130 //
00131 // Helper macro for User and Sensor tasks
00132 //
00133 
00134 // use these in a constructor or any other member fn for the object
00135 // NAME is a string, double quotes
00136 
00137 #define ADDUSERTASK(NAME,PRIORITY,CLASS,PROC) \
00138   Sf::robot()->addUserTask(NAME, PRIORITY,   \
00139    new ArFunctorC<CLASS>(this, &CLASS::PROC));
00140 
00141 #define ADDSENSORTASK(NAME,PRIORITY,CLASS,PROC) \
00142   Sf::robot()->addSensorInterpTask(NAME, PRIORITY,   \
00143    new ArFunctorC<CLASS>(this, &CLASS::PROC));
00144 
00145 
00146 //
00147 // Various connection globals
00148 //
00149 void sfSetSerialBaud(int rate);
00150 void sfSetSerialPort(char *dev);
00151 
00152 
00153 #endif // SFSYSTEM_H
00154 

Generated on Tue Nov 12 17:49:34 2002 for Saphira by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001