## 3 Controller Design
### Tracking via IDA-PBC  
Trajectory Tracking Strategy  
Suppose the system  
\[\left[ \begin{array}{c}\dot{\mathbf{q}}\\ \dot{\mathbf{p}}\end{array} \right]=\left[ \begin{array}{cc}\mathbf{0}&\mathbf{ I}\\ -\mathbf{I}&\mathbf{0}\end{array} \right]\left[ \begin{array}{c}\
abla_{ \mathbf{q}}H\\ \
abla_{\mathbf{p}}H\end{array} \right]+\left[ \begin{array}{c}\mathbf{0}\\ \mathbf{G}(\mathbf{q})\end{array} \right]\mathbf{u}, \tag{9}\]  
where \(\mathbf{q}\) and \(\mathbf{p}\) are the generalized position and momenta, respectively. The matrix \(\mathbf{G}(\mathbf{q})\in\mathbb{R}^{n\times m}\) represents the way that the control acts to the system. Moreover, the energy function of the system is given by  
\[H=\frac{1}{2}\mathbf{p}^{T}\mathbf{M}^{-1}(\mathbf{q})\mathbf{p}+V(\mathbf{q}), \tag{10}\]where the first right-hand term represents the co-energy function of the system (usually related with kinetic co-energy of mechanical systems), while the second right-hand term stands for the energy function (potential mechanical energy). In this sense, \(\mathbf{M}\in\mathbb{R}^{n\times m}\) is known as the inertia matrix. Using the tracking error \(\bar{\mathbf{x}}(t)=\mathbf{x}(t)-\mathbf{x}_{d}(t)\) in (9), it is possible to define the error system dynamics of the form  
\[\left[ \begin{array}{c}\dot{\mathbf{q}}\\ \dot{\mathbf{p}}\end{array} \right]=\left[ \begin{array}{cc}\mathbf{0}&\mathbf{ I}\\ -\mathbf{I}&\mathbf{0}\end{array} \right]\left[ \begin{array}{c}\
abla_{ \mathbf{q}}H\\ \
abla_{\mathbf{p}}H\end{array} \right]+\left[ \begin{array}{c}\mathbf{0}\\ \mathbf{G}(\mathbf{q})\end{array} \right]\mathbf{u}-\left[ \begin{array}{c} \dot{\mathbf{q}}_{d}\\ \dot{\mathbf{p}}_{d}\end{array} \right], \tag{11}\]  
where \(\mathbf{q}_{d}\) and \(\mathbf{p}_{d}\) are the desired trajectories. Physical systems present limitations on the behavior that can be imposed. For this reason, the desired trajectories must be restricted to behaviors the system can accomplish. Thus, consider the Definition 1. **Definition 1**. : _A trajectory is realizable if and only if there exists at least one \(\mathbf{u}^{*}\) such that the states of the closed-loop system satisfy \(\mathbf{x}(t)=\mathbf{x}_{d}(t)\). In case there does not exist any \(\mathbf{u}^{*}\), then, the trajectory \(\mathbf{x}_{d}(t)\) is not realizable._  
Consider that \(\mathbf{p}_{d}=\mathbf{M}(\mathbf{q})\dot{\mathbf{q}}_{d}\), consequently, the dynamics of trajectories can be described as follows:  
\[\left[ \begin{array}{c}\dot{\mathbf{q}}_{d}\\ \dot{\mathbf{p}}_{d}\end{array} \right]=\left[ \begin{array}{cc}\mathbf{0}& \mathbf{I}\\ -\mathbf{I}&\mathbf{0}\end{array} \right]\left[ \begin{array}{c}\
abla_{ \mathbf{q}_{d}}H_{a}\\ \
abla_{\mathbf{p}_{d}}H_{a}\end{array} \right]+\left[ \begin{array}{c} \mathbf{0}\\ \mathbf{G}(\mathbf{q})\end{array} \right]\mathbf{u}^{*}, \tag{12}\]  
\[H_{a}=\frac{1}{2}\mathbf{p}_{d}{}^{T}\mathbf{M}^{-1}(\mathbf{q})\mathbf{p}_{d }+V(\mathbf{q}_{d})=\frac{1}{2}\mathbf{p}_{d}{}^{T}\mathbf{M}^{-1}(\mathbf{q} _{d}+\bar{\mathbf{q}})\mathbf{p}_{d}+V(\mathbf{q}_{d}). \tag{13}\]  
Therefore, the open-loop system error dynamics is defined as  
\[\left[ \begin{array}{c}\dot{\mathbf{q}}\\ \dot{\mathbf{p}}\end{array} \right]=\left[ \begin{array}{cc}\mathbf{0}& \mathbf{I}\\ -\mathbf{I}&\mathbf{0}\end{array} \right]\left[ \begin{array}{c}\
abla_{ \mathbf{q}}H\\ \
abla_{\mathbf{p}}H\end{array} \right]-\left[ \begin{array}{cc}\mathbf{0}& \mathbf{I}\\ -\mathbf{I}&\mathbf{0}\end{array} \right]\left[ \begin{array}{c}\
abla_{ \mathbf{q}_{d}}H_{a}\\ \
abla_{\mathbf{p}_{d}}H_{a}\end{array} \right]+\left[ \begin{array}{c} \mathbf{0}\\ \mathbf{G}(\mathbf{q})\end{array} \right]\bar{\mathbf{u}}. \tag{14}\]  
Once we obtain the system error dynamics, the next step is to stabilize it via IDA-PBC. Tracking is achieved if the error dynamics is stabilized at \(\bar{\mathbf{x}}^{*}=0\). The trajectories must be realizable for any system, allowing us to solve the PDE associated with this approach and find the control law that solves the problem.