summaryrefslogtreecommitdiffhomepage
path: root/digital/io-hub/src/apbirthday
diff options
context:
space:
mode:
authorNicolas Schodet2013-05-08 19:58:05 +0200
committerNicolas Schodet2013-05-08 19:58:05 +0200
commitf50a7e8d96cb8daf95b5e3f422f1350237d34dc3 (patch)
tree908b875a96ab234dec041bbc4ba3d4615c8a542e /digital/io-hub/src/apbirthday
parentee07cf05d3e699bdca7c807c4d09abddf5b2fba7 (diff)
digital/io-hub/src/apbirthday: add cannon fire in simple strat
Diffstat (limited to 'digital/io-hub/src/apbirthday')
-rw-r--r--digital/io-hub/src/apbirthday/strat.cc10
-rw-r--r--digital/io-hub/src/apbirthday/strat.hh1
-rw-r--r--digital/io-hub/src/apbirthday/top.cc25
3 files changed, 35 insertions, 1 deletions
diff --git a/digital/io-hub/src/apbirthday/strat.cc b/digital/io-hub/src/apbirthday/strat.cc
index d92f98bd..446b8b7a 100644
--- a/digital/io-hub/src/apbirthday/strat.cc
+++ b/digital/io-hub/src/apbirthday/strat.cc
@@ -34,6 +34,8 @@ Strat::decision (Position &pos)
static int step;
static const int plate_app = pg_plate_size_border + BOT_SIZE_RADIUS + 20;
static const int plate_load = pg_plate_size_border + BOT_SIZE_BACK - 40;
+ if (step > 4)
+ step = 2;
switch (step++)
{
case 0:
@@ -65,11 +67,17 @@ Strat::decision (Position &pos)
pos.v = (vect_t) { 900, pg_gifts_distance + BOT_SIZE_SIDE };
pos.a = 0;
return GIFTS;
- case 2:
default:
+ case 2:
pos.v = pg_cake_pos;
pos.a = 0;
return CANDLES;
+ case 4:
+ if (team_color)
+ pos = pg_position_deg (1500, 1200, 90);
+ else
+ pos = pg_position_deg (1500 - 200, 1200, 90);
+ return CANNON;
}
}
diff --git a/digital/io-hub/src/apbirthday/strat.hh b/digital/io-hub/src/apbirthday/strat.hh
index 5dfa0768..f5266827 100644
--- a/digital/io-hub/src/apbirthday/strat.hh
+++ b/digital/io-hub/src/apbirthday/strat.hh
@@ -35,6 +35,7 @@ class Strat
{
CANDLES,
PLATE,
+ CANNON,
GIFTS,
};
/// Information on a candle decision.
diff --git a/digital/io-hub/src/apbirthday/top.cc b/digital/io-hub/src/apbirthday/top.cc
index 25c344dd..4fd39c36 100644
--- a/digital/io-hub/src/apbirthday/top.cc
+++ b/digital/io-hub/src/apbirthday/top.cc
@@ -307,6 +307,10 @@ ANGFSM_STATES (
TOP_PLATE_LOADING,
// Plate: drop plate.
TOP_PLATE_DROPING,
+ // Cannon: go to fire position.
+ TOP_CANNON_GOTO,
+ // Cannon: Firing.
+ TOP_CANNON_FIRING,
// Gifts: go to gifts.
TOP_GIFTS_GOTO,
// Gifts: go to first gift.
@@ -358,6 +362,7 @@ FSM_TRANS (TOP_INIT, init_start_round, TOP_DECISION)
FSM_TRANS_TIMEOUT (TOP_DECISION, 1,
candles, TOP_CANDLES_GOTO_NORMAL,
plate, TOP_PLATE_GOTO,
+ cannon, TOP_CANNON_GOTO,
gifts, TOP_GIFTS_GOTO,
none, TOP_START)
{
@@ -376,6 +381,9 @@ FSM_TRANS_TIMEOUT (TOP_DECISION, 1,
robot->strat.decision_plate (top.plate);
robot->move.start (d_pos, Asserv::BACKWARD_REVERT_OK);
return FSM_BRANCH (plate);
+ case Strat::CANNON:
+ robot->move.start (d_pos);
+ return FSM_BRANCH (cannon);
case Strat::GIFTS:
robot->strat.decision_gifts (top.gifts);
robot->move.start (d_pos, Asserv::REVERT_OK);
@@ -537,6 +545,23 @@ FSM_TRANS (TOP_PLATE_LOADING, plate_taken, TOP_DECISION)
}
///
+/// Cannon mode.
+///
+
+FSM_TRANS (TOP_CANNON_GOTO, move_success, TOP_CANNON_FIRING)
+{
+ ANGFSM_HANDLE (AI, cannon_fire);
+}
+
+FSM_TRANS (TOP_CANNON_GOTO, move_failure, TOP_DECISION)
+{
+}
+
+FSM_TRANS (TOP_CANNON_FIRING, cannon_fire_ok, TOP_DECISION)
+{
+}
+
+///
/// Gifts mode.
///