State Feedback and Observer Based Control Design for a Two Inverted Pendulum on a Cart System

1. System Definition


The image at right is of a cart of mass supporting two inverted pendulums of mass with lengths and , respectively.
The variables and parameters of the system are summarized in the following table:
System Parameters

Mass of cart

Mass of pendulums

Length of pendulum 1

Length of pendulum 2

Angle of pendulum 1 from vertical

Angle of pendulum 2 from vertical

Forcing input

Velocity







For small and , the equations of motion for this system are:
With some simple term rewriting and by letting , , , the equations of motion can be converted into state space form, that is .
where:
Since the states of the system, and , act as our outputs and since this design assumes that both state variables are measured, the matrix for our system can be defined as:
Using the DynamicSystems[StateSpace] command we can create the state space representation for our system.
 (1) 


2. StateFeedback Control Design


The system defined in the previous section can be controlled so that the inverted pendulums remain vertical on top of the cart, that is , using a statefeedback control strategy provided the system is: (1) controllable by the input, and (2) the states and can be measured directly

2. 1 Determining Controllability


The controllability matrix for the above system can be determined using the DynamicSystems[ControllabilityMatrix] command.
 (2) 
Rank of :
 (3) 
Determinant of :
 (4) 
Even though the generic rank of the above matrix is 4 (i.e. matrix is generically full rank), we cannot say the system is controllable without verifying the conditions upon which the determinant of the controllability matrix becomes 0. For this system, the determinant becomes 0 when . From this we can conclude that the system is controllable if the lengths of the inverted pendulums differ from each other.


2. 2 Designing a StateFeedback Controller


Assuming we have prior knowledge of the desired location of the closedloop poles for our system, we can use the ControlDesign[StateFeedback][PolePlacement] command to calculate the state feedback gain for a singleinput system.
For this design, let us assume that the desired location of the closedloop poles are:
The statefeedback gain, , is then:
 (5) 
We can obtain the closedloop statespace matrices using the ControlDesign[StateFeedbackClosedLoop] command. Then we can verify that the closedloop system has its poles located at the desired pole locations.
 (6) 
At this point, we can simulate the closedloop system to verify if the controller that we designed is able to stabilize the inverted pendulums on the cart. Since the controller was developed symbolically we can perturb any number of the system parameters. Doing so, will give us a sense of the controller's robustness to parameter variations.
Investigating the ClosedLoop Response Simulation

Parameters

Value

Mass of cart


Mass of pendulums


Length of pendulum 1


Length of pendulum 2


Gravity









3. ObserverBased Control Design


The statefeedback controller which was designed in the previous section assumed that the states and are measured directly. This is not practical in many situations, and consequently control designers must turn into observerbased control design to control their systems. Observerbased control design makes use of an observer module to estimate the states. It requires the system to be observable in addition to being controllable.

3. 1 Determining Observability


This section will examine the observability of the system under the following conditions: (1) is measured and is not, (2) is measured and is not, and (3) and are measured.

3.1.1  is measured and is not


We get a subsystem using DynamicSystems[Subsystem] command where only is measurable:
The observability matrix can be determined by using the DynamicSystems[ObservabilityMatrix] command.
 (7) 
Rank of :
 (8) 
Determinant of :
 (9) 
Since the observability matrix is calculated symbolically, knowing that the matrix is generically full rank does not provide us with enough information to say that the system is observable for all possible values of parameters. We must determine for what parameter values the determinant of the observability matrix becomes 0. For this example, the system is observable for all values of the parameters.


3.1.2  is measured and is not


We get a subsystem using DynamicSystems[Subsystem] command where only is measurable:
The observability matrix can be determined by using the DynamicSystems[ObservabilityMatrix] command.
 (10) 
Rank of :
 (11) 
Determinant of :
 (12) 
As in section 3.1.1, the system is observable for all parameter values. This means that the system is observable when either of the angles are measured.


3.1.3  and are measured


If the both states are measurable, the observability matrix of the system is:
 (13) 
Rank of :
 (14) 
The observability matrix is full rank. Clearly, the system is observable when both angles are measured, as well.



3. 2 Designing an ObserverBased Controller


In section 2.2, we showed how the ControlDesign toolbox could be used to design a statefeedback controller when both angles are measured. In this section, we will show how the ControlDesign toolbox can be used to design an observerbased control system when only one state, let us say , is measured.
According to the separation principle, for linear time invariant systems, the state feedback and state observer can be designed independently. We select the desired poles for the observer error dynamic to be about 510 times further away from the axis than those of the state feedback gain design. This ensures that the state feedback poles are the dominant poles of the system.
For this example, the following values for the statefeedback poles and the observer poles were chosen. If you will recall, the state feedback poles that were chosen here are the same as those used in the statefeedback control design section.
Using the ControlDesign[StateObserver][PolePlacement] and ControlDesign[StateFeedback][PolePlacement] commands the observer gain, , and state feedback gain, , to stabilize the inverted pendulum configuration on top of the cart are:
 (15) 
 (16) 
Using the ControlDesign[ControllerObserver] command, the closedloop system of the statefeedback controller and observer can be obtained. We can verify that closedloop system poles match the desired pole locations.
 (17) 
We modify the statespace representation of the closedloop system so that there are 8 outputs corresponding to all the states of the closedloop system. The first four outputs represent the state outputs, while the last four outputs represent the observer error.
As in the previous section, we can simulate the closedloop system to verify if the observerbased controller that was designed can stabilize the two inverted pendulums on the cart system.
Investigating the ClosedLoop Response Simulation to ObserverBased Control Design

Parameters

Value

Mass of cart


Mass of pendulums


Length of pendulum 1


Length of pendulum 2


Gravity









LQG Control Design


We design the LQR controller using the ControlDesign[LQR] command. First, using the ControlDesign[ComputeQR] command, we compute the values of the weighting matrices Q and R based on a desired closedloop time constant.
 (18) 
 (19) 
We design the Kalman observer using the ControlDesign[Kalman] command.
 (20) 
We get the LQG controller equations using the ControlDesign[ControllerObserver] command.
 (21) 
We get the closedloop system using the ControlDesign[ControllerObserver] command with the 'closedloop' option
 (22) 
We modify the statespace representation of the closedloop system so that there are 8 outputs corresponding to all the states of the closedloop system. The first four outputs represent the state outputs, while the last four outputs represent the observer error.
Investigating the ClosedLoop Response Simulation to LQG Control Design

Parameters

Value

Mass of cart


Mass of pendulums


Length of pendulum 1


Length of pendulum 2


Gravity







