Main Page   Modules   Class Hierarchy   Compound List   File List   Compound Members  

SfLogger.h

00001 //
00002 // SfLogger.h
00003 //
00004 // Logging code 
00005 // Saves/replays a robot data log
00006 // FLTK window code is in SfLoggerFl.cpp
00007 //
00008 // Copyright 2002 by Kurt Konolige
00009 //
00010 // The author hereby grants to SRI permission to use this software.
00011 // The author also grants to SRI permission to distribute this software
00012 // to schools for non-commercial educational use only.
00013 //
00014 // The author hereby grants to other individuals or organizations
00015 // permission to use this software for non-commercial
00016 // educational use only.  This software may not be distributed to others
00017 // except by SRI, under the conditions above.
00018 //
00019 // Other than these cases, no part of this software may be used or
00020 // distributed without written permission of the author.
00021 //
00022 // Neither the author nor SRI make any representations about the 
00023 // suitability of this software for any purpose.  It is provided 
00024 // "as is" without express or implied warranty.
00025 //
00026 // Kurt Konolige
00027 // Senior Computer Scientist
00028 // SRI International
00029 // 333 Ravenswood Avenue
00030 // Menlo Park, CA 94025
00031 // E-mail:  konolige@ai.sri.com
00032 //
00033 
00034 //
00035 // Log files are a way of saving and playing back actual robot data, as opposed 
00036 //   running the simulator.  Currently only robot motion and sonar data is logged.
00037 // Of course, control commands sent to the robot don't do anything when operating
00038 //   on a log file.  These files are most useful for understanding how sensor data
00039 //   is interpreted.
00040 // It might be useful to save commands, also, so we could check what Saphira/Aria
00041 //   did on the data.
00042 //
00043 
00044 #ifndef SFLOGGER_H
00045 #define SFLOGGER_H
00046 
00047 #include <stdio.h>
00048 #include "export.h"
00049 
00050 class SfLogger
00051 {
00052  public:
00053   SfLogger(SfRobot *robot = SfROBOT, char *fname = NULL);
00054   ~SfLogger();
00055   void setLogFile(char *fname)
00056     { fileName = fname; };
00057 
00058   bool startRecord();  // starts up recording, opens file
00059   void stopRecord();   // stops recording and closes file
00060   void pauseRecord();  // pauses recording; restart with startRecord()
00061 
00062   bool startPlay() { return false; };    // starts playback, opens file
00063   void stopPlay();     // stops playback and closes file
00064   void pausePlay() {};  // pauses playback; restart with startPlay()
00065 
00066  private:
00067   // main callback fn for logging to a file
00068   ArRetFunctor1C<bool, SfLogger, ArRobotPacket *> myPacketLoggerCB;
00069   bool processPacket(ArRobotPacket *packet);
00070   
00071   // robot object
00072   SfRobot *robot;
00073 
00074   // file name, file handle
00075   char *fileName;
00076   FILE *fd;
00077 
00078   // recording or playing
00079   bool recordFlag, playFlag;
00080 };
00081 
00082 
00083 
00084 #endif

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