0
0
Drone Programmingprogramming~30 mins

Optical flow for indoor positioning in Drone Programming - Mini Project: Build & Apply

Choose your learning style9 modes available
Optical flow for indoor positioning
📖 Scenario: You are programming a small indoor drone to help it know how it moves inside a room. The drone uses a camera to see the floor and calculates how much it has moved by looking at the changes in the floor pattern. This is called optical flow.We will write a simple program that takes a list of movement vectors detected by the camera and calculates the drone's total movement inside the room.
🎯 Goal: Build a program that sums up the optical flow vectors to find the drone's total movement in the X and Y directions inside a room.
📋 What You'll Learn
Create a list of optical flow vectors with exact values
Add a variable to hold the total movement initialized to zero
Use a for loop to sum the X and Y movements separately
Print the total movement as a tuple (total_x, total_y)
💡 Why This Matters
🌍 Real World
Indoor drones use optical flow to understand how they move without GPS. This helps them fly safely inside buildings.
💼 Career
Understanding optical flow and vector summing is important for drone programmers and robotics engineers working on navigation systems.
Progress0 / 4 steps
1
Create the optical flow data
Create a list called optical_flow_vectors with these exact tuples representing movement: (1, 2), (-1, 3), (0, -2), (2, 1).
Drone Programming
Need a hint?

Use square brackets to create a list and put the tuples inside separated by commas.

2
Set up total movement variables
Create two variables called total_x and total_y and set both to 0 to hold the total movement in X and Y directions.
Drone Programming
Need a hint?

Use simple assignment to create variables and set them to zero.

3
Sum the optical flow vectors
Use a for loop with variables dx and dy to iterate over optical_flow_vectors. Inside the loop, add dx to total_x and dy to total_y.
Drone Programming
Need a hint?

Use a for loop to get each tuple and add the parts to total_x and total_y.

4
Print the total movement
Write a print statement to display the total movement as a tuple: (total_x, total_y).
Drone Programming
Need a hint?

Use print() with parentheses around total_x and total_y to show the tuple.