This repo provides a C++ Library for implementation of LQR.
This repo was made with ROS2 in mind, so colcon build tool is required and ROS2 standard workspace structure should be used while building the package.
The code and math validity can be confirmed by the test examples implemented.
This solution was displayed in CoppeliaSim. In order to check that, you need to add Float32MultiArray message to the meta of the ros2 package. For more information: A good starting point
LQR as the name suggests is a regulator, maintains a value or state while trying to minimize a quadratic cost function that is based upon the effort it can apply on the actuators as well as the error importance of the state (R and Q respectively).
For reaching a reference state with LQR, we have to regulate the error to a 0. Which implies that instead of considering the state vector to be system state, the state vector should be the error.