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.9  2008/09/12 10:22:28  martius
00024  *   set cnt to 1 to have round times in log file when using interval >1
00025  *
00026  *   Revision 1.8  2008/04/18 09:49:41  guettler
00027  *   Added the OdeAgent as a friend class
00028  *
00029  *   Revision 1.7  2007/08/29 11:33:20  martius
00030  *   simulation time enters logfile
00031  *
00032  *   Revision 1.6  2007/06/21 16:18:57  martius
00033  *   do not free scene -> Segfault
00034  *
00035  *   Revision 1.5  2007/04/05 15:14:15  martius
00036  *   angular speed tracking
00037  *
00038  *   Revision 1.4  2006/08/04 15:16:13  martius
00039  *   documentation
00040  *
00041  *   Revision 1.3  2006/08/02 09:33:21  martius
00042  *   Todo updated
00043  *
00044  *   Revision 1.2  2006/07/14 12:24:02  martius
00045  *   selforg becomes HEAD
00046  *
00047  *   Revision 1.1.2.3  2006/03/31 16:18:32  fhesse
00048  *   tracing in oderagent via trackrobots
00049  *
00050  *   Revision 1.1.2.2  2006/03/30 12:33:15  fhesse
00051  *   trace via trackrobot
00052  *
00053  *   Revision 1.1.2.1  2005/11/16 11:24:27  martius
00054  *   moved to selforg
00055  *
00056  *   Revision 1.4  2005/11/10 09:08:26  martius
00057  *   trace has a name
00058  *
00059  *   Revision 1.3  2005/11/09 13:31:51  martius
00060  *   GPL'ised
00061  *
00062  ***************************************************************************/
00063 #ifndef __TRACKROBOTS_H
00064 #define __TRACKROBOTS_H
00065 
00066 #include <stdio.h>
00067 #include <string.h>
00068 
00069 class AbstractRobot;
00070 class Agent;
00071 
00072 namespace lpzrobots {
00073   class OdeAgent;
00074 }
00075 
00076 /**
00077    This class provides tracking possibilies of a robot.
00078    The position, speed, and orientation can be logged.
00079 */
00080 class TrackRobot {
00081 public:
00082 
00083   friend class Agent;
00084   friend class lpzrobots::OdeAgent;
00085 
00086   /// constructor for no tracking at all
00087   TrackRobot(){
00088     trackPos = false;
00089     trackSpeed = false;
00090     trackOrientation = false;
00091     displayTrace = false;
00092     interval = 1;
00093     file=0;
00094     cnt=1;
00095     scene=0;
00096   }
00097 
00098   /** Constructor that allows individial setting of tracking options.
00099       The tracked data is written into a file with the current date and time appended by a name given by scene.
00100       @param trackPos if true the trace (position vectors) of the robot are logged
00101       @param trackSpeed if true the speed vectors (linear and angular) of the robot are logged
00102       @param trackOrientation if true the orientation matrices  of the robot are logged
00103       @param displayTrace if true the trace of the robot should be displayed (used in ODE simulations)
00104       @param scene name of the scene (is appended to log file name)
00105       @param interval timesteps between consequent logging events (default 1)
00106    */
00107   TrackRobot(bool trackPos, bool trackSpeed, bool trackOrientation, bool displayTrace,
00108              const char* scene, int interval = 1){
00109     this->trackPos     = trackPos;
00110     this->trackSpeed   = trackSpeed;
00111     this->trackOrientation = trackOrientation;
00112     this->displayTrace     = displayTrace;
00113     this->interval = interval;
00114     this->scene = strdup(scene);
00115     file=0;
00116     cnt=0;
00117   }
00118 
00119   ~TrackRobot(){
00120     // if(scene) free(scene);
00121   }
00122 
00123   /// returns whether tracing is activated
00124   bool isDisplayTrace() const {return displayTrace;};
00125 
00126  protected:
00127   bool open(const AbstractRobot* robot);
00128   void track(AbstractRobot* robot, double time);
00129   void close();
00130 
00131  protected:
00132   bool trackPos;
00133   bool trackSpeed;
00134   bool trackOrientation;
00135   bool displayTrace;
00136 
00137   int interval;
00138   FILE* file;
00139   char* scene;
00140   long cnt;
00141 };
00142 
00143 
00144 
00145 #endif

Generated on Tue Sep 16 22:00:22 2008 for Robotsystem of the Robot Group Leipzig by  doxygen 1.4.7