Course materials · Robot Basic Lab

Take off with Tello

English translation

clc;
clear variables;
 
mode = 0; % 0: simulation mode / 1: real mode

Take off with Tello

if (mode>0)
my_tello = ryze();
takeoff(my_tello);
pause(3); % wait for stability
else
my_tello = 0;
end

Acquire images

if (mode>0)
my_camera = camera(my_tello);
img = snapshot(my_camera);
%imwrite(img, 'snapshot.png');
else
img = imread('snapshot.png');
end

Track a red ball - Control it toward the image center

[height, width, channels] = size(img);
center = [width/2, height/2];
offset = [round(width/10), round(height/10)];
 
flag = true;
while(flag)
[ball_pos, ball_radius] = FindRedBall(img);
displace = (ball_pos - center);
[img, flag] = MoveAndSnap(mode, my_tello, img, displace, offset);
drawrectangle('Position',[center-offset,offset*2],'Color',[0 1 0]);
a = input('press enter');
end
drone move to 0.0, 0.1, 0.1 drone move to 0.0, 0.1, 0.0 drone move to 0.0, 0.1, 0.0 done
Camera image with a detected red ball, showing a circular boundary around the ball overlaid with a green rectangle marking the target region around the image center.

Land Tello

if (mode>0)
land(my_tello);
end
clear variables;