Robot Simulator of the Robotics Group for Self-Organization of Control  0.8.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
replayrobot.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2011 LpzRobots development team *
3  * Georg Martius <georg dot martius at web dot de> *
4  * Frank Guettler <guettler at informatik dot uni-leipzig dot de *
5  * Frank Hesse <frank at nld dot ds dot mpg dot de> *
6  * Ralf Der <ralfder at mis dot mpg dot de> *
7  * *
8  * This program is free software; you can redistribute it and/or modify *
9  * it under the terms of the GNU General Public License as published by *
10  * the Free Software Foundation; either version 2 of the License, or *
11  * (at your option) any later version. *
12  * *
13  * This program is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16  * GNU General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU General Public License *
19  * along with this program; if not, write to the *
20  * Free Software Foundation, Inc., *
21  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
22  * *
23  ***************************************************************************/
24 #ifndef __REPLAYROBOT_H
25 #define __REPLAYROBOT_H
26 
27 
28 #include "oderobot.h"
29 #include <selforg/types.h>
30 #include <selforg/matrix.h>
31 
32 namespace lpzrobots {
33 
34  /**
35  *
36  */
37  class ReplayRobot : public OdeRobot{
38  public:
39  ReplayRobot(const OdeHandle& odeHandle, const OsgHandle& osgHandle, const char* filename);
40 
41  ~ReplayRobot();
42 
43 
44 
45  /** sets the pose of the vehicle
46  @param pose desired 4x4 pose matrix
47  */
48  virtual void placeIntern(const osg::Matrix& pose) {}
49 
50  /** returns actual sensorvalues
51  @param sensors sensors scaled to [-1,1]
52  @param sensornumber length of the sensor array
53  @return number of actually written sensors
54  */
55  virtual int getSensorsIntern(sensor* sensors, int sensornumber);
56 
57  /** sets actual motorcommands
58  @param motors motors scaled to [-1,1]
59  @param motornumber length of the motor array
60  */
61  virtual void setMotorsIntern(const double* motors, int motornumber);
62 
63  /** returns number of sensors
64  */
65  virtual int getSensorNumberInternIntern() {return sensorEnd - sensorStart + 1; }
66 
67  /** returns number of motors
68  */
69  virtual int getMotorNumberInternIntern() {return motorEnd - motorStart + 1; }
70 
71  /** this function is called in each timestep. It should perform robot-internal checks,
72  like space-internal collision detection, sensor resets/update etc.
73  @param globalData structure that contains global data from the simulation environment
74  */
75  virtual void doInternalStuff(GlobalData& globalData) {}
76 
77  protected:
78  /** the main object of the robot, which is used for position and speed tracking */
79  virtual Primitive* getMainPrimitive() const { return 0; }
80 
81  static bool parseDataFileForHeader(FILE* f, int & sensorstart, int& sensorend, int& motorstart, int& motorend);
82  static bool parseDataLine(matrix::Matrix& data, FILE* f);
83  static bool isEmpty(const char* c);
84  static bool check4Number(const char* c);
85 
86 
87  protected:
89  int sensorEnd;
91  int motorEnd;
92 
94  const char* filename;
95  FILE* f;
96 
97 
98  };
99 
100 }
101 
102 #endif
103 
static bool parseDataLine(matrix::Matrix &data, FILE *f)
Definition: replayrobot.cpp:123
virtual void setMotorsIntern(const double *motors, int motornumber)
sets actual motorcommands
Definition: replayrobot.cpp:57
Matrix type.
Definition: matrix.h:65
Data structure for accessing the ODE.
Definition: odehandle.h:44
matrix::Matrix sensors
Definition: replayrobot.h:93
Matrixd Matrix
Definition: osgforwarddecl.h:47
ReplayRobot(const OdeHandle &odeHandle, const OsgHandle &osgHandle, const char *filename)
Definition: replayrobot.cpp:34
double sensor
Definition: types.h:29
Definition: replayrobot.h:37
Data structure for accessing the OpenSceneGraph.
Definition: osghandle.h:79
static bool isEmpty(const char *c)
Definition: replayrobot.cpp:103
virtual Primitive * getMainPrimitive() const
the main object of the robot, which is used for position and speed tracking
Definition: replayrobot.h:79
int motorStart
Definition: replayrobot.h:90
Interface class for primitives represented in the physical and graphical world.
Definition: primitive.h:80
Data structure holding all essential global information.
Definition: globaldata.h:57
virtual void placeIntern(const osg::Matrix &pose)
sets the pose of the vehicle
Definition: replayrobot.h:48
int sensorStart
Definition: replayrobot.h:88
FILE * f
Definition: replayrobot.h:95
int motorEnd
Definition: replayrobot.h:91
virtual int getSensorNumberInternIntern()
returns number of sensors
Definition: replayrobot.h:65
const char * filename
Definition: replayrobot.h:94
OsgHandle osgHandle
Definition: oderobot.h:278
OdeHandle odeHandle
Definition: oderobot.h:277
virtual int getSensorsIntern(sensor *sensors, int sensornumber)
returns actual sensorvalues
Definition: replayrobot.cpp:60
Abstract class for ODE robots.
Definition: oderobot.h:64
static bool check4Number(const char *c)
Definition: replayrobot.cpp:114
virtual int getMotorNumberInternIntern()
returns number of motors
Definition: replayrobot.h:69
int sensorEnd
Definition: replayrobot.h:89
virtual void doInternalStuff(GlobalData &globalData)
this function is called in each timestep.
Definition: replayrobot.h:75
~ReplayRobot()
Definition: replayrobot.cpp:53
std::list< MotorAttachment > motors
Definition: oderobot.h:270
static bool parseDataFileForHeader(FILE *f, int &sensorstart, int &sensorend, int &motorstart, int &motorend)
Definition: replayrobot.cpp:71
int c
Definition: hexapod.cpp:56