From 370fa5662360eaa582bed9d55e092b627aef8920 Mon Sep 17 00:00:00 2001 From: Nélio Laranjeiro Date: Thu, 10 Apr 2008 13:51:28 +0200 Subject: Start to fill the FSMs. (not finished). --- digital/io/src/getsamples_cb.c | 2 ++ digital/io/src/ia.c | 40 ---------------------- digital/io/src/ia.h | 75 ------------------------------------------ digital/io/src/top.c | 5 ++- digital/io/src/top.h | 27 ++++++++++++++- digital/io/src/top_cb.c | 16 +++++++++ 6 files changed, 48 insertions(+), 117 deletions(-) delete mode 100644 digital/io/src/ia.c delete mode 100644 digital/io/src/ia.h (limited to 'digital/io/src') diff --git a/digital/io/src/getsamples_cb.c b/digital/io/src/getsamples_cb.c index 916027c3..fb7d2be7 100644 --- a/digital/io/src/getsamples_cb.c +++ b/digital/io/src/getsamples_cb.c @@ -103,6 +103,8 @@ fsm_branch_t getsamples__BACKWARD__position_reached (void) { asserv_move_arm (5000, 100); + + fsm_handle_event (&top_fsm, TOP_EVENT_samples_took); return getsamples_next (BACKWARD, position_reached); } diff --git a/digital/io/src/ia.c b/digital/io/src/ia.c deleted file mode 100644 index 954459bc..00000000 --- a/digital/io/src/ia.c +++ /dev/null @@ -1,40 +0,0 @@ -/* ia.c */ -/* io - Input & Output with Artificial Intelligence (ai) support on AVR. {{{ - * - * Copyright (C) 2008 Nélio Laranjeiro - * - * APBTeam: - * Web: http://apbteam.org/ - * Email: team AT apbteam DOT org - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * }}} */ -#include "ia.h" -#include "asserv.h" -#include "modules/proto/proto.h" - -static ia_t ia_global; - -/** Initialize the IA. - */ -void -ia_init (void) -{ - ia_global.sequence = false; - ia_global.ice_status_our = false; - ia_global.team_color = TEAM_COLOR_RED; -} - diff --git a/digital/io/src/ia.h b/digital/io/src/ia.h deleted file mode 100644 index 3a11ed30..00000000 --- a/digital/io/src/ia.h +++ /dev/null @@ -1,75 +0,0 @@ -#ifndef ia_h -#define ia_h -/* ia.h */ -/* {{{ - * - * Copyright (C) 2008 Nélio Laranjeiro - * - * APBTeam: - * Web: http://apbteam.org/ - * Email: team AT apbteam DOT org - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * }}} */ -#include "asserv.h" - -#define TABLE_MAX_Y 3000 -#define TABLE_MAX_X 2100 - -#define DISTRIBUTOR_SAMPLES_Y 2100 - -#define DISTRIBUTOR_SAMPLES_BLUE_X 700 -#define DISTRIBUTOR_SAMPLES_RED_X 2300 - -#define DISTRIBUTOR_ICE_Y 1350 - -#define ASSERV_ARM_ROTATION_INIT 0 -#define ASSERV_ARM_ROTATION_FULL 5000 -#define ASSERV_ARM_ROTATION_THIRD (ASSERV_ARM_ROTATION_FULL / 3) - -#define ASSERV_ARM_SPEED_FULL 100 -#define ASSERV_ARM_SPEED_HALF (ASSERV_ARM_SPEED_FULL / 2) - -enum ia_team_e -{ - TEAM_COLOR_RED, - TEAM_COLOR_BLUE -}; - -struct ia_t -{ - /* Bool status of the previous sequence loaded. - * If the previous was the sequence ISISI the next one shall be SISIS (S = - * sample, I = ice). - * false = ISISI. - * true = SISIS. - */ - bool sequence; - - /* Bool status indicating our ice distributor status. */ - bool ice_status_our; - - /* Team color */ - bool team_color; -}; - - -/** Initialize the IA. - */ -void -ia_init (void); - -#endif /* ia_h */ diff --git a/digital/io/src/top.c b/digital/io/src/top.c index 42ffa80b..f358445d 100644 --- a/digital/io/src/top.c +++ b/digital/io/src/top.c @@ -31,10 +31,13 @@ struct top_data_t top_data; /** Start a main FSM. */ void -robot_main_start (void) +top_start (uint8_t color_team) { /* Set parameters. */ top_data.sequence = 0x15; + /* Get the team color. + * !! I supose that the 0 value is 0 and red value is 1 */ + top_data.team_color = color_team; /* Start the FSM. */ fsm_init (&top_fsm); fsm_handle_event (&top_fsm, TOP_EVENT_ok); diff --git a/digital/io/src/top.h b/digital/io/src/top.h index 651e13f5..169cf278 100644 --- a/digital/io/src/top.h +++ b/digital/io/src/top.h @@ -25,15 +25,40 @@ * * }}} */ +#define BLUE_DISTRIBUTOR_X 700 +#define BLUE_DISTRIBUTOR_Y 2100 + +#define RED_DISTRIBUTOR_X 2300 +#define RED_DISTRIBUTOR_Y 2100 + +#define ICE_DISTRIBUTOR_LEFT 0 +#define ICE_DISTRIBUTOR_RIGHT 3000 +#define ICE_DISTRIBUTOR_Y 1350 + +enum team_color_e +{ + BLUE_TEAM, + RED_TEAM +}; + struct top_data_t { + /** The sequence to get. + * Each bit corresponds to the slot in the collector (where the balls a + * stored in the robot). + * bit 0 = slot 0 + * bit 1 = slot 1 and so on. + */ uint8_t sequence; + /** The color of the balls the robot shall take. + * RED_TEAM or BLUE_TEAM. */ + uint8_t team_color; }; extern struct top_data_t top_data; /** Start a Top FSM. */ void -top_start (void); +top_start (uint8_t team_color); #endif /* top_h */ diff --git a/digital/io/src/top_cb.c b/digital/io/src/top_cb.c index 52a5129d..bf92b204 100644 --- a/digital/io/src/top_cb.c +++ b/digital/io/src/top_cb.c @@ -7,7 +7,9 @@ */ #include "common.h" #include "fsm.h" +#include "top.h" #include "top_cb.h" +#include "getsamples.h" /* * START =ok=> @@ -17,6 +19,20 @@ fsm_branch_t top__START__ok (void) { + // Call the get samples state machine. + + // Blue color. + if (top_data.team_color == BLUE_TEAM) + { + getsamples_start (BLUE_DISTRIBUTOR_X, BLUE_DISTRIBUTOR_Y, + top_data.sequence); + } + else + { + getsamples_start (RED_DISTRIBUTOR_X, RED_DISTRIBUTOR_Y, + top_data.sequence); + } + return top_next (START, ok); } -- cgit v1.2.3