## 2 Materials and Methods
### Design Optimization and Control Tuning
#### 2.2.2 Objectives Definition  
The optimization process was aimed to achieve good behavior and autonomy from the orthosis. Therefore, three objectives were selected to address ankle angle tracking accuracy, the amount of oscillations, and energy consumption. These objectives are as follows:  
* MSE. The mean squared error between the ankle angle reference signal and the actual ankle angle is calculated to measure the ankle angle tracking accuracy. \[\text{MSE}=\frac{1}{N}\sum_{n=1}^{N}(\theta_{out}(n)-\theta_{in}(n))^{2}\] (1) where \(N\) is the number of samples of the total simulation, \(\theta_{out}(n)\) is the ankle angle output in radians at time sample \(n\), and \(\theta_{in}(n)\) is the ankle angle reference at time sample \(n\). This \(\theta_{in}(n)\) was set to 0 when the foot is 90 degrees relative to the tibia, with positive values for plantar flexion and negative values for dorsiflexion.
* Oscillations. The ankle angle signal must present a minimal amount of oscillations. This second objective was obtained with the following steps:  
\begin{table}
\begin{tabular}{c c c c} \hline \hline
**Variable** & **Description** & **Min Value** & **Max Value** \\ \hline \(Kp\) & Proportional gain for external control & 1 & \(1\times 10^{4}\) \\ \hline \(Kd\) & Derivative gain for external control & 0 & 0.05 \\ \hline \(Kp_{s}\) & Proportional gain for internal control (Motor velocity) & 0.005 & 0.1 \\ \hline \(Kd_{s}\) & Derivative gain for internal control (Motor velocity) & 0 & \(5\times 10^{-5}\) \\ \hline \(K1\) & Stiffness of \(Susp_{Rigid}\) & \(5\times 10^{3}\) & \(5\times 10^{4}\) \\ \hline \(B1\) & Damping of \(Susp_{Rigid}\) & 0 & 20 \\ \hline \(K2\) & Stiffness of \(Susp_{Soft}\) & 5 & 100 \\ \hline \hline \end{tabular}
\end{table}
Table 1: Design variables for the AAFO optimization. All gains refer to controllers for the cam actuator. From the suspension block, the \(Susp_{Rigid}\) element is a spring with a dampener, while \(Susp_{Soft}\) is an element with just a spring.  
We determined that a Butterworth high-pass filter with a cut-off frequency of 10 and order 4 is adequate to separate the reference signal spectrum from unwanted components of the output.
2. After applying this filter, the power of the resulting signal is computed.
* Energy. The energy used for the servomotor should be minimized during the gait cycle to extend the AAFO use time. This objective is calculated from the integral of the power, computed as the product of the torque \(\tau\) and the angular velocity \(\phi\). \[E=\int_{0}^{T}\tau(t)\phi(t)dt\] (2)  
We decided to implement a flag to stop the simulation when the angle increases over 0.5 radians in flexion, which signals that the toes struck the floor. If the flag is activated, then the simulation ends and the costs of all objectives are set to their maximum. During optimization the variables are normalized in the range \([0,1]\). In order to provide robustness to the solutions with respect to the initial dorsiflexion of the foot, we calculated the cost for every separate objective as the mean of 5 simulations with different initial positions of dorsiflexion from 7 to 13 degrees, i.e., with 1.5 degree increments.