00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef __GT2004SimpleBasicBehaviors_h_
00014 #define __GT2004SimpleBasicBehaviors_h_
00015
00016 #include "../../BehaviorControl.h"
00017 #include "Tools/Xabsl2/Xabsl2Engine/Xabsl2Engine.h"
00018 #include "Tools/Actorics/WalkAccelerationRestrictor.h"
00019 #include "Tools/Math/PIDsmoothedValue.h"
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 class GT2004BasicBehaviorGoToBall : public Xabsl2BasicBehavior, public BehaviorControlInterfaces
00030 {
00031 public:
00032
00033
00034
00035
00036
00037 GT2004BasicBehaviorGoToBall(BehaviorControlInterfaces& interfaces,
00038 Xabsl2ErrorHandler& errorHandler)
00039 : Xabsl2BasicBehavior("go-to-ball", errorHandler),
00040 BehaviorControlInterfaces(interfaces),
00041 accelerationRestrictor(motionRequest)
00042 {
00043 registerParameter("go-to-ball.distance",distanceAtEnd);
00044 registerParameter("go-to-ball.max-speed", maxSpeed);
00045 registerParameter("go-to-ball.max-speed.y", maxSpeedY);
00046 registerParameter("go-to-ball.max-turn-speed", maxTurnSpeed);
00047 registerParameter("go-to-ball.target-angle-to-ball", targetAngleToBall);
00048 registerParameter("go-to-ball.walk-type", walkType);
00049 registerParameter("go-to-ball.y-offset", yOffset);
00050 }
00051
00052
00053 virtual void execute();
00054
00055 private:
00056
00057 double distanceAtEnd;
00058
00059
00060 double maxSpeed;
00061
00062
00063 double maxSpeedY;
00064
00065
00066 WalkAccelerationRestrictor accelerationRestrictor;
00067
00068
00069 double targetAngleToBall;
00070
00071
00072 double yOffset;
00073
00074
00075 double walkType;
00076
00077
00078 double maxTurnSpeed;
00079 };
00080
00081
00082
00083
00084
00085
00086 class GT2004BasicBehaviorGoToBallWithoutTurning: public Xabsl2BasicBehavior, public BehaviorControlInterfaces
00087 {
00088 public:
00089
00090
00091
00092
00093
00094 GT2004BasicBehaviorGoToBallWithoutTurning(BehaviorControlInterfaces& interfaces,
00095 Xabsl2ErrorHandler& errorHandler)
00096 : Xabsl2BasicBehavior("go-to-ball-without-turning", errorHandler),
00097 BehaviorControlInterfaces(interfaces),
00098 accelerationRestrictor(motionRequest)
00099 {
00100 registerParameter("go-to-ball-without-turning.max-speed", maxSpeed);
00101 }
00102
00103
00104 virtual void execute();
00105
00106 private:
00107
00108 double distanceAtEnd;
00109
00110
00111 double maxSpeed;
00112
00113
00114 double maxSpeedY;
00115
00116
00117 WalkAccelerationRestrictor accelerationRestrictor;
00118
00119
00120 double targetAngleToBall;
00121
00122
00123 double yOffset;
00124
00125
00126 double walkType;
00127
00128
00129 double maxTurnSpeed;
00130 };
00131
00132
00133
00134
00135
00136
00137
00138 class GT2004BasicBehaviorGoToPoint : public Xabsl2BasicBehavior, public BehaviorControlInterfaces
00139 {
00140 public:
00141
00142
00143
00144
00145
00146 GT2004BasicBehaviorGoToPoint(BehaviorControlInterfaces& interfaces,
00147 Xabsl2ErrorHandler& errorHandler)
00148 : Xabsl2BasicBehavior("go-to-point", errorHandler),
00149 BehaviorControlInterfaces(interfaces),
00150 accelerationRestrictor(motionRequest)
00151 {
00152 registerParameter("go-to-point.x", x);
00153 registerParameter("go-to-point.y", y);
00154 registerParameter("go-to-point.destination-angle", destinationAngle);
00155 registerParameter("go-to-point.distance-remain", distanceRemain);
00156 registerParameter("go-to-point.angle-remain", angleRemain);
00157 registerParameter("go-to-point.max-speed", maxSpeed);
00158 registerParameter("go-to-point.max-speed.y", maxSpeedY);
00159 registerParameter("go-to-point.walk-type", walkType);
00160 }
00161
00162
00163 virtual void execute();
00164
00165 protected:
00166
00167 double x;
00168
00169
00170 double y;
00171
00172
00173 double destinationAngle;
00174
00175
00176 double distanceRemain;
00177
00178
00179 double angleRemain;
00180
00181
00182 double maxSpeed;
00183
00184
00185 double maxSpeedY;
00186
00187
00188 double walkType;
00189
00190
00191 WalkAccelerationRestrictor accelerationRestrictor;
00192 };
00193
00194
00195
00196
00197
00198
00199 class GT2004BasicBehaviorTurnAroundPoint : public Xabsl2BasicBehavior, public BehaviorControlInterfaces
00200 {
00201 public:
00202
00203
00204
00205
00206
00207 GT2004BasicBehaviorTurnAroundPoint(BehaviorControlInterfaces& interfaces,
00208 Xabsl2ErrorHandler& errorHandler)
00209 : Xabsl2BasicBehavior("turn-around-point", errorHandler),
00210 BehaviorControlInterfaces(interfaces),
00211 accelerationRestrictor(motionRequest)
00212 {
00213 registerParameter("turn-around-point.x", x);
00214 registerParameter("turn-around-point.y", y);
00215 registerParameter("turn-around-point.radius", radius);
00216 registerParameter("turn-around-point.left-right", leftRight);
00217 registerParameter("turn-around-point.forward-component", forwardComponent);
00218 }
00219
00220
00221 virtual void execute();
00222
00223 protected:
00224
00225 double x;
00226
00227
00228 double y;
00229
00230
00231 double radius;
00232
00233
00234 double leftRight;
00235
00236
00237 double forwardComponent;
00238
00239
00240 WalkAccelerationRestrictor accelerationRestrictor;
00241 };
00242
00243
00244 class GT2004BasicBehaviorGoaliePosition : public Xabsl2BasicBehavior, public BehaviorControlInterfaces
00245 {
00246 public:
00247
00248
00249
00250
00251
00252 GT2004BasicBehaviorGoaliePosition(BehaviorControlInterfaces& interfaces,
00253 Xabsl2ErrorHandler& errorHandler)
00254 : Xabsl2BasicBehavior("goalie-position", errorHandler),
00255 BehaviorControlInterfaces(interfaces)
00256 {
00257 registerParameter("goalie-position.max-speed", maxSpeed);
00258 registerParameter("goalie-position.min-x-trans", minXTrans);
00259 registerParameter("goalie-position.min-y-trans", minYTrans);
00260 registerParameter("goalie-position.weight-pose", weightPose);
00261 registerParameter("goalie-position.weight-odo", weightOdo);
00262 registerParameter("goalie-position.cut-y", cutY);
00263 registerParameter("goalie-position.guard-direct-to-goal", guardDirectToGoal);
00264 registerParameter("goalie-position.guard-line", guardLine);
00265 }
00266
00267
00268 virtual void execute();
00269
00270 protected:
00271
00272 double maxSpeed;
00273 double minXTrans;
00274 double minYTrans;
00275 double weightPose;
00276 double weightOdo;
00277 double cutY;
00278 double guardDirectToGoal;
00279 double guardLine;
00280
00281 Pose2D lastRobotPose;
00282 Pose2D lastOdometry;
00283 Pose2D goaliePose;
00284 Pose2D lastGoaliePose;
00285
00286
00287 };
00288
00289
00290
00291
00292
00293 class GT2004BasicBehaviorGoaliePositionReturn : public Xabsl2BasicBehavior, public BehaviorControlInterfaces
00294 {
00295 public:
00296
00297
00298
00299
00300
00301 GT2004BasicBehaviorGoaliePositionReturn(BehaviorControlInterfaces& interfaces,
00302 Xabsl2ErrorHandler& errorHandler)
00303 : Xabsl2BasicBehavior("goalie-position-return", errorHandler),
00304 BehaviorControlInterfaces(interfaces),
00305 accelerationRestrictor(motionRequest)
00306 {
00307 registerParameter("goalie-position-return.x", x);
00308 registerParameter("goalie-position-return.y", y);
00309 registerParameter("goalie-position-return.destination-angle", destinationAngle);
00310 registerParameter("goalie-position-return.max-speed", maxSpeed);
00311 }
00312
00313
00314 virtual void execute();
00315
00316 protected:
00317
00318 double x;
00319
00320
00321 double y;
00322
00323
00324 double destinationAngle;
00325
00326
00327 double maxSpeed;
00328
00329
00330 WalkAccelerationRestrictor accelerationRestrictor;
00331 };
00332
00333
00334
00335
00336
00337
00338 class GT2004BasicBehaviorGoForwardToPoint : public Xabsl2BasicBehavior, public BehaviorControlInterfaces
00339 {
00340 public:
00341
00342
00343
00344
00345
00346 GT2004BasicBehaviorGoForwardToPoint(BehaviorControlInterfaces& interfaces,
00347 Xabsl2ErrorHandler& errorHandler)
00348 : Xabsl2BasicBehavior("go-forward-to-point", errorHandler),
00349 BehaviorControlInterfaces(interfaces),
00350 accelerationRestrictor(motionRequest)
00351 {
00352 registerParameter("go-forward-to-point.x", x);
00353 registerParameter("go-forward-to-point.y", y);
00354 registerParameter("go-forward-to-point.max-speed", maxSpeed);
00355 }
00356
00357
00358 virtual void execute();
00359
00360 protected:
00361
00362 double x;
00363
00364
00365 double y;
00366
00367
00368 double maxSpeed;
00369
00370
00371 WalkAccelerationRestrictor accelerationRestrictor;
00372 };
00373
00374
00375
00376
00377
00378 class GT2004BasicBehaviorGoToPointAndAvoidObstacles : public Xabsl2BasicBehavior, public BehaviorControlInterfaces
00379 {
00380 public:
00381
00382
00383
00384
00385
00386 GT2004BasicBehaviorGoToPointAndAvoidObstacles(BehaviorControlInterfaces& interfaces,
00387 Xabsl2ErrorHandler& errorHandler)
00388 : Xabsl2BasicBehavior("go-to-point-and-avoid-obstacles", errorHandler),
00389 BehaviorControlInterfaces(interfaces),
00390 turnSpeed(0, .5, 0, 0, -pi, pi, pi/2),
00391 speedX(0, .4, 0, 0, -80, 350, 100),
00392 speedY(0, .4, 0, 0, -100, 100, 100)
00393 {
00394 registerParameter("go-to-point-and-avoid-obstacles.x", x);
00395 registerParameter("go-to-point-and-avoid-obstacles.y", y);
00396 registerParameter("go-to-point-and-avoid-obstacles.max-speed", maxSpeed);
00397 registerParameter("go-to-point-and-avoid-obstacles.avoidance-level", avoidanceLevel);
00398 }
00399
00400
00401 virtual void execute();
00402
00403 private:
00404
00405 double x;
00406
00407
00408 double y;
00409
00410
00411 double maxSpeed;
00412
00413
00414 double avoidanceLevel;
00415
00416
00417 PIDsmoothedValue turnSpeed;
00418
00419
00420 PIDsmoothedValue speedX;
00421
00422
00423 PIDsmoothedValue speedY;
00424
00425
00426 long lastTimeExecuted;
00427 };
00428
00429
00430
00431
00432
00433 class GT2004BasicBehaviorMoveTheBridge : public Xabsl2BasicBehavior, public BehaviorControlInterfaces
00434 {
00435 public:
00436
00437
00438
00439
00440
00441 GT2004BasicBehaviorMoveTheBridge(BehaviorControlInterfaces& interfaces,
00442 Xabsl2ErrorHandler& errorHandler)
00443 : Xabsl2BasicBehavior("move-the-bridge", errorHandler),
00444 BehaviorControlInterfaces(interfaces)
00445 {
00446 registerParameter("move-the-bridge.type", type);
00447 registerParameter("move-the-bridge.x", x);
00448 registerParameter("move-the-bridge.y", y);
00449 registerParameter("move-the-bridge.rotation", rotation);
00450 }
00451
00452
00453 virtual void execute();
00454
00455 private:
00456
00457 double x;
00458
00459
00460 double y;
00461
00462
00463 double type;
00464
00465
00466 double rotation;
00467
00468 };
00469
00470
00471
00472
00473
00474 class GT2004BasicBehaviorDogAsJoystick : public Xabsl2BasicBehavior, public BehaviorControlInterfaces
00475 {
00476 public:
00477
00478
00479
00480
00481
00482 GT2004BasicBehaviorDogAsJoystick(BehaviorControlInterfaces& interfaces,
00483 Xabsl2ErrorHandler& errorHandler)
00484 : Xabsl2BasicBehavior("dog-as-joystick", errorHandler),
00485 BehaviorControlInterfaces(interfaces)
00486 {
00487 }
00488
00489
00490 virtual void execute();
00491
00492 private:
00493 };
00494
00495
00496
00497
00498
00499
00500 class GT2004SimpleBasicBehaviors : public BehaviorControlInterfaces
00501 {
00502 public:
00503
00504
00505
00506 GT2004SimpleBasicBehaviors(BehaviorControlInterfaces& interfaces,
00507 Xabsl2ErrorHandler& errorHandler)
00508 : BehaviorControlInterfaces(interfaces),
00509 errorHandler(errorHandler),
00510 basicBehaviorGoToBallWoTurning(interfaces,errorHandler),
00511 basicBehaviorGoToBall(interfaces,errorHandler),
00512 basicBehaviorGoToPoint(interfaces,errorHandler),
00513 basicBehaviorGoForwardToPoint(interfaces,errorHandler),
00514 basicBehaviorTurnAroundPoint(interfaces,errorHandler),
00515 basicBehaviorGoToPointAndAvoidObstacles(interfaces,errorHandler),
00516 basicBehaviorMoveTheBridge(interfaces,errorHandler),
00517 basicBehaviorDogAsJoystick(interfaces,errorHandler),
00518 basicBehaviorGoaliePosition(interfaces,errorHandler),
00519 basicBehaviorGoaliePositionReturn(interfaces,errorHandler)
00520 {}
00521
00522
00523 void registerBasicBehaviors(Xabsl2Engine& engine)
00524 {
00525 engine.registerBasicBehavior(basicBehaviorGoToBallWoTurning);
00526 engine.registerBasicBehavior(basicBehaviorGoToBall);
00527 engine.registerBasicBehavior(basicBehaviorGoToPoint);
00528 engine.registerBasicBehavior(basicBehaviorGoForwardToPoint);
00529 engine.registerBasicBehavior(basicBehaviorGoToPointAndAvoidObstacles);
00530 engine.registerBasicBehavior(basicBehaviorTurnAroundPoint);
00531 engine.registerBasicBehavior(basicBehaviorMoveTheBridge);
00532 engine.registerBasicBehavior(basicBehaviorDogAsJoystick);
00533 engine.registerBasicBehavior(basicBehaviorGoaliePosition);
00534 engine.registerBasicBehavior(basicBehaviorGoaliePositionReturn);
00535
00536 }
00537
00538 private:
00539
00540 Xabsl2ErrorHandler& errorHandler;
00541
00542
00543
00544 GT2004BasicBehaviorGoToBallWithoutTurning
00545 basicBehaviorGoToBallWoTurning;
00546 GT2004BasicBehaviorGoToBall basicBehaviorGoToBall;
00547 GT2004BasicBehaviorGoToPoint basicBehaviorGoToPoint;
00548 GT2004BasicBehaviorGoForwardToPoint basicBehaviorGoForwardToPoint;
00549 GT2004BasicBehaviorTurnAroundPoint basicBehaviorTurnAroundPoint;
00550 GT2004BasicBehaviorGoToPointAndAvoidObstacles basicBehaviorGoToPointAndAvoidObstacles;
00551 GT2004BasicBehaviorMoveTheBridge basicBehaviorMoveTheBridge;
00552 GT2004BasicBehaviorDogAsJoystick basicBehaviorDogAsJoystick;
00553 GT2004BasicBehaviorGoaliePosition basicBehaviorGoaliePosition;
00554 GT2004BasicBehaviorGoaliePositionReturn basicBehaviorGoaliePositionReturn;
00555
00556 };
00557
00558 #endif // __GT2004SimpleBasicBehaviors_h_
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639