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
operators.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 __OPERATORS_H
25 #define __OPERATORS_H
26 
27 #include "operator.h"
28 #include "axis.h"
29 
30 namespace lpzrobots {
31  /**
32  An Operator for limiting the orientation of the main primitive of a robot.
33  If the robot axis has a larger enclosing angle with the global axis than
34  maxAngle the force is applied until the angle is lower than minAngle.
35  If minAngle<0 then minAngle=maxAngle/2.
36  */
38  public:
40  double maxAngle, double force, double minAngle=-1)
41  : Operator("LimitOrientationOperator","1.0"),
42  robotAxis(robotAxis), globalAxis(globalAxis),
43  maxAngle(maxAngle), force(force), minAngle(minAngle),
44  currentforce(force), active(false) {
45  if(this->minAngle<0) this->minAngle=maxAngle/2;
46  }
47 
48  virtual ManipType observe(OdeAgent* agent, GlobalData& global, ManipDescr& descr);
49  protected:
52  double maxAngle;
53  double force;
54  double minAngle;
55  double currentforce;
56  bool active;
57  };
58 
59 
61  bool resetForceIfLifted; ///< force is reseted as soon as robot has reached height
62  bool increaseForce; ///< increase force (until robot has reached height)
63  bool propControl; ///< if true then applied force is scaled with distance
64 
65  bool intervalMode; ///< if true then the operator works only in intervals
66  double duration; ///< duration of operation in interval-mode
67  double interval; ///< interval between restart of operation ( > duration)
68 
69  double height; ///< height to which it is lifted
70  double force; ///< initial force
71  double visualHeight; ///< height above the robot main object for the visual sphere
72  };
73 
74  /**
75  An Operator for lifting up a robot from time to time.
76  */
77  class LiftUpOperator : public Operator {
78  public:
80  : Operator("LiftUpOperator","0.8"), conf(conf)
81  {
83  addParameter("force", &this->conf.force, 0, 100, "lift up force");
84  addParameter("height", &this->conf.height, 0, 100, "lift up height");
85  if(conf.intervalMode){
86  addParameter("interval", &this->conf.interval, 0, 1000, "interval of operation");
87  addParameter("duration", &this->conf.duration, 0, 1000, "duration of lifting within interval");
88  }
89  }
90 
93  c.resetForceIfLifted = true;
94  c.increaseForce = true;
95  c.intervalMode = false;
96  c.propControl = true;
97  c.duration = 1;
98  c.interval = 10;
99  c.height = 1;
100  c.force = 1;
101  c.visualHeight = 0.5;
102  return c;
103  }
104 
105  virtual ManipType observe(OdeAgent* agent, GlobalData& global, ManipDescr& descr);
106  protected:
108 
109  double currentforce;
110  };
111 
112 
113  /**
114  An Operator for pulling the main primitive of a robot towards a point
115  */
116  class PullToPointOperator : public Operator {
117  public:
118  /// defines which dimensions should be effected
119  enum Dimensions { X = 1, Y = 2, Z = 4, XY = X | Y, XZ = X | Z, YZ = Y | Z,
120  XYZ = X | Y | Z };
121 
122  /**
123  @param dim dimensions along the force acts
124  (also only these coordinates of point are considered)
125  @minDist threshold for distance below which no force acts
126  @damp damping factor for movement of the robot
127  @confPos whether to make the point configurable
128  */
130  bool showPoint, Dimensions dim = XYZ,
131  double minDist = 0, double damp = 0, bool confPos = false)
132 
133  : Operator("PullToPointOperator","1.0"),
134  point(point), force(force), showPoint(showPoint), dim(dim),
136  {
137  addParameter("force", &this->force, 0, 100, "pull to point force");
138  addParameter("damp", &this->damp, 0, 1, "pull to point damping");
139  if(confPos){
140  if(dim & X)
141  addParameterDef("point_x", &px, point.x(), -100, 100,"pull to point x position");
142  if(dim & Y)
143  addParameterDef("point_y", &py, point.y(), -100, 100,"pull to point y position");
144  if(dim & Z)
145  addParameterDef("point_z", &pz, point.z(), -100, 100,"pull to point z position");
146  }
147  }
148 
149  virtual ManipType observe(OdeAgent* agent, GlobalData& global, ManipDescr& descr);
150 
151  virtual void notifyOnChange(const paramkey& key);
152 
153  protected:
155  double force;
156  bool showPoint;
158  double minDist;
159  double damp;
160  double px,py,pz; // used to configure position (are floats and not doubles)
161  };
162 
163  /**
164  An Operator for keeping robots within a sphere / box
165  */
166  class BoxRingOperator : public Operator {
167  public:
168 
169  /** a box ring (cube with edges 2*size or sphere with radius size)
170  @param offset distance to wall before acting (to compensate for body width)
171  @sphere spherical or box shape area
172  */
173 
174  BoxRingOperator(const Pos& center, double size, double offset,
175  double force, bool sphere = false)
176  : Operator("BoxRingOperator","1.0"),
177  center(center), size(size), offset(offset), force(force), sphere(sphere)
178  {
179  addParameter("force", &this->force, 0, 1000,
180  "force of the boxring to keep robots inside");
181  addParameter("boxringsize", &this->size, .5, 100,
182  "size of boxring/spherical arena (in radius or half-length)");
183  }
184 
185  virtual ManipType observe(OdeAgent* agent, GlobalData& global, ManipDescr& descr);
186 
187  protected:
188 
190  double size;
191  double offset;
192  double force;
193  bool sphere;
194  };
195 
196 
197 
198 }
199 
200 #endif
virtual ManipType observe(OdeAgent *agent, GlobalData &global, ManipDescr &descr)
called every simulation step
Definition: operators.cpp:59
double force
initial force
Definition: operators.h:70
double minDist
Definition: operators.h:158
double visualHeight
height above the robot main object for the visual sphere
Definition: operators.h:71
virtual void notifyOnChange(const paramkey &key)
Is called when a parameter was changes via setParam().
Definition: operators.cpp:134
ManipType
type of manipulation of the robot (for display) and or operation RemoveOperator means that the operat...
Definition: operator.h:47
Definition: axis.h:36
Definition: operators.h:119
bool active
Definition: operators.h:56
An Operator for lifting up a robot from time to time.
Definition: operators.h:77
Axis globalAxis
Definition: operators.h:51
double pz
Definition: operators.h:160
charArray paramkey
Definition: avrtypes.h:36
double minAngle
Definition: operators.h:54
Definition: operators.h:60
double py
Definition: operators.h:160
double force
Definition: operators.h:155
double maxAngle
Definition: operators.h:52
double interval
interval between restart of operation ( > duration)
Definition: operators.h:67
double height
height to which it is lifted
Definition: operators.h:69
Definition: pos.h:36
Definition: operators.h:120
Definition: operators.h:119
virtual ManipType observe(OdeAgent *agent, GlobalData &global, ManipDescr &descr)
called every simulation step
Definition: operators.cpp:145
virtual ManipType observe(OdeAgent *agent, GlobalData &global, ManipDescr &descr)
called every simulation step
Definition: operators.cpp:104
double currentforce
Definition: operators.h:109
bool propControl
if true then applied force is scaled with distance
Definition: operators.h:63
An Operator for keeping robots within a sphere / box.
Definition: operators.h:166
bool showPoint
Definition: operators.h:156
Definition: operators.h:119
Axis robotAxis
Definition: operators.h:50
static LiftUpOperatorConf getDefaultConf()
Definition: operators.h:91
double damp
Definition: operators.h:159
virtual ManipType observe(OdeAgent *agent, GlobalData &global, ManipDescr &descr)
called every simulation step
Definition: operators.cpp:30
Data structure holding all essential global information.
Definition: globaldata.h:57
Specialised agent for ode robots.
Definition: odeagent.h:62
Pos point
Definition: operators.h:154
double size
Definition: operators.h:190
virtual void addParameter(const paramkey &key, paramval *val, paramval minBound, paramval maxBound, const paramdescr &descr=paramdescr())
This is the new style for adding configurable parameters.
Definition: configurable.h:172
LiftUpOperatorConf conf
Definition: operators.h:107
PullToPointOperator(const Pos &point, double force, bool showPoint, Dimensions dim=XYZ, double minDist=0, double damp=0, bool confPos=false)
Definition: operators.h:129
Definition: operator.h:42
virtual void addParameterDef(const paramkey &key, paramval *val, paramval def, paramval minBound, paramval maxBound, const paramdescr &descr=paramdescr())
This function is only provided for convenience.
Definition: configurable.h:220
An Operator for pulling the main primitive of a robot towards a point.
Definition: operators.h:116
bool sphere
Definition: operators.h:193
double offset
Definition: operators.h:191
double px
Definition: operators.h:160
BoxRingOperator(const Pos &center, double size, double offset, double force, bool sphere=false)
a box ring (cube with edges 2*size or sphere with radius size)
Definition: operators.h:174
bool intervalMode
if true then the operator works only in intervals
Definition: operators.h:65
double force
Definition: operators.h:53
LimitOrientationOperator(const Axis &robotAxis, const Axis &globalAxis, double maxAngle, double force, double minAngle=-1)
Definition: operators.h:39
Dimensions
defines which dimensions should be effected
Definition: operators.h:119
bool increaseForce
increase force (until robot has reached height)
Definition: operators.h:62
Definition: operators.h:119
An Operator for limiting the orientation of the main primitive of a robot.
Definition: operators.h:37
double currentforce
Definition: operators.h:55
Dimensions dim
Definition: operators.h:157
double duration
duration of operation in interval-mode
Definition: operators.h:66
bool resetForceIfLifted
force is reseted as soon as robot has reached height
Definition: operators.h:61
Definition: operators.h:119
Pos center
Definition: operators.h:189
LiftUpOperator(const LiftUpOperatorConf conf=getDefaultConf())
Definition: operators.h:79
Definition: operators.h:119
int c
Definition: hexapod.cpp:56
double force
Definition: operators.h:192