2
$\begingroup$

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?

$\endgroup$
1
  • $\begingroup$ The fact they are coupled makes no difference. You can use your standard methodology. :), set one for x2 and x1 and then solve. $\endgroup$ – morbo Dec 20 '20 at 9:07
3
$\begingroup$

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&g\end{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_2\end{matrix}\right]. $$

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

$$ \left[\begin{matrix}a&b\\f&g\end{matrix}\right]^{-1}\left[\begin{matrix}a&b\\f&g\end{matrix}\right]\left[\begin{matrix}\ddot{x_1}\\\ddot{x_2}\end{matrix}\right]=\left[\begin{matrix}a&b\\f&g\end{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_2\end{matrix}\right]. $$

Thus, we get: $$ \left[\begin{matrix}\ddot{x_1}\\\ddot{x_2}\end{matrix}\right] = {1\over ag-bf} \left[\begin{matrix}g&-b\\-f&a\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_2\end{matrix}\right], $$

$$ \left[\begin{matrix}\ddot{x_1}\\\ddot{x_2}\end{matrix}\right] = {1\over 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] +{1\over 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}\alpha\dot{x_1}+\beta\dot{x_2}+\gamma\\ \delta\dot{x_1}+\epsilon\dot{x_2} + \zeta\end{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}\alpha\dot{x_1}+\beta\dot{x_2}\\ \delta\dot{x_1}+\epsilon\dot{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}\alpha\dot{x_1}+\beta\dot{x_2}\\ \delta\dot{x_1}+\epsilon\dot{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_4\end{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_4\end{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.

$\endgroup$
2
  • $\begingroup$ Thank you. Is this generally the way computed torque control is done? I am wondering if it would be possible to transform this into a second order state space by representing x1 and x2 in a single vector q = [x1;x2]? $\endgroup$ – james_erikson Dec 20 '20 at 17:23
  • $\begingroup$ In youtube.com/watch?v=MV-xBPP3H2k, you can see that a combination of feedfoward and PID can be used to control using the torque as input. $\endgroup$ – Accácio Dec 21 '20 at 16:30
0
$\begingroup$

$$ \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 - e\right] \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 $ag\neq bf$. You can proceed from here.

$\endgroup$
-1
$\begingroup$

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.

$\endgroup$
1
  • 2
    $\begingroup$ Students are educated on such easy equations to write them out by hand and learn the method, then use software. I don’t know of any good university that would teach students to write a state space model in Matlab, this isn’t a helpful answer on the method on how to write in state space methodology, coming from a poor basis to suggest that universities teach only to use commercial software, particularly for such a simple example. $\endgroup$ – morbo Dec 20 '20 at 9:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.