0
0
Drone Programmingprogramming~20 mins

Optical flow for indoor positioning in Drone Programming - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Optical Flow Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Calculate displacement from optical flow data
Given the optical flow vectors detected by a drone's downward camera, what is the resulting displacement in meters after processing the flow data for 1 second?

Assume the drone's altitude is 2 meters, and the optical flow sensor reports pixel shifts that translate to velocity components as shown in the code.
Drone Programming
altitude = 2.0  # meters
flow_x = 0.1  # meters/second
flow_y = -0.05  # meters/second
time_seconds = 1

displacement_x = flow_x * time_seconds
displacement_y = flow_y * time_seconds

print(f"Displacement X: {displacement_x} m")
print(f"Displacement Y: {displacement_y} m")
ADisplacement X: 0.0 m\nDisplacement Y: 0.0 m
BDisplacement X: 2.0 m\nDisplacement Y: -1.0 m
CDisplacement X: 0.2 m\nDisplacement Y: -0.1 m
DDisplacement X: 0.1 m\nDisplacement Y: -0.05 m
Attempts:
2 left
💡 Hint
Multiply the velocity components by the time to get displacement.
🧠 Conceptual
intermediate
1:30remaining
Understanding optical flow limitations indoors
Which of the following is the main challenge when using optical flow sensors for indoor positioning of drones?
AStrong GPS signals interfering with optical sensors
BLack of distinct visual features on uniform surfaces
CExcessive sunlight causing sensor overheating
DHigh altitude causing blurred images
Attempts:
2 left
💡 Hint
Think about what optical flow needs to detect movement.
🔧 Debug
advanced
2:30remaining
Fix the error in optical flow velocity calculation
The following code attempts to calculate the velocity from optical flow pixel shifts and altitude, but it raises an error. Identify the cause and select the correct fixed code.
Drone Programming
pixel_shift_x = 15
pixel_shift_y = 10
altitude = 3.0
focal_length = 2.5
velocity_x = pixel_shift_x * altitude / focal_length
velocity_y = pixel_shift_y * altitude / focal_length

print(f"Velocity X: {velocity_x}")
print(f"Velocity Y: {velocity_y}")
A
velocity_x = pixel_shift_x * altitude / focal_length
velocity_y = pixel_shift_y * altitude / focal_length
B
velocity_x = pixel_shift_x * altitude // focal_length
velocity_y = pixel_shift_y * altitude // focal_length
C
velocity_x = pixel_shift_x / altitude / focal_length
velocity_y = pixel_shift_y / altitude / focal_length
D
velocity_x = pixel_shift_x * altitude * focal_length
velocity_y = pixel_shift_y * altitude * focal_length
Attempts:
2 left
💡 Hint
Check the operators used for division and multiplication.
📝 Syntax
advanced
2:00remaining
Identify the syntax error in optical flow data processing
Which option contains a syntax error when trying to create a dictionary of pixel shifts mapped to their velocities?
Drone Programming
pixel_shifts = {'x': 12, 'y': 8}
altitude = 2.5
focal_length = 3.0
velocities = {axis: pixel_shifts[axis] * altitude / focal_length for axis in pixel_shifts}
print(velocities)
Avelocities = {axis: pixel_shifts[axis] * altitude / focal_length for axis in pixel_shifts}
Bvelocities = {axis: pixel_shifts[axis] * altitude / focal_length for axis in pixel_shifts.keys()}
Cvelocities = {axis: pixel_shifts[axis] * altitude / focal_length for axis pixel_shifts}
Dvelocities = {axis: pixel_shifts[axis] * altitude / focal_length for axis in pixel_shifts.items()}
Attempts:
2 left
💡 Hint
Check the syntax of the for loop in the dictionary comprehension.
🚀 Application
expert
3:00remaining
Calculate total distance traveled using optical flow data
A drone collects optical flow velocity data every second for 5 seconds as follows (in meters/second): [0.1, 0.15, 0.12, 0.13, 0.20]. What is the total distance traveled in meters after 5 seconds?
A0.70
B0.75
C0.65
D0.60
Attempts:
2 left
💡 Hint
Sum all velocities and multiply by the time interval (1 second each).