Robot Simulator of the Robotics Group for Self-Organization of Control: odeagent.h Source File

- Main Page
- Namespaces
- Classes
- Files
- Directories
- Related Pages
- Examples

- Search for |

- File List
- File Members

# odeagent.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: odeagent.h,v $
    00023  *   Revision 1.10  2009/08/07 09:27:58  martius
    00024  *   additional constructor with globaldata
    00025  *
    00026  *   Revision 1.9  2009/03/27 13:55:06  martius
    00027  *   traceing in a extra function
    00028  *
    00029  *   Revision 1.8  2008/04/18 09:50:24  guettler
    00030  *   Implemented step functions for multiple threads of the class Simulation
    00031  *
    00032  *   Revision 1.7  2008/04/17 15:59:00  martius
    00033  *   OSG2 port finished
    00034  *
    00035  *   Revision 1.6.2.1  2008/04/17 15:05:47  martius
    00036  *   use RandGen
    00037  *
    00038  *   Revision 1.6  2007/08/30 09:46:41  martius
    00039  *   simulation time
    00040  *
    00041  *   Revision 1.5  2007/03/28 07:16:58  martius
    00042  *   trace is drawn thicker
    00043  *
    00044  *   Revision 1.4  2006/12/11 18:11:01  martius
    00045  *   noisefactor and default constructor
    00046  *
    00047  *   Revision 1.3  2006/07/20 17:19:43  martius
    00048  *   removed using namespace std from matrix.h
    00049  *
    00050  *   Revision 1.2  2006/07/14 12:23:31  martius
    00051  *   selforg becomes HEAD
    00052  *
    00053  *   Revision 1.1.2.6  2006/05/15 13:14:10  robot3
    00054  *   STRG-R now makes screenshots in jpg-format
    00055  *   STRG-F now toggles the file logging (controller stuff) on/off
    00056  *   STRG-G now restarts the GuiLogger
    00057  *
    00058  *   Revision 1.1.2.5  2006/03/31 16:16:58  fhesse
    00059  *   changed trace() to init_tracing()
    00060  *   and check for init at beginning of step
    00061  *
    00062  *   Revision 1.1.2.4  2006/03/29 15:08:06  martius
    00063  *   Agent::interninit not necessary
    00064  *
    00065  *   Revision 1.1.2.3  2006/03/28 14:14:44  fhesse
    00066  *   tracing of a given primitive (in the osg window) added
    00067  *
    00068  *   Revision 1.1.2.2  2005/12/06 10:13:23  martius
    00069  *   openscenegraph integration started
    00070  *
    00071  *   Revision 1.1.2.1  2005/11/15 12:29:18  martius
    00072  *   new selforg structure and OdeAgent, OdeRobot ...
    00073  *
    00074  *                                                                 *
    00075  ***************************************************************************/
    00076 #ifndef __ODEAGENT_H
    00077 #define __ODEAGENT_H
    00078
    00079 #include <selforg/agent.h>
    00080 #include "oderobot.h"
    00081 #include "osgprimitive.h"
    00082 #include "primitive.h"
    00083
    00084 namespace lpzrobots {
    00085
    00086
    00087   /** Specialised agent for ode robots
    00088    */
    00089   class OdeAgent : public Agent {
    00090   public:
    00091     /** constructor
    00092      */
    00093     OdeAgent(const PlotOption& plotOption = PlotOption(NoPlot), double noisefactor = 1)
    00094       : Agent(plotOption, noisefactor) { tracing_initialized=false; }
    00095     OdeAgent(const std::list<PlotOption>& plotOptions, double noisefactor = 1)
    00096       : Agent(plotOptions, noisefactor) {tracing_initialized=false;}
    00097     OdeAgent(const GlobalData& globalData, double noisefactor = 1);
    00098     /** destructor
    00099      */
    00100     virtual ~OdeAgent() {}
    00101
    00102     /** initializes the object with the given controller, robot and wiring
    00103         and initializes pipe to guilogger
    00104     */
    00105     virtual bool init(AbstractController* controller, OdeRobot* robot, AbstractWiring* wiring,
    00106                       long int seed = 0){
    00107       return Agent::init(controller, robot, wiring, seed);
    00108     }
    00109
    00110
    00111     virtual void step(double noise, double time);
    00112
    00113     /**
    00114      * Special function for the class Simulation to seperate the step
    00115      * of the WiredController (plus TrackRobot) and the setting and getting
    00116      * of the motor- and sensorvalues.
    00117      * @param noise @see step()
    00118      * @param time @see step()
    00119      */
    00120     virtual void stepOnlyWiredController(double noise, double time);
    00121
    00122     /**
    00123      * Special function for the class Simulation to seperate the step
    00124      * of the WiredController (plus TrackRobot) and the setting and getting
    00125      * of the motor- and sensorvalues.
    00126      */
    00127     virtual void setMotorsGetSensors();
    00128
    00129
    00130     void internInit(){
    00131       trace_length=0; // number of past robot positions shown in osg
    00132     }
    00133
    00134     /**
    00135      * Returns a pointer to the robot.
    00136      */
    00137     virtual OdeRobot* getRobot() { return (OdeRobot*)robot;}
    00138
    00139     /// gives the number of past robot positions shown as trace in osg
    00140     virtual int getTraceLength(){return trace_length;}
    00141
    00142     /**
    00143      * initialize tracing in ode
    00144      * @param tracelength number of past positions shown as trace in osg
    00145      * @param tracethickness  thickness of the trace
    00146      */
    00147     virtual void init_tracing(int tracelength=1000, double tracethickness=0.05);
    00148
    00149
    00150     /**
    00151      * continues the trace by one segment
    00152      */
    00153     virtual void trace();
    00154
    00155
    00156   private:
    00157     int trace_length;
    00158     double trace_thickness;
    00159     int counter;
    00160     bool tracing_initialized;
    00161
    00162     OSGPrimitive** segments; // stores segments(cylinders) of the trace
    00163     osg::Vec3 lastpos;
    00164   };
    00165
    00166 }
    00167
    00168 #endif