Host side SPMSM simulation for regression tests
When developing features for the moteus controller, testing on actual hardware has long been the primary way that new motor control features were validated. That includes “hero” testing on the lab bench, and the hardware-in-the-loop (HIL) dynamometer fixture used to validate each new firmware release.
While those are valuable techniques, dynamometer testing is not something that you can do rapidly, is limited to validating a small number of things at a time, and has a non-zero fraction of false positive failures due to unmodeled effects. To enable more rapid feature development, I wanted to test a lot of what was validated on the dynamometer fixture in a host side simulation. This would provide a lot of benefits:
- It could run much faster than real time
- 100% deterministic
- Multiple instances can run in parallel
- Agents can use it as success criteria for validating development
Read on to see how it was done: