trackrobots.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2005 by Robot Group Leipzig                             *
00003  *    martius@informatik.uni-leipzig.de                                    *
00004  *    fhesse@informatik.uni-leipzig.de                                     *
00005  *    der@informatik.uni-leipzig.de                                        *
00006  *                                                                         *
00007  *   This program is free software; you can redistribute it and/or modify  *
00008  *   it under the terms of the GNU General Public License as published by  *
00009  *   the Free Software Foundation; either version 2 of the License, or     *
00010  *   (at your option) any later version.                                   *
00011  *                                                                         *
00012  *   This program is distributed in the hope that it will be useful,       *
00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00015  *   GNU General Public License for more details.                          *
00016  *                                                                         *
00017  *   You should have received a copy of the GNU General Public License     *
00018  *   along with this program; if not, write to the                         *
00019  *   Free Software Foundation, Inc.,                                       *
00020  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00021  *                                                                         *
00022  *   $Log: trackrobots.h,v $
00023  *   Revision 1.4  2006/08/04 15:16:13  martius
00024  *   documentation
00025  *
00026  *   Revision 1.3  2006/08/02 09:33:21  martius
00027  *   Todo updated
00028  *
00029  *   Revision 1.2  2006/07/14 12:24:02  martius
00030  *   selforg becomes HEAD
00031  *
00032  *   Revision 1.1.2.3  2006/03/31 16:18:32  fhesse
00033  *   tracing in oderagent via trackrobots
00034  *
00035  *   Revision 1.1.2.2  2006/03/30 12:33:15  fhesse
00036  *   trace via trackrobot
00037  *
00038  *   Revision 1.1.2.1  2005/11/16 11:24:27  martius
00039  *   moved to selforg
00040  *
00041  *   Revision 1.4  2005/11/10 09:08:26  martius
00042  *   trace has a name
00043  *
00044  *   Revision 1.3  2005/11/09 13:31:51  martius
00045  *   GPL'ised
00046  *
00047  ***************************************************************************/
00048 #ifndef __TRACKROBOTS_H
00049 #define __TRACKROBOTS_H
00050 
00051 #include <stdio.h>
00052 #include <string.h>
00053 
00054 class AbstractRobot;
00055 class Agent;
00056 
00057 /**
00058    This class provides tracking possibilies of a robot.    
00059    The position, speed, and orientation can be logged.
00060 */
00061 class TrackRobot {
00062 public:
00063 
00064   friend class Agent;
00065   //friend class OdeAgent;
00066 
00067   /// constructor for no tracking at all
00068   TrackRobot(){
00069     trackPos = false;
00070     trackSpeed = false;
00071     trackOrientation = false;
00072     displayTrace = false;
00073     interval = 1;
00074     file=0;
00075     cnt=0;
00076     scene=0;
00077   }
00078 
00079   /** Constructor that allows individial setting of tracking options.      
00080       The tracked data is written into a file with the current date and time appended by a name given by scene.
00081       @param trackPos if true the trace (position vectors) of the robot are logged
00082       @param trackSpeed if true the speed vectors of the robot are logged
00083       @param trackOrientation if true the orientation matrices  of the robot are logged
00084       @param displayTrace if true the trace of the robot should be displayed (used in ODE simulations)
00085       @param scene name of the scene (is appended to log file name)
00086       @param interval timesteps between consequent logging events (default 1)
00087    */ 
00088   TrackRobot(bool trackPos, bool trackSpeed, bool trackOrientation, bool displayTrace, 
00089              const char* scene, int interval = 1){
00090     this->trackPos     = trackPos;
00091     this->trackSpeed   = trackSpeed;
00092     this->trackOrientation = trackOrientation;
00093     this->displayTrace     = displayTrace;
00094     this->interval = interval;
00095     this->scene = strdup(scene);
00096     file=0;
00097     cnt=0;
00098   }
00099 
00100   ~TrackRobot(){
00101     if(scene) free(scene);
00102   }
00103 
00104   /// returns whether tracing is activated
00105   bool isDisplayTrace() const {return displayTrace;};
00106 
00107  protected:
00108   bool open(const AbstractRobot* robot);
00109   void track(AbstractRobot* robot);
00110   void close();
00111 
00112  protected:
00113   bool trackPos;
00114   bool trackSpeed;
00115   bool trackOrientation;
00116   bool displayTrace;
00117 
00118   int interval;
00119   FILE* file;
00120   char* scene;
00121   long cnt;
00122 };
00123 
00124 
00125 
00126 #endif

Generated on Mon Aug 7 16:40:14 2006 for Robotsystem of the Robot Group Leipzig by  doxygen 1.4.7