Air-ground collaborative intelligent fire protection system—UAV and car collaboration

1 topic

1.1 Tasks

Design an air-ground collaborative intelligent firefighting system consisting of quadrotor drones and fire trucks. A vertically downward laser pointer is installed on the UAV to indicate the patrol track. The patrol area is 40dm×48dm. When the drone patrols, it can cover an 8dm wide area on the ground. Based on the principle of shortening the time to complete full-coverage patrols, the UAV patrols according to the planned route. Immediately take preliminary fire-fighting measures after discovering the fire, and send the location information of the fire source to the fire truck, so that it can go to extinguish the fire source. The shorter the completion time of air-ground coordinated patrol and fire-fighting work, the better.

insert image description here

1.2 Mission points

1. Basic requirements (50 points)

  • (1) Teams need to make their own simulated fire source. The simulated fire source is a battery-powered red light source, such as LED, etc. It can be turned on or off by continuous irradiation with a laser pointer: it will be turned on for about 2 seconds after continuous irradiation, and then turned off for about 2 seconds after continuous irradiation. (5 points)
  • (2) Display the planned patrol route map. After pressing the button on the fire truck to start the UAV to take off vertically, the UAV
    will complete the full-coverage patrol in the patrol area according to the planned route at a height of about 18dm. (22 points)
  • (3) Wireless communication is used between the UAV and the fire truck; during the patrol period, the UAV sends
    position coordinate information to the fire truck once per second, and the display on the fire truck updates and displays the UAV position coordinate information in real time. (8 points)
  • (4) During the patrol, the display of the fire truck displays the patrol track curve, calculates and displays the cumulative patrol range. (8 points)
  • (5) After completing the patrol, the UAV returns and lands accurately in the take-off area. (7 points)

2. Play part (50 points)

  • (1) Manually operate the laser pointer to light up - a source of fire. Start drone patrols on fire trucks. The UAV
    patrols according to the planned route. After finding a fire, go to the fire source (horizontal distance ≤ 5dm) to identify and confirm, and then use the LED indicator on the UAV to warn. (8 points)
  • (2) The UAV flies above the fire source, lowers to a height of about 10dm, and after hovering for 3s, throws
    the fire extinguishing bag. The fire extinguishing bag falls in a circular area with a radius of 3dm centered on the fire source point; The position coordinates of the location are sent to the fire truck, and then continue to patrol, and return to the take-off point after completion. (12 points)
  • (3) After receiving the fire information and displaying the location coordinates of the fire source, the fire truck departs from the fire station
    to the fire source location. It must not crush the block and its boundary on the way, and irradiates the simulated fire with a laser pointer beam within a distance of 5dm. source to turn it off. (15 marks)
  • (4) After extinguishing the simulated fire source, the fire truck returns to the starting area. The play part is completed within 360s within the time limit. (10 points)
  • (5) Others. (5 points)

1.3 Design part

1.3.1 Simulated fire source

The requirements of this part are as follows:
the simulated fire source can be a red LED powered by a battery, etc., and an upward horn-shaped hood is required. The angle of the hood is about 60°, and the height does not exceed 10cm. It can be turned on or off with a laser pointer.
The schematic diagram is as follows:
insert image description here
the external hood can be modified like a pet bite hood; the
Please add a picture description
internal LED lampshade is to expand the lighting area to facilitate the work of the image recognition system in the system. At the same time, in order to improve the working efficiency of the car's laser following algorithm, it is necessary to expand the detection area of ​​the photosensitive sensor. It is recommended to use the plastic lens on the microwave detection module of the human body to achieve the effect of concentrating light.
Please add a picture description
Circuit design diagram: STC8 minimum system board plus two 1.5V dry batteries, a red LED, a resistor of about 300Ω, and a photosensitive sensor are almost enough.
Programming: A GPIO output, ADC, and timer are used in the program.

1.3.2 Car part

The requirements of this part are as follows:
fire trucks are required to use 4-wheel electric trolleys, the length and width projection dimensions are not greater than 20cm×35cm, and the height is not greater than 40cm; Mecanum wheels are not allowed.

1. Chassis and motor:
(1) Chassis: optional.
(2) Motor: It is best to use a metal gear with an encoder to decelerate and click, so that the speed and angle can be obtained, so as to estimate the position of the car and better control the car.
(3) Motor drive: H-bridge motor drive module.
(4) Battery: 12V high rate lithium battery pack.
It is best to look for a car chassis with motor drive, encoder interface, and the ability to step down to supply power to the main control, such as the mountain ax motor drive module.
Please add a picture description

2. Main control chip
(1) Pangu:
If you choose TI's, the development of the Pangu system board is relatively smooth, and there are few bugs in use. There are OLED driver chips and acceleration sensors, buzzers, multiple buttons, and serial ports on the board.
Please add a picture description

(2) TM4C123GXL:
This board is not recommended. There is a problem with the debugging interface, the driver is not easy to play (ICDI, you need to install CCS), the performance is relatively poor, and there are few power supply ports. When writing code, Keil crashes countless times. The hardware running program is also easy to enter the interrupt and get stuck.
If there are finished products that have been modified and developed by others, it is still possible to use them.
Please add a picture description

3. Display screen
It is recommended to use Tao Jingchi's serial port screen, which is easy to configure, simple in code, and able to return strings.
Pins: 5V, GND, TXD, RXD
Please add a picture description

4. The wireless module
can use Bluetooth, WIFI, Lora and so on.
The wireless module is recommended to use a module with broadcast function, so that multi-machine debugging is more convenient.
Pins: VCC (5~3.3V), GND, TXD, RXD
Please add a picture description
are also allowed to use UWB this year, which can realize the precise positioning of drones and cars, and can also transmit data. As long as there is time to develop the code, it can be said to be a blow to dimensionality reduction. But the price is still relatively expensive.

5. Machine vision and steering gear
For the detection of simulated fire sources, there are OpenMV solutions and K210 solutions.
The OpenMV module has a routine for controlling the steering gear, which can control the laser pointer to turn off the simulated fire source, but the premium is too high, so you can DIY it yourself.

6.
It is best to have the IMU on the main control board. If not, use the modular MPU6050, but it must be installed in the center of the car.

7. Other modules:
(1) Gray scale sensor: white light illuminates the ground of different colors, and the reflected light intensity is different, which can perform tasks such as line inspection.
(2) Laser head.
(3)...

1.3.3 UAV part

If you directly purchase a finished TI drone, the main control board can use the aforementioned main control.

2 Program design

I mainly make small cars, so I will talk about the design of my small car.
The main control board on the car uses the development board of TI Pangu. The onboard chip is TM4C123GH6PZT7. The MCU core is ARM Cortex-M4F. It is 256 KB, the EEPROM is 2 KB, the core bit width is 32-Bit, and the ADC is 12 bit.
Peripherals and internal resources need to use serial screen, Bluetooth module/UWB module, timer, PWM, LED output, key input (this can be replaced by the key serial port information return event of the serial screen), and buzzer driver.

2.1 Bluetooth module configuration

I use the dual-mode Bluetooth module of Big Bear Smart. If two Bluetooth modules are paired, one master and one slave need to be set. The following Bluetooth modules are connected to the CH340 module, and the two modules are configured on the computer using AT commands. By default, 115200 baud rate is used to connect.

Bluetooth slave, connect drone:

AT+NAME=DX2003-S		# 设置从机名称
AT+MASTER=01			# 设置从机工作模式
AT+BAUD=115200			# 设置波特率为115200
AT+LADDR				# 读取从机蓝牙地址,以便主机连接

+LADDR=22345000891f

Bluetooth host, connect to the car:

AT+NAME=DX2003-M		# 设置主机名称
AT+MASTER=04			# 设置主机工作模式
AT+BAUD=115200			# 设置波特率为115200
AT+CONN=22345000891f	# 主机连接从机地址

After connecting:
(1) The host displays:

IM_CONN:0		# 0代表是BLE连接上,1代表是SPP连接上

(2) The slave machine displays:

IM_CONN:8

Bluetooth disconnect command:

AT+DSCET=1	

2.2 Interface design of serial screen

The serial screen uses USART HMI software to draw the interface, which requires interface typesetting, font addition, and program compilation.
Software download and learning link:

http://mall.micromove.cn/start/download_ide.html

2.2.1 Serial communication protocol

1. Serial screen reception:
the protocol is: string + HEX identifier.
The HEX identifier is: \xff\xff\xff
The simulation on the USART HMI software does not need to add the HEX identifier (\xff\xff\xff).
Example:
If the serial port screen uses CH340 to connect to the computer, then the serial port tool input on the computer (do not add spaces):

t0.txt="陶晶驰电子"\xff\xff\xff
b0.txt="Hello World"\xff\xff\xff
j0.val=100\xff\xff\xff
page0.bco=WHITE\xff\xff\xff

If the MCU serial port sends data: 2.4.2detailed in.

2. Serial screen sending:
(1) prints: print a variable/constant from the serial port.
(2) printh: print hexadecimal from the serial port.

2.2.2 Drawing functions

The main uses are:
(1) cirs: Draw a solid circle

cirs x,y,radius,color\xff\xff\xff
cirs 160,266,6,RED\xff\xff\xff

(2) line: draw a straight line

line x_start,y_start,x_end,y_end,color\xff\xff\xff
line 185,246,185,26,BLUE\xff\xff\xff

(3) Insert picture

pic x,y,picid\xff\xff\xff					# picid为软件插入的ID号为x的图片
pic,123,150,0\xff\xff\xff

2.2.3 Serial screen interface design

The car can receive the waypoint data (protocol A) and fire location data (protocol B) returned by the drone through the Bluetooth serial port, and display the blue origin and red hexagon on the serial screen.

insert image description here

2.3 Communication protocol design between UAV and car

1. The string sent by the UAV to the car through the serial port:

A,160,150,F			// 无人机航点坐标(160,150)
B,250,100,F			// 模拟火源坐标(250,100)
C,1,F				// 模拟火源ID: 1

Class A indicates the waypoint of the UAV, F is the end flag, and
Class B represents the coordinates of the fire source detected by the UAV, and F is the end flag.
Class C indicates the ID of the area where the simulated fire source detected by the UAV is located, and F is the end flag. This protocol can not be sent, and the car directly calculates the position of the simulated fire source through the B-type protocol.

2. The string sent by the car to the drone through the serial port only needs one button to enable, use the button input or click on the serial port screen, send the "TakeOff" string through the Bluetooth serial port, and the drone can take off after detecting it.

2.4 Car program design

Initialize each part first, then enter the while (1) loop, and write most of the processing functions in the loop. The enable bit of the processing function is stored in the interrupt processing function. When some functions work for a long time, the flag bit needs to be enabled in the interrupt, and then processed in the main function main to avoid interrupt blocking.
insert image description here

2.4.1 Bluetooth serial program

The Bluetooth serial port program includes serial port initialization, serial port sending, serial port interrupt service function (serial port receiving), serial port data analysis and other parts.

1. Main function:

#include "stdio.h"
#include <stdint.h>
#include <stdbool.h>
// ......

// 全局变量
char uart4_rec_temp[50];		// 接收到暂存的字符数组
bool uart4_rec_check_flag = 0;		// 接收数据解包的标志位

// ......

int main(void)
{
    
    
	ROM_FPUEnable();//使能浮点单元
	ROM_FPULazyStackingEnable();//浮点延迟堆栈,减少中断响应延迟  
	ROM_SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN);//配置系统时钟
	initTime();					// 初始化滴答定时器
	GPIO_Init();				// LED灯初始化
	// ......
	ConfigureUART4();			// 初始化蓝牙BLE-串口4
	UART4_BLE_CONNECT();		// 串口4连接蓝牙
	// ......
	
	while(1)
	{
    
    
		// ......
		uart4_data_check();		//串口4数据包解包
		// ......
	}
}

2. Serial port initialization:

// 蓝牙-串口4驱动 PC4/PC5
void ConfigureUART4(void)
{
    
     
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);// Enable the GPIO Peripheral used by the UART.
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART4);// Enable UART0
    ROM_GPIOPinConfigure(GPIO_PC4_U4RX);// Configure GPIO Pins for UART mode.
    ROM_GPIOPinConfigure(GPIO_PC5_U4TX);
    ROM_GPIOPinTypeUART(GPIO_PORTC_BASE, GPIO_PIN_4 | GPIO_PIN_5);
	UARTConfigSetExpClk(UART4_BASE,SysCtlClockGet(),115200,
												(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));
	UARTFIFODisable(UART4_BASE);			// 使能UART4中断
	UARTIntEnable(UART4_BASE,UART_INT_RX);	// 使能UART4接收中断
	UARTIntRegister(UART4_BASE,UART4_IRQHandler);	//UART4中断地址注册
	IntPrioritySet(INT_UART4,USER_INT3);			//中断优先级设置USER_INT3(0最高)
}

3. Serial port interrupt service function:

void UART4_IRQHandler(void)		//UART4中断函数-蓝牙BLE接收中断(无人机信息发送给小车)
{
    
    
	uint32_t flag = UARTIntStatus(UART4_BASE,1);//获取中断标志 原始中断状态 屏蔽中断标志		
	UARTIntClear(UART4_BASE,flag);//清除中断标志	
	char ch;
	while(UARTCharsAvail(UART4_BASE))//判断FIFO是否还有数据		
	{
    
    
		ch = UARTCharGet(UART4_BASE);	
		uart4_rec_temp[temp_cnt] = ch;
		temp_cnt ++;
 	}
	if(ch == 'F')
		uart4_rec_check_flag = 1;			// 接收数据解包的标志位置1
	if(temp_cnt >= 50)						//数组存满后清空
	{
    
    
		memset(uart4_rec_temp, 0, sizeof(uart4_rec_temp));		// 清空字符数组
		temp_cnt = 0;
	}
	bit_data = !bit_data;
	GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_5, bit_data);		//置低位点亮,保持闪烁,如果LED不闪烁了,表示程序卡死了
}

4. Serial port sending function:

void UART4_SendString(const char *string)
{
    
    
	int len = strlen(string);
	while(len--)
	{
    
    
		// 等待UART发送缓冲区为空
		while(UARTSpaceAvail(UART4_BASE) == 0);
		
		// 发送字符到UART
		UARTCharPut(UART4_BASE, *string++);
	}
}

5. Analyze the data received by the serial port:
first check whether the first number is "A" or "B", and then check whether the last character of the string is "F". Then index the "," in the string, split the two numeric strings in the middle, and use the atof() function to convert the string to a floating point number. Finally, store the obtained floating-point number into the corresponding variable, or use the debugging interface to output, or use the OLED screen to output.

// 串口4数据包解包
void uart4_data_check(void)
{
    
    
	if(uart4_rec_check_flag == 1)		// 分析uart4_rec_temp中的数据
	{
    
    
		uart4_rec_check_flag = 0;
		if(uart4_rec_temp[0] == 'A')		// 是无人机XY坐标数据包
		{
    
    
			int len = strlen(uart4_rec_temp);
			if(uart4_rec_temp[len-1] == 'F')
			{
    
    
				char* token;
				token = strtok(uart4_rec_temp,",");
				token = strtok(NULL,",");
				uart4_rec_x[uav_cnt] = atof(token);
				token = strtok(NULL,",");
				uart4_rec_y[uav_cnt] = atof(token);
				uart4_flight_dist = uart4_flight_dist + sqrt(pow(uart4_rec_x[uav_cnt]-uart4_rec_x[uav_cnt-1],2) + pow(uart4_rec_y[uav_cnt]-uart4_rec_y[uav_cnt-1],2));
				printf("A-X: uart4_rec_x[%d]:%f\r\n",uav_cnt,uart4_rec_x[uav_cnt]);		// 测试
				printf("A-Y: uart4_rec_y[%d]:%f\r\n",uav_cnt,uart4_rec_y[uav_cnt]);		// 测试
				printf("A-D: uart4_flight_dist[%d]:%fm\r\n",uav_cnt,uart4_flight_dist/100);		// 测试
				// ......
			}
			// 处理完成后,清空uart4_rec_temp
			memset(uart4_rec_temp, 0, sizeof(uart4_rec_temp));
			temp_cnt = 0;
		}
		else if(uart4_rec_temp[0] == 'B')		// 是火源XY坐标数据包
		{
    
    
			int len = strlen(uart4_rec_temp);
			if(uart4_rec_temp[len-1] == 'F')
			{
    
    
				char* token;
				token = strtok(uart4_rec_temp,",");
				token = strtok(NULL,",");
				uart4_fire[0] = atof(token);
				token = strtok(NULL,",");
				uart4_fire[1] = atof(token);
				printf("B-X: uart4_fire[0]:%f\r\n",uart4_fire[0]);		// 测试
				printf("B-Y: uart4_fire[1]:%f\r\n",uart4_fire[1]);		// 测试
				// ......
			}
			// 处理完成后,清空uart4_rec_temp
			memset(uart4_rec_temp, 0, sizeof(uart4_rec_temp));
			temp_cnt = 0;
		}
		else
		{
    
    	// 没找到A/B数据包,清空uart4_rec_temp
			memset(uart4_rec_temp, 0, sizeof(uart4_rec_temp));
			temp_cnt = 0;
		}
	}
}

Guess you like

Origin blog.csdn.net/qq_45362336/article/details/132128317