odeagent.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef __ODEAGENT_H
00025 #define __ODEAGENT_H
00026
00027 #include <selforg/agent.h>
00028 #include <selforg/storeable.h>
00029 #include "oderobot.h"
00030 #include "osgprimitive.h"
00031 #include "primitive.h"
00032 #include "operator.h"
00033
00034 namespace lpzrobots {
00035 class Joint;
00036
00037 class TraceDrawer {
00038 public:
00039 TraceDrawer() : obj(0){}
00040 Position lastpos;
00041 Trackable* obj;
00042 TrackRobot tracker;
00043 Color color;
00044 void init();
00045 void close();
00046
00047 void track(double time);
00048
00049 void drawTrace(GlobalData& global);
00050 protected:
00051 bool initialized;
00052 };
00053
00054
00055 typedef std::list<PlotOption> PlotOptionList;
00056 typedef std::list<Operator*> OperatorList;
00057 typedef std::list<TraceDrawer> TraceDrawerList;
00058
00059
00060
00061 class OdeAgent : public Agent, public Storeable {
00062 public:
00063
00064
00065
00066 OdeAgent(const PlotOption& plotOption = PlotOption(NoPlot), double noisefactor = 1, const std::string& name = "OdeAgent", const std::string& revision = "$ID$") __attribute__ ((deprecated));
00067
00068
00069 OdeAgent(const std::list<PlotOption>& plotOptions, double noisefactor = 1, const std::string& name = "OdeAgent", const std::string& revision = "$ID$") __attribute__ ((deprecated));
00070
00071
00072
00073 OdeAgent(const GlobalData& globalData, double noisefactor = 1, const std::string& name = "OdeAgent", const std::string& revision = "");
00074
00075 OdeAgent(const GlobalData& globalData, const PlotOption& plotOption, double noisefactor = 1, const std::string& name = "OdeAgent", const std::string& revision = "");
00076
00077
00078
00079 OdeAgent(const GlobalData& globalData, const PlotOptionList& plotOptions, double noisefactor = 1, const std::string& name = "OdeAgent", const std::string& revision = "");
00080 virtual ~OdeAgent();
00081
00082
00083
00084
00085 virtual bool init(AbstractController* controller, OdeRobot* robot, AbstractWiring* wiring,
00086 long int seed = 0){
00087 return Agent::init(controller, robot, wiring, seed);
00088 }
00089
00090 virtual void step(double noise, double time);
00091
00092
00093
00094
00095
00096
00097
00098
00099 virtual void stepOnlyWiredController(double noise, double time);
00100
00101
00102
00103
00104
00105
00106 virtual void setMotorsGetSensors();
00107
00108
00109
00110
00111 virtual void beforeStep(GlobalData& global);
00112
00113
00114
00115
00116
00117 virtual void startMotorBabblingMode (int steps,
00118 AbstractController* babblecontroller = 0,
00119 bool fixRobot=true);
00120
00121
00122 virtual void stopMotorBabblingMode ();
00123
00124
00125
00126
00127 virtual OdeRobot* getRobot() { return (OdeRobot*)robot;}
00128
00129
00130
00131 virtual const OdeRobot* getRobot() const { return (OdeRobot*)robot;}
00132
00133
00134 virtual int getTraceLength(){return 0;}
00135
00136
00137 virtual bool setTraceLength(int tracelength) {return true;}
00138
00139
00140 virtual void setTraceThickness(int tracethickness){ }
00141
00142
00143 virtual void addTracking(unsigned int primitiveIndex,const TrackRobot& trackrobot,
00144 const Color& color);
00145 virtual void setTrackOptions(const TrackRobot& trackrobot);
00146
00147
00148 virtual bool store(FILE* f) const;
00149 virtual bool restore(FILE* f);
00150
00151
00152
00153
00154 virtual void addOperator(Operator* o, bool addToConfigurable = true );
00155
00156
00157
00158
00159 virtual bool removeOperator(Operator* o);
00160
00161 virtual void removeOperators();
00162
00163 protected:
00164
00165
00166
00167
00168 virtual void trace(GlobalData& global);
00169
00170
00171 virtual void tryFixateRobot();
00172
00173 private:
00174 void constructor_helper(const GlobalData* globalData);
00175
00176 TraceDrawer mainTrace;
00177 Pos fixatingPos;
00178 bool fixateRobot;
00179 Joint* fixedJoint;
00180
00181 OperatorList operators;
00182
00183 TraceDrawerList segmentTracking;
00184 };
00185
00186 }
00187
00188 #endif