0
0
Drone Programmingprogramming~20 mins

Software-In-The-Loop (SITL) concept in Drone Programming - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
SITL Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
SITL Simulation Output

Consider a drone SITL simulation script that runs a simple flight plan. What will be the output after running this code snippet?

Drone Programming
def simulate_flight():
    waypoints = [(0,0), (10,0), (10,10), (0,10)]
    for i, point in enumerate(waypoints):
        print(f"Flying to waypoint {i+1}: {point}")
    return "Flight complete"

result = simulate_flight()
print(result)
A
Flying to waypoint 1: (0, 0)
Flying to waypoint 2: (10, 0)
Flying to waypoint 3: (10, 10)
Flight complete
B
Flying to waypoint 0: (0, 0)
Flying to waypoint 1: (10, 0)
Flying to waypoint 2: (10, 10)
Flying to waypoint 3: (0, 10)
Flight complete
C
Flying to waypoint 1: (0, 0)
Flying to waypoint 2: (10, 0)
Flying to waypoint 3: (10, 10)
Flying to waypoint 4: (0, 10)
Flight complete
DFlight complete
Attempts:
2 left
💡 Hint

Remember that enumerate starts counting from 0 by default, but the code adds 1 to the index.

🧠 Conceptual
intermediate
1:30remaining
Purpose of SITL in Drone Development

What is the main purpose of using Software-In-The-Loop (SITL) simulation in drone programming?

ATo simulate weather conditions only
BTo test drone flight code in a virtual environment without physical hardware
CTo replace the drone's autopilot hardware permanently
DTo control the drone manually during a real flight
Attempts:
2 left
💡 Hint

Think about why developers want to test code before flying a real drone.

🔧 Debug
advanced
2:30remaining
Debugging SITL Flight Path Code

Identify the error in this SITL flight path code snippet that causes the drone to skip the last waypoint.

Drone Programming
waypoints = [(0,0), (5,5), (10,10)]
for i in range(len(waypoints)-1):
    print(f"Going to waypoint {i+1}: {waypoints[i]}")
AThe loop stops one index too early, so the last waypoint is never reached
BThe waypoints list is empty, so no output is printed
CThe print statement has a syntax error causing a crash
DThe range should start at 1 instead of 0
Attempts:
2 left
💡 Hint

Check how the range function is used with the length of the list.

📝 Syntax
advanced
1:30remaining
SITL Command Syntax Error

Which option contains a syntax error that will prevent the SITL script from running?

Drone Programming
commands = ['takeoff', 'hover', 'land']
for cmd in commands
    print(f"Executing {cmd}")
A
for cmd in commands:
    print("Executing " + cmd)
B
for cmd in commands:
    print(f"Executing {cmd}")
C
)"}dmc{ gnitucexE"f(tnirp    
:sdnammoc ni dmc rof
D
for cmd in commands
    print(f"Executing {cmd}")
Attempts:
2 left
💡 Hint

Look for missing punctuation in the for loop syntax.

🚀 Application
expert
3:00remaining
SITL Simulation State After Commands

Given this SITL simulation code, what is the final battery percentage after executing all commands?

Drone Programming
class DroneSim:
    def __init__(self):
        self.battery = 100
    def fly(self, distance):
        self.battery -= distance * 2
    def hover(self, time):
        self.battery -= time

sim = DroneSim()
sim.fly(10)
sim.hover(5)
sim.fly(10)
final_battery = sim.battery
print(final_battery)
A55
B60
C65
D70
Attempts:
2 left
💡 Hint

Calculate battery drain step by step: flying drains 2% per distance unit, hovering drains 1% per time unit.