Check-in [2678fffc57]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Добавлен алгоритм поиска огня
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:2678fffc57df7700f29ba4c3ef2ad4a37b02f632
User & Date: zhekasakun 2016-11-24 23:39:45
Context
2016-12-02
13:56
Добавлены разделы ПЗ. Остались титулка, требования, ПО и моделирование check-in: 80f3c312ac user: zhekasakun tags: trunk
2016-11-24
23:39
Добавлен алгоритм поиска огня check-in: 2678fffc57 user: zhekasakun tags: trunk
2016-11-19
20:38
Исправлена ошибка с ложными срабатываниями УЗ датчика при питании от сети. При питании от батарей ложные срабатывания остались. check-in: 9fe8e5126e user: zhekasakun tags: trunk
Changes

Changes to src/firebot2/firebot/firebot.atsuo.

cannot compute difference between binary files

Changes to src/firebot2/firebot/src/Movement subsystem/MovementAgent.c.

91
92
93
94
95
96
97
98
99
100
101



102
103
104
105
106
107
108
...
120
121
122
123
124
125
126









127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
	return 0;
}

void move(DirectRobot_t direction, Speed_t speed)
{
	/*const uint8_t MIN_LEFT = 140;
	const uint8_t MIN_RIGHT = 152;*/
	const uint8_t MIN_LEFT = 188;
	const uint8_t MIN_RIGHT = 180;
	const uint8_t MAX_LEFT = 255;
	const uint8_t MAX_RIGHT = 255;



	switch (direction)
	{
		case STOP:
			rotationWheel(0,0,0);
			rotationWheel(1,0,0);
			break;	
		case FORWARD:
................................................................................
				rotationWheel(1,BACKWARD,MIN_RIGHT);
			}else{
				rotationWheel(0,BACKWARD,MAX_LEFT);
				rotationWheel(1,BACKWARD,MAX_RIGHT);
			}
			break;
		case LEFT:









			if (speed == MIN){
				rotationWheel(0,BACKWARD,MIN_LEFT);
				rotationWheel(1,FORWARD,MIN_RIGHT);
			}else{
				rotationWheel(0,BACKWARD,MAX_LEFT);
				rotationWheel(1,FORWARD,MAX_RIGHT);
			}
			break;
		case RIGHT:
			if (speed == MIN){
				rotationWheel(0,FORWARD,MIN_LEFT);
				rotationWheel(1,BACKWARD,MIN_RIGHT);
			}else{
				rotationWheel(0,1,MAX_LEFT);
				rotationWheel(1,2,MAX_RIGHT);
			}
			break;						
	}
}







|



>
>
>







 







>
>
>
>
>
>
>
>
>







<
<
<
<
<
<
<
<
<



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
...
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145









146
147
148
	return 0;
}

void move(DirectRobot_t direction, Speed_t speed)
{
	/*const uint8_t MIN_LEFT = 140;
	const uint8_t MIN_RIGHT = 152;*/
	const uint8_t MIN_LEFT = 180;
	const uint8_t MIN_RIGHT = 180;
	const uint8_t MAX_LEFT = 255;
	const uint8_t MAX_RIGHT = 255;
	
	speed = MAX;	// WARNING!!! Sakun!!!
	
	switch (direction)
	{
		case STOP:
			rotationWheel(0,0,0);
			rotationWheel(1,0,0);
			break;	
		case FORWARD:
................................................................................
				rotationWheel(1,BACKWARD,MIN_RIGHT);
			}else{
				rotationWheel(0,BACKWARD,MAX_LEFT);
				rotationWheel(1,BACKWARD,MAX_RIGHT);
			}
			break;
		case LEFT:
			if (speed == MIN){
				rotationWheel(0,FORWARD,MIN_LEFT);
				rotationWheel(1,BACKWARD,MIN_RIGHT);
			}else{
				rotationWheel(0,FORWARD,MAX_LEFT);
				rotationWheel(1,BACKWARD,MAX_RIGHT);
			}
			break;
		case RIGHT:
			if (speed == MIN){
				rotationWheel(0,BACKWARD,MIN_LEFT);
				rotationWheel(1,FORWARD,MIN_RIGHT);
			}else{
				rotationWheel(0,BACKWARD,MAX_LEFT);
				rotationWheel(1,FORWARD,MAX_RIGHT);
			}









			break;						
	}
}

Changes to src/firebot2/firebot/src/RobotControl.c.

32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
..
76
77
78
79
80
81
82
83

84
85
86
87
88
89
90
...
118
119
120
121
122
123
124





125
126
127
128
129
130






131
132
133
134
135
136
137
...
140
141
142
143
144
145
146
147

























148
149
150
151
152
153
154
...
173
174
175
176
177
178
179



































180










181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
...
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353

354
355
356
357
358
359
360
...
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522

523
524
525
526
527
528
529
#include "Scanning subsystem/ScanAgent.h"
#include "Scanning subsystem/CollisionAgent.h"
#include "Movement subsystem/WheelDrive.h"
#include "Movement subsystem/MovementAgent.h"
#include "RobotControl.h"

//Состояния конечного автомата
typedef enum{WAIT, MOVE, SCAN, MEASURE, AUTO}StatesRobot_t;

//Управление роботом
void processRobot();
/*
Установка состояния робота.
set_state - задание состояния.
*/
................................................................................

uint8_t state_autopilot;
float dist_left, dist_right;
enum {
	WAIT_LEFT_MEAS,
	WAIT_RIGHT_MEAS,
	WAIT_ROTATION,
	WAIT_REVERSE_MOVE

} chose_way;
uint8_t turn_left;
uint8_t tmp1,tmp2;
uint8_t degree_turn = 1;

//Главная функция управления роботом
void mainRobot()
................................................................................
			;//LED(ON,LED_RFM);
		//else
			//LED(OFF,LED_RFM);
		//processTransmitUART();
    }
}






//Управление роботом
void processRobot()
{
	static uint32_t i = 0, state_led = 0;
	static char* ptr_scan_result;
	static uint8_t state_tmp = 0;






	switch (state_robot){
		case WAIT:
			if (i++ > 10000)
			{
				switch (state_led){
					case 0:
						LED(ON,LED_SCAN);
................................................................................
					case 1:
						LED(OFF,LED_SCAN);
						state_led = 0;
						break;
				}
				i = 0;
			}
			break;					

























		case MOVE:
			if(processMovement()){
				setStateRobot(WAIT);
				sendStrRFM("Move complete");
			}
			/*if(isObstacleSurface()){
				setStateRobot(WAIT);
................................................................................
				sendStrRFM(ptr_scan_result);
				setStateRobot(WAIT); 
			}
			break;
		case AUTO:
			switch(state_autopilot){
				//static uint8_t ctr_tmp = 0;



































				case MOVE:










					if(isObstacleSpace()){
						stop();
						offCheckCollision();
						/*LED(ON,IR_ROBOT_3);
						LED(ON,IR_ROBOT_4);*/
						LED(ON,LED_RFM);
						LED(OFF,LED_SCAN);
						measure(ULTRASONIC, HEAD, HEAD_LEFT);
						state_autopilot = OBSTACLE_SPACE;
						chose_way = WAIT_LEFT_MEAS;
						//ctr_tmp = 0;
						state_tmp = 0;
						//sendStrRFM("1");
					}
					else{
						//if(isObstacleSurface()){
						if(0){	
							stop();
							LED(ON,LED_RFM);
							LED(OFF,LED_SCAN);
							tmp1 = gettingADC(IR_ROBOT_1);
							tmp2 = gettingADC(IR_ROBOT_2); 
							offCheckCollision();
							if(tmp2 >= tmp1){
								turn_left = 1;
								LED(ON, IR_ROBOT_4);
							}
							else{
								LED(ON, IR_ROBOT_3);
								turn_left = 0;
							}
							movement(BACKWARD,MIN,5);	
							state_autopilot = OBSTACLE_SURFACE;
							chose_way = WAIT_LEFT_MEAS;
						}
					}
					break; 
				//Обнаружено припядствие
				case OBSTACLE_SPACE:
					
					switch(chose_way){
						case WAIT_LEFT_MEAS:
						switch (state_tmp)
................................................................................
							if(processMovement()){
								measure(ULTRASONIC, HEAD, HEAD_LEFT);
								chose_way = WAIT_LEFT_MEAS;
							}
							break;	
					}
					break;
				case OBSTACLE_SURFACE:
					switch(chose_way){
						case WAIT_LEFT_MEAS:
							if(processMovement()){
								if(turn_left){
									movement(LEFT, MIN, 222);
									setPositionDrive(HEAD,HEAD_LEFT);
									chose_way = WAIT_RIGHT_MEAS;
								}
								else{
									movement(RIGHT, MAX, 222);
									setPositionDrive(HEAD,HEAD_RIGHT);
									chose_way = WAIT_RIGHT_MEAS;
								}
							}
							break;
						case WAIT_RIGHT_MEAS:
							if (turn_left)
								tmp1 = gettingADC(IR_ROBOT_4);
							else
								tmp1 = gettingADC(IR_ROBOT_3);	
							if((processMovement() == 1) || (tmp1 < 100)){
								LED(OFF,LED_RFM);
								LED(ON,LED_SCAN);
								LED(OFF, IR_ROBOT_3);
								LED(OFF, IR_ROBOT_4);
								onCheckCollision(FORWARD_CHECK);
								movement(FORWARD, MAX, 0);
								state_autopilot = MOVE;
							}
							break;
						default:
							break;
					}
			}
			break;
	}
}

//Установка состояния робота
void setStateRobot(StatesRobot_t set_state)
{
	//autopilot = 0;
	switch(set_state){
		case WAIT:

			stop();
			offCheckCollision();
			LED(OFF,LED_SCAN);
			LED(OFF,LED_RFM);
			//sprintf(status_robot,"Wait");
			break;
		case MOVE:
................................................................................
					onCheckCollision(BACKWARD_CHECK);
					movement(BACKWARD,MIN,0);
					return 1;
			}
			if (strcmp(direct,"left") == 0){
					offCheckCollision();
					onCheckCollision(LEFT_CHECK);
					movement(RIGHT,MIN,0);
					return 1;
			}
			if (strcmp(direct,"right") == 0){
					offCheckCollision();
					onCheckCollision(RIGHT_CHECK);
					movement(LEFT,MIN,0);
					return 1;
			}
			if(strcmp(direct,"stop") == 0){
				setStateRobot(WAIT);
				return 0;
			}	
			if(strcmp(direct,"auto") == 0){	
				setStateRobot(AUTO);
				return 0;
			}
			if(strcmp(direct,"fire") == 0){
				setStateRobot(WAIT);
				answer[0] = (char)gettingADC(1);
				answer[1] = 123;
				answer[2] = '\0';
				PORTC ^= (1<<6);
				sendingStrRFM(answer);

				return 0;
			}	
	}
	return 0;		
}
	
void scanningCurrent()







|







 







|
>







 







>
>
>
>
>






>
>
>
>
>
>







 







|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

>
>
>
>
>
>
>
>
>
>
|













<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







 







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<











>







 







|





|











|
|


<
|
>







32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
..
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
...
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
...
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
...
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276






















277
278
279
280
281
282
283
...
362
363
364
365
366
367
368


































369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
...
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547

548
549
550
551
552
553
554
555
556
#include "Scanning subsystem/ScanAgent.h"
#include "Scanning subsystem/CollisionAgent.h"
#include "Movement subsystem/WheelDrive.h"
#include "Movement subsystem/MovementAgent.h"
#include "RobotControl.h"

//Состояния конечного автомата
typedef enum{WAIT, MOVE, SCAN, MEASURE, AUTO, FIRE}StatesRobot_t;

//Управление роботом
void processRobot();
/*
Установка состояния робота.
set_state - задание состояния.
*/
................................................................................

uint8_t state_autopilot;
float dist_left, dist_right;
enum {
	WAIT_LEFT_MEAS,
	WAIT_RIGHT_MEAS,
	WAIT_ROTATION,
	WAIT_REVERSE_MOVE,
	WAIT_STEP_FW
} chose_way;
uint8_t turn_left;
uint8_t tmp1,tmp2;
uint8_t degree_turn = 1;

//Главная функция управления роботом
void mainRobot()
................................................................................
			;//LED(ON,LED_RFM);
		//else
			//LED(OFF,LED_RFM);
		//processTransmitUART();
    }
}

int16_t fire_cnt;

#define ADC_FIRE (100)
#define FIRE_CNT_MAX (10000)

//Управление роботом
void processRobot()
{
	static uint32_t i = 0, state_led = 0;
	static char* ptr_scan_result;
	static uint8_t state_tmp = 0;
	static uint8_t psc=0;
	
	if(state_robot != FIRE){
		PORTC &= ~(1<<6);
	}
	
	switch (state_robot){
		case WAIT:
			if (i++ > 10000)
			{
				switch (state_led){
					case 0:
						LED(ON,LED_SCAN);
................................................................................
					case 1:
						LED(OFF,LED_SCAN);
						state_led = 0;
						break;
				}
				i = 0;
			}
			break;
		case FIRE:
			if(fire_cnt-- > 0){
				PORTC |= (1<<6);
			}
			else{
				PORTC &= ~(1<<6);
			}				
			if (i++ > 10000)
			{
				switch (state_led){
					case 0:
						LED(ON,LED_SCAN);
						state_led = 1;
						break;
					case 1:
						LED(OFF,LED_SCAN);
						state_led = 0;
						break;
				}
				i = 0;
			}
			if(gettingADC(1) < ADC_FIRE){
				fire_cnt = FIRE_CNT_MAX;
			}
			break;
		case MOVE:
			if(processMovement()){
				setStateRobot(WAIT);
				sendStrRFM("Move complete");
			}
			/*if(isObstacleSurface()){
				setStateRobot(WAIT);
................................................................................
				sendStrRFM(ptr_scan_result);
				setStateRobot(WAIT); 
			}
			break;
		case AUTO:
			switch(state_autopilot){
				//static uint8_t ctr_tmp = 0;
				case WAIT_STEP_FW:
					if(processMovement()){
						fire_cnt = FIRE_CNT_MAX;
						stop();
						offCheckCollision();
						/*LED(ON,IR_ROBOT_3);
						LED(ON,IR_ROBOT_4);*/
						LED(ON,LED_RFM);
						LED(OFF,LED_SCAN);
						state_autopilot = FIRE_FIGHTING;
					}
					break;
				case FIRE_FIGHTING:
					psc++;
					if(psc >= 10){
						psc = 0;
						fire_cnt--;
					}					
					if(fire_cnt > 0){
						PORTC |= (1<<6);
						if((fire_cnt < 100) && (gettingADC(1) < ADC_FIRE)){
							movement(FORWARD, MIN, 2);
							state_autopilot = WAIT_STEP_FW;
							break;
						}
					}
					else{
						PORTC &= ~(1<<6);
						LED(OFF,LED_RFM);
						LED(ON,LED_SCAN);
						onCheckCollision(FORWARD_CHECK);
						movement(FORWARD, MIN, 0);
						state_autopilot = MOVE;				
					}	
					break;	
				case MOVE:
					if(gettingADC(1) < ADC_FIRE){
						fire_cnt = FIRE_CNT_MAX;
						stop();
						offCheckCollision();
						/*LED(ON,IR_ROBOT_3);
						LED(ON,IR_ROBOT_4);*/
						LED(ON,LED_RFM);
						LED(OFF,LED_SCAN);
						state_autopilot = FIRE_FIGHTING;
					}
					else if(isObstacleSpace()){
						stop();
						offCheckCollision();
						/*LED(ON,IR_ROBOT_3);
						LED(ON,IR_ROBOT_4);*/
						LED(ON,LED_RFM);
						LED(OFF,LED_SCAN);
						measure(ULTRASONIC, HEAD, HEAD_LEFT);
						state_autopilot = OBSTACLE_SPACE;
						chose_way = WAIT_LEFT_MEAS;
						//ctr_tmp = 0;
						state_tmp = 0;
						//sendStrRFM("1");
					}






















					break; 
				//Обнаружено припядствие
				case OBSTACLE_SPACE:
					
					switch(chose_way){
						case WAIT_LEFT_MEAS:
						switch (state_tmp)
................................................................................
							if(processMovement()){
								measure(ULTRASONIC, HEAD, HEAD_LEFT);
								chose_way = WAIT_LEFT_MEAS;
							}
							break;	
					}
					break;


































			}
			break;
	}
}

//Установка состояния робота
void setStateRobot(StatesRobot_t set_state)
{
	//autopilot = 0;
	switch(set_state){
		case WAIT:
		case FIRE:
			stop();
			offCheckCollision();
			LED(OFF,LED_SCAN);
			LED(OFF,LED_RFM);
			//sprintf(status_robot,"Wait");
			break;
		case MOVE:
................................................................................
					onCheckCollision(BACKWARD_CHECK);
					movement(BACKWARD,MIN,0);
					return 1;
			}
			if (strcmp(direct,"left") == 0){
					offCheckCollision();
					onCheckCollision(LEFT_CHECK);
					movement(LEFT,MIN,0);
					return 1;
			}
			if (strcmp(direct,"right") == 0){
					offCheckCollision();
					onCheckCollision(RIGHT_CHECK);
					movement(RIGHT,MIN,0);
					return 1;
			}
			if(strcmp(direct,"stop") == 0){
				setStateRobot(WAIT);
				return 0;
			}	
			if(strcmp(direct,"auto") == 0){	
				setStateRobot(AUTO);
				return 0;
			}
			if(strcmp(direct,"fire") == 0){
				setStateRobot(FIRE);
				/*answer[0] = (char)gettingADC(1);
				answer[1] = 123;
				answer[2] = '\0';

				sendingStrRFM(answer);*/
				fire_cnt = FIRE_CNT_MAX;
				return 0;
			}	
	}
	return 0;		
}
	
void scanningCurrent()

Changes to src/firebot2/firebot/src/Scanning subsystem/CollisionAgent.c.

22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "ADC.h"
#include "Ultrasonic.h"
#include "ScanDrives.h"
#include "TimerScan.h"
#include "CollisionAgent.h"

#define  THRESHOLD_SURFACE 100
#define  THRESHOLD_SPACE_CM_MID 8
#define  THRESHOLD_SPACE_CM_MIN 9
#define  THRESHOLD_SPACE_CM_MAX 10

#define STEP_HEAD_MIN 3
#define STEP_HEAD_MID 5
#define STEP_HEAD_MAX 8

enum {
	LEFT_MIN_1,







|
|
|







22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "ADC.h"
#include "Ultrasonic.h"
#include "ScanDrives.h"
#include "TimerScan.h"
#include "CollisionAgent.h"

#define  THRESHOLD_SURFACE 100
#define  THRESHOLD_SPACE_CM_MID 10
#define  THRESHOLD_SPACE_CM_MIN 11
#define  THRESHOLD_SPACE_CM_MAX 12

#define STEP_HEAD_MIN 3
#define STEP_HEAD_MID 5
#define STEP_HEAD_MAX 8

enum {
	LEFT_MIN_1,

Changes to src/firebot2/firebot/src/Scanning subsystem/CollisionAgent.h.

18
19
20
21
22
23
24

25
26
27
28
29
30
31

typedef enum{FORWARD_CHECK = 1, BACKWARD_CHECK, LEFT_CHECK, RIGHT_CHECK}DirectCollision_t;

#define OBSTACLE_SURFACE 2
#define OBSTACLE_SPACE 3
#define TURN_HEAD 4
#define CHECK 5


/*
Запуск проверки столкновений.
direct_move - направление движения робота.
*/
void onCheckCollision(DirectCollision_t direct_move);








>







18
19
20
21
22
23
24
25
26
27
28
29
30
31
32

typedef enum{FORWARD_CHECK = 1, BACKWARD_CHECK, LEFT_CHECK, RIGHT_CHECK}DirectCollision_t;

#define OBSTACLE_SURFACE 2
#define OBSTACLE_SPACE 3
#define TURN_HEAD 4
#define CHECK 5
#define FIRE_FIGHTING 6

/*
Запуск проверки столкновений.
direct_move - направление движения робота.
*/
void onCheckCollision(DirectCollision_t direct_move);