From 3a54854defda7b59411b691e0fc0f074edb6e88e Mon Sep 17 00:00:00 2001 From: NĂ©lio Laranjeiro Date: Thu, 17 Apr 2008 23:34:13 +0200 Subject: Update the gutter FSM to only eject the balls from the robot. --- digital/io/src/gutter.c | 2 +- digital/io/src/gutter.fsm | 26 +++++++-------------- digital/io/src/gutter_cb.c | 43 +++++++--------------------------- digital/io/src/test/gutter/main.c | 49 +++++---------------------------------- 4 files changed, 23 insertions(+), 97 deletions(-) (limited to 'digital') 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,35 +53,9 @@ 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 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"); -} -- cgit v1.2.3