Bird
Raised Fist0
Drone Programmingprogramming~10 mins

Axes of rotation (roll, pitch, yaw) in Drone Programming - Step-by-Step Execution

Choose your learning style10 modes available
Concept Flow - Axes of rotation (roll, pitch, yaw)
Start: Drone Orientation
↓
Apply Roll Rotation
↓
Apply Pitch Rotation
↓
Apply Yaw Rotation
↓
Update Drone Orientation
↓
End
The drone orientation updates by applying roll, then pitch, then yaw rotations in sequence.
Execution Sample
Drone Programming
roll = 10  # degrees
pitch = 5  # degrees
yaw = 15  # degrees
orientation = apply_rotations(roll, pitch, yaw)
print(orientation)
This code applies roll, pitch, and yaw rotations to a drone and prints the updated orientation.
Execution Table
StepRotation AxisInput Angle (degrees)ActionOrientation Change
1Roll10Rotate drone around front-to-back axisRoll angle set to 10°
2Pitch5Rotate drone around side-to-side axisPitch angle set to 5°
3Yaw15Rotate drone around vertical axisYaw angle set to 15°
4UpdateN/ACombine rotations to update orientationOrientation updated with roll=10°, pitch=5°, yaw=15°
💡 All three rotations applied; final orientation updated.
Variable Tracker
VariableStartAfter RollAfter PitchAfter YawFinal
roll010101010
pitch00555
yaw0001515
orientationinitialroll=10roll=10, pitch=5roll=10, pitch=5, yaw=15roll=10, pitch=5, yaw=15
Key Moments - 2 Insights
Why do we apply roll before pitch and yaw?
The order matters because each rotation changes the drone's axes; applying roll first sets the base orientation for pitch and yaw to build on, as shown in steps 1-3 of the execution_table.
Are roll, pitch, and yaw angles independent?
No, because each rotation affects the drone's orientation axes, the next rotation uses the updated axes. This is why orientation updates cumulatively in the variable_tracker.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the orientation after applying pitch?
Aroll=10°, pitch=5°, yaw=0°
Broll=0°, pitch=5°, yaw=0°
Croll=10°, pitch=0°, yaw=0°
Droll=0°, pitch=0°, yaw=15°
💡 Hint
Check the 'Orientation Change' column at Step 2 in the execution_table.
At which step does the yaw rotation get applied?
AStep 2
BStep 3
CStep 1
DStep 4
💡 Hint
Look at the 'Rotation Axis' column in the execution_table.
If the roll angle was changed to 20°, how would the final orientation change in variable_tracker?
Aroll=10°, pitch=5°, yaw=15°
Broll=20°, pitch=0°, yaw=0°
Croll=20°, pitch=5°, yaw=15°
Droll=0°, pitch=5°, yaw=15°
💡 Hint
Check the 'roll' values in variable_tracker and imagine updating the initial roll from 10 to 20.
Concept Snapshot
Axes of rotation control drone orientation:
- Roll: rotation around front-to-back axis
- Pitch: rotation around side-to-side axis
- Yaw: rotation around vertical axis
Apply in order: roll, then pitch, then yaw
Each rotation updates orientation cumulatively
Full Transcript
This visual execution shows how a drone's orientation changes by applying three rotations: roll, pitch, and yaw. First, the drone rotates 10 degrees around its front-to-back axis (roll). Next, it rotates 5 degrees around its side-to-side axis (pitch). Then, it rotates 15 degrees around its vertical axis (yaw). Each step updates the drone's orientation, building on the previous rotation. The order of applying these rotations matters because each rotation changes the drone's axes for the next rotation. The variable tracker shows how roll, pitch, yaw, and the overall orientation change step-by-step. This helps beginners understand how combined rotations control drone movement in 3D space.

Practice

(1/5)
1.

Which axis controls the drone's rotation that tilts it side to side?

easy
A. Pitch
B. Roll
C. Yaw
D. Throttle

Solution

  1. Step 1: Understand the meaning of roll

    Roll is the rotation that tilts the drone left or right, like tipping side to side.
  2. Step 2: Match roll to the axis

    Since roll controls side to side tilt, it matches the question.
  3. Final Answer:

    Roll -> Option B
  4. Quick Check:

    Side to side tilt = Roll [OK]
Hint: Roll = side tilt, Pitch = forward/back, Yaw = turn [OK]
Common Mistakes:
  • Confusing pitch with roll
  • Thinking yaw controls tilt
  • Selecting throttle which controls speed
2.

Which of the following is the correct way to set the yaw angle to 45 degrees in a drone control program?

drone.set_yaw(____)
easy
A. "45"
B. set_yaw(45)
C. yaw = 45
D. 45

Solution

  1. Step 1: Identify the correct argument type

    The method expects a number for the angle, so 45 without quotes is correct.
  2. Step 2: Check the method call syntax

    drone.set_yaw(45) correctly calls the method with the number 45.
  3. Final Answer:

    45 -> Option D
  4. Quick Check:

    Number angle without quotes = 45 [OK]
Hint: Use numbers for angles, no quotes needed [OK]
Common Mistakes:
  • Using quotes around numbers
  • Assigning inside method call
  • Calling method without object prefix
3.

What will be the output of this code snippet controlling drone rotation?

roll = 10
pitch = -5
yaw = 90
print(f"Roll: {roll}, Pitch: {pitch}, Yaw: {yaw}")
medium
A. Roll: 10, Pitch: -5, Yaw: 90
B. Roll: 10, Pitch: 5, Yaw: 90
C. Roll: 0, Pitch: -5, Yaw: 90
D. Error: yaw not defined

Solution

  1. Step 1: Check variable assignments

    roll is 10, pitch is -5, yaw is 90 as assigned.
  2. Step 2: Evaluate the print statement

    The f-string prints the values exactly as assigned.
  3. Final Answer:

    Roll: 10, Pitch: -5, Yaw: 90 -> Option A
  4. Quick Check:

    Print variables as assigned = Roll: 10, Pitch: -5, Yaw: 90 [OK]
Hint: Print variables exactly as assigned in f-string [OK]
Common Mistakes:
  • Ignoring negative sign in pitch
  • Assuming yaw is zero
  • Mistyping variable names
4.

Find the error in this code that sets drone rotation angles:

drone.roll = 15
pitch = 20
drone.yaw = 45
print(f"Roll: {drone.roll}, Pitch: {pitch}, Yaw: {yaw}")
medium
A. roll should be assigned with drone.set_roll()
B. pitch should be drone.pitch
C. Variable yaw is not defined before print
D. print statement syntax is incorrect

Solution

  1. Step 1: Check variable definitions

    roll and yaw are accessed as drone.roll and drone.yaw, pitch is a separate variable.
  2. Step 2: Identify undefined variable in print

    yaw is used without drone prefix and not defined as variable, causing error.
  3. Final Answer:

    Variable yaw is not defined before print -> Option C
  4. Quick Check:

    Undefined variable in print = yaw [OK]
Hint: Check all variables used in print are defined [OK]
Common Mistakes:
  • Assuming yaw variable exists without prefix
  • Confusing pitch variable scope
  • Thinking print syntax is wrong
5.

You want to program a drone to tilt forward by 30 degrees, roll right by 15 degrees, and turn left by 90 degrees. Which code snippet correctly sets these rotations?

Option A:
drone.set_pitch(30)
drone.set_roll(15)
drone.set_yaw(-90)

Option B:
drone.set_pitch(-30)
drone.set_roll(-15)
drone.set_yaw(90)

Option C:
drone.set_pitch(30)
drone.set_roll(-15)
drone.set_yaw(90)

Option D:
drone.set_pitch(-30)
drone.set_roll(15)
drone.set_yaw(-90)
hard
A. Pitch 30, Roll 15, Yaw -90
B. Pitch -30, Roll -15, Yaw 90
C. Pitch 30, Roll -15, Yaw 90
D. Pitch -30, Roll 15, Yaw -90

Solution

  1. Step 1: Understand direction signs

    Forward tilt means positive pitch (30), roll right means positive roll (15), turn left means negative yaw (-90).
  2. Step 2: Match signs to code options

    Pitch 30, Roll 15, Yaw -90 matches pitch=30, roll=15, yaw=-90 correctly.
  3. Final Answer:

    Pitch 30, Roll 15, Yaw -90 -> Option A
  4. Quick Check:

    Forward=+pitch, Right=+roll, Left=-yaw [OK]
Hint: Positive pitch forward, positive roll right, negative yaw left [OK]
Common Mistakes:
  • Mixing positive/negative signs for directions
  • Confusing roll and pitch directions
  • Assuming yaw left is positive
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard