Challenge - 5 Problems
Velocity Command Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediateWhat 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)Attempts:
2 left
💡 Hint
Look at the dictionary values assigned to current_velocity.
✗ Incorrect
The velocity_command dictionary sets the drone's velocity directly. Assigning it to current_velocity means the drone's velocity is exactly {'vx': 5, 'vy': 0, 'vz': -2}.
🧠 Conceptual
intermediateWhich 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?
Attempts:
2 left
💡 Hint
Upward movement affects the vertical velocity component.
✗ Incorrect
The 'vz' key controls vertical velocity. Positive 'vz' moves the drone up, so {'vz': 3} moves it straight up at 3 m/s.
🔧 Debug
advancedWhy 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)Attempts:
2 left
💡 Hint
Check the data types of the velocity values.
✗ Incorrect
Velocity values must be numbers. 'vz' is given as a string 'fast', causing a TypeError when the drone tries to process it.
📝 Syntax
advancedWhich velocity command syntax is correct?
Select the option that correctly defines a velocity command dictionary for moving the drone forward at 4 m/s.
Attempts:
2 left
💡 Hint
Remember how to write dictionaries in Python.
✗ Incorrect
Dictionaries require keys in quotes and colons to separate keys and values. Option A follows this syntax correctly.
🚀 Application
expertWhat 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?
Attempts:
2 left
💡 Hint
Add the corresponding velocity components from both commands.
✗ Incorrect
Adding vx: 3 + (-1) = 2, vy: 2 + 0 = 2, vz: 0 + 4 = 4 results in {'vx': 2, 'vy': 2, 'vz': 4}.
