2 * Copyright Droids Corporation (2009)
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: main.h,v 1.10 2009-11-08 17:24:33 zer0 Exp $
22 #define LED_TOGGLE(port, bit) do { \
23 if (port & _BV(bit)) \
49 /* only 90 seconds, don't forget it :) */
52 /* decrease track to decrease angle */
53 #define EXT_TRACK_MM 302.0188
54 #define VIRTUAL_TRACK_MM EXT_TRACK_MM
56 #define ROBOT_LENGTH 320
57 #define ROBOT_WIDTH 320
59 /* it is a 2048 imps -> 8192 because we see 1/4 period
60 * and diameter: 55mm -> perimeter 173mm
62 /* increase it to go further */
63 #define IMP_ENCODERS 2048
64 #define WHEEL_DIAMETER_MM 55.0
65 #define WHEEL_PERIM_MM (WHEEL_DIAMETER_MM * M_PI)
67 #define DIST_IMP_MM (((IMP_ENCODERS*4) / WHEEL_PERIM_MM) * IMP_COEF)
69 #define LEFT_ENCODER ((void *)0)
70 #define RIGHT_ENCODER ((void *)1)
72 #define LEFT_PWM ((void *)0)
73 #define RIGHT_PWM ((void *)1)
76 #define E_USER_STRAT 194
77 #define E_USER_I2C_PROTO 195
78 #define E_USER_SENSOR 196
86 #define I2C_POLL_PRIO 20
87 #define EEPROM_TIME_PRIO 10
89 #define CS_PERIOD 5000L
93 /* generic to all boards */
95 /* command line interface */
97 char prompt[RDLINE_PROMPT_SIZE];
100 uint8_t logs[NB_LOGS+1];
108 struct pid_filter pid;
109 struct quadramp_filter qr;
110 struct blocking_detection bd;
113 /* mainboard specific */
115 #define DO_ENCODERS 1
122 uint8_t flags; /* misc flags */
124 /* control systems */
125 struct cs_block angle;
126 struct cs_block distance;
128 /* x,y positionning */
129 struct robot_system rs;
130 struct robot_position pos;
131 struct trajectory traj;
135 volatile int16_t speed_a; /* current angle speed */
136 volatile int16_t speed_d; /* current dist speed */
137 int32_t pwm_l; /* current left pwm */
138 int32_t pwm_r; /* current right pwm */
139 uint8_t enable_pickup_wheels; /* these PWM are on sensorboard */
143 extern struct genboard gen;
144 extern struct mainboard mainboard;
146 #define SPEED_DIST_FAST 2500
147 #define SPEED_ANGLE_FAST 2000
148 #define SPEED_DIST_SLOW 1000
149 #define SPEED_ANGLE_SLOW 1000
150 #define SPEED_DIST_VERY_SLOW 400
151 #define SPEED_ANGLE_VERY_SLOW 400
153 #define WAIT_COND_OR_TIMEOUT(cond, timeout) \
155 microseconds __us = time_get_us2(); \
158 if (time_get_us2() - __us > (timeout)*1000L) {\
164 DEBUG(E_USER_STRAT, "cond is true at line %d",\
167 DEBUG(E_USER_STRAT, "timeout at line %d", \