2 * Copyright Droids Corporation, Microb Technology, Eirbot (2008)
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * Revision : $Id: strat.h,v 1.7 2009-11-08 17:24:33 zer0 Exp $
25 /* convert coords according to our color */
26 #define COLOR_Y(y) ((mainboard.our_color==I2C_COLOR_YELLOW)? (y) : (AREA_Y-(y)))
27 #define COLOR_A(a) ((mainboard.our_color==I2C_COLOR_YELLOW)? (a) : (-a))
28 #define COLOR_SIGN(x) ((mainboard.our_color==I2C_COLOR_YELLOW)? (x) : (-x))
29 #define COLOR_INVERT(x) ((mainboard.our_color==I2C_COLOR_YELLOW)? (x) : (!x))
36 #define START_Y COLOR_Y(200)
37 #define START_A COLOR_A(45)
43 #define CORNER_Y COLOR_Y(2100)
45 /* XXX these offset are not related to corn, but to waypoints */
46 #define OFFSET_CORN_X 150
47 #define OFFSET_CORN_Y 222
48 #define STEP_CORN_X 225
49 #define STEP_CORN_Y 250
54 #define WAYPOINTS_NBX 13
55 #define WAYPOINTS_NBY 8
58 * Corn position and lines
62 * 2100 +-----|-----|-----|-----|-----|-----|-----+
64 * | c2 c7 c11 c17 | diag
72 * 0 +-----+-----------------------------+-----+
75 * Ball (tomato) and i,j coords (for waypoints)
77 * 2100 +--0--1--2--3--4--5--6--7--8--9-10-11-12--+
87 * 0 +-----+-----------------------------+-----+
92 /* useful traj flags */
93 #define TRAJ_SUCCESS(f) (f & (END_TRAJ|END_NEAR))
94 #define TRAJ_FLAGS_STD (END_TRAJ|END_BLOCKING|END_NEAR|END_OBSTACLE|END_INTR|END_TIMER)
95 #define TRAJ_FLAGS_NO_TIMER (END_TRAJ|END_BLOCKING|END_NEAR|END_OBSTACLE|END_INTR)
96 #define TRAJ_FLAGS_NO_NEAR (END_TRAJ|END_BLOCKING|END_OBSTACLE|END_INTR|END_TIMER)
97 #define TRAJ_FLAGS_NO_NEAR_NO_TIMER (END_TRAJ|END_BLOCKING|END_OBSTACLE|END_INTR)
98 #define TRAJ_FLAGS_SMALL_DIST (END_TRAJ|END_BLOCKING|END_INTR)
102 #define ACC_ANGLE 10.
105 #define SPEED_DIST_FAST 2500.
106 #define SPEED_ANGLE_FAST 2000.
107 #define SPEED_DIST_SLOW 1000.
108 #define SPEED_ANGLE_SLOW 1000.
109 #define SPEED_DIST_VERY_SLOW 400.
110 #define SPEED_ANGLE_VERY_SLOW 400.
112 /* strat infos structures */
114 uint8_t dump_enabled;
116 #define STRAT_CONF_XXX 0x01
120 extern struct strat_conf strat_conf;
123 void strat_conf_dump(const char *caller);
124 void strat_reset_infos(void); /* reset current known state */
125 void strat_preinit(void);
126 void strat_init(void);
127 void strat_exit(void);
128 void strat_dump_flags(void);
129 void strat_goto_near(int16_t x, int16_t y, uint16_t dist);
130 uint8_t strat_main(void);
131 void strat_event(void *dummy);