Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1659 | giacomo | 1 | #include <stdlib.h> |
2 | #include "kernel/kern.h" |
||
3 | #include "kernel/func.h" |
||
4 | #include "ll/i386/x-dos.h" |
||
5 | #include "modules/cabs.h" |
||
6 | #include "modules/hartport.h" |
||
7 | #include "string.h" |
||
8 | #include <math.h> |
||
9 | #include <drivers/glib.h> |
||
10 | #include <drivers/keyb.h> |
||
11 | #include <drivers/pxc.h> |
||
12 | |||
13 | //#include "modules/pi.h" |
||
14 | //#include "modules/nop.h" |
||
15 | |||
16 | //#define PI |
||
17 | //#define CAMERA_X |
||
18 | //#define TIMEJET //e` incompatibile con PLOTIMG on |
||
19 | //#define DATAPLANT |
||
20 | /*//#define SOFTCARR |
||
21 | //#define SOFTTRACK unused!!!! |
||
22 | */ |
||
23 | |||
24 | #define SOFTPROG |
||
25 | #define PLOTIMG // e` incompatibile con TIMEJET on (???perche`?) |
||
26 | |||
27 | #define FRAMEGRABBER_ON |
||
28 | #define JET_ON |
||
29 | |||
30 | |||
31 | /* |
||
32 | * WCET, Periods and Models |
||
33 | */ |
||
34 | |||
35 | |||
36 | /* define if you want NRT or SOFT... */ |
||
37 | |||
38 | |||
39 | // dipendono dalla macchina !!!! |
||
40 | |||
41 | #define TASK_TYPE SOFT |
||
42 | |||
43 | // SOFT + HARD tasks !!!!!!!!!!!!!!!!!! |
||
44 | |||
45 | /* |
||
46 | // TASK carrello |
||
47 | #ifdef SOFTCARR // SOFT |
||
48 | //#define WCET_CARRELLO 240 //460 |
||
49 | //#define PERIOD_CARRELLO 1200 |
||
50 | #else // HARD |
||
51 | #define WCET_CARRELLO 600//500 |
||
52 | //#define PERIOD_CARRELLO 1800//1800 |
||
53 | #endif |
||
54 | |||
55 | // TASK tracking |
||
56 | #ifdef SOFTTRACK // SOFT |
||
57 | //#define WCET_TRACKING 7200 //5000 |
||
58 | //#define PERIOD_TRACKING 12000 |
||
59 | #else // HARD |
||
60 | #define WCET_TRACKING 10000 //10000 |
||
61 | //#define PERIOD_TRACKING 22200 //30000 |
||
62 | #endif |
||
63 | */ |
||
64 | |||
65 | #ifdef SOFTPROG |
||
66 | extern long int PERIOD_CARRELLO, WCET_CARRELLO, PERIOD_TRACKING, WCET_TRACKING; |
||
67 | #else |
||
68 | #define WCET_CARRELLO 600//500 |
||
69 | #define WCET_TRACKING 10000 //10000 |
||
70 | extern long int PERIOD_CARRELLO , PERIOD_TRACKING; |
||
71 | #endif |
||
72 | |||
73 | |||
74 | |||
75 | |||
76 | |||
77 | |||
78 | |||
79 | /*+ altri TASKS +*/ |
||
80 | |||
81 | // TIMEJET non viene attivato nei run.Incompatibile con i tasks JETCTRL |
||
82 | #define WCET_TIMEJET 900 |
||
83 | #define PERIOD_TIMEJET 2000 |
||
84 | |||
85 | |||
86 | #define WCET_DESIGN 4000 // 4000 |
||
87 | #define PERIOD_DESIGN 100000 // 50000 |
||
88 | |||
89 | |||
90 | #define WCET_CAMERA 5000 // 5000 |
||
91 | #define PERIOD_CAMERA 100000 // 50000 |
||
92 | |||
93 | #define WCET_JETCTRL 1000 |
||
94 | #define WCET_JETDUMMY WCET_JETCTRL |
||
95 | #define WCET_JETSLIDE WCET_JETCTRL |
||
96 | |||
97 | #define PERIOD_JETCTRL 100000 |
||
98 | #define PERIOD_JETDUMMY 100000 |
||
99 | #define PERIOD_JETSLIDE 100000 |
||
100 | |||
101 | |||
102 | /* controllo stuffs */ |
||
103 | |||
104 | |||
105 | struct Data_cab1 { |
||
106 | float rif; |
||
107 | int imp; |
||
108 | }; |
||
109 | struct Data_cab2 { |
||
110 | float x; |
||
111 | float y; |
||
112 | } ; |
||
113 | |||
114 | struct Parametri{ |
||
115 | float GUAD[4]; |
||
116 | float COST; |
||
117 | float NOISE; |
||
118 | float WCUT; |
||
119 | float WCUT1; |
||
120 | float OFFSVAL; |
||
121 | int DEADLINE; |
||
122 | int SCAN; |
||
123 | float XTRASL; |
||
124 | }; |
||
125 | |||
126 | extern mutex_t mutex, mutexadc; |
||
127 | extern CAB cab1, cab2; |
||
128 | extern struct Parametri prm; |
||
129 | |||
130 | void app_mutex_init(mutex_t *); |
||
131 | |||
132 | int da_motor(float v); |
||
133 | float v2x(float v); |
||
134 | float v2theta(float v); |
||
135 | float bass1(float u); |
||
136 | float bass2(float u); |
||
137 | float bass3(float u); |
||
138 | float bass4(float u); |
||
139 | float dx(float u); |
||
140 | float dth(float u); |
||
141 | |||
142 | |||
143 | |||
144 | |||
145 | |||
146 | |||
147 | |||
148 | |||
149 | /* scenario */ |
||
150 | #define SCENARIO_NLABEL 16 |
||
151 | |||
152 | |||
153 | /* |
||
154 | * Global Stuffs |
||
155 | */ |
||
156 | |||
157 | /* graphic mutex... */ |
||
158 | extern mutex_t mutex; |
||
159 | |||
160 | /* useful colors... */ |
||
161 | int white; |
||
162 | int black; |
||
163 | int red; |
||
164 | int gray; |
||
165 | int green; |
||
166 | int blue; |
||
167 | |||
168 | void init_jetcontrol(); |
||
169 | |||
170 | void init_framegrabber(); |
||
171 | |||
172 | /* |
||
173 | * |
||
174 | * JETCONTROL stuffs |
||
175 | * |
||
176 | */ |
||
177 | |||
178 | #define JET_NTASK 13 |
||
179 | #define JET_Y_NAME 480 //500 |
||
180 | |||
181 | #define DUMMY_PID 1 |
||
182 | |||
183 | #define JET_DUMMY_WIDTH 210 |
||
184 | #define JET_DUMMY_HEIGHT 40 |
||
185 | |||
186 | /* the point (x, y) is the top left corner */ |
||
187 | #define JET_DUMMY_X 60 |
||
188 | #define JET_DUMMY_Y 514 |
||
189 | |||
190 | #define JET_SLIDE_WIDTH 50 |
||
191 | #define JET_SLIDE_X (384+200) |
||
192 | |||
193 | |||
194 | /* |
||
195 | * |
||
196 | * FRAMEGRABBER stuffs |
||
197 | * |
||
198 | */ |
||
199 | |||
200 | // if defined... object black on a white background |
||
201 | #ifndef __BLACK_ON_WHITE |
||
202 | #define __BLACK_ON_WHITE |
||
203 | #endif |
||
204 | |||
205 | #define ABS_NUM(a) ((a >= 0) ? a : -a) |
||
206 | #define MIN_NUM(a, b) ((a < b) ? a : b) |
||
207 | #define MAX_NUM(a, b) ((a > b) ? a : b) |
||
208 | |||
209 | |||
210 | // Cols and rows of the framegrabber image |
||
211 | #define N_COL 384 // 384 |
||
212 | #define N_ROW 288 |
||
213 | #define N_BPS 8 // Bits per pixel |
||
214 | #define N_GRIGI 256 |
||
215 | |||
216 | #define N_FRAMES 20 // 100 |
||
217 | |||
218 | /* pixel of the video image */ |
||
219 | #define IMG_COL 230 // 230 //256 |
||
220 | #define IMG_ROW 160 // 160 //192 |
||
221 | |||
222 | /* position of the video image */ |
||
223 | #define IMG_X 500 // 644 // 384 |
||
224 | #define IMG_Y 32 // 200 // 32 |
||
225 | |||
226 | // I singoli pixel sono caratteri a 8 bit |
||
227 | typedef unsigned char TPixel; |
||
228 | |||
229 | typedef struct { |
||
230 | int x1, y1; |
||
231 | int x2, y2; |
||
232 | int xb, yb; |
||
233 | TIME time_stamp; |
||
234 | } TDataObj; |
||
235 | |||
236 | typedef struct { |
||
237 | int found; |
||
238 | int top_frame; |
||
239 | int vx,vy; |
||
240 | int predx; |
||
241 | int predy; |
||
242 | TDataObj current; |
||
243 | } TTracking; |
||
244 | |||
245 | |||
246 | float distance(unsigned int x1, unsigned int y1, |
||
247 | unsigned int x2, unsigned int y2); |
||
248 | |||
249 | char scan_all_frame(TDataObj *data, TPixel *in_frame); |
||
250 | |||
251 | char scan_window_frame(TDataObj *data, TPixel *in_frame, \ |
||
252 | unsigned int xc, unsigned int yc, int border, int border_y); |
||
253 | void threshold_up_function(KEY_EVT key); |
||
254 | void threshold_down_function(KEY_EVT key); |
||
255 | void border_up_function(KEY_EVT key); |
||
256 | void border_down_function(KEY_EVT key); |
||
257 | void tracking(int top_frame, int *track_x, int *track_y, int *int_vx, int *int_vy, int time_to); |
||
258 | TASK elab_image_TASK(void); |
||
259 | |||
260 |