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

# agent.h

Go to the documentation of this file.

    00001 /***************************************************************************
    00002  *   Copyright (C) 2005-2011 LpzRobots development team                    *
    00003  *    Georg Martius  <georg dot martius at web dot de>                     *
    00004  *    Frank Guettler <guettler at informatik dot uni-leipzig dot de        *
    00005  *    Frank Hesse    <frank at nld dot ds dot mpg dot de>                  *
    00006  *    Ralf Der       <ralfder at mis dot mpg dot de>                       *
    00007  *                                                                         *
    00008  *   This program is free software; you can redistribute it and/or modify  *
    00009  *   it under the terms of the GNU General Public License as published by  *
    00010  *   the Free Software Foundation; either version 2 of the License, or     *
    00011  *   (at your option) any later version.                                   *
    00012  *                                                                         *
    00013  *   This program is distributed in the hope that it will be useful,       *
    00014  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
    00015  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
    00016  *   GNU General Public License for more details.                          *
    00017  *                                                                         *
    00018  *   You should have received a copy of the GNU General Public License     *
    00019  *   along with this program; if not, write to the                         *
    00020  *   Free Software Foundation, Inc.,                                       *
    00021  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
    00022  *                                                                         *
    00023  ***************************************************************************/
    00024 #ifndef __AGENT_H
    00025 #define __AGENT_H
    00026
    00027 #include <stdio.h>
    00028 #include <list>
    00029 #include <string>
    00030
    00031 #include "wiredcontroller.h"
    00032 #include "randomgenerator.h"
    00033
    00034 class AbstractRobot;
    00035
    00036 #include "types.h"
    00037 #include "trackrobots.h"
    00038
    00039 /** The Agent contains a controller, a robot and a wiring, which connects robot and controller.
    00040     Additionally there are some ways to keep track of internal information.
    00041     You have the possibility to keep track of sensor values,
    00042      motor values and internal parameters of the controller with PlotOptions.
    00043     The name PlotOptions is a bit missleaded, it should be "OutputOptions",
    00044      however you can write the data into a file or send it to visialisation tools like
    00045      guilogger or neuronviz.
    00046
    00047     If want to log the position, speed and orienation of your robot
    00048     you can use setTrackOptions().
    00049     Please be aware that the Agent inherits from WiredController. You
    00050      might also find useful functions there.
    00051  */
    00052 class Agent : public WiredController {
    00053 public:
    00054   /** constructor. PlotOption as output setting.
    00055       noisefactor is used to set the relative noise strength of this agent
    00056    */
    00057   Agent(const PlotOption& plotOption = PlotOption(NoPlot), double noisefactor = 1, const iparamkey& name = "Agent", const paramkey& revision = "$ID");
    00058   /** constructor. A list of PlotOption can given.
    00059       noisefactor is used to set the relative noise strength of this agent
    00060    */
    00061   Agent(const std::list<PlotOption>& plotOptions, double noisefactor = 1, const iparamkey& name = "Agent", const paramkey& revision = "$ID");
    00062
    00063   /** destructor
    00064    */
    00065   virtual ~Agent();
    00066
    00067   /** initializes the object with the given controller, robot and wiring
    00068       and initializes the output options.
    00069       It is also possible to provide a random seed,
    00070        if not given (0) rand() is used to create one
    00071   */
    00072   virtual bool init(AbstractController* controller, AbstractRobot* robot,
    00073                     AbstractWiring* wiring, long int seed=0);
    00074
    00075   /** Performs an step of the agent, including sensor reading, pushing sensor values through the wiring,
    00076       controller step, pushing controller outputs (= motorcommands) back through the wiring and sent
    00077       resulting motorcommands to robot.
    00078       @param noise Noise strength.
    00079       @param time (optional) current simulation time (used for logging)
    00080   */
    00081   virtual void step(double noise, double time=-1);
    00082
    00083   /** Sends only last motor commands again to robot.  */
    00084   virtual void onlyControlRobot();
    00085
    00086   /** Returns a pointer to the robot.
    00087    */
    00088   virtual AbstractRobot* getRobot() { return robot;}
    00089
    00090   /// sets the trackoptions which enable tracking of a robot
    00091   virtual void setTrackOptions(const TrackRobot& trackrobot);
    00092
    00093 protected:
    00094
    00095   AbstractRobot* robot;
    00096
    00097   sensor *rsensors;
    00098   motor  *rmotors;
    00099
    00100   RandGen randGen; // random generator for this agent
    00101
    00102   TrackRobot trackrobot;
    00103   int t; // access to this variable is needed from OdeAgent
    00104
    00105
    00106 };
    00107
    00108 #endif