replayrobot.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2005-2011 LpzRobots development team                    *
00003  *    Georg Martius  <georg dot martius at web dot de>                     *
00004  *    Frank Guettler <guettler at informatik dot uni-leipzig dot de        *
00005  *    Frank Hesse    <frank at nld dot ds dot mpg dot de>                  *
00006  *    Ralf Der       <ralfder at mis dot mpg dot de>                       *
00007  *                                                                         *
00008  *   This program is free software; you can redistribute it and/or modify  *
00009  *   it under the terms of the GNU General Public License as published by  *
00010  *   the Free Software Foundation; either version 2 of the License, or     *
00011  *   (at your option) any later version.                                   *
00012  *                                                                         *
00013  *   This program is distributed in the hope that it will be useful,       *
00014  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00015  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00016  *   GNU General Public License for more details.                          *
00017  *                                                                         *
00018  *   You should have received a copy of the GNU General Public License     *
00019  *   along with this program; if not, write to the                         *
00020  *   Free Software Foundation, Inc.,                                       *
00021  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00022  *                                                                         *
00023  ***************************************************************************/
00024 #ifndef __REPLAYROBOT_H
00025 #define __REPLAYROBOT_H
00026 
00027 
00028 #include "oderobot.h"
00029 #include <selforg/types.h>
00030 #include <selforg/matrix.h>
00031 
00032 namespace lpzrobots {
00033 
00034   /**
00035    *
00036    */
00037   class ReplayRobot : public OdeRobot{
00038   public:
00039     ReplayRobot(const OdeHandle& odeHandle, const OsgHandle& osgHandle, const char* filename);
00040 
00041     ~ReplayRobot();
00042 
00043     virtual void update() {}
00044 
00045     /** sets the pose of the vehicle
00046         @param pose desired 4x4 pose matrix
00047     */
00048     virtual void place(const osg::Matrix& pose) {}
00049 
00050     /** returns actual sensorvalues
00051         @param sensors sensors scaled to [-1,1]
00052         @param sensornumber length of the sensor array
00053         @return number of actually written sensors
00054     */
00055     virtual int getSensors(sensor* sensors, int sensornumber);
00056 
00057     /** sets actual motorcommands
00058         @param motors motors scaled to [-1,1]
00059         @param motornumber length of the motor array
00060     */
00061     virtual void setMotors(const motor* motors, int motornumber);
00062 
00063     /** returns number of sensors
00064      */
00065     virtual int getSensorNumber() {return sensorEnd - sensorStart + 1; }
00066 
00067     /** returns number of motors
00068      */
00069     virtual int getMotorNumber() {return motorEnd - motorStart + 1; }
00070 
00071     /** this function is called in each timestep. It should perform robot-internal checks,
00072         like space-internal collision detection, sensor resets/update etc.
00073         @param globalData structure that contains global data from the simulation environment
00074     */
00075     virtual void doInternalStuff(GlobalData& globalData) {}
00076 
00077   protected:
00078     /** the main object of the robot, which is used for position and speed tracking */
00079     virtual Primitive* getMainPrimitive() const { return 0; }
00080 
00081     static bool parseDataFileForHeader(FILE* f, int & sensorstart, int& sensorend,  int& motorstart, int& motorend);
00082     static bool parseDataLine(matrix::Matrix& data, FILE* f);
00083     static bool isEmpty(const char* c);
00084     static bool check4Number(const char* c);
00085 
00086 
00087   protected:
00088     int sensorStart;
00089     int sensorEnd;
00090     int motorStart;
00091     int motorEnd;
00092 
00093     matrix::Matrix sensors;
00094     const char* filename;
00095     FILE* f;
00096 
00097 
00098   };
00099 
00100 }
00101 
00102 #endif
00103 
Generated on Thu Jun 28 14:45:37 2012 for Robot Simulator of the Robotics Group for Self-Organization of Control by  doxygen 1.6.3