summaryrefslogtreecommitdiff
path: root/digital/io-hub/src
diff options
context:
space:
mode:
authorNicolas Schodet2011-05-20 08:27:02 +0200
committerNicolas Schodet2011-05-20 08:27:02 +0200
commit2277c9a7aa41c347ba04fca8e202c77b43618802 (patch)
treea73904b3ed877677411caecadaf83ee5b3ff6319 /digital/io-hub/src
parentc3274377f05073c6d40265ab7849df2a72cfd54e (diff)
digital/{ai,io-hub}: add init FSM
Diffstat (limited to 'digital/io-hub/src')
-rw-r--r--digital/io-hub/src/robospierre/Makefile2
-rw-r--r--digital/io-hub/src/robospierre/bot.h10
-rw-r--r--digital/io-hub/src/robospierre/clamp.c6
-rw-r--r--digital/io-hub/src/robospierre/init_defs.h50
-rw-r--r--digital/io-hub/src/robospierre/main.c14
5 files changed, 74 insertions, 8 deletions
diff --git a/digital/io-hub/src/robospierre/Makefile b/digital/io-hub/src/robospierre/Makefile
index 20e9dee0..d69918f5 100644
--- a/digital/io-hub/src/robospierre/Makefile
+++ b/digital/io-hub/src/robospierre/Makefile
@@ -5,7 +5,7 @@ PROGS = io_hub
# Sources to compile.
io_hub_SOURCES = main.c \
clamp.c logistic.c \
- fsm.host.c fsm_AI_gen.avr.c fsm_queue.c \
+ init.c fsm.host.c fsm_AI_gen.avr.c fsm_queue.c \
pwm.avr.c pwm.host.c \
contact.avr.c contact.host.c \
twi_master.c asserv.c mimot.c \
diff --git a/digital/io-hub/src/robospierre/bot.h b/digital/io-hub/src/robospierre/bot.h
index e014321e..a986c015 100644
--- a/digital/io-hub/src/robospierre/bot.h
+++ b/digital/io-hub/src/robospierre/bot.h
@@ -34,6 +34,16 @@
# define BOT_SCALE 0.0415178942124
#endif
+/** Distance between the front contact point and the robot center. */
+#define BOT_FRONT_CONTACT_DIST_MM 150
+/** Angle error at the front contact point. */
+#define BOT_FRONT_CONTACT_ANGLE_ERROR_DEG 0
+
+/** Speed used for initialisation. */
+#define BOT_SPEED_INIT 0x10, 0x10, 0x10, 0x10
+/** Normal cruise speed. */
+#define BOT_SPEED_NORMAL 0x40, 0x40, 0x20, 0x20
+
#ifdef HOST
# define BOT_CLAMP_SLOT_FRONT_BOTTOM_ELEVATION_STEP 0
diff --git a/digital/io-hub/src/robospierre/clamp.c b/digital/io-hub/src/robospierre/clamp.c
index 6c063979..583cadb5 100644
--- a/digital/io-hub/src/robospierre/clamp.c
+++ b/digital/io-hub/src/robospierre/clamp.c
@@ -83,8 +83,6 @@ FSM_STATES (
CLAMP_MOVE_DST_CLAMP_OPENING)
FSM_EVENTS (
- /* Here for the moment, to be moved later. */
- start,
/* New element inside bottom slot. */
clamp_new_element,
/* Order to drop elements. */
@@ -325,10 +323,10 @@ clamp_route (void)
/* CLAMP FSM */
-FSM_TRANS (CLAMP_START, start, CLAMP_GOING_IDLE)
+FSM_TRANS (CLAMP_START, init_actuators, CLAMP_GOING_IDLE)
{
clamp_move (CLAMP_SLOT_FRONT_MIDDLE);
- return FSM_NEXT (CLAMP_START, start);
+ return FSM_NEXT (CLAMP_START, init_actuators);
}
FSM_TRANS (CLAMP_GOING_IDLE, clamp_move_success, CLAMP_IDLE)
diff --git a/digital/io-hub/src/robospierre/init_defs.h b/digital/io-hub/src/robospierre/init_defs.h
new file mode 100644
index 00000000..6ce6eaae
--- /dev/null
+++ b/digital/io-hub/src/robospierre/init_defs.h
@@ -0,0 +1,50 @@
+#ifndef init_defs_h
+#define init_defs_h
+/* init_defs.h */
+/* robospierre - Eurobot 2011 AI. {{{
+ *
+ * Copyright (C) 2011 Nicolas Schodet
+ *
+ * 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 "playground.h"
+#include "bot.h"
+
+/** Parameters to push the first wall. */
+#define INIT_FIRST_WALL_PUSH \
+ 0, PG_X (BOT_FRONT_CONTACT_DIST_MM), 200, \
+ PG_A_DEG (180 + BOT_FRONT_CONTACT_ANGLE_ERROR_DEG)
+/** Parameters to go away from the first wall. */
+#define INIT_FIRST_WALL_AWAY -500
+/** Parameter to face the second wall. */
+#define INIT_SECOND_WALL_ANGLE PG_A_DEG (90)
+/** Parameters to push the second wall. */
+#define INIT_SECOND_WALL_PUSH \
+ 0, -1, PG_Y (PG_LENGTH - BOT_FRONT_CONTACT_DIST_MM), -1
+/** Parameters to go away from the second wall. */
+#define INIT_SECOND_WALL_AWAY -(200 - BOT_FRONT_CONTACT_DIST_MM)
+/** Parameter to face the start position. */
+#define INIT_START_POSITION_ANGLE PG_A_DEG (0)
+/** Start position. */
+#define INIT_START_POSITION \
+ PG_X (200), PG_Y (PG_LENGTH - 200), PG_A_DEG (0), ASSERV_BACKWARD
+
+#endif /* init_defs_h */
diff --git a/digital/io-hub/src/robospierre/main.c b/digital/io-hub/src/robospierre/main.c
index 97d5bd40..f1b4d8de 100644
--- a/digital/io-hub/src/robospierre/main.c
+++ b/digital/io-hub/src/robospierre/main.c
@@ -110,9 +110,15 @@ main_event_to_fsm (void)
/* Update FSM timeouts. */
FSM_HANDLE_TIMEOUT_E (AI);
/* Motor status. */
- asserv_status_e mimot_motor0_status, mimot_motor1_status;
+ asserv_status_e robot_move_status, mimot_motor0_status,
+ mimot_motor1_status;
+ robot_move_status = asserv_move_cmd_status ();
mimot_motor0_status = mimot_motor0_cmd_status ();
mimot_motor1_status = mimot_motor1_cmd_status ();
+ if (robot_move_status == success)
+ FSM_HANDLE_E (AI, robot_move_success);
+ else if (robot_move_status == failure)
+ FSM_HANDLE_E (AI, robot_move_failure);
if (mimot_motor0_status == success
&& mimot_motor1_status == success)
FSM_HANDLE_E (AI, clamp_elevation_rotation_success);
@@ -123,9 +129,11 @@ main_event_to_fsm (void)
/* Clamp specific events. */
if (clamp_handle_event ())
return;
- /* Jack, XXX to be changed! */
+ /* Jack. */
if (!contact_get_jack ())
- FSM_HANDLE_E (AI, start);
+ FSM_HANDLE_E (AI, jack_inserted);
+ else
+ FSM_HANDLE_E (AI, jack_removed);
/* Events from the event queue. */
if (fsm_queue_poll ())
{