00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef __OPERATORS_H
00025 #define __OPERATORS_H
00026
00027 #include "operator.h"
00028 #include "axis.h"
00029
00030 namespace lpzrobots {
00031
00032
00033
00034 class LimitOrientationOperator : public Operator {
00035 public:
00036 LimitOrientationOperator(const Axis& robotAxis, const Axis& globalAxis,
00037 double maxAngle, double force)
00038 : Operator("LimitOrientationOperator","1.0"),
00039 robotAxis(robotAxis), globalAxis(globalAxis),
00040 maxAngle(maxAngle), force(force), currentforce(force) {
00041 }
00042
00043 virtual ManipType observe(OdeAgent* agent, GlobalData& global, ManipDescr& descr);
00044 protected:
00045 Axis robotAxis;
00046 Axis globalAxis;
00047 double maxAngle;
00048
00049 double force;
00050 double currentforce;
00051 };
00052
00053
00054 struct LiftUpOperatorConf {
00055 bool resetForceIfLifted;
00056 bool increaseForce;
00057 bool propControl;
00058
00059 bool intervalMode;
00060 double duration;
00061 double interval;
00062
00063 double height;
00064 double force;
00065 double visualHeight;
00066 };
00067
00068
00069
00070
00071 class LiftUpOperator : public Operator {
00072 public:
00073 LiftUpOperator(const LiftUpOperatorConf conf = getDefaultConf())
00074 : Operator("LiftUpOperator","0.8"), conf(conf)
00075 {
00076 currentforce = conf.force;
00077 addParameter("force", &this->conf.force, 0, 100, "lift up force");
00078 addParameter("height", &this->conf.height, 0, 100, "lift up height");
00079 if(conf.intervalMode){
00080 addParameter("interval", &this->conf.interval, 0, 1000, "interval of operation");
00081 addParameter("duration", &this->conf.duration, 0, 1000, "duration of lifting within interval");
00082 }
00083 }
00084
00085 static LiftUpOperatorConf getDefaultConf(){
00086 LiftUpOperatorConf c;
00087 c.resetForceIfLifted = true;
00088 c.increaseForce = true;
00089 c.intervalMode = false;
00090 c.propControl = true;
00091 c.duration = 1;
00092 c.interval = 10;
00093 c.height = 1;
00094 c.force = 1;
00095 c.visualHeight = 0.5;
00096 return c;
00097 }
00098
00099 virtual ManipType observe(OdeAgent* agent, GlobalData& global, ManipDescr& descr);
00100 protected:
00101 LiftUpOperatorConf conf;
00102
00103 double currentforce;
00104 };
00105
00106
00107
00108
00109
00110 class PullToPointOperator : public Operator {
00111 public:
00112
00113 enum Dimensions { X = 1, Y = 2, Z = 4, XY = X | Y, XZ = X | Z, YZ = Y | Z,
00114 XYZ = X | Y | Z };
00115
00116
00117
00118
00119
00120
00121
00122
00123 PullToPointOperator(const Pos& point, double force,
00124 bool showPoint, Dimensions dim = XYZ,
00125 double minDist = 0, double damp = 0, bool confPos = false)
00126 : Operator("PullToPointOperator","1.0"),
00127 point(point), force(force), showPoint(showPoint), dim(dim),
00128 minDist(minDist), damp(damp)
00129 {
00130 addParameter("force", &this->force, 0, 100, "pull to point force");
00131 addParameter("damp", &this->damp, 0, 1, "pull to point damping");
00132 if(confPos){
00133 if(dim & X)
00134 addParameterDef("point_x", &px, point.x(), -100, 100,"pull to point x position");
00135 if(dim & Y)
00136 addParameterDef("point_y", &py, point.y(), -100, 100,"pull to point y position");
00137 if(dim & Z)
00138 addParameterDef("point_z", &pz, point.z(), -100, 100,"pull to point z position");
00139 }
00140 }
00141
00142 virtual ManipType observe(OdeAgent* agent, GlobalData& global, ManipDescr& descr);
00143
00144 virtual void notifyOnChange(const paramkey& key);
00145
00146 protected:
00147 Pos point;
00148 double force;
00149 bool showPoint;
00150 Dimensions dim;
00151 double minDist;
00152 double damp;
00153 double px,py,pz;
00154 };
00155
00156
00157
00158
00159 class BoxRingOperator : public Operator {
00160 public:
00161
00162
00163
00164
00165
00166
00167 BoxRingOperator(const Pos& center, double size, double offset,
00168 double force, bool sphere = false)
00169 : Operator("BoxRingOperator","1.0"),
00170 center(center), size(size), offset(offset), force(force), sphere(sphere)
00171 {
00172 addParameter("force", &this->force, 0, 1000,
00173 "force of the boxring to keep robots inside");
00174 addParameter("boxringsize", &this->size, .5, 100,
00175 "size of boxring/spherical arena (in radius or half-length)");
00176 }
00177
00178 virtual ManipType observe(OdeAgent* agent, GlobalData& global, ManipDescr& descr);
00179
00180 protected:
00181
00182 Pos center;
00183 double size;
00184 double offset;
00185 double force;
00186 bool sphere;
00187 };
00188
00189
00190
00191 }
00192
00193 #endif