Bird
Raised Fist0
Drone Programmingprogramming~10 mins

Sending velocity commands in Drone Programming - Step-by-Step Execution

Choose your learning style10 modes available
Concept Flow - Sending velocity commands
Start
↓
Set velocity values
↓
Send velocity command to drone
↓
Drone moves accordingly
↓
Check if more commands
↓
Repeat
The flow shows setting velocity, sending it to the drone, drone moves, then repeats or stops.
Execution Sample
Drone Programming
velocity_x = 1.0
velocity_y = 0.0
velocity_z = 0.5
send_velocity(velocity_x, velocity_y, velocity_z)
# Drone moves forward and up
This code sets velocity in x, y, z directions and sends it to the drone to move.
Execution Table
StepActionVelocity (x,y,z)Drone ResponseNotes
1Set velocity_x(1.0, -, -)No movement yetVelocity x set to 1.0
2Set velocity_y(1.0, 0.0, -)No movement yetVelocity y set to 0.0
3Set velocity_z(1.0, 0.0, 0.5)No movement yetVelocity z set to 0.5
4Send velocity command(1.0, 0.0, 0.5)Drone moves forward and upCommand sent to drone
5Check for more commands(1.0, 0.0, 0.5)Movement continuesLoop or stop decided here
6Stop sending commands(0.0, 0.0, 0.0)Drone stops movingVelocity zero to stop
💡 No more velocity commands to send, drone stops moving
Variable Tracker
VariableStartAfter Step 1After Step 2After Step 3After Step 4Final
velocity_xundefined1.01.01.01.00.0
velocity_yundefinedundefined0.00.00.00.0
velocity_zundefinedundefinedundefined0.50.50.0
Key Moments - 3 Insights
Why does the drone not move immediately after setting velocity variables?
Because setting variables only stores values; the drone moves only after the velocity command is sent (see Step 4 in execution_table).
What happens if we send zero velocities?
Sending zero velocities tells the drone to stop moving (see Step 6 in execution_table).
Can we send velocity commands repeatedly to keep the drone moving?
Yes, sending velocity commands repeatedly updates the drone's movement continuously (see Step 5 in execution_table).
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the velocity_z value after Step 3?
A0.0
B0.5
C1.0
Dundefined
💡 Hint
Check the 'Velocity (x,y,z)' column at Step 3 in the execution_table.
At which step does the drone start moving?
AStep 2
BStep 3
CStep 4
DStep 5
💡 Hint
Look for the 'Drone Response' column where movement begins in the execution_table.
If velocity_x is set to 0.0 at Step 1, how does the drone move after sending the command?
AMoves only up
BDoes not move
CMoves forward and up
DMoves backward
💡 Hint
Refer to variable_tracker and execution_table to see effect of velocity_x = 0.0 and velocity_z = 0.5.
Concept Snapshot
Sending velocity commands:
- Set velocity_x, velocity_y, velocity_z variables
- Use send_velocity(x,y,z) to command drone
- Drone moves according to velocities
- Repeat commands to update movement
- Send zero velocities to stop drone
Full Transcript
This visual execution shows how sending velocity commands to a drone works. First, velocity values for x, y, and z directions are set. These values alone do not move the drone. When the send_velocity function is called with these values, the drone moves accordingly. The drone continues moving until new commands are sent. Sending zero velocities stops the drone. The execution table traces each step, showing variable changes and drone responses. Key moments clarify common confusions like why setting variables alone doesn't move the drone and how to stop it. The quiz tests understanding of velocity values and drone movement timing.

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