Deep Dives — Algorithms and Sensor Methods

This section explains the sensor processing, control theory, and geometry behind raccoon’s key built-in algorithms. You do not need to read this to use the SDK — the high-level steps handle everything — but this material helps when:

  • tuning PID gains or thresholds and you want to understand why a parameter exists
  • debugging unexpected behavior (oscillation, false triggers, drift)
  • implementing a custom step that reuses the same ideas

Mental model

Every algorithm here follows the same three-phase pattern:

  Sense  →  Compute  →  Act
PhaseWhat happens
SenseRead one or two calibrated IR sensors, an IMU, or a light sensor
ComputeApply a control law (PID, geometry, Kalman filter) to produce a correction
ActApply a velocity override to the drive, or signal a stop

The pages in this section go from beginner-relevant (line following, lineup, wait-for-light) to more diagnostic (IR calibration internals, wall alignment parameters).

Pages in this section

PageCore ideaWhen you need it
Line FollowingPID error from sensor difference → angular or lateral velocity correctionAny surface-tracking mission
LineupSingle-pass stagger geometry → exact turn angle, no iterationSquaring up before a pickup or delivery
Wait for LightKalman baseline + relative-drop trigger for the start lampEvery competition run
Wall AlignmentIMU linear-acceleration spike → settle-then-stop, heading resetRe-localization after odometry drift
IR Sensor Calibration (K-Means)K-Means clustering separates black/white readings robustlyUnderstanding calibration quality or debugging mis-triggers

Reading order

If you are new: read Line Following first (it explains the PID error signal used everywhere), then Lineup (pure geometry, no tuning), then Wait for Light (competition workflow). Come back to Wall Alignment and IR Calibration when you need to tune or debug.

Cross-links:

  • IR calibration produces the probabilityOfBlack() values that line following and lineup consume — see IR Sensor Calibration
  • After wall alignment, call mark_heading_reference() to lock in the corrected heading for subsequent turns — see Wall Alignment
  • Multiple calibration sets (for different floor surfaces) are covered in Calibration