Software-In-The-Loop (SITL) concept in Drone Programming - Time & Space Complexity
When using Software-In-The-Loop (SITL), we run drone software inside a simulation. It helps us test code without flying a real drone.
We want to know how the time to run the simulation grows as we add more tasks or complexity.
Analyze the time complexity of the following SITL simulation loop.
while simulation_running:
read_sensors()
update_flight_controls()
simulate_physics()
send_telemetry()
wait_for_next_cycle()
This loop runs repeatedly to simulate drone behavior step-by-step.
Look at what repeats in the simulation loop.
- Primary operation: The entire loop runs once every simulation cycle.
- How many times: It repeats many times, depending on simulation length.
Each cycle does a fixed set of steps. More cycles mean more total work.
| Input Size (cycles) | Approx. Operations |
|---|---|
| 10 | 10 cycles x fixed steps |
| 100 | 100 cycles x fixed steps |
| 1000 | 1000 cycles x fixed steps |
Pattern observation: The total work grows directly with the number of cycles.
Time Complexity: O(n)
This means the time to run the simulation grows in a straight line as we add more cycles.
[X] Wrong: "The simulation time stays the same no matter how many cycles run."
[OK] Correct: Each cycle repeats all steps, so more cycles mean more total time.
Understanding how simulation loops scale helps you explain performance in real drone software testing. It shows you can think about how code runs over time.
"What if we added a nested loop inside simulate_physics that checks every drone part each cycle? How would the time complexity change?"