I’ve learned a little about state-space control and the equations behind them. I’ve also learned what a Linear Quadratic Regulator is. Now, I want to try to implement state space control with LQR but I can’t find many resources about it. How exactly would I do this? I feel like I’m missing something obvious. Any example code would be greatly appreciated!

Have you seen the WPILib documentation about it? There are code snippets and a full walkthrough example.

Sorry, I should have clarified. I have read through that, but I want to try and write the code for it myself (for fun). How it works makes sense to me, but I couldn’t find any code examples of making one from scratch.

Are you talking about implementing state space control / LQR for a different system than the example one? Or reimplementing the implementation internals of WPILib’s LQR class?

The internal code

Ok. The WPILib LQR controller largely relies on the Drake C++ implementation of the discrete-time algebraic Riccati equation (aka DARE) solver to do the heavy lifting. You can look at the referenced papers to better understand the algorithm used by Drake, but reimplementing this solver is not a trivial exercise.

What are you controlling using state-space control? I’m curious as the mechanism can also affect the complexity of the controller.

5687 has a state space model of a diff swerve module, as an example.

Paper:

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.