Robot Simulator of the Robotics Group for Self-Organization of Control  0.8.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
agent.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2011 LpzRobots development team *
3  * Georg Martius <georg dot martius at web dot de> *
4  * Frank Guettler <guettler at informatik dot uni-leipzig dot de *
5  * Frank Hesse <frank at nld dot ds dot mpg dot de> *
6  * Ralf Der <ralfder at mis dot mpg dot de> *
7  * *
8  * This program is free software; you can redistribute it and/or modify *
9  * it under the terms of the GNU General Public License as published by *
10  * the Free Software Foundation; either version 2 of the License, or *
11  * (at your option) any later version. *
12  * *
13  * This program is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16  * GNU General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU General Public License *
19  * along with this program; if not, write to the *
20  * Free Software Foundation, Inc., *
21  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
22  * *
23  ***************************************************************************/
24 #ifndef __AGENT_H
25 #define __AGENT_H
26 
27 #include <stdio.h>
28 #include <list>
29 #include <string>
30 
31 #include "wiredcontroller.h"
32 #include "randomgenerator.h"
33 
34 class AbstractRobot;
35 
36 #include "types.h"
37 #include "trackrobots.h"
38 
39 /** The Agent contains a controller, a robot and a wiring, which connects robot and controller.
40  Additionally there are some ways to keep track of internal information.
41  You have the possibility to keep track of sensor values,
42  motor values and internal parameters of the controller with PlotOptions.
43  The name PlotOptions is a bit missleaded, it should be "OutputOptions",
44  however you can write the data into a file or send it to visialisation tools like
45  guilogger or neuronviz.
46 
47  If want to log the position, speed and orienation of your robot
48  you can use setTrackOptions().
49  Please be aware that the Agent inherits from WiredController. You
50  might also find useful functions there.
51  */
52 class Agent : public WiredController {
53 public:
54  /** constructor. PlotOption as output setting.
55  noisefactor is used to set the relative noise strength of this agent
56  */
57  Agent(const PlotOption& plotOption = PlotOption(NoPlot), double noisefactor = 1, const iparamkey& name = "Agent", const paramkey& revision = "$ID");
58  /** constructor. A list of PlotOption can given.
59  noisefactor is used to set the relative noise strength of this agent
60  */
61  Agent(const std::list<PlotOption>& plotOptions, double noisefactor = 1, const iparamkey& name = "Agent", const paramkey& revision = "$ID");
62 
63  /** destructor
64  */
65  virtual ~Agent();
66 
67  /** initializes the object with the given controller, robot and wiring
68  and initializes the output options.
69  It is also possible to provide a random seed,
70  if not given (0) rand() is used to create one
71  */
73  AbstractWiring* wiring, long int seed=0);
74 
75  /** Performs an step of the agent, including sensor reading, pushing sensor values through the wiring,
76  controller step, pushing controller outputs (= motorcommands) back through the wiring and sent
77  resulting motorcommands to robot.
78  @param noise Noise strength.
79  @param time (optional) current simulation time (used for logging)
80  */
81  virtual void step(double noise, double time=-1);
82 
83  /** Sends only last motor commands again to robot. */
84  virtual void onlyControlRobot();
85 
86 
87  /** Returns a pointer to the robot.
88  */
89  virtual AbstractRobot* getRobot() { return robot; }
90 
91  /// sets the trackoptions which starts spatial tracking of a robot
92  virtual void setTrackOptions(const TrackRobot& trackrobot);
93 
94  /// stop tracking (returns true of tracking was on);
95  virtual bool stopTracking();
96 
97  /// returns the tracking options
98  virtual TrackRobot getTrackOptions() const { return trackrobot; }
99 
100 protected:
101 
103 
106 
107  RandGen randGen; // random generator for this agent
108 
110  int t; // access to this variable is needed from OdeAgent
111 
112 
113 };
114 
115 #endif
Agent(const PlotOption &plotOption=PlotOption(NoPlot), double noisefactor=1, const iparamkey &name="Agent", const paramkey &revision="$ID")
constructor.
Definition: agent.cpp:39
std::string paramkey
Definition: configurable.h:85
Abstract class for robot controller (with some basic functionality).
Definition: abstractcontroller.h:46
This class provides tracking possibilies of a robot.
Definition: trackrobots.h:60
virtual AbstractRobot * getRobot()
Returns a pointer to the robot.
Definition: agent.h:89
AbstractRobot * robot
Definition: agent.h:102
TrackRobot trackrobot
Definition: agent.h:109
AbstractWiring * wiring
Definition: wiredcontroller.h:154
double sensor
Definition: types.h:29
iparamkey name
Definition: inspectable.h:251
random generator with 48bit integer arithmentic
Definition: randomgenerator.h:34
virtual void onlyControlRobot()
Sends only last motor commands again to robot.
Definition: agent.cpp:104
dummy (does nothing) is there for compatibility, might be removed later
Definition: plotoption.h:42
The WiredController contains a controller and a wiring, which connects the controller with the robot...
Definition: wiredcontroller.h:58
virtual void setTrackOptions(const TrackRobot &trackrobot)
sets the trackoptions which starts spatial tracking of a robot
Definition: agent.cpp:111
virtual ~Agent()
destructor
Definition: agent.cpp:52
virtual TrackRobot getTrackOptions() const
returns the tracking options
Definition: agent.h:98
Abstract wiring-object between controller and robot.
Definition: abstractwiring.h:39
std::string iparamkey
Definition: inspectable.h:53
motor * rmotors
Definition: agent.h:105
This class contains options for the use of an external plot utility like guilogger or neuronviz or ju...
Definition: plotoption.h:66
The Agent contains a controller, a robot and a wiring, which connects robot and controller.
Definition: agent.h:52
virtual void step(double noise, double time=-1)
Performs an step of the agent, including sensor reading, pushing sensor values through the wiring...
Definition: agent.cpp:89
int t
Definition: agent.h:110
double motor
Definition: types.h:30
AbstractController * controller
Definition: wiredcontroller.h:153
RandGen randGen
Definition: agent.h:107
sensor * rsensors
Definition: agent.h:104
virtual bool init(AbstractController *controller, AbstractRobot *robot, AbstractWiring *wiring, long int seed=0)
initializes the object with the given controller, robot and wiring and initializes the output options...
Definition: agent.cpp:61
double noisefactor
factor that is muliplied with noise stength
Definition: wiredcontroller.h:166
virtual bool stopTracking()
stop tracking (returns true of tracking was on);
Definition: agent.cpp:132
Abstract class (interface) for robot in general.
Definition: abstractrobot.h:41