Teaching pack · UAT 305
A 15-week teaching plan, 5 worksheets, a scoring rubric and a map from the course description to the lessons, for instructors to evaluate and adapt before teaching.
Coverage of the course description
The lessons fully teach 10 of 10 description topics. Each topic lists the modules and lesson sections that teach it, and incomplete topics say what is missing.
| Description topic | Modules | Where it is taught | Status |
|---|---|---|---|
| Flight dynamics | M2 | Module 2: Flight dynamics: forces and moments (rigid-body translation and rotation equations, thrust and horizontal acceleration when tilted, moments from thrust differences, thrust headroom), with Example 3 and step 5 of the lab | Covered |
| State estimation | M3 | Module 3: the two steps of a Kalman filter, and testing innovations before using data | Covered |
| Control loops | M1M2 | Module 1: from sensors to motors (main loop and scheduler) and delay eats phase · Module 2: nested angle and rate loops | Covered |
| Stabilization | M2 | Module 2: ArduPilot's attitude controller and limiting angular acceleration | Covered |
| Position and path control | M5 | Module 5: The position loop and path following (position P, velocity PID, acceleration to lean angle, feedforward and AC_WPNav, cross-track error), with Example 3 on a crosswind and the I term | Covered |
| PID and related control algorithms | M2M4 | Module 2: angle P, rate PID and feedforward · Module 4: notch, harmonic notch, and low-pass filters and phase | Covered |
| Autopilot hardware and software architectures | M1 | Module 1: From sensors to motors (ArduPilot's main loop and PX4's uORB) and Autopilot hardware (FMU processor, three redundant IMUs with several EKF3 cores, UART, CAN, I2C and DroneCAN buses, ESCs with PWM and DShot), with Example 3 and step 6 of the lab | Covered |
| Tuning | M2M4 | Module 2: effect of outer-loop gain · Module 4: the log-based tuning process | Covered |
| Simulation | M1M2M3M5 | SITL labs in modules 1, 2, 3 and 5, such as simulated GPS glitches and GCS link loss | Covered |
| Performance testing | M1M5 | Module 1: performance (PM) messages and scheduler load · Module 5: The test plan and Flight performance testing (position-tracking accuracy from PSCN/PSCE, RMS and maximum, error to target versus cross-track error, limits of EKF positions), with Example 4 and step 5 of the lab | Covered |
Weekly teaching plan
| Week | Topic | Pre-class | Lecture | Lab | Evidence |
|---|---|---|---|---|---|
| 1 M1 | From sensors to motors: the main loop and uORB | Read module 1 up to 'From sensors to motors' | SCHED_LOOP_RATE, fast tasks and PX4 publish/subscribe | In class: read the scheduler_tasks table in ArduCopter/Copter.cpp together and pick 10 tasks · Self-study: Worksheet 1 part A, build the table of the 10 tasks with rates and expected times | Table of tasks, rates and expected times |
| 2 M1 | Scheduler load | Run Example 1 | Load when the loop rate rises, and deferring low-priority tasks | In class: compute load with Example 1 and read PM messages in a SITL log · Self-study: Worksheet 1 part B, change SCHED_LOOP_RATE in SITL, observe, restore it and compare computed load with real loop time | Computed load against real loop time |
| 3 M1 | Delay eats phase; autopilot hardware | Read the delay and autopilot-hardware sections; run Examples 2–3; take the module 1 quiz | Phase lag ωτ · the FMU board, redundant IMUs, buses and ESC protocols versus delay | In class: estimate total delay and compute the phase lost with Example 2 and compare with PX4's structure, with the lecturer showing the lab board (unpowered, no propellers) · Self-study: Worksheet 1 part C, draw the board hardware diagram from the manufacturer documents and compute output delay with Example 3 | Worksheet 1 short report and quiz result |
| 4 M2 | ArduPilot's attitude controller | Read module 2 up to the attitude controller | Angle P, rate PID and feedforward | In class: log step tilt commands in SITL and compare desired and actual values in RATE and ATT · Self-study: Worksheet 2 part A, plot both loops from the log | Plots of both loops from the log |
| 5 M2 | Too much outer-loop gain | Run Example 1 | An outer loop faster than the inner loop, overshoot and oscillation | In class: try three values of ATC_ANG_RLL_P within the allowed range in SITL and compare with Example 1 · Self-study: Worksheet 2 part B, make the table of results for three values, restore defaults and explain the overshoot or oscillation | Results for three values |
| 6 M2 | Limiting angular acceleration; flight dynamics | Read the angular-acceleration and flight-dynamics sections; run Examples 2–3; take the module 2 quiz | Time to tilt 20° at different accelerations · equations of motion, forces and moments, thrust headroom | In class: try the documented ATC_ACC_R_MAX presets in SITL, compare rotation times, then restore defaults · Self-study: Worksheet 2 part C, compute the training drone's thrust headroom with Example 3 from its mass, arm length and the maximum-thrust data in the manufacturer documents | Recommended values for the training drone, and quiz result |
| 7 M3 | The two steps of a Kalman filter | Read module 3 up to the Kalman filter section; run Example 1 | Predict and update; height from an accelerometer and a barometer | In class: change Q and R in Example 1 and see which sensor the filter trusts more · Self-study: Worksheet 3 part A, plot at least three Q and R settings | Plots comparing Q and R settings |
| 8 M3 | Testing innovations before using data | Read the innovation test section; run Example 2 | Innovation gates, variances and rejected GNSS positions | In class: open a SITL log and track the SV, SP, SH and SM fields of XKF4 through the flight · Self-study: Worksheet 3 part B, plot the XKF4 test ratios and compute the largest accepted innovation with Example 2 | XKF4 test ratio plots |
| 9 M3 | GPS glitches; midterm | Review modules 1–3; take the module 3 quiz | Midterm examination (modules 1–3) | The midterm takes the class period, so there is no in-class practice · Self-study: Worksheet 3 part C, simulate a GPS glitch in SITL, see when SP exceeds 1 and write an EKF health guide | Worksheet 3 report and midterm score |
| 10 M4 | Notch and harmonic notch | Read module 4 up to the notch section; run Example 1 | Motor frequency with throttle and the attenuation of an 80 Hz notch | In class: open the hover log prepared by the lecturer (with detailed IMU data), view the spectrum in FilterReview and find the motors' fundamental · Self-study: Worksheet 4 part A, compute notch attenuation with Example 1 and keep the spectrum image | Spectrum image and fundamental frequency |
| 11 M4 | Low-pass filters and phase | Read the low-pass filter section; run Example 2 | Cutoff frequency and phase at an 8 Hz crossover | In class: choose INS_HNTCH_* values from the spectrum and simulate the notch on the raw log data with Python · Self-study: Worksheet 4 part B, compare the spectra before and after filtering (also against a post-notch log if the lecturer has one) | Spectra before and after the notch |
| 12 M4 | The log-based tuning process | Read the tuning process section; take the module 4 quiz | Fix vibration before tuning PID, and change one value at a time | In class: try low-pass cutoffs in SITL, compute the phase and log every change in the configuration register · Self-study: Worksheet 4 part C, finish the configuration register so every change can be traced and restored | Configuration register and quiz result |
| 13 M5 | Types of geofence in ArduPilot | Read module 5 up to the geofence types; run Example 1 | Inclusion and exclusion fences, FENCE_TYPE and FENCE_ACTION | In class: draw inclusion and exclusion fences in the GCS, upload to SITL and check points with Example 1 · Self-study: Worksheet 5 part A, fly towards the fence in SITL and record the stopping distance and action | Point check results and observed stopping distance |
| 14 M5 | Proving the GCS failsafe from a log; the position loop | Read the failsafe and position-loop sections; run Examples 2–3; take the module 5 quiz | Missing heartbeats and when the failsafe must act · position loop, velocity loop and path following | In class: cut the GCS link in SITL and collect heartbeat and mode-change times from the log · Self-study: Worksheet 5 part B, check the event times with Example 2 and make the event timing table | Event timing table and quiz result |
| 15 M5 | The test plan and flight performance testing; mini-project presentations | Read the test-plan and performance-testing sections; run Example 4; prepare the test report | Course wrap-up and project criteria | The class period is used to present the failsafe, geofence and performance test report with firmware version and parameters · Self-study: Worksheet 5 part C, test position-tracking accuracy in SITL with Example 4 before submitting the report | Mini-project report and presentation, scored with the rubric |
Worksheets and instructor guide
One worksheet per module. Students open it on the web, print it or download the .docx. The instructor guide under each worksheet gives the class timing, expected results, discussion questions and notes for students with different backgrounds.
1Worksheet 1 Exploring timing in the autopilot
Lab · About 3 h of class time · CLO1
Objective: Assess scheduler load and loop delay and link them to the phase lost
Equipment
- ArduCopter source for the version in use
- ArduPilot SITL and a log viewer
- Python and the module 1 example code
- PX4 uORB documentation
- Manufacturer documents of the lab's flight controller board (and the board itself, shown in class by the lecturer)
Safety
- Simulation and desk work only; no real flights
- A board shown in class must be unpowered and have no propellers fitted
Steps
- In class: read scheduler_tasks and pick 10 tasks
- Self-study: compute the load of the 10 tasks with Example 1 and build the table of tasks, rates and expected times
- In class: run SITL and compare PM messages in the log with the expected loop time
- Self-study: change SCHED_LOOP_RATE in SITL, observe, then restore
- In class: estimate total delay from Figure 1 and compute the phase lost with Example 2
- In class: compare with PX4's structure from the uORB documentation
- Self-study: draw how the board connects IMUs, GPS, ESCs and buses from the manufacturer documents, check MOT_PWM_TYPE and EK3_IMU_MASK, and compute output delay with Example 3
Deliverables
- Task load table
- Loop timing comparison from the log
- Phase calculation
- ArduPilot versus PX4 comparison
- Board hardware diagram and output-delay table
Checklist
- Table 1 lists all 10 tasks, each with rate, expected time and share in %, with a total, and names the firmware version of the source read
- Table 2 computes phase with 360 f τ after converting ms to s, and shows the remaining margin in every row
- The original SCHED_LOOP_RATE, the value tried, and confirmation that the original was restored in SITL are recorded
- The hardware diagram cites the manufacturer documents used and gives the MOT_PWM_TYPE and EK3_IMU_MASK values actually read
Instructor guide
Class timing
- Review of the main loop, SCHED_LOOP_RATE and uORB20 min
- Read scheduler_tasks and fill in Table 145 min
- Run SITL, read PM messages, try a loop rate and restore it40 min
- Estimate total delay, compute phase and compare with PX435 min
- View the real board (unpowered, no propellers) and start the hardware diagram30 min
- Wrap-up and hand-in checklist10 min
Expected results
- Table 1: numbers depend on the tasks chosen and the source version. With the lesson's Example 1 values (Copter 4.7.1): fast loop 400 Hz × 700 µs = 28.0%, rc_loop 250 Hz × 130 µs = 3.25%, fence_check 25 Hz × 100 µs = 0.25%, ekf_check 10 Hz × 75 µs = 0.075%; these four total 31.6% of the 2,500 µs loop period. Ten chosen tasks should total about 30-40% if they include the assumed 700 µs fast loop (the real value depends on the board). Accept ±0.1 point from rounding.
- Table 2: using the delays in Figure 1 (IMU ~1 ms, filtering ~5 ms, EKF ~2.5 ms, controller to ESC ~3 ms), the total is 11.5 ms, which at an 8 Hz crossover costs 33.1° and leaves 26.9° of the 60° margin. From Example 2: 8 ms costs 23.0° (37.0° left), 12 ms costs 34.6° (25.4° left), 20 ms costs 57.6° (2.4° left), and the margin is gone at 20.8 ms. Accept a different delay estimate if 360 f τ is applied correctly.
- Table 3: values read from the board depend on the lab's board (the lesson's example is the Pixhawk 6X: STM32H753 FMU at 480 MHz, 3 IMUs, 4 UARTs, 2 CAN buses, 1 I2C port). Output delays from Example 3: 50 Hz PWM 12.00 ms (34.6°), 490 Hz PWM 3.02 ms (8.7°), DShot150 at 400 Hz 1.36 ms (3.9°), DShot600 at 400 Hz 1.28 ms (3.7°). A 100-byte GPS message at 10 Hz uses about 8.7% of a 115200 bit/s UART.
- The fast loop (rate controller and motors) uses the most because it runs every cycle at 400 Hz with the largest time per run. At 800 Hz it would need 800 × 700 µs = 56% of all time and the loop period drops to 1,250 µs, so other tasks get deferred, which shows in the PM messages. A strong answer notes that the documentation calls values above 400 Hz experimental.
- With 11.5 ms, 26.9° remains, and the margin is gone at 20.8 ms. A strong answer points out that a low filter cutoff adds delay and so cuts the margin directly, and the loop can oscillate even with unchanged PID values.
- 50 Hz PWM costs 34.6° against 3.7° for DShot600, a difference of about 31°, more than half the 60° margin. DShot150 and DShot600 differ by only 0.08 ms (0.2°) because sending a 16-bit frame (106.7 µs or 26.7 µs) is tiny compared with the average half-period wait of 1.25 ms. The difference comes mostly from the update rate, not the bit rate, so DShot150 suits long leads at little cost in time.
- EKF3 runs one core per IMU selected; all cores run in parallel, the healthiest core's output is used, and the vehicle can switch cores (lane switching) when one IMU fails or vibrates badly. On software, ArduPilot uses a main loop and a task table with rates, times and priorities, while PX4 splits into modules that publish and subscribe to messages through uORB, with the rate loop running at the IMU_GYRO_RATEMAX rate (default 400 Hz).
Discussion questions
- If a drone oscillates after moving to a new board with the same PID values, what timing checks come before retuning?
- What does raising the loop rate trade against what, and when is it worth it?
- Why can low-priority tasks such as logging be deferred while the rate controller cannot?
Adapting to student background
- Upper secondary (M.6)
- Have them write U = Σ f t and φ = 360 f τ with units before substituting and predict results before running code; pair them with a SITL-confident peer when opening logs.
- Vocational certificate
- Start by handling the real board and pointing out the ports, then give a fill-in table that converts µs and ms to s step by step; let them check with a calculator alongside the code.
- Diploma
- Extension: compare the output delay of 490 Hz PWM and DShot, then propose a protocol and ports for the lab's large drone with long ESC leads, with reasons.
2Worksheet 2 Nested loops in SITL
Lab · About 3 h of class time · CLO1, CLO3
Objective: Observe the angle and rate loops in logs and the effect of gain and acceleration limits
Equipment
- ArduPilot SITL and a GCS
- Log viewer
- Python and the module 2 example code
- The training drone's mass, arm length and maximum-thrust data from the manufacturer or supplied by the lecturer
Safety
- Simulation only; no real flights
- Never use trial values on a real drone without review
Steps
- In class: log step tilt commands in Stabilize or AltHold
- Self-study: compare desired and actual values of both loops in RATE and ATT and plot them
- In class: try three ATC_ANG_RLL_P values in range and compare with Example 1
- In class: try the documented ATC_ACC_R_MAX presets and compare rotation times with Example 2
- Self-study: take the mass, arm length and maximum thrust from motor and propeller data and compute headroom and angular acceleration with Example 3
- Self-study: restore all defaults and record conclusions
Deliverables
- Plots of both loops
- Table of gain and acceleration results
- Recommended values for the training drone
- Table of the training drone's thrust headroom and accelerations
Checklist
- Table 1 has all three values, each within 3-12, and names the log message (RATE or ATT) used to measure them
- Parameters were changed one at a time, with the original value, the value tried and confirmation of every restore recorded
- Every value in Table 3 has a unit and a source for mass, arm length and maximum thrust, and uses the L/√2 arm for an X frame
- The recommended values for the training drone are clearly marked as SITL results not to be used on a real drone before review
Instructor guide
Class timing
- Review the angle and rate loops and the safety rule for trial values20 min
- Step tilt commands in SITL and plot RATE and ATT45 min
- Try three ATC_ANG_RLL_P values, compare with Example 1, restore40 min
- Try the documented ATC_ACC_R_MAX presets, compare with Example 2, restore30 min
- Compute the training drone's thrust headroom with Example 330 min
- Summarise suitable values and hand-in checklist15 min
Expected results
- Table 1: SITL values differ from the model, so look mainly at the trend. The Example 1 model gives: P 3 rise 0.53 s, overshoot 1.8%, settle 0.64 s; P 4.5 rise 0.37 s, 12.3%, 1.25 s; P 9 rise 0.23 s, 40.0%, 1.55 s; P 12 rise 0.20 s, 54.4%, 1.96 s. An acceptable result shows rise time falling and overshoot growing as P rises.
- Table 2 (Example 2): 1100 deg/s² takes 0.27 s with a 148.3 deg/s peak rate; 1080 takes 0.27 s, 147.0 deg/s; 720 takes 0.33 s, 120.0 deg/s; 300 takes 0.52 s, 77.5 deg/s. Times measured from the log should be slightly longer than computed because of command smoothing with ATC_INPUT_TC (0.10 s in 4.7.1) and the loop's own response time.
- Table 3: depends on the real training drone. With the Example 3 values (1.6 kg, 0.25 m arm, J 0.015 kg·m², 8 N maximum thrust per motor): hover 3.92 N per motor (49%), headroom 3.92 N, maximum roll torque 2.77 N·m, angular acceleration about 10,599 deg/s², of which the 1100 deg/s² default uses about 10%. Tilts of 10°, 20° and 30° need total thrust of 15.94 N (50%), 16.70 N (52%) and 18.12 N (57%) and give horizontal accelerations of 1.73, 3.57 and 5.66 m/s².
- A stronger outer loop commands rotation rates faster than the inner loop can follow, so the angle shoots past the target and swings back. SITL numbers differ from the model because the model is not in ArduPilot units (except the angle gain) and ArduPilot adds feedforward and a square-root controller that reduce overshoot. A strong answer concludes that the inner loop is tuned first and the outer loop raised afterwards.
- Check ATC_ACC_R_MAX first. At a low value such as 300 deg/s², tilting 20° takes 0.52 s, almost twice the 0.27 s at 1100 deg/s², regardless of gain. Raising the gain fixes the wrong thing and adds overshoot, matching the lesson's common mistakes.
- The example value is 49%. Hovering at 80% (6.4 N per motor, total mass about 2.61 kg) leaves 1.60 N of headroom, 41% of before, a torque of 1.13 N·m and about 4,322 deg/s² (assuming J unchanged; in reality J rises and lowers it further). The rate loop then has far less authority against gusts.
- a = g tan 30° = 5.66 m/s² using 57% of total thrust. It is the acceleration ceiling the position loop in Module 5 can command; if wind or turns need more, the acceleration is limited and the position error grows.
Discussion questions
- How should ATC_ACC_R_MAX differ between a camera drone and a racing drone, and why?
- What can model or SITL results tell you about a real drone, and what can they not?
- Before flying with a heavier payload, what would you check to know there is still enough thrust headroom?
Adapting to student background
- Upper secondary (M.6)
- Have them write T = mg/cos θ and a = g tan θ and check against practice question 2 (2 kg at 20° gives 20.9 N and 3.57 m/s²) before using the training drone data; give extra time with the GCS and SITL.
- Vocational certificate
- Let them weigh the training drone and measure its arm length themselves (propellers and battery removed), then fill Table 3 line by line with a template that already converts degrees to radians.
- Diploma
- Extension: use the Example 1 model to find an inner-loop gain that keeps overshoot at P 4.5 below 10%, and explain why a faster inner loop helps.
3Worksheet 3 Reading EKF health
Lab · About 3 h of class time · CLO2
Objective: Understand the effect of Q and R and read EKF test ratios from logs to judge readiness to fly
Equipment
- Python and the module 3 example code
- ArduPilot SITL
- Log viewer
Safety
- Simulation only; no real flights
Steps
- In class: change Q and R in Example 1 and see which sensor the filter trusts more
- Self-study: plot at least three Q and R settings
- In class: open a SITL log and track SV, SP, SH and SM of XKF4
- Self-study: simulate a GPS glitch in SITL and see when SP exceeds 1 and what the EKF does
- Self-study: compute the largest accepted innovation with Example 2 from the log variances
- Self-study: write an EKF health guide for the field team
Deliverables
- Q and R comparison plots
- XKF4 plots for normal and glitch periods
- One-page EKF health guide
Checklist
- Table 1 has at least three Q and R sets, including the Example 1 default, with a plot for each
- Table 2 separates normal and glitch periods, gives the time SP exceeds 1, and reads SV, SP, SH and SM as square-root test ratios, not variances
- The glitch method and the SITL parameters changed are recorded, with confirmation they were restored
- The EKF health guide gives clear criteria (for example above 1 means rejected) and what the team must do before flight, in one page or less
Instructor guide
Class timing
- Review the predict and update steps and what an innovation is20 min
- Change Q and R in Example 1 and fill in Table 145 min
- Open a SITL log and read XKF4 in normal flight30 min
- Simulate a GPS glitch and fill in Table 240 min
- Compute the largest accepted innovation with Example 2 and draft the EKF health guide35 min
- Wrap-up and hand-in checklist10 min
Expected results
- Table 1 (simulated data of Example 1, seed 3, true final height 3.98 m): Q = diag(1e-5, 1e-3), R = 0.25 m² gives RMS 0.08 m (barometer alone 0.50 m, accelerometer alone 26.7 m off at 30 s); R = 0.0025 m² gives 0.15 m (trusts the barometer, chases noise); R = 25 m² gives 0.09 m (trusts the accelerometer, follows slowly); Q = diag(1e-3, 1e-1) gives 0.15 m (trusts the barometer more); Q = diag(1e-7, 1e-5) gives 0.09 m. With another seed numbers may differ by about ±0.02 m but the trend must be the same.
- Table 2: in normal flight SV, SP, SH and SM should stay clearly below 1 (usually no more than about 0.3-0.5 in SITL). During the glitch SP jumps above 1 as soon as the GNSS position jumps; the exact value depends on the glitch size the lecturer sets. The EKF rejects positions while SP > 1 and may reset to the new GNSS position if rejection lasts long.
- Part 3: largest accepted innovation = (gate/100) × √S. With S = 4 m² as in Example 2 it is 10.0 m (innovations of 0.8, 1.5, 3.9 and 9.2 m are used, logged as 0.08, 0.15, 0.39 and 0.92; 12.0 m is rejected, logged as 1.20). With another S from the log, for example 1 m², it is 5.0 m. A good guide says an XKF4 value above 1 means rejected and a value near 1 means find the cause before flying.
- A very small R (0.0025 m²) makes the RMS worse, from 0.08 to 0.15 m, because the filter trusts a barometer with 0.5 m noise and chases the noise (the height Kalman gain rises from about 0.036 to 0.121). A strong answer says R should reflect the sensor's real variance (0.5² = 0.25 m²).
- SP exceeds 1 from the moment the glitch starts. The EKF rejects position data then and relies on accelerometer prediction; if rejection lasts long, the estimate drifts and the EKF may reset to the new GNSS position, making the position jump.
- 5 × √2.25 = 7.5 m. SP = 0.6 means the innovation is at 60% of the gate boundary, so the data is used (test ratio 0.36 < 1).
- Widening the gate lets wrong data in, such as positions jumping from multipath, which corrupts the estimate. The warning says the sensors disagree, so the cause must be found, such as vibration, GNSS signal or compass. A strong answer cites the lesson's common mistakes.
Discussion questions
- If prop wash hits the barometer, should you raise R or fix the mounting, and why?
- What should the field team check before every flight, and when should they decide not to fly?
- Why can airframe vibration corrupt the EKF even when GNSS is fine?
Adapting to student background
- Upper secondary (M.6)
- Use school statistics (mean, variance, standard deviation) to explain R and a 5-standard-deviation gate before the lab, and pair them with a SITL-confident peer.
- Vocational certificate
- Focus on reading plots and the working rule (below 1 used, above 1 rejected); give a code template where only Q and R can be edited, and have them compute (gate/100) × √S on a calculator.
- Diploma
- Extension: simulate two glitch sizes, compare which one the EKF rejects and resets on and which it accepts, then write a pre-flight check for the lab drone.
4Worksheet 4 Setting the harmonic notch from a recorded log
Lab · About 3 h of class time · CLO3
Objective: Find vibration frequencies in logs, set the harmonic notch and understand the phase cost of low-pass filters
Equipment
- A hover log with detailed IMU data from the ArduPilot training drone, prepared by the lecturer
- FilterReview tool
- ArduPilot SITL
- Python and the module 4 example code
Safety
- Desk and simulation work; students do not fly in this course
- The lecturer's log must come from a flight made within CAAT conditions by an authorised pilot outside class time
- Remove propellers whenever editing parameters on a real drone, and never apply values that have not been reviewed
Steps
- In class: open the hover log, view the spectrum in FilterReview and find the motors' fundamental
- Self-study: compute notch attenuation with Example 1
- In class: choose INS_HNTCH_* for the supported mode and simulate the notch on the raw log data with Python
- Self-study: compare the spectra before and after filtering
- In class: try low-pass cutoffs in SITL and compute the phase with Example 2
- Self-study: record every change in the configuration register
Deliverables
- Spectra before and after the notch
- Attenuation and phase calculations
- Configuration register
Checklist
- Table 1 gives the fundamental and harmonics with spectrum images before and after filtering, and names the log they came from
- Table 2 computes the phase with the second-order Butterworth formula for all three cutoffs and shows the remaining margin
- The configuration register lists every change, one value at a time, and every row says whether it was restored
- The proposed INS_HNTCH_* values are clearly marked as unreviewed and not to be set on a real drone before the lecturer checks them
Instructor guide
Class timing
- Review notch and low-pass filters and the log-based tuning order20 min
- Open the log in FilterReview and find the fundamental and harmonics40 min
- Compute attenuation with Example 1 and choose INS_HNTCH_*35 min
- Simulate the notch on raw data with Python and compare spectra35 min
- Try low-pass cutoffs in SITL and compute phase with Example 235 min
- Finish the configuration register and hand-in checklist15 min
Expected results
- Table 1: frequencies depend on the lecturer's log. A motor at 5,400 rpm has a 5400/60 = 90 Hz fundamental (4,800 rpm = 80 Hz), with harmonics at two and three times. Attenuation of the prototype notch at f0 80 Hz, BW 40 Hz (Q = 2) from Example 1: 60 Hz -2.4 dB, 80 Hz very deep (limited in practice by INS_HNTCH_ATT 40 dB), 83 Hz -16.7 dB, 90 Hz -7.4 dB, 100 Hz -3.5 dB, 160 Hz -0.5 dB. The filtered peak must be clearly lower at the set frequency.
- Table 2 (Example 2, second-order Butterworth, 8 Hz crossover): 40 Hz cutoff gives -16.4°, leaving 43.6°; 20 Hz (the INS_GYRO_FILTER default) -34.0°, leaving 26.0°; 10 Hz -72.3°, a margin of minus 12.3°, so unstable. In SITL more oscillation should appear as the cutoff falls.
- Table 3: every row has old and new values, for example INS_HNTCH_ENABLE 0 to 1, INS_HNTCH_FREQ at the fundamental found, INS_HNTCH_BW about half the fundamental, INS_HNTCH_MODE to suit the hardware, and the INS_GYRO_FILTER values tried in SITL. Every row cites the log file name and is restored.
- If the fundamental in the log moves with throttle, it comes from the motors. A notch at 80 Hz removes only 16.7 dB at 83 Hz and 7.4 dB at 90 Hz compared with a very deep cut at the centre, so the notch must track the real frequency.
- If the ESCs report motor speed (bi-directional DShot or ESC telemetry), use MODE 3, which the documentation calls generally the best; otherwise MODE 1 (throttle) or 4 (in-flight FFT). A strong answer links this to the ESC hardware surveyed in Worksheet 1.
- At 10 Hz the phase lag is 72.3°, more than the 60° margin, so the loop becomes unstable and oscillates. The 80 Hz notch adds only 2.9° at 8 Hz because it acts on a narrow band around the motor frequency, far from crossover.
- A strong answer says a register with old value, new value, reason and before-and-after logs makes changes traceable; changing several at once hides which one helped or hurt and makes restoring hard, matching the lesson's common mistakes.
Discussion questions
- Why fix mechanical vibration before setting filters and tuning PID?
- Without a log flown after setting the notch, how far can a Python simulation confirm the result?
- Who should approve parameter values before they go on a real drone, and what evidence is needed?
Adapting to student background
- Upper secondary (M.6)
- Review frequency, decibels and phase with familiar sound waves first, then have them substitute one frequency by hand before running the code.
- Vocational certificate
- Focus on reading spectrum images, finding peaks and noting frequencies; give a complete configuration-register template and start with converting rpm to Hz by dividing by 60.
- Diploma
- Extension: compare spectra at two throttle levels in the same log and argue for a fixed or tracking notch with attenuation figures.
5Worksheet 5 Testing failsafes and geofences in SITL
Lab · About 3 h of class time · CLO3
Objective: Check missions against fences before flight, prove from logs that failsafes act on time, and measure position-tracking accuracy
Equipment
- ArduPilot SITL and a GCS
- Log viewer
- Python and the module 5 example code
Safety
- Simulation only; no real flights
Steps
- In class: draw inclusion and exclusion fences in the GCS, upload to SITL and set FENCE_TYPE and FENCE_ACTION
- In class: export fence and mission points and check them with Example 1
- Self-study: fly towards the fence in SITL and observe stopping distance and action
- In class: cut the GCS link in SITL and collect heartbeat and mode-change times from the log
- Self-study: check the event times with Example 2 and make the failsafe event timing table
- Self-study: fly a 200 m line out and back in SITL with a simulated crosswind, extract PSCN and PSCE and assess error with Example 4 before and after changing PSC_NE_VEL_I
- Self-study: write a test report with firmware version and parameters
- In class (week 15): present the report
Deliverables
- Fence point check results
- Failsafe event timing table
- Test report
- RMS and maximum error table before and after the change
Checklist
- Table 1 checks every fence and mission point with the program and records the FENCE_TYPE, FENCE_ACTION and FENCE_MARGIN actually set
- The test plan states pass criteria before testing (for example within 0.5 s of the expected time, RMS and maximum error limits) and every result is proven with log messages
- Table 3 names the error type, flight speed and simulated wind, and only PSC_NE_VEL_I was changed and then restored
- The test report gives the firmware version, the parameter file and the limits of SITL results
Instructor guide
Class timing
- Review fence types, the GCS failsafe and pass criteria in the test plan20 min
- Draw fences, upload to SITL and check points with Example 135 min
- Fly towards the fence in SITL and record the action25 min
- Cut the GCS link and check event times with Example 235 min
- Fly the 200 m line in a simulated crosswind and assess error with Example 450 min
- Summarise the report and hand-in checklist15 min
Expected results
- Table 1: with the Example 1 fences (400 × 300 m inclusion, exclusion around a building at 250-320 × 120-200 m, FENCE_MARGIN 2 m): (100, 100) ok, 100 m from an edge; (398.5, 150) within the margin, 1.5 m away; (300, 150) breach, inside the exclusion zone; (410, 50) breach, outside the inclusion fence. The SITL stopping distance depends on speed and FENCE_ACTION (default 1 = RTL or land); the lesson's pass criterion is a breach of no more than 2 m.
- Table 2 (Example 2, FS_GCS_TIMEOUT 5 s): the last heartbeat before the link loss is at 10 s with a 6.4 s gap, so the failsafe should act at 15.0 s; the log records RTL at 15.2 s, +0.2 s, within the ±0.5 s criterion. The largest gap that did not trigger it is 1.1 s. Real SITL numbers will differ, but the action must come about 5 s after the last heartbeat.
- Table 3 (simulated data of Example 4, 200 m line at 8 m/s, criteria RMS ≤ 0.8 m and maximum ≤ 1.5 m): error to target RMS 1.35 m, maximum 1.63 m, FAIL; cross-track error RMS 0.65 m, maximum 1.20 m, PASS. Before and after PSC_NE_VEL_I in SITL depends on the wind set; the Example 3 model (4 m/s wind) gives, without I: maximum 0.60 m, RMS 0.57 m, steady 0.60 m; with I = 1.0: maximum 0.40 m, RMS 0.14 m, steady 0.00 m.
- It is not a breach; the point is still inside the fence but within the margin, which ArduPilot uses to keep missions from getting too close to the edge. Checking with a program before upload catches misplaced points, such as one inside an exclusion zone, before flight.
- It acted as configured if the difference is within 0.5 s (the example is +0.2 s). If it differs a lot, check that FS_GCS_ENABLE is set correctly and whether another GCS is still sending heartbeats, and beware of confusing log time with GCS screen time.
- Error to the target includes lag along the path (about 1.1-1.3 m throughout in the example), so it fails, while cross-track error measures how far the aircraft leaves the line, so it passes. Corridor surveys and staying inside fences call for cross-track error. A strong answer says the test plan must name the error type in advance.
- The I term accumulates error until the aircraft leans about 7° into the wind with no steady error, so the steady error disappears and the peak is smaller (model: 0.60 to 0.40 m). The logged position is the EKF's estimate; if GNSS is 2 m off, both log and controller see a straight flight while the whole aircraft is in the wrong place, so an external measurement such as RTK GNSS is needed.
Discussion questions
- Which SITL tests still need a real test in a safe area, and which should come first?
- If the wind needs more lean than ATC_ANGLE_MAX, what happens to the error and to stopping before the fence?
- Why is drawing an exclusion fence over the take-off point dangerous?
Adapting to student background
- Upper secondary (M.6)
- Have them compute RMS by hand from practice question 2 (0.2, 0.4, 0.4, 0.8 m gives 0.5 m) and explain the FENCE_TYPE bitmask in binary before working in SITL.
- Vocational certificate
- Focus on step-by-step GCS work with an illustrated step sheet; get them drawing fences and reading log times first, then use example code where only the inputs are edited.
- Diploma
- Extension: design a test plan covering every failsafe and fence type set, with pass criteria, and propose the first real test at low altitude in a safe area.
Scoring rubric
For worksheets and the mini-project. Each criterion scores level (1–4) ÷ 4 × weight.
| Criterion | Weight | Excellent (4) | Good (3) | Fair (2) | Needs work (1) |
|---|---|---|---|---|---|
| Accuracy of calculations and log analysis | 30% | All numbers and log readings correct, citing the right log messages | Nearly all correct | Some errors or missing log evidence | Many errors or no log used |
| Systematic tuning and configuration control | 25% | One change at a time, full configuration register, always restorable | Mostly systematic | Incomplete records or several changes at once | Not traceable |
| Test design and proof | 25% | Test plan covers every type with pass criteria set in advance and proven with logs | Nearly complete coverage | Missing pass criteria or cases | No test plan |
| Safety and reporting | 20% | Follows all safety rules (no trial values applied to a real drone without review); clear report with firmware versions and limits | Nearly complete | Some key points missing | Ignores safety or no report |
Assessment map: CLOs and how they are assessed Draft
The CLOs are a web-team draft; the course owner sets the final ones (curriculum book, part 4). This table is built from the worksheet and module-quiz data, so it follows any change to the CLOs.