## 4 Nonlinear Control Design  
In this section we propose a new control methodology for the manipulation of ornithopters while they are perched. Roughly speaking, it aims to track a desired trajectory for the end effector (beak) of the underactuated manipulator while the passive joint (claw) maintains the equilibrium. The proposed control methodology is stated for an \(n\)-link manipulator with the first joint passive by means of a grabbing mechanism. For experimental validation the prototype had \(n=3\) as described in Section 2.2. The proposed control strategy relies on the fact that the grasping torque the claws can exert is limited and unknown a priori because it depends on both contact surfaces. Furthermore, since the pose of the whole system depends on the balance of torques at the passive joint, the control strategy accounts for both the limited grasping torque and the system posture. Thus, the condition to maintain the passive joint at equilibrium can be obtained directly from (2) and (3) as \(|\tau_{1}|\leq\tau_{c,l}\) and \(\dot{q}_{1}=0\). To simplify the control problem, we know that at slow speed the inertial and centripetal terms in (2) are very small in comparison with gravity ones, and the previous equilibrium condition is well approximated by  
\[|\tau_{1}|\simeq|g_{1}|\leq\tau_{c,l},\quad\text{with}\quad g_{1}=\sum_{i=1}^{ n}\beta_{i}\cos\left(\sum_{k=1}^{i}q_{k}\right), \tag{5}\]  
where the function \(g_{1}\) accounts for the resultant torque at the passive joint due to gravity and \(\beta_{i}\) constant parameters. Even with that simplification, the control of this robot is challenging because the grasping torque is unknown and its accurate estimation is not available for feedback. The controller must, therefore, adequately perform for different values of grasping torque, which means to control the position of the system while the base is at equilibrium. To this end, we propose to minimize the resultant torque at the passive joint, for any initial angle \(q_{1}(0)=q_{10}\), through the first active joint \(q_{2}\) and achieve a nearly perfect tracking in the position of the remaining active joints \(\mathbf{q_{3n}}\). This can be mathematically formulated as follows. **Control problem statement:** Consider the input (\(\boldsymbol{\tau}\)) to output (\(\mathbf{y}\)) nonlinear control system given by  
\[\mathbf{M_{2n}}(\mathbf{q})\ddot{\mathbf{q}}_{2n}+\mathbf{C_{2n} }(\mathbf{q},\dot{\mathbf{q}}_{2n})\dot{\mathbf{q}}_{2n}+\mathbf{g_{2n}}( \mathbf{q})=\boldsymbol{\tau}, \tag{6}\] \[\mathbf{y}=[y_{1},\mathbf{y_{2}}]^{T}:=[g_{1}(q_{10},\mathbf{q_{ 2n}}),\ \mathbf{q_{3n}}]^{T}\in\mathbb{R}\times\mathbb{R}^{n-2}, \tag{7}\]  
with \(\dot{q}_{1}(t)\equiv 0\), \(t\geq 0\). The control objective is to guarantee the asymptotic output tracking of a _smooth_ bounded desired output \(\mathbf{y}^{*}(t)\) with bounded \(\dot{\mathbf{y}}^{*}(t)\) and \(\dot{\mathbf{y}}^{*}(t)\) for \(t\geq 0\). **Remark 2**. : _Notice that, in (7) even though \(q_{2}\) is measured, it is not defined as a direct output. However, its desired behavior is indirectly defined through the output \(y_{1}\). Setting \(y_{1}^{*}=0\) minimizes the gravitational forces at the passive link and eventually maintains this joint \(q_{1}\) at equilibrium \(q_{1}=q_{10}\) by enforcing \(|g_{1}|\leq\tau_{c,l}\) of (5)._  
To control the system (6) and (7) we used feedback linearization. The gist of this control technique is to cancel out all the nonlinearities so that the output dynamics become linear. In essence it transforms the original system into an equivalent linear form by change of coordinates and feedback. Thus, since the whole state \(\mathbf{X}=[\mathbf{q},\dot{\mathbf{q}}]\) is measurable, the system can be linearized by means of a fictitious control input \(\mathbf{v}\). To facilitate the understanding we split the controller design in an inner and outer loop. The inner loop is in charge of linearizing the actuated dynamics.