# Question on flatness based control

I am currently studying flatness based control using the book: Sira-Ramirez, Hebertt, and Sunil K. Agrawal. Differentially flat systems. CRC Press, 2004.

I have two questions on a particular example from this book.

1.)

They study an example there, a flexible joint manipulator with the following equations:

$$\begin{split} \dot{x}_1 &= x_2 \\ \dot{x}_2 &= -\frac{m g L}{I}\sin(x_1) - \frac{k}{I}(x_1 - x_3) \\ \dot{x}_3 &= x_4 \\ \dot{x}_4 &= \frac{k}{J}(x_1 - x_3) + \frac{1}{J}u \end{split}$$

with the flat output $y = x_1$. This is shown by expressing the state variables using this flat output and its derivatives as follows:

$$\begin{split} x_1 &= y \\ x_2 &= \dot{y} \\ x_3 &= \frac{I}{k}\Big(\ddot{y} + \frac{m g L}{I}\sin(y)\Big) + y \\ x_4 &= \frac{I}{k}\Big(y^{(3)} + \frac{m g L}{I}\dot{y}\Big) + \dot{y} \,. \end{split}$$

Now I understand the first three expressions $x_1, x_2$ and $x_3$. However, I don't get how they derive $x_4$ here or more specifically, why the $\sin$ term disapears in $x_4$. Since to get $x_4$ you would have to take the time derivative of $x_3$, wouldn't the correct solution be

$$x_4 = \frac{I}{k}\Big(y^{(3)} + \frac{m g L}{I}\cos(y)\dot{y}\Big) + \dot{y}$$

or do I miss something here?

2.)

The input $u$ is derived in the book as

$$u = J\Big[\Big(y^{(4)} + \frac{m g L}{I}(\ddot{y}\cos(y) - \dot{y}^2\sin(y))\Big) + \ddot{y}\Big] + k I \Big( \ddot{y} + \frac{m g L}{I}\sin(y) \Big) \,.$$

How can I use this input now if I construct for example a Simulink model of this system? I would just feedback $y = x_1$ and feed that through 3 derivatives blocks to compute $\dot{y}, \ddot{y}$ and $y^{(3)}$ (to use them in $u$) and define $v = y^{(4)}$ as new input... is that correct? How to proceed from there?

1. Apparently, there is a typo in the book. The expression for $x_4$ must contain a $\cos y$ and you can easily see it if you look at the expression for $u$. It contains $(\ddot{y}\cos y - \dot{y}^2 \sin y)$ which clearly comes from differentiating $\dot{y}\cos y$.
2. As far as I know, the standard approach in flatness-based control is to define a sufficiently smooth (desired) trajectory $y(t)$ s.t. $y(0)=y_0$, $y(1)=y_1$ and some other constraints hold. Differentiating $y(t)$ with respect to $t$ you get all required derivatives which are then substituted into $u$.
• I suspected that... some pages later the second derivative of the flat output is stated as $\ddot{y} = -\frac{m g L}{I}x_2\sin(x_1) - \frac{k}{I}(x_1 - x_3)$. For me it seems this is another mistake, because where does the $x_2$ come here come from... However, even if I leave that term out, I can't manage to get the simulation run (the states are always diverging to infinity)... – SampleTime Jun 18 '17 at 13:31
• Yes, this seems to be another typo. Regarding your simulation, I'm not quite sure if I understand what exactly are you doing. As for me, the idea of flatness based control is that you transform a dynamic control problem into an algebraic one. But it seems that you have something different in your mind. In your example you mentioned that you feedback $y=x_1$. What is the goal of this feedback? – Dmitry Jun 19 '17 at 4:35
• Maybe I missunderstand something conceptually... My idea is: since $u$ is a function of $y$ (and its derivatives), if I feedback $y = x_1$ I can use that to compute $u(y, \dot{y}, \ddot{y}, y^{(3)}, y^{(4)})$ (and with that close the control loop). The derivatives of $y$ would be computed with derivatives-blocks (transfer function like $s/(T s + 1)$ with $T$ small). However, this approach seems to be wrong? – SampleTime Jun 19 '17 at 6:40
• Well, feedback means that you compare your output (i.e., $y(t)=x_1(t)$) with some reference signal, say $r(t)$, and try to determine the control signal in such a way that the difference $e(t)=r(t)-y(t)\rightarrow 0$ as $t\rightarrow \infty$, right? In the case of flatness based control you do not need to design a controller, you compute it right away using $r(t)$ and its derivatives. The only thing you should take care of is that $r(0)=y(0)=x_1(0)$, $\dot{r}(0)=\dot{y}(0)=\dot{x}_1(0)$ and so on. – Dmitry Jun 19 '17 at 17:06