# How to obtain the state space representation of a computed torque control system?

Robotics Asked by james_erikson on December 27, 2020

Assuming I have a system:

$$a , ddot{x}_1 + b , ddot{x}_2 + c ,dot{x_1} + d ,dot{x_2} + e = u_1 \ f , ddot{x}_1 + g , ddot{x}_2 + h ,dot{x_1} + i ,dot{x_2} + j = u_2$$

How would I write this system in state space representation:
$$dot{x} = Ax+Bu$$
$$y = Cx + Du$$

Usually, I would isolate for $$ddot{x_1}$$ or $$ddot{x_2}$$, but in this case, they are functions of each other.
Would the only way be to rewrite the dynamics in matrix form after setting new state variables?

First, isolate the second order from the other terms:

$$a , ddot{x}_1 + b , ddot{x}_2 =- c ,dot{x_1} - d ,dot{x_2} - e + u_1 \ f , ddot{x}_1 + g , ddot{x}_2 = - h ,dot{x_1} - i ,dot{x_2} - j + u_2$$

Then, put it in a matrix form:

$$left[begin{matrix}a&b\f&gend{matrix}right]left[begin{matrix}ddot{x_1}\ddot{x_2}end{matrix}right]=left[begin{matrix}- c ,dot{x_1} - d ,dot{x_2} - e + u_1\- h ,dot{x_1} - i ,dot{x_2} - j + u_2end{matrix}right].$$

Supposing $$left[begin{smallmatrix}a&b\f&gend{smallmatrix}right]$$ is invertible, we can left multiply both sides by $$left[begin{smallmatrix}a&b\f&gend{smallmatrix}right]^{-1}$$:

$$left[begin{matrix}a&b\f&gend{matrix}right]^{-1}left[begin{matrix}a&b\f&gend{matrix}right]left[begin{matrix}ddot{x_1}\ddot{x_2}end{matrix}right]=left[begin{matrix}a&b\f&gend{matrix}right]^{-1}left[begin{matrix}- c ,dot{x_1} - d ,dot{x_2} - e + u_1\- h ,dot{x_1} - i ,dot{x_2} - j + u_2end{matrix}right].$$

Thus, we get: $$left[begin{matrix}ddot{x_1}\ddot{x_2}end{matrix}right] = {1over ag-bf} left[begin{matrix}g&-b\-f&aend{matrix}right]left[begin{matrix}- c ,dot{x_1} - d ,dot{x_2} - e + u_1\- h ,dot{x_1} - i ,dot{x_2} - j + u_2end{matrix}right],$$

$$left[begin{matrix}ddot{x_1}\ddot{x_2}end{matrix}right] = {1over ag-bf} left[begin{matrix}(bh-gc)dot{x_1}+(bi-gd)dot{x_2}+(bj-je)\ (fc-ah)dot{x_1}+(fd-ai)dot{x_2} + (fe-aj)end{matrix}right] +{1over ag-bf} left[begin{matrix} g&-b\ -f&a end{matrix}right] left[begin{matrix} u_1\ u_2 end{matrix}right].$$

Using auxiliary variables: $$left[begin{matrix}ddot{x_1}\ddot{x_2}end{matrix}right] = left[begin{matrix}alphadot{x_1}+betadot{x_2}+gamma\ deltadot{x_1}+epsilondot{x_2} + zetaend{matrix}right] + left[begin{matrix} eta&theta\ iota&kappa end{matrix}right] left[begin{matrix} u_1\ u_2 end{matrix}right].$$

Here, $$gamma$$ and $$zeta$$ can represent either uncontrolled inputs or disturbances.

As uncontrolled inputs: $$left[begin{matrix}ddot{x_1}\ddot{x_2}end{matrix}right] = left[begin{matrix}alphadot{x_1}+betadot{x_2}\ deltadot{x_1}+epsilondot{x_2}end{matrix}right] + left[begin{matrix} eta&theta&gamma\ iota&kappa&zeta end{matrix}right] left[begin{matrix} u_1\ u_2\ 1 end{matrix}right].$$

As disturbances: $$left[begin{matrix}ddot{x_1}\ddot{x_2}end{matrix}right] = left[begin{matrix}alphadot{x_1}+betadot{x_2}\ deltadot{x_1}+epsilondot{x_2}end{matrix}right] + left[begin{matrix} eta&theta\ iota&kappa end{matrix}right] left[begin{matrix} u_1\ u_2 end{matrix}right]+ left[begin{matrix} gamma\ zeta end{matrix}right].$$

Creating the state $$s=[s_1;s_2;s_3;s_4]^T=[x_1;dot{x_1};x_2;dot{x_2}]^T$$:

$$dot{s} = dot{left[begin{matrix}s_1\ s_2\ s_3\ s_4end{matrix}right]} = left[begin{matrix} 0&1&0&0\ 0&alpha&0&beta\ 0&0&0&1\ 0&delta&0&epsilon end{matrix}right] left[begin{matrix}s_1\ s_2\ s_3\ s_4end{matrix}right] + left[begin{matrix} 0&0\ eta&theta\ 0&0\ iota&kappa end{matrix}right] left[begin{matrix} u_1\ u_2 end{matrix}right] + left[begin{matrix} 0\ gamma\ 0\ zeta end{matrix}right].$$

Depending on your system, you can design a controller that rejects those disturbances; the presence of integrators in the system can help remove steady-state errors.

Answered by Accácio on December 27, 2020

begin{align} a , ddot{x}_1 + b , ddot{x}_2 + c ,dot{x_1} + d ,dot{x_2} + e &= u_1 tag{1} \ f , ddot{x}_1 + g , ddot{x}_2 + h ,dot{x_1} + i ,dot{x_2} + j &= u_2 tag{2} end{align} Let's write Eq(1) without $$ddot{x}_2$$, hence: begin{align} a , ddot{x}_1 + b , Big[frac{u_2-f , ddot{x}_1 - h ,dot{x}_1 - i ,dot{x}_2 - j}{g}Big] + c ,dot{x}_1 + d ,dot{x}_2 + e &= u_1 \ left[a-frac{bf}{g} right] , ddot{x}_1 + , frac{b}{g}u_2 - frac{bh}{g} ,dot{x}_1 - frac{bi}{g} ,dot{x}_2 - frac{b}{g}j + c ,dot{x}_1 + d ,dot{x}_2 + e &= u_1 \ % left[a-frac{bf}{g} right] , ddot{x}_1 = u_1 - , frac{b}{g}u_2 + frac{bh}{g} ,dot{x}_1 + frac{bi}{g} ,dot{x}_2 + frac{b}{g}j - c ,dot{x}_1 - d ,dot{x}_2 - &e \ % ddot{x}_1 = left[frac{g}{(ag-bf)} right] left[u_1 - , frac{b}{g}u_2 + frac{bh}{g} ,dot{x}_1 + frac{bi}{g} ,dot{x}_2 + frac{b}{g}j - c ,dot{x}_1 - d ,dot{x}_2 - eright] tag{3} end{align} Now we do same procedure which is eliminating $$ddot{x}_1$$ from Eq(2) hence, begin{align} f , Big[frac{u_1- b , ddot{x}_2 - c ,dot{x_1} - d ,dot{x_2} - e}{a}Big] + g , ddot{x}_2 + h ,dot{x_1} + i ,dot{x_2} + j &= u_2 \ % Big[ g - frac{fb}{a}Big] ddot{x}_2 + frac{f}{a} u_1 - frac{fc}{a} ,dot{x_1} - frac{fd}{a} ,dot{x_2} - frac{fe}{a} + h ,dot{x_1} + i ,dot{x_2} + j &= u_2 \ % Big[ g - frac{fb}{a}Big] ddot{x}_2 = u_2 - frac{f}{a} u_1 + frac{fc}{a} ,dot{x_1} + frac{fd}{a} ,dot{x_2} + frac{fe}{a} - h ,dot{x_1} - i ,dot{x_2} - j \ % ddot{x}_2 = left[frac{a}{(ag-bf)} right] left[ u_2 - frac{f}{a} u_1 + frac{fc}{a} ,dot{x_1} + frac{fd}{a} ,dot{x_2} + frac{fe}{a} - h ,dot{x_1} - i ,dot{x_2} - j right] tag{4} end{align} Now let $$y_1=x_1, y_2=dot{x}_1, y_3=x_2, y_4=dot{x}_2$$, hence: begin{align} dot{y}_1 &= y_2 \ dot{y}_2 &= left[frac{g}{(ag-bf)} right] left[u_1 - , frac{b}{g}u_2 + Big[frac{bh-cg}{g}Big] ,y_2 + Big[frac{bi-dg}{g} Big] ,y_4 + frac{bj-eg}{g}right] \ dot{y}_3 &= y_4 \ dot{y}_4 &= left[frac{a}{(ag-bf)} right] left[ u_2 - frac{f}{a} u_1 + Big[frac{fc-ha}{a} ,Big] y_2 + Big[frac{fd-ia}{a}Big] ,y_4 + frac{fe-aj}{a} right] end{align}

where $$agneq bf$$. You can proceed from here.

Answered by CroCo on December 27, 2020

Before the question can be answered with mathematical terms, a bit meta knowledge may help to understand the thought system. The goal of creating a state space formula for robotics problems is a typical application of the matlab software. The students are educated how to use a commercial software package for describing real world problems.

With this pre-knowledge in mind it is much easier to identify the correct answer. It was given in the internet already under the URL https://in.mathworks.com/help/control/getstart/linear-lti-models.html The website explains, how to use the famous mathematical software for creating a state space model for a torgue control. What is provided too, is how to create the differential equations and transform them into the matrix notation.

Answered by Manuel Rodriguez on December 27, 2020