0
0
Drone Programmingprogramming~10 mins

Optical flow for indoor positioning in Drone Programming - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to initialize the optical flow sensor.

Drone Programming
optical_flow_sensor = OpticalFlowSensor([1])
Drag options to blanks, or click blank then click option'
Aport=3
Bport=0
Cport=2
Dport=1
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong port number causes the sensor not to initialize.
2fill in blank
medium

Complete the code to read the optical flow data.

Drone Programming
flow_data = optical_flow_sensor.[1]()
Drag options to blanks, or click blank then click option'
Aread
Bstart
Cstop
Dreset
Attempts:
3 left
💡 Hint
Common Mistakes
Using start() instead of read() does not return data.
3fill in blank
hard

Fix the error in the code to calculate displacement from flow data.

Drone Programming
displacement = flow_data.[1] * time_interval
Drag options to blanks, or click blank then click option'
Aspeed
Bdistance
Cvelocity
Dposition
Attempts:
3 left
💡 Hint
Common Mistakes
Using distance attribute directly causes incorrect calculation.
4fill in blank
hard

Fill both blanks to update the drone's position using optical flow data.

Drone Programming
new_position = (current_position[0] + displacement[1], current_position[1] + displacement[2])
Drag options to blanks, or click blank then click option'
A[0]
B[1]
C[2]
D[3]
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong indices causes position update errors.
5fill in blank
hard

Fill all three blanks to filter optical flow data for valid movement detection.

Drone Programming
filtered_flow = {k: v for k, v in flow_data.items() if v[1] [2] and v[3] 0}
Drag options to blanks, or click blank then click option'
A>
B0
C<
D-1
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong comparison operators or values causes incorrect filtering.