回到首页 返回首页
回到顶部 回到顶部
返回上一页 返回上一页

“抗疫”无人机系列课程第二课——巡逻无人机 简单

头像 scnu-天码行空 2021.01.04 729 0

【课程引入】

疫情期间,大家都需要减少外出,居家隔离,尽量避免与他人接触,这样才能最大限度的保障安全。虽然大家都积极配合,但是总有人想出门聚会聚餐,这时候就需要一个空中飞行员执行巡逻任务,提醒大家不要四处走动,尽量居家配合安排,共同抗击疫情。

【教学目标】

1、学会使用mind+编程控制无人机

2、能够编程控制无人机精确飞行

3、学会使用编程控制LED点阵屏和灯带模块

【任务要求】

1、日常巡逻模式,使用mind+给TT编程,控制TT循环飞行,同时LED点阵屏显示SECURITY表明其安保功能,使TT能够完成巡逻任务。

2、紧急呼救模式,使用mind+给TT编程,控制TT飞行到指定地点,到达后灯带闪烁红蓝灯光提供警示作用,使TT能够完成紧急呼救任务。

材料清单

制作显示“SECURITY”字样并且巡逻飞行的无人机


无人机按照既定路线循环飞行,LED显示屏循环播放"SECURITY"字样,提示小区用户尽量减少出门,进入公共环境需戴口罩。


步骤1 将LED点阵屏和ESP32连接到TT上,并将开关拨到AP单机模式

project-image
project-image

步骤2 制作流程图

project-image

步骤3 编写代码

project-image
代码
/*!
 * MindPlus
 * telloesp32
 *
 */
#include <Wire.h>
#include <RMTT_Libs.h>
// 创建对象
RMTT_RGB      tt_rgb;
RMTT_Protocol protocol;
RMTT_TOF      tt_sensor;
RMTT_Matrix   tt_matrix;


// 主程序开始
void setup() {
	tt_rgb.Init();
	Serial1.begin(1000000, 23, 18, SERIAL_8N1);
	Wire.begin(27, 26);
	tt_sensor.Init();
	tt_matrix.Init(127);
	tt_matrix.SetLEDStatus(RMTT_MATRIX_CS, RMTT_MATRIX_SW, RMTT_MATRIX_LED_ON);
	matrix_effect_init(255);
	led_effect_init();
	tt_rgb.SetRGB(0,0,255);
	delay(1000);
	protocol.startUntilControl();
	matrix_effect_move_str("SECURITY", 8, 'r', 'l', 1);
	protocol.sendTelloCtrlMsg("takeoff");
	led_effect_blink(255, 0, 0, 0, 0, 255, 2);
	protocol.sendTelloCtrlMsg((char *)String(String("forward ")+int(300)).c_str());
	protocol.sendTelloCtrlMsg((char *)String(String("cw ")+int(90)).c_str());
	protocol.sendTelloCtrlMsg((char *)String(String("forward ")+int(150)).c_str());
	protocol.sendTelloCtrlMsg((char *)String(String("cw ")+int(90)).c_str());
	protocol.sendTelloCtrlMsg((char *)String(String("forward ")+int(300)).c_str());
	protocol.sendTelloCtrlMsg((char *)String(String("cw ")+int(90)).c_str());
	protocol.sendTelloCtrlMsg((char *)String(String("forward ")+int(150)).c_str());
	protocol.sendTelloCtrlMsg((char *)String(String("cw ")+int(90)).c_str());
	protocol.sendTelloCtrlMsg("land");
}
void loop() {

}

制作亮红色灯光并且巡逻飞行的无人机

无人机飞到指定地点降落,并且灯带闪烁红蓝警示灯,实现紧急呼救功能。

步骤4 将灯带和ESP32连接到TT上,并将开关拨到AP单机模式

project-image

步骤5 制作流程图

project-image

步骤6 编写代码

project-image
代码
/*!
 * MindPlus
 * telloesp32
 *
 */
#include <RMTT_Libs.h>
#include <DFRobot_NeoPixel.h>
// 创建对象
DFRobot_NeoPixel neoPixel_13;
RMTT_RGB         tt_rgb;
RMTT_Protocol    protocol;


// 主程序开始
void setup() {
	tt_rgb.Init();
	Serial1.begin(1000000, 23, 18, SERIAL_8N1);
	led_effect_init();
	neoPixel_13.begin(13, 7);
	tt_rgb.SetRGB(0,0,255);
	delay(1000);
	protocol.startUntilControl();
	protocol.sendTelloCtrlMsg("takeoff");
	led_effect_blink(255, 0, 0, 0, 0, 255, 2);
	protocol.sendTelloCtrlMsg((char *)String(String("forward ")+int(150)).c_str());
	protocol.sendTelloCtrlMsg((char *)String(String("cw ")+int(90)).c_str());
	protocol.sendTelloCtrlMsg((char *)String(String("forward ")+int(150)).c_str());
	protocol.sendTelloCtrlMsg((char *)String(String("ccw ")+int(90)).c_str());
	protocol.sendTelloCtrlMsg((char *)String(String("forward ")+int(300)).c_str());
	protocol.sendTelloCtrlMsg("land");
	neoPixel_13.setRangeColor(0, 3, 0xFF0000);
	neoPixel_13.setRangeColor(4, 6, 0x0000FF);
}
void loop() {
	neoPixel_13.rotate(4);
	delay(100);
}

评论

user-avatar