24 #ifndef __REPLAYCONTROLLER_H
25 #define __REPLAYCONTROLLER_H
38 f=fopen(filename,
"r");
40 std::cerr<<
"ReplayController: error while opening file " << filename << std::endl;
44 std::cerr<<
"ReplayController: error while seaching for header in file " << filename << std::endl;
47 printf(
"ReplayController: columns: Senors [%i, %i], Motors [%i, %i]\n",
51 virtual void init(
int sensornumber,
int motornumber,
RandGen* randGen = 0){
60 virtual void step(
const sensor* sensors,
int sensornumber,
61 motor* motors,
int motornumber){
66 motor* motors,
int number_motors){
70 std::cout <<
"ReplayController: rewind" << std::endl;
73 std::cout <<
"ReplayController: no datafile in file" <<
filename << std::endl;
82 virtual bool store(FILE*
f)
const {
return false;}
100 while(fgets(buffer, 1024, f)) {
101 if(buffer[0]==
'#' && buffer[1]==
'C'){
105 p=strtok(buffer,
" ");
107 while((p=strtok(NULL,
" "))!=NULL ) {
108 if(p[0]==
'x' && p[1]==
'['){
112 if(p[0]==
'y' && p[1]==
'['){
126 bool foundsomething =
false;
128 if(*p >
' ') foundsomething =
true;
131 return !foundsomething;
138 if(*p >=
'0' && *p <=
'9')
return true;
148 while(fgets(buffer, 1024, f)){
149 if(buffer[0]==
'#' ||
isEmpty(buffer)){
154 p=strtok(buffer,
" ");
158 while((p=strtok(NULL,
" "))!=NULL ) {
Matrix type.
Definition: matrix.h:65
virtual int getMotorNumber() const
Definition: replaycontroller.h:58
ReplayController(const char *filename, bool repeat=false)
Definition: replaycontroller.h:34
Abstract class for robot controller (with some basic functionality).
Definition: abstractcontroller.h:46
matrix::Matrix m
Definition: replaycontroller.h:177
random generator with 48bit integer arithmentic
Definition: randomgenerator.h:34
virtual bool store(FILE *f) const
stores the controller values to a given file (binary).
Definition: replaycontroller.h:82
int convertToBuffer(D *buffer, I len) const
stores the content of the matrix (row-wise) in the given buffer
Definition: matrix.cpp:160
double sensor
Definition: abstractcontroller.h:48
FILE * f
Definition: replaycontroller.h:179
int sensorStart
Definition: replaycontroller.h:173
virtual bool restore(FILE *f)
loads the controller values from a given file (binary).
Definition: replaycontroller.h:84
Controller that replays a file.
Definition: replaycontroller.h:32
bool repeat
Definition: replaycontroller.h:180
int motorStart
Definition: replaycontroller.h:175
Matrix rows(I startindex, I endindex) const
Definition: matrix.cpp:116
virtual void stepNoLearning(const sensor *, int number_sensors, motor *motors, int number_motors)
performs one step without learning.
Definition: replaycontroller.h:65
static bool parseDataLine(matrix::Matrix &data, FILE *f)
Definition: replaycontroller.h:144
bool parseDataFileForHeader(FILE *f)
Definition: replaycontroller.h:92
virtual std::list< iparamval > getInternalParams() const
Definition: replaycontroller.h:88
int sensorEnd
Definition: replaycontroller.h:174
virtual std::list< iparamkey > getInternalParamNames() const
The list of the names of all internal parameters given by getInternalParams().
Definition: replaycontroller.h:87
void set(I _m, I _n, const D *_data=0)
sets the size of the matrix and maybe the data if given (row-wise).
Definition: matrix.cpp:147
virtual int getSensorNumber() const
Definition: replaycontroller.h:56
static bool check4Number(const char *c)
Definition: replaycontroller.h:135
int motorEnd
Definition: replaycontroller.h:176
static bool isEmpty(const char *c)
Definition: replaycontroller.h:124
double motor
Definition: abstractcontroller.h:49
virtual void init(int sensornumber, int motornumber, RandGen *randGen=0)
initialisation of the controller with the given sensor/ motornumber Must be called before use...
Definition: replaycontroller.h:51
virtual void step(const sensor *sensors, int sensornumber, motor *motors, int motornumber)
performs one step (includes learning).
Definition: replaycontroller.h:60
int c
Definition: hexapod.cpp:56
const char * filename
Definition: replaycontroller.h:178
double atof(const char *)