Project

General

Profile

Revision 1045

Added by Ben Poole about 15 years ago

added a sample world, updated main to load the sample world

View differences:

branches/simulator/projects/simulator/simulator/core/main.c
15 15

  
16 16
#include "gtk_gui.h"
17 17
#include "robot.h"
18
#include "world.h"
18 19

  
19 20
int main(int argc, char** argv)
20 21
{
......
26 27
		exit(-1);
27 28
	}
28 29

  
30
	load_world("../../test/world.txt", 100);
29 31

  
32

  
30 33
	robot_create(argv[1]);
31
	/*robot_create(argv[1]);
32 34
	robot_create(argv[1]);
33 35
	robot_create(argv[1]);
34 36
	robot_create(argv[1]);
......
47 49
	robot_create(argv[1]);
48 50
	robot_create(argv[1]);
49 51
	robot_create(argv[1]);
50
	*/
52
	robot_create(argv[1]);
51 53

  
52 54

  
53 55
	sigset_t set;
branches/simulator/projects/simulator/simulator/core/world.c
61 61
    point_t p1 = ray->p;
62 62
    point_t p2 = {ray->p.x+cos(ray->d),ray->p.y+sin(ray->d)};
63 63

  
64
#if DEBUG
65
    printf("(%g,%g) --> (%g,%g) with (%g,%g) --> (%g,%g)\n",p1.x,p1.y,p2.x,p2.y,p3.x,p3.y,p4.x,p4.y);
66
#endif
64
    //printf("(%g,%g) --> (%g,%g) with (%g,%g) --> (%g,%g)\n",p1.x,p1.y,p2.x,p2.y,p3.x,p3.y,p4.x,p4.y);
67 65
    denom = (p2.y-p1.y)*(p4.x-p3.x)-(p2.x-p1.x)*(p4.y-p3.y);
68 66
    if (denom == 0) {
69 67
	return RAY_MISS;
......
84 82
    xint = p3.x+ua*(p4.x-p3.x);
85 83
    yint = p3.y+ua*(p4.y-p3.y);
86 84
    dist = sqrt((xint-p1.x)*(xint-p1.x)+(yint-p1.y)*(yint-p1.y));
87
#if DEBUG
88
    printf("Got: %g\n", dist);
89
#endif
90 85
    return dist;
91 86

  
92 87
}
branches/simulator/projects/simulator/simulator/core/world.h
26 26
#define POLY_RECT 2
27 27

  
28 28
#define NUM_SHAPES 3
29
#define RAY_MISS 1E30
29
#define RAY_MISS 10000
30 30
#define CREATE(id, ...) (create_func[id](__VA_ARGS__))
31 31
#define PBBOX(b) {printf("(%g,%g) --> (%g, %g)\n",(b).p1.x,(b).p1.y,(b).p2.x,\
32 32
						  (b).p2.y);}
branches/simulator/projects/simulator/simulator/Makefile
1 1
# Add new files here
2 2
COMMON_SRCS :=
3
CORE_SRCS := main.c robot.c motion.c
3
CORE_SRCS := main.c robot.c motion.c world.c
4 4
GUI_SRCS := gtk_gui.c gtk_environment_view.c
5 5

  
6 6
CORE_DIR := core
branches/simulator/projects/simulator/test/world.txt
1
WORLD 0 0 512 512
2
POLYGON 4 CONNECTED -1 -1 -1 1 1 1 1 -1
0 3

  

Also available in: Unified diff