say I have an inverted pendulum system like
$$ \begin{split} \dot{x}_1 &= x_2 \\ \dot{x}_2 &= \sin(x_1) - 0.5x_2 + u \,. \end{split} $$
I now want to design a controller that tracks a user defined reference for the system output $y = x_1$ such that the error $e := y_{set} - y$ gets zero.
Remark: I know that it doesn't really make sense to try to track any other reference for $y$ other than one of the equilibria, but I am more interested in the method itself rather than the result (the pendulum is just a minimal example, in reality I would track the position of the cart carrying the pendulum).
First I transform the system into error coordinates:
$$ e = y_{set} - x_1 \rightarrow x_1 = y_{set} - e $$
and therefore, assuming constant references values $y_{set}$ we get the new system equations
$$ \begin{split} \dot{e} &= -x_2 \\ \dot{x}_2 &= \sin(y_{set} - e) - 0.5x_2 + u \,. \end{split} $$
Correct so far?
Question: Now here is my problem: If I want to perform a stability analysis using the standard Lyapunov function approach, how do I have to deal with the $y_{set}$ in the system equation above?
Because for $y_{set} \neq 0$, the term $\dot{x}_2 \neq 0$ even if $e = x_2 = u = 0$.
Since the reference can in principle be an arbitrary constant, how can I deal with it efficiently?
Let $y_{set}$ be some function of $t$; we suppose we know $y_{set}(t)$, $\dot y_{set}(t)$, $\ddot y_{set}(t)$. The tracking error is a vector $e=(e_1,e_2)$, $e_1= y_{set}-x_1$, $e_2=\dot y_{set}-\dot x_1= \dot y_{set}-x_2$. The error dynamics is $$ \dot e_1=\dot y_{set}-\dot x_1=e_2, $$ $$ \dot e_2=\frac{d}{dt}(\dot y_{set}-\dot x_1)=\ddot y_{set}-\sin x_1+0.5x_2-u= \ddot y_{set}-\sin(y_{set}-e_1)+0.5(\dot y_{set}-e_2)-u. $$ Now we can use the feedback linearization method to introduce the tracking controller:
$$ u=\ddot y_{set}-\sin(y_{set}-e_1)+0.5(\dot y_{set}-e_2)+k_0 e_1+k_1 e_2,\quad k_0,k_1>0 $$ or $$ u=\ddot y_{set}-\sin(x_1)+0.5(x_2)+k_0 (y_{set}-x_1)+k_1 (\dot y_{set}-x_2),\quad k_0,k_1>0. $$ Now we can search for a Lyapunov function of the closed system; it can be found as a quadratic form $V(e)=e^T Pe$.