Robotsystem from Robot Group Leipzig: odeagent.h Source File

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- 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.1.2.5  2006/03/31 16:16:58  fhesse
    00024  *   changed trace() to init_tracing()
    00025  *   and check for init at beginning of step
    00026  *
    00027  *   Revision 1.1.2.4  2006/03/29 15:08:06  martius
    00028  *   Agent::interninit not necessary
    00029  *
    00030  *   Revision 1.1.2.3  2006/03/28 14:14:44  fhesse
    00031  *   tracing of a given primitive (in the osg window) added
    00032  *
    00033  *   Revision 1.1.2.2  2005/12/06 10:13:23  martius
    00034  *   openscenegraph integration started
    00035  *
    00036  *   Revision 1.1.2.1  2005/11/15 12:29:18  martius
    00037  *   new selforg structure and OdeAgent, OdeRobot ...
    00038  *
    00039  *                                                                 *
    00040  ***************************************************************************/
    00041 #ifndef __ODEAGENT_H
    00042 #define __ODEAGENT_H
    00043
    00044 #include <selforg/agent.h>
    00045 #include "oderobot.h"
    00046 #include "osgprimitive.h"
    00047 #include "primitive.h"
    00048
    00049 namespace lpzrobots {
    00050
    00051 /** Specialised agent for ode robots
    00052  */
    00053   class OdeAgent : public Agent {
    00054   public:
    00055   /** constructor
    00056    */
    00057   OdeAgent(const PlotOption& plotOption)  : Agent(plotOption) {tracing_initialized=false;}
    00058   OdeAgent(const list<PlotOption>& plotOptions) : Agent(plotOptions) {tracing_initialized=false;}
    00059   /** destructor
    00060    */
    00061   virtual ~OdeAgent() {}
    00062
    00063   /** initializes the object with the given controller, robot and wiring
    00064       and initializes pipe to guilogger
    00065   */
    00066   virtual bool init(AbstractController* controller, OdeRobot* robot, AbstractWiring* wiring){
    00067     return Agent::init(controller, robot, wiring);
    00068   }
    00069
    00070   /** Performs an step of the agent, including sensor reading, pushing sensor values through wiring,
    00071       controller step, pushing controller outputs (= motorcommands) back through wiring and sent
    00072       resulting motorcommands to robot.
    00073       @param noise Noise strength.
    00074   */
    00075   virtual void step(double noise);
    00076
    00077   void internInit(){
    00078     trace_length=0; // number of past robot positions shown in osg
    00079   }
    00080
    00081
    00082   /**
    00083    * Returns a pointer to the robot.
    00084    */
    00085   virtual OdeRobot* getRobot() { return (OdeRobot*)robot;}
    00086
    00087   /// gives the number of past robot positions shown as trace in osg
    00088   virtual int getTraceLength(){return trace_length;}
    00089
    00090   /**
    00091    * initialize tracing in ode
    00092    * @param tracelength number of past positions shown as trace in osg
    00093    * @param tracethickness  thickness of the trace
    00094    */
    00095   virtual void init_tracing(int tracelength=1000, double tracethickness=0.003);
    00096
    00097
    00098  private:
    00099   int trace_length;
    00100   double trace_thickness;
    00101   int counter;
    00102   bool tracing_initialized;
    00103
    00104   OSGPrimitive** segments; // stores segments(cylinders) of the trace
    00105   osg::Vec3 lastpos;
    00106 };
    00107
    00108 }
    00109
    00110 #endif