Air vehicles move a little differently than land vehicles. Since land vehicles operate in two dimensions (we can call these X and Y), they only move forward and backward or left and right. Air vehicles, however, move in three-dimensional space (X, Y, and Z). This means that they not only move in the same directions as a land vehicle, but they also move up and down and can spin. Because of this we have different terms to describe how air vehicles move through the sky as you will see below.
Movement Commands
Key Terms
Parameter: a placeholder for a value that a function will use. These let the user know that values are required for the function to behave properly.
Argument: the actual value that a user puts into a function when it is called. For example, in the code drone.set_roll(25)
the value 25 is the argument for this function.
There are three components to each movement of the drone that you will specify in order to make it behave properly:
- The movement you want the drone to make (Roll, Pitch, Yaw, Throttle)
- How much power to apply to the movement (How fast you want the movement to be)
- How long you want the movement to execute or last
As you see in the image above, each of the movement commands follows the same format. You specify the drone object that you want to move, tell it which of the movement commands to do, and then specify what direction and speed you want the movement to occur. When setting the speed and direction, you put into the commands an argument value ranging from -100 to 100. The values 0-100 are the percentage of the drone’s power you want to use. 0 would be no power while 100 would be full power (100%). Whether the argument value is positive or negative determines the direction the drone will take. For example, -50 and 50 will move at the same speed but in opposite directions.
BE CAREFUL: setting the drone’s power to 100% will make it move very quickly and result in collisions with objects. We recommend that you start at lower power settings and work your way up to higher settings once you understand how quickly the drone moves.
Calling the function takes care of steps 1 and 2, but not step 3. You will notice that there is no parameter in the movement commands that tells the drone how long to move. This is because the movement commands are all set commands. What this means is that we are changing the value of a variable (the movement) to a new value. We will learn the difference between setter and getter commands and what variables are in later lessons. Since we are only setting or changing the speed and direction of the drone with the movement commands, we have a separate function called move that tells the drone the duration or time that it should move:
drone.move(1) # has the drone move for 1 second
drone.move(2.5) # has the drone move for 2 and a half seconds
By combining the movement and move commands, we can make the drone move in a specific direction for an amount of time. So, each time we program one of the movement commands, don’t forget to pair it with a drone.move()
command as well!