summaryrefslogtreecommitdiffhomepage
path: root/digital/beacon/src/main_simu.c
blob: 0ad0dfddf29e7fc474c0b1bec46a39ed8902b3bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/* main_simu.c */
/* Beacon Simulator Interface. {{{
 *
 * Copyright (C) 2011 Florent Duchon
 *
 * APBTeam:
 *        Web: http://apbteam.org/
 *      Email: team AT apbteam DOT org
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *
 * }}} */
#ifdef SIMULATOR

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "position.h"

/* Globals Declaration */
extern opponent_s opponent[MAX_OBSTACLE];

int main (int argc, char **argv)
{
	char saisie[30];
	char ret = 0;
	int id = 0;
	float angle = 0;
	int angle_id = 0;
	int i = 0;
	/* Init global structures */
  	position_init_struct();

	while(1)
	{
		ret = fgets (saisie, sizeof saisie, stdin);
		if(ret != NULL)
		{
			id = strtol (saisie, NULL, 10);
		}
		ret = fgets (saisie, sizeof saisie, stdin);
		if(ret != NULL)
		{
			angle = strtod (saisie, NULL);
		}
		ret = fgets (saisie, sizeof saisie, stdin);
		if(ret != NULL)
		{
			angle_id = strtod (saisie, NULL);
		}
		
  		update_position(id,angle_id,angle);
		 
		/* Return position to the simulator */
		for(i=1;i<=MAX_OBSTACLE;i++)
		{
			printf("%d\n",(int)opponent[i].x);
			printf("%d\n",(int)opponent[i].y);
			printf("%d\n",(int)opponent[i].trust);
		}
		fflush(stdout);
	}
	return 0;
}
#endif //SIMULATOR