Beginners Series Lesson 4: Throttle, Yaw, Pitch and Roll
In this lesson, we learn how to control the CoDrone using the movement commands Throttle, Yaw, Pitch and Roll.

Summary

Our next step in programming our CoDrone is understanding how a drone flies. This lesson will explain throttle, pitch, yaw, and roll and how we use these terms to maneuver in 3D space.  We’ll use this knowledge to improve our flight code.

Throttle, Yaw, Pitch and Roll

To keep track of movement in 3D space we use the following terms:

Throttle controls the vertical up and down motion of the drone.  Positive throttle will make the drone fly higher and negative throttle will make the drone fly lower.

Yaw is the left and right rotation of the drone.  Positive yaw will make the drone turn to the right and negative yaw will make the drone turn to the left.

Pitch is the forward and backward tilt of the drone.  positive pitch will make the drone tilt and move forward and negative pitch will make the drone tilt and move backwards.

Roll is the side to side tilt of the drone.  Positive roll will make the drone tilt to the right and negative roll will make the drone tilt to the left.

Activity: Blind Drone

Blindfold a friend and try to get him to walk around obstacles using only drone terminology.  Make sure you clear the room of anything dangerous first:

• Plus Pitch – Move Forward
• Minus Pitch – Move Backward
• Plus Yaw – Turn Right
• Minus Yaw – Turn Left
• Plus Roll – Move Right
• Minus Roll – Move Left
• Plus Throttle – Stand Taller
• Minus Throttle – Crouch

Don’t let them run into anything!

Making the CoDrone Move

There are three steps to making our CoDrone fly autonomously:

1. Movement Command
2. CoDrone.Control();
3. delay();

Movement commands are the terms we just learned above: Yaw, Pitch, Roll, Throttle.  We can set these numbers to a value in Arduino by using the following format:

The value for these numbers can range from -100 to 100.  For example, if we wanted to set throttle to 70, we would write:

This saves THROTTLE as 70, but doesn’t send the command to our CoDrone just yet.

When we want to send all our movement values to the CoDrone, we use CoDrone.Control()

CoDrone.Control();

CoDrone.Control();

• Send the saved YAW, PITCH, ROLL, and THROTTLE commands to the CoDrone.  The saved YAW, PITCH, ROLL and THROTTLE values are reset to 0 afterwards.

CoDrone.Control(Interval);

• Send the stored steering maneuvers to the CoDrone at the set minimum interval.  The interval is a number in milliseconds.  The default is 50 (ms).  Using the variable SEND_INTERVAL sends 50 (ms).  Leaving the parenthesis empty will also default to 50ms.  You should just leave it blank.

This will send all the saved movement values to the CoDrone, then reset all of the values back to zero.

For example, if I wanted to make my CoDrone fly upwards at a speed of 70, I would write:

This will send a positive throttle (70) to the CoDrone, making it fly upwards.  It automatically assumes that PITCH, ROLL, and YAW are 0 since they haven’t been set to anything else.

You can also set multiple directions at once.  If I wanted my CoDrone to fly to the right and backwards at the same time, I would write:

This will send a positive roll, making it fly to the right, and a negative pitch, making it fly backwards.

The last thing we need to remember is to give our movements time to execute.  You might remember from the last lesson that we used delay. We’ll be using delay again:

This will pause our code for 1.5 seconds after we send our movement commands, giving the CoDrone 1.5 seconds to execute the command before we send it something else.

Lets put it all together now.  We’ll start with the setup code:

Then insert our movement codes after we connect to the CoDrone:

The code above will do the following:

Connect to a Nearby CoDrone

Perform a takeoff for 2 seconds

Throttle at 50 for 2 seconds (go upwards)

Move diagonally forward and left for 2 seconds

Perform a landing

Now try making your own CoDrone code!

Activity: Pin-Point

Set up a starting pad and a landing pad a few feet apart.  Try to get the CoDrone to fly from one pad to the next using your own autonomous program.

Rules: