replayrobot.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: replayrobot.h,v $
00023  *   Revision 1.3  2008/04/29 08:45:14  guettler
00024  *   include-section corrected
00025  *
00026  *   Revision 1.2  2007/11/07 13:21:16  martius
00027  *   doInternal stuff changed signature
00028  *
00029  *   Revision 1.1  2007/06/14 13:53:11  martius
00030  *   a robot, that just replays a logfile
00031  *
00032  *
00033  ***************************************************************************/
00034 #ifndef __REPLAYROBOT_H
00035 #define __REPLAYROBOT_H
00036 
00037 
00038 #include "oderobot.h"
00039 #include <selforg/types.h>
00040 #include <selforg/matrix.h>
00041 
00042 namespace lpzrobots {
00043 
00044   /**
00045    *
00046    */
00047   class ReplayRobot : public OdeRobot{
00048   public:
00049     ReplayRobot(const OdeHandle& odeHandle, const OsgHandle& osgHandle, const char* filename);
00050 
00051     ~ReplayRobot();
00052 
00053     virtual void update() {}
00054 
00055     /** sets the pose of the vehicle
00056         @param pose desired 4x4 pose matrix
00057     */
00058     virtual void place(const osg::Matrix& pose) {}
00059 
00060     /** returns actual sensorvalues
00061         @param sensors sensors scaled to [-1,1]
00062         @param sensornumber length of the sensor array
00063         @return number of actually written sensors
00064     */
00065     virtual int getSensors(sensor* sensors, int sensornumber);
00066 
00067     /** sets actual motorcommands
00068         @param motors motors scaled to [-1,1]
00069         @param motornumber length of the motor array
00070     */
00071     virtual void setMotors(const motor* motors, int motornumber);
00072 
00073     /** returns number of sensors
00074      */
00075     virtual int getSensorNumber() {return sensorEnd - sensorStart + 1; }
00076 
00077     /** returns number of motors
00078      */
00079     virtual int getMotorNumber() {return motorEnd - motorStart + 1; }
00080 
00081     /** this function is called in each timestep. It should perform robot-internal checks,
00082         like space-internal collision detection, sensor resets/update etc.
00083         @param globalData structure that contains global data from the simulation environment
00084     */
00085     virtual void doInternalStuff(GlobalData& globalData) {}
00086 
00087     virtual bool collisionCallback(void *data, dGeomID o1, dGeomID o2) { return false;}
00088 
00089   protected:
00090     /** the main object of the robot, which is used for position and speed tracking */
00091     virtual Primitive* getMainPrimitive() const { return 0; }
00092 
00093     static bool parseDataFileForHeader(FILE* f, int & sensorstart, int& sensorend,  int& motorstart, int& motorend);
00094     static bool parseDataLine(matrix::Matrix& data, FILE* f);
00095     static bool isEmpty(const char* c);
00096     static bool check4Number(const char* c);
00097 
00098 
00099   protected:
00100     int sensorStart;
00101     int sensorEnd;
00102     int motorStart;
00103     int motorEnd;
00104 
00105     matrix::Matrix sensors;
00106     const char* filename;
00107     FILE* f;
00108 
00109 
00110   };
00111 
00112 }
00113 
00114 #endif
00115 

Generated on Fri Oct 30 16:29:01 2009 for Robot Simulator of the Robotics Group for Self-Organization of Control by  doxygen 1.4.7