summaryrefslogtreecommitdiff
path: root/digital
diff options
context:
space:
mode:
authorNélio Laranjeiro2008-04-17 23:34:13 +0200
committerNélio Laranjeiro2008-04-17 23:34:13 +0200
commit3a54854defda7b59411b691e0fc0f074edb6e88e (patch)
tree48d5d96bcc990b5f32e6429a6bf8e0d99d1f7269 /digital
parent978ad79ed12c8ad2d69e26f410aa4b5a94f3ca30 (diff)
Update the gutter FSM to only eject the balls from the robot.
Diffstat (limited to 'digital')
-rw-r--r--digital/io/src/gutter.c2
-rw-r--r--digital/io/src/gutter.fsm26
-rw-r--r--digital/io/src/gutter_cb.c43
-rw-r--r--digital/io/src/test/gutter/main.c49
4 files changed, 23 insertions, 97 deletions
diff --git a/digital/io/src/gutter.c b/digital/io/src/gutter.c
index 0337b974..569f0f6b 100644
--- a/digital/io/src/gutter.c
+++ b/digital/io/src/gutter.c
@@ -31,5 +31,5 @@ gutter_start (void)
{
/* Start the FSM. */
fsm_init (&gutter_fsm);
- fsm_handle_event (&gutter_fsm, GUTTER_EVENT_ok);
+ fsm_handle_event (&gutter_fsm, GUTTER_EVENT_start);
}
diff --git a/digital/io/src/gutter.fsm b/digital/io/src/gutter.fsm
index 6faa340d..906feaf9 100644
--- a/digital/io/src/gutter.fsm
+++ b/digital/io/src/gutter.fsm
@@ -2,33 +2,23 @@
gutter
States:
- START
- GO_TO_GUTTER
+ IDLE
OPEN_COLLECTOR
CLOSE_COLLECTOR
- END
Events:
- ok
- position_reached
- position_failed
+ start
collector_opened
collector_closed
-START:
- ok -> GO_TO_GUTTER
- Go to the gutter.
-
-GO_TO_GUTTER:
- position_reached -> OPEN_COLLECTOR
- The robo is near the gutter and the door can be opened.
- position_failed -> .
- The position failed, shall try another path.
+IDLE:
+ start -> OPEN_COLLECTOR
+ Open the collector and wait for a while.
OPEN_COLLECTOR:
collector_opened -> CLOSE_COLLECTOR
- Wait some time and clse the door.
+ Close the rear panel.
CLOSE_COLLECTOR:
- collector_closed-> END
- The samples has been inserted in the gutter.
+ collector_closed-> IDLE
+ The samples has been inserted in the gutter. Go to the idle state.
diff --git a/digital/io/src/gutter_cb.c b/digital/io/src/gutter_cb.c
index 298a2f26..85b48ef5 100644
--- a/digital/io/src/gutter_cb.c
+++ b/digital/io/src/gutter_cb.c
@@ -26,24 +26,23 @@
#include "fsm.h"
#include "gutter.h"
#include "gutter_cb.h"
-#include "asserv.h"
#include "trap.h"
#include "modules/utils/utils.h"
-#include "top.h"
-#include "top_fsm.h"
/*
- * START =ok=>
- * => GO_TO_GUTTER
- * Go to the gutter.
+ * IDLE =start=>
+ * => OPEN_COLLECTOR
+ * Open the collector and wait for a while.
*/
fsm_branch_t
-gutter__START__ok (void)
+gutter__IDLE__start (void)
{
- asserv_go_to_the_wall();
- return gutter_next (START, ok);
+ // Open the rear panel.
+ trap_open_rear_panel ();
+ return gutter_next (IDLE, start);
}
+
/*
* CLOSE_COLLECTOR =collector_closed=>
* => END
@@ -54,36 +53,10 @@ gutter__CLOSE_COLLECTOR__collector_closed (void)
{
//Close the collector.
trap_close_rear_panel();
- // Post an event to the top fsm machine
- fsm_handle_event (&top_fsm, TOP_EVENT_gutter_fsm_finished);
return gutter_next (CLOSE_COLLECTOR, collector_closed);
}
/*
- * GO_TO_GUTTER =position_failed=>
- * => GO_TO_GUTTER
- * The position failed, shall try another path.
- */
-fsm_branch_t
-gutter__GO_TO_GUTTER__position_failed (void)
-{
- return gutter_next (GO_TO_GUTTER, position_failed);
-}
-
-/*
- * GO_TO_GUTTER =position_reached=>
- * => OPEN_COLLECTOR
- * The robo is near the gutter and the door can be opened.
- */
-fsm_branch_t
-gutter__GO_TO_GUTTER__position_reached (void)
-{
- // Open the collector.
- trap_open_rear_panel();
- return gutter_next (GO_TO_GUTTER, position_reached);
-}
-
-/*
* OPEN_COLLECTOR =collector_opened=>
* => CLOSE_COLLECTOR
* Wait some time and clse the door.
diff --git a/digital/io/src/test/gutter/main.c b/digital/io/src/test/gutter/main.c
index 37eefbda..877545fc 100644
--- a/digital/io/src/test/gutter/main.c
+++ b/digital/io/src/test/gutter/main.c
@@ -34,15 +34,12 @@ gutter_print_test (fsm_t *gutter)
switch (gutter->state_current)
{
- case GUTTER_STATE_END:
- printf ("END");
+ case GUTTER_STATE_IDLE:
+ printf ("IDLE");
break;
case GUTTER_STATE_CLOSE_COLLECTOR:
printf ("CLOSE COLLECTOR");
break;
- case GUTTER_STATE_GO_TO_GUTTER:
- printf ("GO_TO_GUTTER");
- break;
case GUTTER_STATE_OPEN_COLLECTOR:
printf ("OPEN COLLECTOR");
break;
@@ -57,61 +54,27 @@ main (void)
{
fsm_init (&gutter_fsm);
- fsm_handle_event (&gutter_fsm, GUTTER_EVENT_ok);
-
- gutter_print_test (&gutter_fsm);
-
- fsm_handle_event (&gutter_fsm, GUTTER_EVENT_position_failed);
-
- gutter_print_test (&gutter_fsm);
-
- fsm_handle_event (&gutter_fsm, GUTTER_EVENT_position_reached);
-
+ fsm_handle_event (&gutter_fsm, GUTTER_EVENT_start);
gutter_print_test (&gutter_fsm);
fsm_handle_event (&gutter_fsm, GUTTER_EVENT_collector_opened);
-
gutter_print_test (&gutter_fsm);
-
+
fsm_handle_event (&gutter_fsm, GUTTER_EVENT_collector_closed);
-
gutter_print_test (&gutter_fsm);
return 0;
}
void
-asserv_set_x_position (uint32_t position)
-{
- printf ("X position : %d\n", position);
-}
-
-void
-asserv_move_arm (uint16_t position, uint8_t speed)
-{
- printf ("Move arm, position : %d, speed : %d\n", position, speed);
-}
-
-void
-asserv_set_y_position (int32_t y)
-{
- printf ("Y position : %d\n", y);
-}
-
-void
trap_open_rear_panel (void)
{
- printf ("Open rear panel\n");
+ printf ("\t Open rear panel\n");
}
void
trap_close_rear_panel(void)
{
- printf ("Close rear panel\n");
+ printf ("\t Close rear panel\n");
}
-void
-asserv_go_to_the_wall (void)
-{
- printf ("Go to gutter\n");
-}