Python program to control a dji tello edu drone, using missions pads.
Upon detecting a new mission pad (must be of a different number), the drone would fly to the pad, different pads would involve different actions.
By default, the drone would move according to as if the mission pad is 1.
Upon detecting a new mission pad, the drone will go to the position (0,0,100) with respect to the mission pad.
Forward, Backward, Leftward, Rightward: distance can be changed using the env variable DISTANCE
.
Most one-time functions expect the mission pad to be placed in front of the center of the obstacle.
Move forwards, non-stop until detecting another pad
Move backwards, non-stop until detecting another pad
Move leftwards, non-stop until detecting another pad
Move rightwards, non-stop until detecting another pad
Move up, then do the previous action if previous mission pad is 1-4, else do 1.
The z-coordinate of the position upon detecting a new mission pad would be increased by the configured height.
The move up height is configurable via the env variable HEIGHT
Move down, then do the previous action if previous mission pad is 1-4, else do 1.
The z-coordinate of the position upon detecting a new mission pad would be decreased by the configured height.
The move down height is configurable via the env variable HEIGHT
Move a right-forward-left path to move around an obstacle, x AROUND_X
and y AROUND_Y
distance and times AROUND_TIMES
can be adjusted using .env.
If times is more than one the drone would move using an s-shape path (right-forward-left then left-forward-right).
If another mission pad is placed on its course the drone would reposition itself to that mission pad after a right-forward-left or left-forward-right path. The drone would then follow the instruction of that mission pad after this function is finished.
Move to a lowest possible height, and then move in accordance if the previous mission pad has the instruction
Otherwise move in accordance with Forward.
Rise to the height specified by the env variable MAX_HEIGHT
.
Then move to the direction defined earlier, or forward very slowly (0.1m/s) until a tof distance significantly less than the initial is detected (detection interval is 0.1s).
Initial tof distance - detected tof distance would be treated as the height of the obstacle.
The drone would then return to the mission pad and try to pass through the obstacle using the height obtained.
WARNING: DO NOT place any other mission pads between the mission pad for this function and the obstacle.
Move to the height specified by the env variable OBS_HEIGHT
(use the times used as index, first time is 0).
Then the drone would fly as instructed before or forward.
Rotate 30 degrees clockwise. The times to rotate could be adjusted using the env variable ROTATE_TIMES
.
Move in an s-shape path (right-forward-left then left-forward-right).
Using Around with AROUND_TIMES=[2]
can achieve the same result.
Move a right-forward-left-back-right path (like a square), finally returns to the mission pad.
Times can be set using CIRCLE_TIMES
.
Move around a curve (like in around).
Auto land. The program is exited after that.
WARNING: Mode 1 is obsolete, please use mode 2 instead.
MODE=1
Land or switch mode (see the SWITCH_MODE
variable)
MODE=2
Do nothing.
NO idea yet.
Land or switch mode (see the SWITCH_MODE
variable)
Copy the example to .env
:
cp example.env .env
The edit the .env
file, even during runtime it would work (the config is re-read upon every operation).
Most variables are self-explanatory. Here are some of the variables you may find difficult to configure:
Ip of the tello drone, usually 192.168.10.1
.
If not scan all the addresses on the network:
sudo nmap 192.168.10.0/24 -sU -p 8889
To make sure the ip belongs to the drone:
sudo nmap 192.168.10.1 -sU -p 8889
The password for the wifi you would setup when running the script wifi.
poetry install
Start up the drone, controlled using the mission pads.
poetry run start
Setup wifi password according to the env variable TELLO_WIFI_PASSWORD
.
poetry run wifi
Land the drone.
poetry run land
Emergency mode: stop the engines immediately.
poetry run emergency