Swerve Chassis & Power Control
Algorithm & Embedded Development · Independently Built and Open-Sourced
Developed chassis power modeling, constraints, and energy control for mecanum/omni, swerve, and wheel-legged platforms, and published the code and technical reports.
- My work
- Power algorithms and three platform adaptations
- Model inputs
- Motor feedback + measured system power
- Public material
- Code, model reports, and demonstration videos
Background
A chassis must respond to motion commands within a power budget. Allocation by speed error also needs to handle low-error conditions, such as holding position on a slope.
I implemented the power algorithms and the three platform adaptations, reusing existing chassis-solving and matrix utilities. Development took place in the 2024 season; the public release was assembled in September that year.
My contribution
- Built the motor-power model and implemented conditional RLS updates, allocation, and energy control for mecanum/omni chassis.
- Implemented power constraints for swerve steering/drive groups and analytical constraints on motion-related terms for wheel-legged chassis.
- Implemented handling for unavailable measurements and documented the model, source code, and demonstrations.
- Technical environment
- STM32 · FreeRTOS · RLS · Power / Energy Control · Swerve Kinematics
Implementation
Mecanum / omni
Build model features from speed and torque; update RLS using trusted total power. Blend speed-error and predicted-power weights, then solve allowable torque.
Swerve
Use separate power models for steering and drive groups, allocate group budgets, and constrain motor outputs. The published adapter accepts model coefficients.
Wheel-legged
Retain balance-related torque terms and solve attenuation for speed/yaw terms, with capacitor energy governing the available budget.
Model & assumptions
P = Σ(τᵢωᵢ) + k₁Σ|ωᵢ| + k₂Στᵢ² + k₃
P is power (W), τ is torque (N·m), and ω is actual angular speed (rad/s). Torque and speed must refer to the same shaft. k₁ and k₂ describe speed- and squared-torque-related losses; k₃ is constant loss. The mecanum/omni implementation estimates k₁ and k₂ online.
- The implementation converts speed using ω = rpm × π / 30 and converts commands to torque using the torque constant, reduction ratio, and current/protocol ranges. Shaft conventions must match the connected motor interface.
- The report assumes relatively fast torque response and small changes in actual speed within a control cycle.
- The mecanum/omni task uses a 1 ms delay; RLS updates also depend on enable state, measurement validity, dead zone, and regenerative-power conditions.
- Measured chassis power from the supercapacitor is preferred as the label. While the capacitor is charging or discharging, referee-side power differs from chassis-side power; label switching is conditional.
Handling unavailable inputs
| Input state | Model & assumptions | 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 | Recent feedback is retained for up to 1000 task iterations for estimation, then excluded | 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
Change allocation weights at low speed error
- Context
- Allocating only by speed error can be sensitive at low error or while holding on a slope.
- Choice
- Blend error-based and predicted-power-based weights according to total speed error.
Retain balance terms on wheel-legged chassis
- Context
- Uniformly scaling all torque also changes the output required for balance.
- Choice
- Decompose torque as in the report, retain posture-related terms, and solve power constraints on speed and yaw terms.
Separate measurement loss from output handling
- Context
- Motors, the capacitor, and the referee system provide different inputs, so one connection flag is insufficient.
- Choice
- Choose model labels and energy feedback from available measurements; stop normal output to a disconnected motor while briefly retaining its last feedback for estimation.
When the budget is below the model’s feasible range
- Context
- Allowable torque is found from a quadratic equation; an insufficient budget can produce a negative discriminant.
- Choice
- The mecanum/omni implementation then uses the torque at the quadratic’s vertex and applies motor-output limits. If minimum modeled power still exceeds the budget, that branch cannot meet the requested limit. The wheel-legged strategy retains posture terms, so its motion constraints also depend on budget feasibility.
Validation & field records
- The public RLS demonstration records debugger parameters and power traces; the swerve video shows chassis motion.
- Charging and supplementary-power clips are match footage accompanying the report’s energy-use examples.
- The public report records no chassis over-power health deductions across the team’s robots in the 2024 season.