remove ~files
[aversive.git] / projects / microb2010 / mainboard / strat_utils.h
1 /*  
2  *  Copyright Droids Corporation, Microb Technology (2009)
3  * 
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.
8  *
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.
13  *
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
17  *
18  *  Revision : $Id: strat_utils.h,v 1.5 2009-11-08 17:24:33 zer0 Exp $
19  *
20  */
21
22
23 #define DEG(x) (((double)(x)) * (180.0 / M_PI))
24 #define RAD(x) (((double)(x)) * (M_PI / 180.0))
25 #define M_2PI (2*M_PI)
26
27 struct xy_point {
28         int16_t x;
29         int16_t y;
30 };
31
32 /* wait traj end flag or cond. return 0 if cond become true, else
33  * return the traj flag */
34 #define WAIT_COND_OR_TRAJ_END(cond, mask)                               \
35         ({                                                              \
36                 uint8_t __err = 0;                                      \
37                 while ( (! (cond)) && (__err == 0)) {                   \
38                         __err = test_traj_end(TRAJ_FLAGS_NO_NEAR);      \
39                 }                                                       \
40                 __err;                                                  \
41         })                                                              \
42
43 int16_t distance_between(int16_t x1, int16_t y1, int16_t x2, int16_t y2);
44 int16_t distance_from_robot(int16_t x, int16_t y);
45 int16_t simple_modulo_360(int16_t a);
46 double simple_modulo_2pi(double a);
47 int16_t angle_abs_to_rel(int16_t a_abs);
48 void rel_da_to_abs_xy(double d_rel, double a_rel_rad, double *x_abs, double *y_abs);
49 double norm(double x, double y);
50 void rel_xy_to_abs_xy(double x_rel, double y_rel, double *x_abs, double *y_abs);
51 void abs_xy_to_rel_da(double x_abs, double y_abs, double *d_rel, double *a_rel_rad);
52 void rotate(double *x, double *y, double rot);
53 uint8_t is_in_area(int16_t x, int16_t y, int16_t margin);
54 uint8_t robot_is_in_area(int16_t margin);
55 uint8_t robot_is_near_disc(void);
56 uint8_t y_is_more_than(int16_t y);
57 uint8_t x_is_more_than(int16_t x);
58 int16_t fast_sin(int16_t deg);
59 int16_t fast_cos(int16_t deg);
60 uint8_t get_color(void);
61 uint8_t get_opponent_color(void);
62 int8_t get_opponent_xy(int16_t *x, int16_t *y);
63 int8_t get_opponent_da(int16_t *d, int16_t *a);
64 int8_t get_opponent_xyda(int16_t *x, int16_t *y, int16_t *d, int16_t *a);
65 uint8_t get_column_count(void);
66 uint8_t get_column_count_right(void);
67 uint8_t get_column_count_left(void);
68 uint8_t get_lintel_count(void);
69 uint8_t get_mechboard_mode(void);
70 uint8_t pump_left1_is_full(void);
71 uint8_t pump_left2_is_full(void);
72 uint8_t pump_right1_is_full(void);
73 uint8_t pump_right2_is_full(void);
74 uint8_t get_scanner_status(void);
75 uint8_t wait_scan_done(uint16_t timeout);
76 uint8_t opponent_is_behind(void);