Swerve Chassis & Power Control
Algorithm & Embedded Development · Independently Built and Open-Sourced
Built regression features from motor speed and torque, used measured total power from the supercapacitor or conditionally trusted referee data as the label, and integrated online identification, allocation, and energy constraints into a 1000 Hz control task.
- Identification
- 1000 Hz task; RLS updates only when label and dead-zone conditions hold
- Hardware dependency
- Existing motor feedback and system-level power data; no additional bus sensor
- Reuse
- Mecanum / omni / swerve / wheel-legged
- Season result
- Zero over-power health deductions
Background
Built regression features from motor speed and torque, used measured total power from the supercapacitor or conditionally trusted referee data as the label, and integrated online identification, allocation, and energy constraints into a 1000 Hz control task.
The module was reused on mecanum, omni, swerve, and wheel-legged chassis, with public code and documentation. The 2024 team incurred no referee health deductions from chassis over-power.
1000 Hz is the 1 ms FreeRTOS power-task period, not a claim that RLS updates on every cycle; updates also depend on label trust, dead zones, energy state, and disconnect conditions.
My contribution
- Built regression features from motor speed and torque, with valid measured total power as the RLS label.
- Implemented RLS estimation, power-budget allocation, allowable-torque inversion, and the energy loop.
- Defined degradation paths for referee, supercapacitor, and individual-motor disconnects.
- Adapted the module to multiple chassis, validated it on hardware, and published code and documentation.
- Technical environment
- STM32 · FreeRTOS · 1 kHz Power-Control Task · Online Power Model · Energy Loop · Swerve Kinematics · Fault Degradation
Implementation
Feedback validity
Motor feedback forms the features; supercapacitor chassis power, or conditionally trusted referee power during degradation, supplies the measured label.
Online model
The power-control task runs every 1 ms; RLS updates model parameters only when label trust, dead-zone, and connection conditions hold.
Power allocation
Speed error and predicted power determine each motor's budget before allowable torque is solved.
Energy and degradation
Referee buffer or supercapacitor energy adjusts the total limit; label availability, energy state, and disconnect combinations determine whether identification continues.
Disconnect conditions and actual behavior
| Input state | Model update | Power / energy limit | Output behavior |
|---|---|---|---|
| Referee, supercapacitor, and motor feedback valid | Motor speed / torque form features; capacitor chassis power is the label, and RLS updates when dead-zone conditions hold | Referee limit and capacitor energy loop jointly constrain power | Budgets are allocated from demand and predicted power |
| Referee offline; capacitor and motors valid | The capacitor still supplies a measured total-power label, so eligible RLS updates may continue | A conservative local referee limit is combined with capacitor energy feedback | Allocation continues within the calculated conservative limit |
| Capacitor offline; referee and motors valid | Referee total power becomes the label only when capacitor energy is judged depleted and the message is valid; otherwise updates stop | Falls back to referee power and buffer-energy paths | Uses a more conservative limit while awaiting capacitor recovery |
| One motor-feedback link offline | The older implementation retained recent speed / torque for up to about 1 s before exclusion instead of assuming zero power immediately | The total limit still follows the current referee / capacitor state | The disconnected motor does not continue normal drive; remaining motors operate within the budget |
| Referee and capacitor both offline | No trusted total-power label; online updates stop and model estimation is used | The energy loop is disabled and a conservative limit is derived from the last known level | Total output is constrained until either measurement path recovers |
Technical decisions
No extra bus sensing
- Context
- Dedicated current/voltage sensing would add hardware, calibration, and deployment complexity across chassis.
- Choice
- Constructed features from existing motor feedback and reused total chassis-power measurements already available from the capacitor or referee system.
- Delivered result
- The software remained portable with no new sensing dependency.
Explicit update conditions over one validity flag
- Context
- Disconnected, CRC-failed, or stale samples can rapidly corrupt parameters and affect allocation for every motor.
- Choice
- Made measured-label trust, energy state, and disconnect combinations explicit. A newly disconnected motor briefly retains its latest feedback for conservative power estimation before exclusion.
- Delivered result
- RLS updates and power limits no longer share one ambiguous online state; each input combination has an inspectable behavior.
Debugging process
From implicit stale data to an explicit fault matrix
Identification converged on normal data, but disconnected hardware could leave stale values looking like fresh samples.
Symptoms
- Immediately treating a newly disconnected motor as zero power could underestimate decaying mechanical and electrical power.
- The total power limit had no consistent meaning when referee or capacitor data disappeared.
Investigation
- Disconnected referee, capacitor, and motors one at a time while recording model inputs and torque limits.
- Wrote the state combinations as a failure matrix and checked every path for stale data.
Root cause
Regression features, total-power labels, and energy limits come from different devices. One online/offline flag cannot represent cases where capacitor measurement remains valid, referee data disappears, or motor feedback has only just timed out.
Fixes
- Used supercapacitor total power as the primary label; with the capacitor offline, referee total power is used only when capacitor energy is judged depleted and the referee message is valid.
- Allowed measured updates to continue when referee data is absent but capacitor measurement remains valid; disabled online updates when neither source is trustworthy.
- Retained recent speed/torque feedback briefly after a motor disconnect, then excluded it to avoid an immediate underestimate.
- Separated abnormal state handling from normal allocation instead of relying on implicit fallbacks.
Validation & evidence
- Ran disconnect, recovery, charging, and supplementary-power hardware tests while observing parameters and output continuity.
- Reused the module across chassis and completed the season without over-power health deductions.
LessonOnline algorithms depend first on input semantics: define what is trustworthy before optimizing convergence or performance.
Validation & evidence
- Verified the model and energy paths with RLS, charging, supplementary-power, and swerve hardware footage.
- Reused the module on mecanum, omni, swerve, and wheel-legged chassis.
- The 2024 fleet incurred no referee health deductions from chassis over-power. This is a season result of the complete electrical system, tuning, and operation—not a standalone accuracy metric for the model.
1000 Hz is the 1 ms FreeRTOS power-task period, not a claim that RLS updates on every cycle; updates also depend on label trust, dead zones, energy state, and disconnect conditions.