- 3.0.2 Documentation
|
In this tutorial, we will take a look how to implement and simulate simple (feedback) controllers.
First, we will implement a controller based on a simple PID Controller. There are at least three different ways to realize a PID Controller in CT. While there is a ct::core::PIDController, it is only SISO. However, CT assumes all systems and controllers are MIMO. Therefore, if you want to use the pre-implemented ct::core::PIDController, you will have to provide a mapping from states to PIDController input and from the output to the control input. Alternatively, you can implement your own Controller class which could utilize the ct::core::PIDController An example is shown in the Custom Controller Tutorial. The third and easiest option is to implement the PID controller as a linear state feedback controller of the form . Herefore, we can use ct::core::StateFeedbackController.
In this example, we create our own implementation of a controller. We create a controller that has two states and one control input. Our control structure will be a PD controller with a feedforward control action. To implement a controller, we derive from ct::core::Controller. As we will see in a bit, this will ensure our feedback controller is interoperable with the rest of the Control Toolbox. Our CustomController.h looks like the following
We can now use this controller to control and simulate a damped oscillator again
You can run this example with the following command