summaryrefslogtreecommitdiffhomepage
path: root/digital/io-hub/src/apbirthday/top.cc
diff options
context:
space:
mode:
authorNicolas Schodet2013-04-21 18:42:49 +0200
committerNicolas Schodet2013-04-21 22:00:08 +0200
commit9a29545859c8513e48b813804b6fc1ea3ec3aa24 (patch)
treed6219fecd527d9d53ee0f3c606f462d49b05e55c /digital/io-hub/src/apbirthday/top.cc
parent64f61347d913f05fc81f08f169e402a3205afd6e (diff)
digital/io-hub/src/apbirthday: add follow the cake demo mode
Diffstat (limited to 'digital/io-hub/src/apbirthday/top.cc')
-rw-r--r--digital/io-hub/src/apbirthday/top.cc26
1 files changed, 24 insertions, 2 deletions
diff --git a/digital/io-hub/src/apbirthday/top.cc b/digital/io-hub/src/apbirthday/top.cc
index fa94f655..c96b8c12 100644
--- a/digital/io-hub/src/apbirthday/top.cc
+++ b/digital/io-hub/src/apbirthday/top.cc
@@ -224,6 +224,13 @@ top_fsm_gen_event ()
return false;
}
+void
+top_demo_follow (int dir_sign)
+{
+ top.candles.dir_sign = dir_sign;
+ ANGFSM_HANDLE (AI, top_demo_follow);
+}
+
ANGFSM_INIT
ANGFSM_STATES (
@@ -253,7 +260,9 @@ ANGFSM_STATES (
// Demo mode: push the wall near the cake.
TOP_DEMO_CANDLES_PUSH_WALL,
// Demo mode: move away from the wall.
- TOP_DEMO_CANDLES_MOVE_AWAY)
+ TOP_DEMO_CANDLES_MOVE_AWAY,
+ // Demo mode: follow the cake (or anything else actually).
+ TOP_DEMO_FOLLOW)
ANGFSM_EVENTS (
// Cake following finished (end point reached).
@@ -261,7 +270,9 @@ ANGFSM_EVENTS (
// Problem with cake following.
top_follow_blocked,
// Start candle demo.
- top_demo_candles)
+ top_demo_candles,
+ // Start follow the cake demo.
+ top_demo_follow)
ANGFSM_START_WITH (TOP_START)
@@ -428,3 +439,14 @@ FSM_TRANS (TOP_INIT, top_demo_candles, TOP_CANDLES_GOTO_NORMAL)
+ pg_cake_distance + BOT_SIZE_SIDE);
}
+FSM_TRANS (TOP_START, top_demo_follow, TOP_DEMO_FOLLOW)
+{
+ robot->asserv.follow (top.candles.dir_sign == 1
+ ? Asserv::FORWARD : Asserv::BACKWARD);
+}
+
+FSM_TRANS (TOP_DEMO_FOLLOW, top_follow_finished, TOP_DEMO_FOLLOW)
+{
+ // Transition needed for top_update.
+}
+