Skip to content

Scripting

Dave Walker edited this page Jan 24, 2020 · 1 revision

Scripting

The script specified in the "runscript" command should be a text file containing a sequence of any of the commands supported by the command dictionary that's been loaded in the API.

For example, the following is a script that puts the drone through a simple set of movements, with a pause in the middle:

# Example Tello control script
battery?
takeoff
height?
up 50
height?
down 50
left 50
right 50
forward 50
back 50
runscript rotate.txt
land
battery?

Comments

Comments are denoted by the "#" character and may be single line, as shown, or may be inline, in which case anything after the "#" character is treated as part of the comment:

takeof # Instruct the drone to take off

Read Commands

Read commands in a script, such as the "height?" command, report their results in the command history and, in the demonstration application, to the console.

Sub-Scripts

The script contains a "runcscript" command that runs the following "rotation" script:

# Rotate the drone by 180 degrees, wait, then rotate it back
cw 180
wait 5
ccw 180

Note that if the sub-script file is not an absolute path to the subscript, its path is assumed to be relative to the script that calls it. In this case, there is neither absolute nor relative path specified with the rotate.txt script so it is assumed to be in the same folder as its calling script.