Bird
Raised Fist0
Drone Programmingprogramming~20 mins

Sending velocity commands in Drone Programming - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Velocity Command Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate
2:00remaining
What is the drone's velocity after this command?
Given the following code snippet that sends velocity commands to a drone, what will be the drone's velocity vector after execution?
Drone Programming
velocity_command = {'vx': 5, 'vy': 0, 'vz': -2}
# Command sent to drone
current_velocity = velocity_command
print(current_velocity)
A{'vx': 5, 'vy': 0, 'vz': -2}
B{'vx': 0, 'vy': 0, 'vz': 0}
C{'vx': -5, 'vy': 0, 'vz': 2}
DNone
Attempts:
2 left
💡 Hint
Look at the dictionary values assigned to current_velocity.
🧠 Conceptual
intermediate
1:30remaining
Which velocity command moves the drone straight up?
You want the drone to move straight up at 3 meters per second. Which velocity command dictionary achieves this?
A{'vx': 0, 'vy': 3, 'vz': 0}
B{'vx': 3, 'vy': 0, 'vz': 0}
C{'vx': 0, 'vy': 0, 'vz': 3}
D{'vx': 0, 'vy': 0, 'vz': -3}
Attempts:
2 left
💡 Hint
Upward movement affects the vertical velocity component.
🔧 Debug
advanced
2:30remaining
Why does this velocity command cause an error?
This code snippet is intended to send a velocity command to the drone, but it raises an error. What is the cause?
Drone Programming
velocity_command = {'vx': 2, 'vy': 3, 'vz': 'fast'}
send_velocity(velocity_command)
ANo error, command sends successfully
BSyntaxError due to missing colon in dictionary
CNameError because send_velocity is not defined
DTypeError because 'vz' value is a string instead of a number
Attempts:
2 left
💡 Hint
Check the data types of the velocity values.
📝 Syntax
advanced
1:30remaining
Which velocity command syntax is correct?
Select the option that correctly defines a velocity command dictionary for moving the drone forward at 4 m/s.
A{'vx': 4, 'vy': 0, 'vz': 0}
B['vx': 4, 'vy': 0, 'vz': 0]
C{'vx' = 4, 'vy' = 0, 'vz' = 0}
D{vx: 4, vy: 0, vz: 0}
Attempts:
2 left
💡 Hint
Remember how to write dictionaries in Python.
🚀 Application
expert
3:00remaining
What is the resulting velocity after combining two commands?
You have two velocity commands sent sequentially: Command 1: {'vx': 3, 'vy': 2, 'vz': 0} Command 2: {'vx': -1, 'vy': 0, 'vz': 4} If the drone adds these velocity vectors, what is the resulting velocity?
A{'vx': 4, 'vy': 2, 'vz': 4}
B{'vx': 2, 'vy': 2, 'vz': 4}
C{'vx': 2, 'vy': 0, 'vz': 4}
D{'vx': 3, 'vy': 2, 'vz': 0}
Attempts:
2 left
💡 Hint
Add the corresponding velocity components from both commands.

Practice

(1/5)
1. What does sending a velocity command to a drone usually control?
send_velocity(x_speed, y_speed, z_speed, duration)
easy
A. The drone's battery level
B. The speed and direction the drone moves in each axis
C. The drone's camera angle
D. The drone's GPS coordinates

Solution

  1. Step 1: Understand velocity command parameters

    The parameters x_speed, y_speed, and z_speed represent how fast the drone moves along each axis.
  2. Step 2: Connect parameters to drone movement

    These speeds control the drone's direction and speed, while duration controls how long it moves.
  3. Final Answer:

    The speed and direction the drone moves in each axis -> Option B
  4. Quick Check:

    Velocity commands = speed and direction control [OK]
Hint: Velocity commands set speed and direction, not camera or battery [OK]
Common Mistakes:
  • Confusing velocity with camera control
  • Thinking velocity sets GPS location directly
  • Assuming velocity changes battery level
2. Which of the following is the correct syntax to send a velocity command moving the drone forward at 2 m/s for 5 seconds?
easy
A. send_velocity(5, 0, 0, 2)
B. send_velocity(0, 2, 0, 5)
C. send_velocity(0, 0, 2, 5)
D. send_velocity(2, 0, 0, 5)

Solution

  1. Step 1: Identify forward direction axis

    Forward movement is usually along the X-axis, so x_speed should be 2.
  2. Step 2: Check duration and other speeds

    Y and Z speeds are zero, duration is 5 seconds, matching the command.
  3. Final Answer:

    send_velocity(2, 0, 0, 5) -> Option D
  4. Quick Check:

    X-axis speed = 2, duration = 5 [OK]
Hint: Forward speed is X-axis; duration is last parameter [OK]
Common Mistakes:
  • Mixing up X and Y axes
  • Putting duration in wrong position
  • Setting speed on wrong axis
3. What will be the drone's movement after running this code?
send_velocity(0, -3, 0, 4)
medium
A. The drone moves left at 3 m/s for 4 seconds
B. The drone moves backward at 3 m/s for 4 seconds
C. The drone moves right at 3 m/s for 4 seconds
D. The drone moves upward at 3 m/s for 4 seconds

Solution

  1. Step 1: Identify axis for Y speed

    The Y-axis controls left-right movement; negative means left.
  2. Step 2: Interpret speed and duration

    Speed is 3 m/s left for 4 seconds, no movement on X or Z axes.
  3. Final Answer:

    The drone moves left at 3 m/s for 4 seconds -> Option A
  4. Quick Check:

    Negative Y speed = left movement [OK]
Hint: Negative Y speed means left movement [OK]
Common Mistakes:
  • Confusing negative Y with backward
  • Mixing Y and Z axes
  • Assuming negative means right
4. Identify the error in this velocity command code:
send_velocity(1, 0, 0)
medium
A. Missing duration parameter
B. Wrong order of speed parameters
C. Negative speed value not allowed
D. Extra parameter included

Solution

  1. Step 1: Check function parameters

    The function requires four parameters: x_speed, y_speed, z_speed, and duration.
  2. Step 2: Identify missing parameter

    Only three parameters are given; duration is missing, causing an error.
  3. Final Answer:

    Missing duration parameter -> Option A
  4. Quick Check:

    Duration required as 4th parameter [OK]
Hint: Velocity commands need 4 parameters: x, y, z, duration [OK]
Common Mistakes:
  • Forgetting duration parameter
  • Swapping speed and duration order
  • Using negative duration
5. You want the drone to move diagonally upward forward at 1 m/s on X and Z axes for 3 seconds, but keep Y speed zero. Which command is correct?
hard
A. send_velocity(1, 1, 0, 3)
B. send_velocity(0, 1, 1, 3)
C. send_velocity(1, 0, 1, 3)
D. send_velocity(1, 0, 0, 1)

Solution

  1. Step 1: Assign speeds to correct axes

    X speed = 1 (forward), Y speed = 0 (no sideways), Z speed = 1 (upward).
  2. Step 2: Check duration matches requirement

    Duration is 3 seconds, matching the problem statement.
  3. Final Answer:

    send_velocity(1, 0, 1, 3) -> Option C
  4. Quick Check:

    X=1, Y=0, Z=1, duration=3 [OK]
Hint: Set speeds on X and Z, zero on Y, duration last [OK]
Common Mistakes:
  • Mixing Y and Z speeds
  • Wrong duration value
  • Setting zero on wrong axis
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