Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1659 | giacomo | 1 | #define PI |
2 | |||
3 | #include "kernel/kern.h" |
||
4 | #include "modules/edf.h" |
||
5 | #include "modules/cbs.h" |
||
6 | #include "modules/rr.h" |
||
7 | |||
8 | #ifndef PI |
||
9 | #include "modules/rrsoft.h" |
||
10 | #endif |
||
11 | |||
12 | #include "modules/dummy.h" |
||
13 | |||
14 | #include "modules/sem.h" |
||
15 | #include "modules/hartport.h" |
||
16 | #include "modules/cabs.h" |
||
17 | #include "modules/pi.h" |
||
18 | #include "modules/pc.h" |
||
19 | #include "modules/srp.h" |
||
20 | #include "modules/npp.h" |
||
21 | #include "modules/nop.h" |
||
22 | |||
23 | #include "drivers/keyb.h" |
||
24 | #include "drivers/glib.h" |
||
25 | |||
26 | /*+ system tick in us +*/ |
||
27 | #define TICK 1000 |
||
28 | |||
29 | /*+ RR tick in us +*/ |
||
30 | #define RRTICK 10000 |
||
31 | //#define RRTICK 3000 |
||
32 | |||
33 | TIME __kernel_register_levels__(void *arg) |
||
34 | { |
||
35 | struct multiboot_info *mb = (struct multiboot_info *)arg; |
||
36 | |||
37 | #ifdef PI |
||
38 | EDF_register_level(EDF_ENABLE_WCET_CHECK); |
||
39 | CBS_register_level(0,0); //CBS_ENABLE_ALL, 0); |
||
40 | #else |
||
41 | RRSOFT_register_level(RRTICK, RR_MAIN_NO, mb, RRSOFT_ONLY_HARD|RRSOFT_ONLY_SOFT); |
||
42 | RRSOFT_register_level(RRTICK, RR_MAIN_NO, mb, RRSOFT_ONLY_SOFT); //cbs |
||
43 | #endif |
||
44 | |||
45 | RR_register_level(RRTICK, RR_MAIN_YES, mb); |
||
46 | dummy_register_level(); |
||
47 | |||
48 | |||
49 | SEM_register_module(); |
||
50 | |||
51 | CABS_register_module(); |
||
52 | |||
53 | PI_register_module(); |
||
54 | NOP_register_module(); |
||
55 | |||
56 | return TICK; |
||
57 | } |
||
58 | |||
59 | TASK __init__(void *arg) |
||
60 | { |
||
61 | struct multiboot_info *mb = (struct multiboot_info *)arg; |
||
62 | |||
63 | HARTPORT_init(); |
||
64 | |||
65 | kern_printf("TIME=%d\n",sys_gettime(NULL)); |
||
66 | KEYB_init(NULL); |
||
67 | kern_printf("TIME=%d\n",sys_gettime(NULL)); |
||
68 | grx_init(); |
||
69 | __call_main__(mb); |
||
70 | |||
71 | return (void *)0; |
||
72 | } |
||
73 | |||
74 | |||
75 | #ifdef PI |
||
76 | void app_mutex_init(mutex_t *m) |
||
77 | { |
||
78 | PI_mutexattr_t attr; |
||
79 | |||
80 | PI_mutexattr_default(attr); |
||
81 | |||
82 | mutex_init(m, &attr); |
||
83 | } |
||
84 | #else |
||
85 | void app_mutex_init(mutex_t *m) |
||
86 | { |
||
87 | NOP_mutexattr_t attr; |
||
88 | |||
89 | NOP_mutexattr_default(attr); |
||
90 | |||
91 | mutex_init(m, &attr); |
||
92 | } |
||
93 | #endif |
||
94 | |||
95 | E_WCET_CHECK); |
||
96 | CBS_register_level(0,0); //CBS_ENABLE_ALL, 0); |
||
97 | #else |
||
98 | RRSOFT_register_level(RRTICK, RR_MAIN_NO, mb, RRSOFT_ONLY_HARD|RRSOFT_ONLY_SOFT); |
||
99 | RRSOFT_register_level(RRTICK, RR_MAIN_NO, mb, RRSOFT_ONLY_SOFT); //cbs |
||
100 | #endif |
||
101 | |||
102 | RR_register_level(RRTICK, RR_MAIN_YES, mb |
||
103 | B cab1, cab2; |
||
104 | extern struct Parametri prm; |
||
105 | |||
106 | void app_mutex_init(mutex_t *); |
||
107 | |||
108 | int da_motor(float v); |
||
109 | float v2x(float v); |
||
110 | float v2theta(float v); |
||
111 | float bass1(float u); |
||
112 | float bass2(float u); |
||
113 | float bass3(float u); |
||
114 | float bass4(float u); |
||
115 | float dx(float u); |
||
116 | float dth(float u); |
||
117 | |||
118 | |||
119 | |||
120 | |||
121 | |||
122 | |||
123 | |||
124 | |||
125 | /* scenario */ |
||
126 | #define SCENARIO_NLABEL 16 |
||
127 | |||
128 | |||
129 | /* |
||
130 | * Global Stuffs |
||
131 | */ |
||
132 | |||
133 | /* graphic mutex... */ |
||
134 | extern mutex_t mutex; |
||
135 | |||
136 | /* useful colors... */ |
||
137 | int white; |
||
138 | int black; |
||
139 | int red; |
||
140 | int gray; |
||
141 | int green; |
||
142 | int blue; |
||
143 | |||
144 | void init_jetcontrol(); |
||
145 | |||
146 | void init_framegrabber(); |
||
147 | |||
148 | /* |
||
149 | * |
||
150 | * JETCONTROL stuffs |
||
151 | * |
||
152 | */ |
||
153 | |||
154 | #define JET_NTASK 13 |
||
155 | #define JET_Y_NAME 480 //500 |
||
156 | |||
157 | #define DUMMY_PID 1 |
||
158 | |||
159 | #define JET_DUMMY_WIDTH 210 |
||
160 | #define JET_DUMMY_HEIGHT 40 |
||
161 | |||
162 | /* the point (x, y) is the top left corner */ |
||
163 | #define JET_DUMMY_X 60 |
||
164 | #define JET_DUMMY_Y 514 |
||
165 | |||
166 | #define JET_SLIDE_WIDTH 50 |
||
167 | #define JET_SLIDE_X (384+200) |
||
168 | |||
169 | |||
170 | /* |
||
171 | * |
||
172 | * FRAMEGRABBER stuffs |
||
173 | * |
||
174 | */ |
||
175 | |||
176 | // if defined... object black on a white background |
||
177 | #ifndef __BLACK_ON_WHITE |
||
178 | #define __BLACK_ON_WHITE |
||
179 | #endif |
||
180 | |||
181 | #define ABS_NUM(a) ((a >= 0) ? a : -a) |
||
182 | #define MIN_NUM(a, b) ((a < b) ? a : b) |
||
183 | #define MAX_NUM(a, b) ((a > b) ? a : b) |
||
184 | |||
185 | |||
186 | // Cols and rows of the framegrabber image |
||
187 | #define N_COL 384 // 384 |
||
188 | #define N_ROW 288 |
||
189 | #define N_BPS 8 // Bits per pixel |
||
190 | #define N_GRIGI 256 |
||
191 | |||
192 | #define N_FRAMES 20 // 100 |
||
193 | |||
194 | /* pixel of the video image */ |
||
195 | #define IMG_COL 230 // 230 //256 |
||
196 | #define IMG_ROW 160 // 160 //192 |
||
197 | |||
198 | /* position of the video image */ |
||
199 | #define IMG_X 500 // 644 // 384 |
||
200 | #define IMG_Y 32 // 200 // 32 |
||
201 | |||
202 | // I singoli pixel sono caratteri a 8 bit |
||
203 | typedef unsigned char TPixel; |
||
204 | |||
205 | typedef struct { |
||
206 | int x1, y1; |
||
207 | int x2, y2; |
||
208 | int xb, yb; |
||
209 | TIME time_stamp; |
||
210 | } TDataObj; |
||
211 | |||
212 | typedef struct { |
||
213 | int found; |
||
214 | int top_frame; |
||
215 | int vx,vy; |
||
216 | int predx; |
||
217 | int predy; |
||
218 | TDataObj current; |
||
219 | } TTracking; |
||
220 | |||
221 | |||
222 | float distance(unsigned int x1, unsigned int y1, |
||
223 | unsigned int x2, unsigned int y2); |
||
224 | |||
225 | char scan_all_frame(TDataObj *data, TPixel *in_frame); |
||
226 | |||
227 | char scan_window_frame(TDataObj *data, TPixel *in_frame, \ |
||
228 | unsigned int xc, unsigned int yc, int border, int border_y); |
||
229 | void threshold_up_function(KEY_EVT key); |
||
230 | void threshold_down_function(KEY_EVT key); |
||
231 | void border_up_function(KEY_EVT key); |
||
232 | void border_down_function(KEY_EVT key); |
||
233 | void tracking(int top_frame, int *track_x, int *track_y, int *int_vx, int *int_vy, int time_to); |
||
234 | TASK elab_image_TASK(void); |
||
235 | |||
236 |