From 0968f4428bd842b06b4218741b7a70f83f9517a4 Mon Sep 17 00:00:00 2001 From: Nélio Laranjeiro Date: Sun, 30 Mar 2008 20:45:33 +0200 Subject: Moved teh getsamples fsm. --- digital/io/src/getsamples/Makefile.getsamples | 23 ----- digital/io/src/getsamples/getSamplesFsm.conf | 5 -- digital/io/src/getsamples/getSamplesFsm.fsm | 47 ----------- digital/io/src/getsamples/getsamples_cb.c | 116 -------------------------- digital/io/src/getsamples/getsamples_robo.h | 40 --------- digital/io/src/getsamples/test/Makefile | 7 -- digital/io/src/getsamples/test/main.c | 88 ------------------- 7 files changed, 326 deletions(-) delete mode 100644 digital/io/src/getsamples/Makefile.getsamples delete mode 100644 digital/io/src/getsamples/getSamplesFsm.conf delete mode 100644 digital/io/src/getsamples/getSamplesFsm.fsm delete mode 100644 digital/io/src/getsamples/getsamples_cb.c delete mode 100644 digital/io/src/getsamples/getsamples_robo.h delete mode 100644 digital/io/src/getsamples/test/Makefile delete mode 100644 digital/io/src/getsamples/test/main.c (limited to 'digital/io/src/getsamples') diff --git a/digital/io/src/getsamples/Makefile.getsamples b/digital/io/src/getsamples/Makefile.getsamples deleted file mode 100644 index c59fdb64..00000000 --- a/digital/io/src/getsamples/Makefile.getsamples +++ /dev/null @@ -1,23 +0,0 @@ -CFLAGS = -O2 -Wall - -all: prgm exe dot png - -prgm: getSamplesFsm.fsm getSamplesFsm.conf - python ../../../../tools/dfagen/dfagen.py -o c -d $< -c getSamplesFsm.conf -p getsamples - -exe: getSamplesFsm.fsm getSamplesFsm.conf - make prgm - #if [ -f getsamples_cb.c ]; then vimdiff getsamples_cb.c getsamples_cb_skel.c; else mv getsamples_cb_skel.c getsamples_cb.c; fi; - -dot: getSamplesFsm.fsm getSamplesFsm.conf - python ../../../../tools/dfagen/dfagen.py -o dot -d $< -c getSamplesFsm.conf -p getsamples - -png: getsamples.dot - dot -Tpng -o getsamples.png getsamples.dot - -clean: - rm -f getsamples.h - rm -f getsamples_cb.h - rm -f getsamples.dot - rm -f getsamples.png - rm -f getsamples.c diff --git a/digital/io/src/getsamples/getSamplesFsm.conf b/digital/io/src/getsamples/getSamplesFsm.conf deleted file mode 100644 index 238c0f6f..00000000 --- a/digital/io/src/getsamples/getSamplesFsm.conf +++ /dev/null @@ -1,5 +0,0 @@ -[user] -type = getsamples_t -type-forward-decl = typedef struct getsamples_t getsamples_t; -type-decl = #include "getsamples_robo.h" -field = fsm diff --git a/digital/io/src/getsamples/getSamplesFsm.fsm b/digital/io/src/getsamples/getSamplesFsm.fsm deleted file mode 100644 index 3f7266d0..00000000 --- a/digital/io/src/getsamples/getSamplesFsm.fsm +++ /dev/null @@ -1,47 +0,0 @@ -#FSM get samples -get_samples - -States: - START - GO_TO_POSITION - PREPARE_ARM - FORWARD_CONTROL - TAKE_SAMPLES - BACKWARD - END - -Events: - ok - position_reached - position_failed - arm_moved - sample_took - classifier_ready - -START: - ok -> GO_TO_POSITION - Go to the distributor. The distributor to reach shall be setted in the fsm structure. - -GO_TO_POSITION: - position_reached -> PREPARE_ARM - Go to the position desired, it is very near the position of the distributor in case it is a ice distributor or sample distributor. - position_failed -> GO_TO_POSITION - Go to another point before trying to go to this one again. - -PREPARE_ARM: - arm_moved -> FORWARD_CONTROL - Prepare the arm to the correct position. - -FORWARD_CONTROL: - position_reached -> TAKE_SAMPLES - End the position to the distributor. - -TAKE_SAMPLES: - sample_took: more -> . - Continue to take samples and classify the next sample. - sample_took: no_more -> BACKWARD - If the quantity of samples are tooked, then go backeward and conitnue classifying the samples. - -BACKWARD: - position_reached -> END - Ending this state machine. diff --git a/digital/io/src/getsamples/getsamples_cb.c b/digital/io/src/getsamples/getsamples_cb.c deleted file mode 100644 index de10ac53..00000000 --- a/digital/io/src/getsamples/getsamples_cb.c +++ /dev/null @@ -1,116 +0,0 @@ -/* - * THIS IS AN AUTOMATICALLY GENERATED FILE, DO NOT EDIT! - * - * Skeleton for get_samples callbacks implementation. - * - * - */ -#include "getsamples_cb.h" - -/* - * PREPARE_ARM =arm_moved=> - * => FORWARD_CONTROL - * Prepare the arm to the correct position. - */ -getsamples_branch_t -getsamples__PREPARE_ARM__arm_moved (getsamples_t *user) -{ - // Try to end the position to the distributor. - asserv_set_x_position (user->distributor_x); - // Go to the color distributor. - asserv_set_y_position (user->distributor_y); - return getsamples_next (PREPARE_ARM, arm_moved); -} - -/* - * FORWARD_CONTROL =position_reached=> - * => TAKE_SAMPLES - * End the position to the distributor. - */ -getsamples_branch_t -getsamples__FORWARD_CONTROL__position_reached (getsamples_t *user) -{ - // Take as many samples as necessary. This shall be updated to verify the - asserv_move_arm (1666, 100); - return getsamples_next (FORWARD_CONTROL, position_reached); -} - -/* - * START =ok=> - * => GO_TO_POSITION - * Go to the distributor. The distributor to reach shall be setted in the fsm structure. - */ -getsamples_branch_t -getsamples__START__ok (getsamples_t *user) -{ - asserv_set_x_position (user->distributor_x - 20); - asserv_set_y_position (user->distributor_y - 20); - return getsamples_next (START, ok); -} - -/** - * TAKE_SAMPLES =sample_took=> - * no_more => BACKWARD - * If the quantity of samples are tooked, then go backeward and conitnue classifying the samples. - * more => TAKE_SAMPLES - * Continue to take samples and classify the next sample. - */ -getsamples_branch_t -getsamples__TAKE_SAMPLES__sample_took (getsamples_t *user) -{ - // Decrement the samples counter. - if (user->samples) - { - asserv_move_arm (1666, 100); - return getsamples_next_branch (TAKE_SAMPLES, sample_took, more); - } - else - { - asserv_move_arm (5000, 100); - // Try to end the position to the distributor. - asserv_set_x_position (user->distributor_x - 20); - // Go to the color distributor. - asserv_set_y_position (user->distributor_y - 20); - - return getsamples_next_branch (TAKE_SAMPLES, sample_took, no_more); - } -} - -/* - * BACKWARD =position_reached=> - * => END - * Ending this state machine. - */ -getsamples_branch_t -getsamples__BACKWARD__position_reached (getsamples_t *user) -{ - return getsamples_next (BACKWARD, position_reached); -} - -/* - * GO_TO_POSITION =position_failed=> - * => GO_TO_POSITION - * Go to another point before trying to go to this one again. - */ -getsamples_branch_t -getsamples__GO_TO_POSITION__position_failed (getsamples_t *user) -{ - // TODO In this case i don't know what to do. - return getsamples_next (GO_TO_POSITION, position_failed); -} - -/* - * GO_TO_POSITION =position_reached=> - * => PREPARE_ARM - * Go to the position desired, it is very near the position of the distributor in case it is a ice distributor or sample distributor. - */ -getsamples_branch_t -getsamples__GO_TO_POSITION__position_reached (getsamples_t *user) -{ - // Put the ARM in the position to allow the robot to take samples from the - // distributor. - asserv_move_arm (625, 100); - return getsamples_next (GO_TO_POSITION, position_reached); -} - - diff --git a/digital/io/src/getsamples/getsamples_robo.h b/digital/io/src/getsamples/getsamples_robo.h deleted file mode 100644 index 11309a10..00000000 --- a/digital/io/src/getsamples/getsamples_robo.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef getsamples_robo_h -#define getsamples_robo_h -/* getsamples_robo.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. - * - * }}} */ - -struct getsamples_t -{ - /* The FSM. */ - getsamples_state_t fsm; - /* Distributor x position to get samples. */ - uint32_t distributor_x; - /* Distributor y position to get samples. */ - uint32_t distributor_y; - /* Samples to take. */ - uint8_t samples; -}; - -#endif /* getsamples_robo_h */ diff --git a/digital/io/src/getsamples/test/Makefile b/digital/io/src/getsamples/test/Makefile deleted file mode 100644 index ad659fdd..00000000 --- a/digital/io/src/getsamples/test/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -BASE= .. - -all: main.c $(BASE)/getsamples.c $(BASE)/getsamples_cb.c - gcc -g -O2 -Wall main.c $(BASE)/getsamples.c $(BASE)/getsamples_cb.c -o fsm - -clean: fsm - rm -f fsm diff --git a/digital/io/src/getsamples/test/main.c b/digital/io/src/getsamples/test/main.c deleted file mode 100644 index 33a3fd80..00000000 --- a/digital/io/src/getsamples/test/main.c +++ /dev/null @@ -1,88 +0,0 @@ -/* main.c */ -/* {{{ - * - * 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. - * - * }}} */ -#define uint32_t (unsigned int) -#define uint16_t (unsigned short) -#define uint8_t (unsigned char) - - -#include "../getsamples.h" -#include "../getsamples_robo.h" - -#include - -void -getsamples_print_test (getsamples_t *getsamples) -{ - printf ("Machine state "); - - switch (getsamples->fsm) - { - case GETSAMPLES_STATE_START: - printf ("START"); - case GETSAMPLES_STATE_PREPARE_ARM: - printf ("PREPARE_ARM"); - break; - case GETSAMPLES_STATE_END: - printf ("END"); - break; - case GETSAMPLES_STATE_FORWARD_CONTROL: - printf ("FORWARD CONTROL"); - break; - case GETSAMPLES_STATE_TAKE_SAMPLES: - printf ("TAKE_SAMPLES"); - break; - case GETSAMPLES_STATE_BACKWARD: - printf ("BACKWARD"); - break; - case GETSAMPLES_STATE_GO_TO_POSITION: - printf ("GO TO POSITION"); - break; - case GETSAMPLES_STATE_NB: - printf ("NB"); - } - printf ("\n"); -} - -int -main (void) -{ - getsamples_t getsamples_fsm; - - getsamples_init (&getsamples_fsm); - getsamples_print_test (&getsamples_fsm); - - getsamples_handle_event (&getsamples_fsm, - GETSAMPLES_EVENT_position_failed); - - getsamples_print_test (&getsamples_fsm); - - getsamples_handle_event (&getsamples_fsm, - GETSAMPLES_EVENT_position_reached); - - - getsamples_print_test (&getsamples_fsm); - - return 0; -} -- cgit v1.2.3