2 * Copyright Droids Corporation, Microb Technology (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: strat_utils.h,v 1.5 2009-11-08 17:24:33 zer0 Exp $
28 /* wait traj end flag or cond. return 0 if cond become true, else
29 * return the traj flag */
30 #define WAIT_COND_OR_TRAJ_END(cond, mask) \
33 while ( (! (cond)) && (__err == 0)) { \
34 __err = test_traj_end(mask); \
37 DEBUG(E_USER_STRAT, "cond is true at line %d", \
40 DEBUG(E_USER_STRAT, "got %s at line %d", \
41 get_err(__err), __LINE__); \
45 #define WAIT_COND_OR_TE_TO(cond, mask, timeout) \
47 microseconds __us = time_get_us2(); \
49 while ( (! (cond)) && (__ret == 0)) { \
50 __ret = test_traj_end(mask); \
51 if (time_get_us2() - __us > (timeout)*1000L) { \
57 DEBUG(E_USER_STRAT, "cond / timeout at line %d", \
60 DEBUG(E_USER_STRAT, "got %s (%d) at line %d", \
61 get_err(__ret), __ret, __LINE__); \
66 int16_t distance_between(int16_t x1, int16_t y1, int16_t x2, int16_t y2);
67 int32_t quad_distance_between(int16_t x1, int16_t y1, int16_t x2, int16_t y2);
68 int16_t distance_from_robot(int16_t x, int16_t y);
69 int16_t simple_modulo_360(int16_t a);
70 int16_t angle_abs_to_rel(int16_t a_abs);
71 void rel_da_to_abs_xy(double d_rel, double a_rel_rad, double *x_abs, double *y_abs);
72 double norm(double x, double y);
73 void rel_xy_to_abs_xy(double x_rel, double y_rel, double *x_abs, double *y_abs);
74 void abs_xy_to_rel_da(double x_abs, double y_abs, double *d_rel, double *a_rel_rad);
75 void rotate(double *x, double *y, double rot);
76 uint8_t is_in_area(int16_t x, int16_t y, int16_t margin);
77 uint8_t robot_is_in_area(int16_t margin);
78 uint8_t robot_is_near_disc(void);
79 uint8_t y_is_more_than(int16_t y);
80 uint8_t x_is_more_than(int16_t x);
81 int16_t fast_sin(int16_t deg);
82 int16_t fast_cos(int16_t deg);
83 uint8_t get_color(void);
84 uint8_t get_opponent_color(void);
85 int8_t get_opponent_xy(int16_t *x, int16_t *y);
86 int8_t get_opponent_da(int16_t *d, int16_t *a);
87 int8_t get_opponent_xyda(int16_t *x, int16_t *y, int16_t *d, int16_t *a);
88 int16_t distance_from_opponent(int16_t x, int16_t y);
90 uint8_t get_ball_count(void);
91 uint8_t get_cob_count(void);