ini
[aversive.git] / modules / devices / robot / obstacle_avoidance / test / main.c
1 /*  
2  *  Copyright Droids Corporation, Microb Technology, Eirbot (2005)
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: main.c,v 1.1.2.2 2009-05-02 10:00:35 zer0 Exp $
19  *
20  */
21
22 #include <stdio.h>
23 #include <stdarg.h>
24 #include <string.h>
25 #include <math.h>
26
27 #include <aversive.h>
28 #include <aversive/error.h>
29
30 #include <vect_base.h>
31 #include <lines.h>
32 #include <polygon.h>
33
34 #include <obstacle_avoidance.h>
35
36 #define PTX 150
37 #define PTY 105
38 #define SIZE 45
39
40 /* log function, add a command to configure
41  * it dynamically */
42 void mylog(struct error * e, ...) 
43 {
44         va_list ap;
45
46         va_start(ap, e);
47         printf_P(PSTR("[%d]: E%d "), e->severity, e->err_num);
48         vfprintf_P(stdout, e->text, ap);
49         printf_P(PSTR("\r\n"));
50         va_end(ap);
51 }
52
53
54 int main(int argc, char** argv)
55 {
56         poly_t *pol;
57
58         /* LOGS */
59         error_register_emerg(mylog);
60         error_register_error(mylog);
61         error_register_warning(mylog);
62         error_register_notice(mylog);
63         error_register_debug(mylog);
64
65         oa_init();
66
67         oa_start_end_points(30, 30, 194, 149);
68
69         pol = oa_new_poly(4);
70
71         oa_poly_set_point(pol, PTX-SIZE, PTY-SIZE, 0);
72         oa_poly_set_point(pol, PTX+SIZE, PTY-SIZE, 1);
73         oa_poly_set_point(pol, PTX+SIZE, PTY+SIZE, 2);
74         oa_poly_set_point(pol, PTX-SIZE, PTY+SIZE, 3);
75         oa_process();
76         
77         return 0;
78 }
79
80