# Tello_Python
## 測試程式
:::success
輸入以下程式後可以正常起飛->前進->降落就表示你成功囉
:::
```py=
from djitellopy import Tello
tello = Tello()#創建無人機
tello.connect()#無人機連線
print("battery:",tello.get_battery())#印出電量
tello.takeoff()#起飛
tello.go_xyz_speed(50,50,0,50)#以飛機當前位置為原點前往P(50,50,0)
tello.land()#降落
tello.end()#結束
```
## 基本指令
```py=
tello.move_forward(x)#前進xcm
tello.move_back(x)#後退xcm
tello.move_up(x)#上升xcm
tello.move_down(x)#下降xcm
tello.move_left(x)#左飛xcm
tello.move_right(x)#右飛xcm
```
### 進階指令
```py=
tello.go_xyz_speed(x, y, z, speed)#前往xyz
tello.go_xyz_speed_mid(x, y, z, speed, mid)#基於挑戰卡前往xyz
tello.go_xyz_speed_yaw_mid(x, y, z, speed, yaw, mid1, mid2)#從mid1挑戰卡前往xyz到達mid2挑戰卡(跳躍)
tello.curve_xyz_speed(x1, y1, z1, x2, y2, z2, speed)#曲線飛行
tello.curve_xyz_speed_mid(x1, y1, z1, x2, y2, z2, speed, mid)#基於mid挑戰卡曲線飛行
```

## 圖解轉換


## 參考程式
```py=
from djitellopy import Tello
import time
# create and connect
# 創建Tello物件並連接
t = Tello()
t.connect()
# configure drone
# 設定無人機
t.enable_mission_pads()
t.set_mission_pad_detection_direction(0) # 開啟鏡頭 0 代表向下識別的鏡頭, 1 代表向前識別的鏡頭
print("bettery:",t.get_battery()) # 印出目前剩下多少電量
t.takeoff() # 起飛 預設高度為 100 cm(以下單位均為公分)
t.move_forward(120) # 前進 120
t.move_down(50) # 下降 50
t.go_xyz_speed_yaw_mid(140, 0, 100, 100, 0, 1, 2) # 由 m1 跳飛到 m2 直行 140 高度 100
t.go_xyz_speed_yaw_mid(110, 0, 120, 100, 0, 2, 3) # 由 m2 跳飛到 m3 直行 110 高度 120
t.curve_xyz_speed_mid(75, -50, 110, 150, 0, 110, 50, 3) # 由 m3 曲飛 直行75 右移 50 高度 110 到 直行 150 高度 110 注意曲飛這裡的速度一定要用 50
t.curve_xyz_speed_mid(75, 50, 100, 150+10, 0, 110, 50, 4) # 由 m4 曲飛 直行75 左移 50 高度 100 到 直行 160 高度 110 注意曲飛這裡的速度一定要用 50
a1=100 # a1 為隧道入口與實際的差
t.go_xyz_speed_yaw_mid(100, 150-20-a1, 60, 100, 0, 5, 6) # 由 m5 跳飛到 m6 直行 100 左移 150-20-a1 高度 60
a2=60 # a2 為隧道出口與實際長度的差
t.go_xyz_speed_yaw_mid(20+130+150-a2,0 , 60, 100, 0, 6, 7) # 由 m6 跳飛到 m7 直行 20+130+150-a2 高度 60
t.go_xyz_speed_yaw_mid(150, 0, 120, 100, 0, 7, 8) # 由 m7 跳飛到 m8 直行 150 高度120
t.move_up(60) #上飛 60
t.move_forward(210) # 直行 210
t.move_down(60) #下降 60
t.move_right(50) # 右移 50
t.curve_xyz_speed_mid(60, 20, 130, 60, 100, 80, 50, 1) # 由 m1 曲飛 直行 60 左移 20 高度 130 到 直行 60 左移 100 高度 80 注意曲飛這裡的速度一定要用 50
t.go_xyz_speed_yaw_mid(-70-15, 0, 80, 100, 0, 2, 3) # 由 m2 跳飛到 m3 後退 85 高度 80
t.move_up(80) # 上飛 80
t.move_forward(80) # 前進 80
t.move_down(80) #下降 80
t.go_xyz_speed_yaw_mid(100, -40, 120, 100, 0, 2, 4) # 由 m2 跳飛到 m4 直行 100 右移 40 高度 120
t.move_forward(210) # 前進 210
print("bettery:",t.get_battery()) # 印出目前剩下多少電量
t.disable_mission_pads() # 關閉鏡頭
t.land() # 降落
t.end() # 結束
```