# Tello EDU
## 規則
https://drive.google.com/drive/folders/1cDu1XlynWLJqYQJRrhnb854bKHjx9ZlV
## 機器屬性
Tomy:飛行偏左
Fred:飛行偏右/起飛偏左
Sony:飛行偏左
## 卡VS關卡
card1:x
card2:x
card3:80/70
card4:80/70
card5:
card6:
card7: /150
card8:50/100
card2:100/110
card1:90/160
三環卡偏左
## 程式共享
### 關卡組合
:::info
1. 刀旗2 刀旗1 高環 三環 中環 :white_check_mark:
2. 高環 刀旗2 刀旗1 三環 中環 :question:
3. 三環 刀旗2 高環 刀旗1 中環 :heavy_check_mark:
4. 中環 刀旗2 高環 三環 刀旗1 :heavy_check_mark:
5. 刀旗1 高環 刀旗2 三環 中環 :heavy_check_mark:
6. 刀旗1 三環 高環 刀旗2 中環 :heavy_check_mark:
7. 刀旗1 中環 高環 三環 刀旗2 :heavy_check_mark:
8. 刀旗1 刀旗2 三環 高環 中環 :-1:
9. 刀旗1 刀旗2 中環 三環 高環 :question:
10. 刀旗1 刀旗2 高環 中環 三環 :heavy_check_mark:
:::
### 2. 高環 刀旗2 刀旗1 三環 中環
:::spoiler
```py=
#高刀刀三中
from djitellopy import Tello
tello = Tello()#創建無人機
tello.connect()#無人機連線
print("battery:",tello.get_battery())#印出電量
tello.takeoff()#起飛
tello.move_down(50)
tello.go_xyz_speed(310, 0, 70, 100)
tello.go_xyz_speed_mid(0, 0, 180,100, 3)
tello.curve_xyz_speed_mid(80, 40, 120, 150, 0, 120, 50, 4)
tello.go_xyz_speed_yaw_mid(80, 0, 60, 60, 0, 5, 6)
tello.go_xyz_speed_yaw_mid(245, 0,60 , 100,0,6,7)
tello.go_xyz_speed_yaw_mid(150,0,120,100,7,8)
tello.curve_xyz_speed_mid(80,40 , 120, 150, 0, 120, 50, 8)
tello.go_xyz_speed_mid(0, 40, 120, 100, 2)
tello.move_up(60)
tello.move_forward(110)
tello.move_down(90)
tello.move_back(90)
tello.move_right(90)
tello.move_up(40)
tello.go_xyz_speed(290, 60, 0, 100)
tello.move_forward(100)
tello.land()
tello.end()#結束
tello.curve_xyz_speed_mid(80, -40, 120, 150, 0, 120, 50, 4)
```
:::
### 3. 三環 刀旗2 高環 刀旗1 中環 tomy
:::spoiler
```py=
from djitellopy import Tello
tello = Tello()#創建無人機
tello.connect()#無人機連線
print("battery:",tello.get_battery())#印出電量
tello.takeoff()#起飛
tello.move_down(50)
tello.go_xyz_speed(350, 0, 70, 60)
tello.go_xyz_speed_mid(0, 40, 120, 100, 3)
tello.move_up(60)
tello.move_forward(110)
tello.move_down(90)
tello.move_back(90)
tello.move_right(80)
tello.move_up(40)
tello.move_forward(110)
tello.move_down(20)
tello.move_left(20)
tello.curve_xyz_speed_mid( 90, 50 , 120, 150 , 0, 120 , 50,4)
tello.go_xyz_speed_yaw_mid(80, 0, 60, 60, 0, 5, 6)
tello.go_xyz_speed_yaw_mid(240, 0,60 , 100,0,6,7)
tello.move_up(60)
tello.go_xyz_speed_mid(300, 0, 180, 100, 7)
tello.move_down(60)
tello.curve_xyz_speed_mid(90, 40, 120, 150, 0,120 , 50, 4)
tello.go_xyz_speed(180, 0, 0, 100)
tello.land()
tello.end()#結束
```
:::
### 4. 中環 刀旗2 高環 三環 刀旗1
:::spoiler
```py=
from djitellopy import Tello
tello = Tello()#創建無人機
tello.connect()#無人機連線
print("battery:",tello.get_battery())#印出電量
tello.takeoff()#起飛
tello.move_down(50)
tello.go_xyz_speed(310, 0, 70, 100)
#3
tello.go_xyz_speed_mid(150, 0, 120, 100, 3)
#4
tello.curve_xyz_speed_mid(80, 40, 120, 150, 0, 120, 50, 4)
#5
tello.go_xyz_speed_yaw_mid(80, 0, 60, 60, 0, 5, 6)
#6
tello.go_xyz_speed_yaw_mid(240, 0,60 , 100,0,6,7)
#7
tello.go_xyz_speed_mid(150,0, 120, 100, 7)
#8
tello.go_xyz_speed_mid(0, 0, 180, 100, 8)
tello.go_xyz_speed(150, 0, 0,100)
tello.move_down(60)
#2
tello.go_xyz_speed_mid(0, 40, 120, 100, 2)
tello.move_up(50)
tello.move_forward(140)
tello.move_down(90)
tello.move_back(90)
tello.move_right(90)
tello.move_up(40)
tello.go_xyz_speed(150, 45, 0, 100)
#1
tello.curve_xyz_speed_mid(80, 40, 120, 150, 0, 120, 50, 1)
tello.move_forward(90)
tello.land()
tello.end()#結束
```
:::
### 5. 刀旗1 高環 刀旗2 三環 中環 tomy
:::spoiler
```Py=
from djitellopy import Tello
tello = Tello()#創建無人機
tello.connect()#無人機連線
print("battery:",tello.get_battery())#印出電量
tello.takeoff()#起飛
tello.move_down(50)
tello.go_xyz_speed(350, 0, 70, 60)
tello.curve_xyz_speed_mid(80, 40, 120, 150, 0, 120, 50, 3)
tello.go_xyz_speed_mid(50, 0, 180,80 , 4)
tello.go_xyz_speed(100, 0, 0, 80)
tello.go_xyz_speed_yaw_mid(80, 0, 60, 60, 0, 5, 6)
tello.go_xyz_speed_yaw_mid(240, 0,60 , 100,0,6,7)
tello.go_xyz_speed_yaw_mid(140, 0, 120, 100, 0, 7, 8)
tello.curve_xyz_speed_mid(80,40 , 120, 150, 0, 120, 50, 8)
tello.go_xyz_speed_mid(0, 40, 120, 100, 2)
tello.move_up(60)
tello.move_forward(110)
tello.move_down(90)
tello.move_back(90)
tello.move_right(90)
tello.move_up(40)
tello.go_xyz_speed(290, 60, 0, 100)
tello.move_forward(100)
tello.land()
tello.end()#結束
```
:::
### 6. 刀旗1 三環 高環 刀旗2 中環 tomy (四號卡偏左)
:::spoiler
```py=
from djitellopy import Tello
tello = Tello()#創建無人機
tello.connect()#無人機連線
print("battery:",tello.get_battery())#印出電量
tello.takeoff()#起飛
tello.move_down(50)
tello.go_xyz_speed(350, 0, 70, 60)
tello.curve_xyz_speed_mid(80, 40, 120, 150, 0, 120, 50, 3)
tello.go_xyz_speed_mid(0, 40, 120, 100, 4)
tello.move_up(50)
tello.move_forward(110)
tello.move_down(90)
tello.move_back(90)
tello.move_right(90)
tello.move_up(40)
tello.go_xyz_speed(130, 45, 0, 100)
tello.go_xyz_speed_yaw_mid(80, 0, 60, 60, 0, 5, 6)
tello.go_xyz_speed_yaw_mid(240, 0,60 , 100,0,6,7)
tello.go_xyz_speed_yaw_mid(140, 0, 120, 100, 0, 7, 8)
tello.move_up(60)
tello.go_xyz_speed(150, 0, 0,100)
tello.move_down(60)
tello.curve_xyz_speed_mid(80, 40, 120, 150, 0, 120, 50, 2)
tello.go_xyz_speed(280, 0, 0, 100)
tello.land()
tello.end()#結束
```
:::
### 7. 刀旗1 中環 高環 三環 刀旗2
:::spoiler
```py=
from djitellopy import Tello
tello = Tello()#創建無人機
tello.connect()#無人機連線
print("battery:",tello.get_battery())#印出電量
tello.takeoff()#起飛
#tello.move_down(50)
tello.go_xyz_speed(310, 0, 10, 100)
tello.curve_xyz_speed_mid(80, 40, 120, 135, 0, 120, 50, 3)
tello.go_xyz_speed_yaw_mid(150, 0, 125, 100, 0,4,5)
tello.go_xyz_speed_yaw_mid(80, 0, 60, 60, 0, 5, 6)
tello.go_xyz_speed_yaw_mid(245, 0,60 , 100,0,6,7)
tello.go_xyz_speed_yaw_mid(140,0,120,100,0,7,8)
tello.move_up(60)
tello.go_xyz_speed(275, 30, -10, 100)
tello.move_down(90)
tello.move_back(90)
tello.move_right(100)
tello.move_up(40)
tello.go_xyz_speed(180, 40, -30, 100)
tello.curve_xyz_speed_mid(80, 50, 120, 150, 25, 120, 50, 1)
tello.move_forward(80)
tello.land()
tello.end()
```
:::
### 8. 刀旗1 刀旗2 三環 高環 中環 tomy
:::spoiler
```py=
from djitellopy import Tello
tello = Tello()#創建無人機
tello.connect()#無人機連線
print("battery:",tello.get_battery())#印出電量
tello.takeoff()#起飛
tello.move_down(50)
tello.go_xyz_speed(310, 0, 70, 100)
tello.curve_xyz_speed_mid(80, 40, 120, 150, 0, 120, 50, 3)
tello.curve_xyz_speed_mid(80, -40, 120, 150, 0, 120, 50, 4)
tello.go_xyz_speed_yaw_mid(80, 0, 60, 60, 0, 5, 6)
tello.go_xyz_speed_yaw_mid(245, 0,60 , 100,0,6,7)
tello.go_xyz_speed_yaw_mid(150,0,120,100,7,8)
tello.go_xyz_speed_mid(0, 40, 120, 100, 8)
tello.move_up(50)
tello.move_forward(110)
tello.move_down(90)
tello.move_back(90)
tello.move_right(90)
tello.move_up(40)
tello.go_xyz_speed(150, 40, 0, 100)
tello.go_xyz_speed_mid(0, 0, 180, 100, 2)
tello.go_xyz_speed(220, 0, 0,100)
tello.move_down(60)
tello.go_xyz_speed_mid(240, 0, 120, 100, 1)
tello.land()
tello.end()#結束
```
:::
### 9.刀旗1 刀旗2 中環 三環 高環
:::spoiler
```py=
from djitellopy import Tello
tello = Tello()#創建無人機
tello.connect()#無人機連線
print("battery:",tello.get_battery())#印出電量
tello.takeoff()#起飛
from djitellopy import Tello
tello = Tello()#創建無人機
tello.connect()#無人機連線
print("battery:",tello.get_battery())#印出電量
tello.takeoff()#起飛
tello.move_down(50)
tello.go_xyz_speed(310, 0, 70, 100)
tello.curve_xyz_speed_mid(80, 40, 120, 150, 0, 120, 50, 3)
tello.curve_xyz_speed_mid(80, -40, 120, 150, 0, 120, 50, 4)
tello.go_xyz_speed_yaw_mid(80, 0, 60, 60, 0, 5, 6)
tello.go_xyz_speed_yaw_mid(245, 0,60 , 100,0,6,7)
tello.go_xyz_speed_yaw_mid(200,0,125,100,7,2)
tello.go_xyz_speed_mid(0, 40, 120, 100, 2)
tello.move_up(60)
tello.move_forward(110)
tello.move_down(90)
tello.move_back(90)
tello.move_right(90)
tello.move_up(40)
tello.go_xyz_speed(160, 50, 0, 100)
tello.go_xyz_speed_mid(0, 0, 180, 100, 1)
tello.go_xyz_speed(290, 0, 0, 100)
tello.land()
tello.end()#結束
```
:::
### 10. 刀旗1 刀旗2 高環 中環 三環 tomy
:::spoiler
```py=
from djitellopy import Tello
tello = Tello()#創建無人機
tello.connect()#無人機連線
print("battery:",tello.get_battery())#印出電量
tello.takeoff()#起飛
tello.move_down(50)
tello.go_xyz_speed(350, 0, 70, 60)
tello.curve_xyz_speed_mid(80, 0, 60, 60, 0, 5, 6)
tello.go_xyz_speed_yaw_mid(240, 0,60 , 100,0,6,7)
tello.go_xyz_speed_yaw_mid(140, 0, 120, 100, 0, 7, 8)
tello.move_up(60)
tello.go_xyz_speed(150, 0, 0, 100)
tello.move_down(60)
tello.go_xyz_speed_mid(215, 0, 120, 100, 2)
tello.go_xyz_speed_mid(0, 40, 120, 100, 1)
tello.move_up(60)
tello.move_forward(110)
tello.move_down(90)
tello.move_back(90)
tello.move_right(90)
tello.move_up(40)
tello.go_xyz_speed(200, 40, 0, 100)
tello.land()
tello.end()#結束
```
:::
### 開頭
##### 刀旗開頭
:::spoiler
```py=
from djitellopy import Tello
tello = Tello()#創建無人機
tello.connect()#無人機連線
print("battery:",tello.get_battery())#印出電量
tello.takeoff()#起飛
tello.move_down(50)
tello.go_xyz_speed(320, 0, 70, 100)
tello.curve_xyz_speed(80, -40 , 0 , 150 , 0, 0 , 50)
tello.land()#降落
tello.end()#結束
```
:::
#### 低環開頭
:::spoiler
```py=
from djitellopy import Tello
tello = Tello()#創建無人機
tello.connect()#無人機連線
print("battery:",tello.get_battery())#印出電量
tello.takeoff()#起飛
tello.move_down(50)
tello.go_xyz_speed(450, 0, 100, 100)
tello.land()#降落
tello.end()#結束
```
:::
#### 高環開頭
:::spoiler
```py=
from djitellopy import Tello
tello = Tello()#創建無人機
tello.connect()#無人機連線
print("battery:",tello.get_battery())#印出電量
tello.takeoff()#起飛
tello.move_down(50)
tello.go_xyz_speed(330, 0, 70, 100)
tello.move_up(80)
tello.move_forward(150)
tello.land()#降落
tello.end()#結束
```
:::
#### 三環開頭
:::spoiler
```py=
from djitellopy import Tello
tello = Tello()#創建無人機
tello.connect()#無人機連線
print("battery:",tello.get_battery())#印出電量
tello.takeoff()#起飛
tello.move_down(50)
tello.go_xyz_speed(350, 0, 70, 60)
tello.move_up(60)
tello.move_left(40)
tello.move_forward(100)
tello.move_down(90)
tello.move_back(100)
tello.move_right(80)
tello.move_up(50)
tello.go_xyz_speed(100, 80, 0, 80)
tello.land()#降落
tello.end()#結束
```
:::
## 原始程式(刀刀高三中)
#### 林
:::spoiler
```py=
from djitellopy import Tello
tello = Tello()#創建無人機
tello.connect()#無人機連線
print("battery:",tello.get_battery())#印出電量
tello.takeoff()#起飛
#tello.go_xyz_speed(120,0,60,50)#以飛機當前位置為原點前往P(50,50,0)
#tello.go_xyz_speed_yaw_mid( 260, 0, 60, 50, 0, 8, 2)
#tello.move_up(60)
#tello.go_xyz_speed_yaw_mid(110, 0, 120, 50, 0, 2, 3)
#tello.curve_xyz_speed( 80, -50 , 0 , 150 , 0, 0 , 50)#x1,y1,z1,x2,y2,z2,speed
#tello.curve_xyz_speed( 90, 50 , 0 , 150 , 0, 0 , 50)
#tello.move_down(90)
#tello.go_xyz_speed_yaw_mid(80,0,60,50,0,5,6)
#tello.move_forward(250)
tello.go_xyz_speed_yaw_mid(150,0,120,80,0,7,8)#150,0,60
tello.move_up(60)
tello.go_xyz_speed(280,40, 0, 50)
tello.move_down(80)
tello.move_back(80)
tello.move_right(80)
tello.move_up(50)
tello.go_xyz_speed(280, 40, 0, 50)
tello.land()#降落
tello.end()#結束
```
:::
#### 廖
:::spoiler
```py=
from djitellopy import Tello
t = Tello()
t.connect()
print("battert:",t.get_battery())
t.takeoff()
#tello.go_xyz_speed(50, 50, 0, 50)
t.go_xyz_speed_yaw_mid( 120, 0, 110, 50, 0, 8, 1)
t.move_down(40)
t.go_xyz_speed_yaw_mid(140, 0, 70, 50, 0, 1, 2)
t.move_up(50)
t.move_forward(110)
t.curve_xyz_speed_mid(75, -40, 120, 150, 0, 120, 50, 3)
t.curve_xyz_speed_mid(75, 40, 120, 150, 0, 120, 50, 4)
t.go_xyz_speed_yaw_mid( 75, 30, 120, 50, 0, 5, 6)
t.move_down(70)
t.move_forward(220)
t.move_up(70)
t.go_xyz_speed_yaw_mid( 150, 0 ,120, 50, 0, 7, 8)
t.move_up(60)
t.go_xyz_speed(295, 40, -10, 50)
t.move_down(80)
t.move_back(85)
t.curve_xyz_speed(0, -40, 20, 45, -80, 40, 50)
t.go_xyz_speed(130, 40, 10, 50)
t.move_forward(30)
t.land()#降落
t.end()#結束
from djitellopy import Tello
t = Tello()
t.connect()
print("battert:",t.get_battery())
t.takeoff()
#tello.go_xyz_speed(50, 50, 0, 50)
#1
#t.go_xyz_speed_yaw_mid( 120, 0, 110, 50, 0, 8, 1)
#t.move_down(40)
#t.go_xyz_speed_yaw_mid(140, 0, 70, 50, 0, 1, 2)
#2
#t.move_up(50)
#t.move_forward(110)
#3
#t.curve_xyz_speed_mid(75, -40, 120, 150, 0, 120, 50, 3)
#4
#t.curve_xyz_speed_mid(75, 40, 120, 150, 0, 120, 50, 4)
#5
t.go_xyz_speed_yaw_mid( 150, 0, 120, 50, 0, 5, 6)
#6
t.move_down(70)
t.move_forward(200)
t.move_forward(200)
t.move_up(70)
#7
t.go_xyz_speed_yaw_mid( 150, 0 ,120, 50, 0, 7, 8)
#8
#t.move_up(60)
#t.go_xyz_speed(295, 40, -10, 50)
#t.move_down(80)
#t.move_back(85)
#t.curve_xyz_speed(0, -40, 20, 45, -80, 40, 50)
#t.go_xyz_speed(130, 40, 10, 50)
#t.move_forward(30)
t.land()#降落
t.end()#結束
```
:::
#### function stable version
:::spoiler
```py=
from djitellopy import Tello
tello = Tello()#創建無人機
tello.connect()#無人機連線
print("battery:",tello.get_battery())#印出電量
forward_time=0
def flag1(card:int):
tello.curve_xyz_speed_mid(75, -40, 120, 140, 0, 120, 50, card)
def flag2(card:int):
tello.curve_xyz_speed_mid(75, 40, 120, 150, 0, 120, 50, card)
def c3(card:int):
tello.go_xyz_speed_mid(150, 40, 170, 80,card)
tello.move_down(90)#80
tello.move_back(85)
tello.curve_xyz_speed(0, -40, 20, 45, -80, 40, 50)
tello.go_xyz_speed(80, 40, -10, 80)
def ct():
tello.move_up(60)
tello.move_forward(140)
tello.move_down(60)
def cm(card:int):
tello.move_up(40)
tello.go_xyz_speed(100, 0, 0, 80)
tello.takeoff()#起飛
tello.move_forward(120) # 前進 120
tello.move_down(50) # 下降 50
tello.go_xyz_speed_yaw_mid(140, 0, 100, 100, 0, 1, 2) # 由 m1 跳飛到 m2 直行 140 高度 100
tello.go_xyz_speed_yaw_mid(110, 0, 120, 100, 0, 2, 3) # 由 m2 跳飛到 m3 直行 110 高度 120
while(forward_time<5):
tello.move_forward(40)
pad = tello.get_mission_pad_id()
forward_time=forward_time+1
if pad==3:
flag1(pad)
elif pad==4:
flag2(pad)
a1=100 # a1 為隧道入口與實際的差
tello.go_xyz_speed_yaw_mid(100, 150-20-a1, 60, 100, 0, 5, 6) # 由 m5 跳飛到 m6 直行 100 左移 150-20-a1 高度 60
a2=60 # a2 為隧道出口與實際長度的差
tello.go_xyz_speed_yaw_mid(20+130+150-a2,0 , 60, 100, 0, 6, 7) # 由 m6 跳飛到 m7 直行 20+130+150-a2 高度 60
elif pad==8:
ct()
elif pad==2:
c3(pad)
elif pad==1:
cm(pad)
print("battery:",tello.get_battery())#印出電量
tello.disable_mission_pads()
tello.land()
tello.end()
```
:::
#### function version
:::spoiler
```py=
from djitellopy import Tello
def A(d:int):
tello.go_xyz_speed_mid(0,0,95,80,2)
tello.move_forward(d)
def flag1():
tello.curve_xyz_speed_mid(75, -40, 120, 140, 0, 120, 50, 3)
def flag2():
tello.curve_xyz_speed_mid(75, 40, 120, 150, 0, 120, 50, 1)
def start(d:int,speed:int):
tello.go_xyz_speed_mid(d,0,70,speed,8)
tello.move_up(20)
def c3():
tello.go_xyz_speed_mid(150, 40, 170, 80,2)
print("found card2")
tello.move_down(90)#80
tello.move_back(85)
tello.curve_xyz_speed(0, -40, 20, 45, -80, 40, 50)
tello.go_xyz_speed(80, 40, -10, 80)
def ct():
tello.move_up(60)
tello.move_forward(140)
tello.move_down(60)
tello = Tello()#創建無人機
tello.connect()#無人機連線
print("battery:",tello.get_battery())#印出電量
tello.takeoff()#起飛
pad = tello.get_mission_pad_id()
#tello.go_xyz_speed(260,0,0,100)
#tello.move_forward(260)
#start(220,80)
'''tello.go_xyz_speed_yaw_mid( 120, 0, 90, 50, 0, 8, 4)
tello.move_down(40)
tello.go_xyz_speed_yaw_mid(140, 0, 100, 50, 0, 4)
#tello.move_up(50)
tello.move_forward(80)'''
ft=0
card4=1
pad = tello.get_mission_pad_id()
#tello.move_up(40)
while ft<6:
if pad==3:
ft=0
#card2=2
print("flag1")
flag1()
#flag2()
if pad==1:
ft=0
print("flag2")
flag2()
if pad==6:
ft=0
print("read card6")
tello.go_xyz_speed_yaw_mid(70,0,80,80,0,6,5)
if pad==5:
break
ft=0
print("read card5")
#tello.go_xyz_speed_mid(0,0,50,80,5)
#print("move_down sucess")
#tello.go_xyz_speed_yaw_mid(230,0,50,80,0,5,7)
tello.go_xyz_speed_mid(250,0,40,80,5)
tello.move_up(70)
#tello.go_xyz_speed_mid(0,0,120,80,7)
'''if pad==7:
print("read card7")
tello.go_xyz_speed_yaw_mid(70,0,120,80,0,7,1)'''
if pad==8:
print("read card8")
ft=0
ct()
if pad==2:
ft=0
print("read card2")
c3()
if pad==4:
print("read card4")
ft=0
tello.go_xyz_speed_yaw_mid(40,0,120,80,0,4,3)
tello.go_xyz_speed(80, 0, 20, 80)
tello.move_forward(40)
ft=ft+1;
pad = tello.get_mission_pad_id()
#tello.move_down(70)
#tello.go_xyz_speed_yaw_mid(80,30,80,50,0,5,6)
#tello.move_forward(220)
if ft>=6:
print("too far")
print("battery:",tello.get_battery())#印出電量
tello.disable_mission_pads()
tello.land()
tello.end()
```
:::
## 常用函式整理
:::spoiler
```py=
def move_up(self, x: int):#上
"""Fly x cm up.
Arguments:
x: 20-500
"""
self.move("up", x)
def move_down(self, x: int):#下
"""Fly x cm down.
Arguments:
x: 20-500
"""
self.move("down", x)
def move_left(self, x: int):#左
"""Fly x cm left.
Arguments:
x: 20-500
"""
self.move("left", x)
def move_right(self, x: int):#右
"""Fly x cm right.
Arguments:
x: 20-500
"""
self.move("right", x)
def move_forward(self, x: int):#前
"""Fly x cm forward.
Arguments:
x: 20-500
"""
self.move("forward", x)
def move_back(self, x: int):#後
"""Fly x cm backwards.
Arguments:
x: 20-500
"""
self.move("back", x)
def rotate_clockwise(self, x: int):#順時針轉
"""Rotate x degree clockwise.
Arguments:
x: 1-360
"""
self.send_control_command("cw {}".format(x))
def rotate_counter_clockwise(self, x: int):#逆時針轉
"""Rotate x degree counter-clockwise.
Arguments:
x: 1-3600
"""
self.send_control_command("ccw {}".format(x))
def go_xyz_speed(self, x: int, y: int, z: int, speed: int):
"""Fly to x y z relative to the current position.
Speed defines the traveling speed in cm/s.
Arguments:
x: -500-500
y: -500-500
z: -500-500
speed: 10-100
"""
cmd = 'go {} {} {} {}'.format(x, y, z, speed)
self.send_control_command(cmd)
def curve_xyz_speed(self, x1: int, y1: int, z1: int, x2: int, y2: int, z2: int, speed: int):
"""Fly to x2 y2 z2 in a curve via x2 y2 z2. Speed defines the traveling speed in cm/s.
- Both points are relative to the current position
- The current position and both points must form a circle arc.
- If the arc radius is not within the range of 0.5-10 meters, it raises an Exception
- x1/x2, y1/y2, z1/z2 can't both be between -20-20 at the same time, but can both be 0.
Arguments:
x1: -500-500
x2: -500-500
y1: -500-500
y2: -500-500
z1: -500-500
z2: -500-500
speed: 10-60
"""
cmd = 'curve {} {} {} {} {} {} {}'.format(x1, y1, z1, x2, y2, z2, speed)
self.send_control_command(cmd)
def go_xyz_speed_mid(self, x: int, y: int, z: int, speed: int, mid: int):
"""Fly to x y z relative to the mission pad with id mid.
Speed defines the traveling speed in cm/s.
Arguments:
x: -500-500
y: -500-500
z: -500-500
speed: 10-100
mid: 1-8
"""
cmd = 'go {} {} {} {} m{}'.format(x, y, z, speed, mid)
self.send_control_command(cmd)
def curve_xyz_speed_mid(self, x1: int, y1: int, z1: int, x2: int, y2: int, z2: int, speed: int, mid: int):
"""Fly to x2 y2 z2 in a curve via x2 y2 z2. Speed defines the traveling speed in cm/s.
- Both points are relative to the mission pad with id mid.
- The current position and both points must form a circle arc.
- If the arc radius is not within the range of 0.5-10 meters, it raises an Exception
- x1/x2, y1/y2, z1/z2 can't both be between -20-20 at the same time, but can both be 0.
Arguments:
x1: -500-500
y1: -500-500
z1: -500-500
x2: -500-500
y2: -500-500
z2: -500-500
speed: 10-60
mid: 1-8
"""
cmd = 'curve {} {} {} {} {} {} {} m{}'.format(x1, y1, z1, x2, y2, z2, speed, mid)
self.send_control_command(cmd)
def go_xyz_speed_yaw_mid(self, x: int, y: int, z: int, speed: int, yaw: int, mid1: int, mid2: int):
"""Fly to x y z relative to mid1.
Then fly to 0 0 z over mid2 and rotate to yaw relative to mid2's rotation.
Speed defines the traveling speed in cm/s.
Arguments:
x: -500-500
y: -500-500
z: -500-500
speed: 10-100
yaw: -360-360
mid1: 1-8
mid2: 1-8
"""
cmd = 'jump {} {} {} {} {} m{} m{}'.format(x, y, z, speed, yaw, mid1, mid2)
self.send_control_command(cmd)
```
:::
## 基礎知識
:::spoiler
### 座標系
跟數學認知的有點不一樣
x軸表前後,y軸表左右,z軸表上下
(向前為正)(向左為正)(向上為正)

### 起飛前檢查
1. 確認機身方向(有鏡頭、LED燈處朝前)
3. 確認四隻螺旋槳平衡插入馬達軸心
4. 確認機身平衡、完好
5. 確認wifi已連接
6. ==程式有起飛也有降落==
### 失控解救方法
如果遇到斷線或任何不可空因素導致無人機失控、無法降落;請從==無人機下方快速抓起並按下電源關閉鍵==(拜託不要從上面、側邊做任何擠壓,很傷螺旋槳)
## 挑戰卡
- 功能:定位&修正無人機方向
- 元素
1. 數字:表示挑戰卡編號
2. 火箭:表x軸方向
- 程式呼叫名稱
mid:定位挑戰卡
mid1:基準挑戰卡
mid2:目標挑戰卡

## Python控制
### 安裝函式庫
- 函式庫名稱:djitellopy
詳細內容請看github:point_down:(常用函式line 618~782) https://github.com/damiafuentes/DJITelloPy/blob/master/djitellopy/tello.py
打開cmd,輸入以下指令(電腦要先裝Python IDE)
Python IDE推薦:Spyder、LDLE、VScode
```py=
pip install djitellopy
```
:::
## 範例程式
:::spoiler
打開程式編輯器,輸入sample code
```py=
from djitellopy import Tello
tello = Tello()#創建無人機
tello.connect()#無人機連線
print("battert:",tello.get_battery())#印出電量
tello.takeoff()#起飛
tello.go_xyz_speed(50,50,0,50)#以飛機當前位置為原點前往P(50,50,0)
tello.land()#降落
tello.end()#結束
```
:::success
可以正常起飛基本就完成了,剩得靠自己QWQ
:::