\part{ADAPTIVE HUMANOID CONTROLLER TO IMPROVE HUMANOID LOCOMOTION ON SLIPPERY FLOORS}

\chapter{Enhancement of Humanoid Robot Locomotion on Slippery Floors using an Adaptive Controller}

\vspace*{\fill}

\begin{center}
\small This is the initial submitted version. The final version was accepted by Cambridge Robotica Journal on December 21, 2023. \\
\end{center}

\label{c5}

\newpage
\thispagestyle{empty} % To remove headers and footers
\mbox{}

\newpage


\section{Abstract}
This paper presents a comprehensive strategy to improve the locomotion performance of humanoid robots on various slippery floors. The strategy involves the implementation and adaptation of a Divergent-Component-of-Motion (DCM) based control architecture for the humanoid NAO, and the introduction of an \gls{eyc}, which is based on a \gls{pid} control algorithm. The EYC is designed not only to address the slip behavior of the robot on low friction floors, but also to tackle the issue of non-straight walking patterns that we observed in this humanoid, even on non-slippery floors. A series of locomotion experiments are conducted in a simulated environment, where the humanoid step frequency and PID gains are varied for each type of floor. The effectiveness of the strategy is evaluated using metrics such as robot stability, energy consumption, and task duration. The results of the study demonstrate that the proposed approach significantly improves humanoid locomotion on different slippery floors, by enhancing stability and reducing energy consumption. The study has practical implications for designing more versatile and effective solutions for humanoid locomotion on challenging surfaces, and highlights the adaptability of the existing controller for different humanoid robots.


\section{Introduction}\label{sec1}
Humanoid robots are anthropomorphic machines that aim to emulate the locomotion and behaviour of humans. Although significant advancements have been made in robot's locomotion, the challenge of navigating on slippery floors remains a difficult and unresolved issue, with significant potential for further improvements. Just as humans use their senses to adapt to changing environments, we believe that humanoid robots should rely on sensor feedback to achieve the same. By utilizing sensor data, robots can better adjust to varying surfaces and conditions, improving their ability to navigate on slippery floors and other challenging terrains \parencite{ding_walking_2018}, as well as perform seemingly simple tasks like setting their home position \parencite{kim_adjustment_2008}. 

On past studies \parencite{almeida2020learning,9598809}, it was hypothesized that adapting the controller of the robot based on the known friction coefficient of various floors could lead to efficient and effective locomotion on such surfaces.
Building upon the development of instrumented shoes (ITShoes) and machine learning algorithms that enable real-time detection of the coefficient of friction for various floor types, this work proposes a comprehensive strategy to enhance humanoid locomotion on slippery surfaces through adaptive control. In addition to addressing the challenges posed by varying slippery floor conditions, a peculiar behavior was also observed in the humanoid when instructed to walk on a straight path. This behavior is attributed to its unconventional building, which will be explain in the next section. As such, the proposed controller aims not only to address slip behavior on slippery floors, but also to mitigate the issue of non-straight walking patterns resulting from the humanoid's particular mechanical construction.

Several techniques have been proposed in the literature for generating Center of Mass (CoM) trajectories based on the concepts of Zero-Moment Point (ZMP) \parencite{VUKOBRATOVIC19721} and Linear Inverted Pendulum (LIP) \parencite{Kajita2001The3L}.
In recent years, there has been significant research on bipedal locomotion, which has resulted in the introduction of new concepts such as the  \gls{dcm} and Virtual Repellent Point (VRP) \parencite{Englsberger2013ThreedimensionalBW,3960bde270c5435b86c992f857e45dd9}. These concepts allow for the decomposition of the second-order dynamics of the CoM into two first-order linear dynamics, where the CoM converges to the DCM (stable dynamics) and the DCM diverges away from the VRP (unstable dynamics) \parencite{Englsberger2013ThreedimensionalBW}. These concepts have been utilized in various methods of generating CoM trajectories and stabilizing humanoid robots during locomotion.

The strategy described in this paper is founded on an implementation and adaptation of a DCM based control architecture. The DCM concept has been applied to various types of robots, including bipeds  \parencite{9424385, 8404119, 9034996, doi:10.1142/S0219843619500348}, quadrupeds \parencite{griffin2022quadrupedal, wagner2021applying}, and exoskeletons \parencite{mehr2021intelligent, xu2022dmp}, and has been shown to be effective in achieving stable and dynamic locomotion. It has also been used in applications such as prosthetics and rehabilitation robotics, where maintaining balance and stability are critical for safe and effective movement. We follow the DCM-based control architecture presented in \parencite{1809.02167}, where the authors present and compare several DCM-based implementations of a layered control architecture. A unicycle-based planner is used to generate desired DCM and foot trajectories for the fixed trajectory optimization layer.
The simplified model control layer comprises two main controllers for DCM tracking, along with an additional inner controller that utilizes 6-axes Force Torque sensors (F/T) to ensure precise tracking of CoM and ZMP \parencite{4359259}. The two main controllers are: an instantaneous feedback controller and a Model Predictive Control (MPC) approach. One common approach to generate feasible CoM trajectories is to combine the Linear Inverted Pendulum Model (LIPM) with MPC techniques, which are also referred to as Receding Horizon Control (RHC) \parencite{Herdt2010OnlineWM}. The MPC is a control technique that uses a mathematical model of the system to predict its future behaviour, and then optimizes the control inputs over a finite time horizon to minimize a cost function while satisfying constraints.
The Whole-Body Quadratic Programming (WBQP) control layer ensures the tracking of the desired CoM and feet trajectories by presenting velocity and inverse kinematics.

In the current work, we propose an Embedded Yaw Controller (EYC) as an extension to the existing control strategy based on the MPC controller from \parencite{1809.02167}. The EYC is specifically designed to address slip behavior on slippery floors and to rectify the non-linear paths observed due to the robot's suspicious building technique. It functions as a Proportional-Integral-Derivative (PID) controller, which allows us to dynamically control and adapt the humanoid gait in real-time. This approach draws upon the well-established use of PID controllers in optimizing various aspects of humanoid locomotion, such as stability, efficiency, and robustness of walking, as demonstrated in prior works such as \parencite{nguyen2020balancing, bestmann2022bipedal, xu2022design}. Thus, in this work, the digital PID control scheme is leveraged to implement the EYC for precise control of the humanoid gait, by continuously monitoring its torso orientation in response to slip behavior and non-linear path observations.

The remainder of the paper is structured into the following sections. Section \ref{sec:2} provides an overview of the DCM-based control architecture that has been implemented, covering key concepts, components, and its integration into the NAO robot. Furthermore, the integration of an EYC within the architecture is detailed. Section \ref{sec:3} describes the preliminary locomotion experiments setup and the experiments conducted with varying step frequencies and PID gains. The metrics used to evaluate the performance of the system are also discussed, and the results obtained are presented. Finally, in Section \ref{sec:4}, conclusions are provided, highlighting the achieved improvements, and recommendations for future work are given.


\section{Humanoid Whole-body Controller}
\label{sec:2}

The whole-body controller used in this work is based on the three-layer control architecture developed and implemented on the iCub robot \parencite{1809.02167}.
The three layer architecture is presented in \autoref{fig:architecture}.

%\begin{landscape}
\begin{figure}[!ht]
    \centering
%    \includegraphics[width=\textwidth]{figure1.eps}
    \input{tex/contents/fig/c5/globalarchitecture.tikz}    
    \caption[Modified humanoid 3-layer control architecture with an additional EYC block.]{Modified humanoid 3-layer control architecture \parencite{1809.02167} with an additional EYC block. The EYC is a controller used to adapt the robot's motion to low-friction environments and to correct the unexpected curved path of the Humanoid NAO by adjusting its behavior based on feedback from an IMU (Inertial Measurement Unit) sensor}\label{fig:architecture}
\end{figure}
%\end{landscape}

This work demonstrates the potential of the Embedded Yaw Controller (EYC) by successfully integrating it into the three-layer control architecture, where it effectively addresses slip behavior and rectifies non-linear paths resulting from the robot's particular building technique. Furthermore, the versatility of the three-layer controller is demonstrated by successfully implementing it on a different humanoid robot, highlighting its potential for application in a wide range of robotic systems.

\subsection{Trajectory optimization}

The purpose of this layer is to plan and evaluate the desired footstep positions and the desired feet and DCM trajectories for a humanoid robot. The robot is approximated as an unicycle, with the feet represented by the unicycle wheels. The footsteps are planned by sampling the unicycle trajectories, with each position associated with a time instant. The impact time is considered as a decision variable, which allows for the selection of feet positions, duration, and step length. Once the footsteps are planned, the desired feet trajectory is obtained by cubic spline interpolation. The DCM trajectory is chosen so as to satisfy a specific time evolution. The DCM trajectory along the walking pattern can be computed recursively, but the presented planning method only takes into account single support phases. To ensure that the ZMP trajectory remains smooth and continuous, it is important to have a reference trajectory for the DCM with smoothly varying derivatives. This means that the rate of change of the DCM trajectory should be continuous, allowing for seamless transitions between different segments of the trajectory. To achieve this, a third-order polynomial is used to smoothly connect the edges of the DCM reference trajectory. The parameters of the polynomial are carefully selected to ensure that both the velocity and position of the trajectory satisfy certain boundary conditions, ensuring a continuous and smooth motion \parencite{1809.02167}.

\subsection{Simplified Model}

The middle layer of the robot's control system utilizes a simplified model control layer that employs a MPC DCM controller. The purpose of this controller is to ensure that the robot's DCM accurately tracks its intended trajectory. The DCM is a specific point in space that represents the robot's movement and serves as the point at which the robot would fall if it stopped moving.

To achieve this level of precision, the humanoid robot's movement is approximated using the LIPM, a widely recognized model for walking on flat surfaces \parencite{Kajita2001The3L}. The LIPM guarantees that the CoM of the robot remains at a constant height on a horizontal plane while walking. The MPC algorithm utilizes this model to predict the robot's future movements and generates a control signal that maintains its stability and trajectory. 

This algorithm takes into account the desired trajectory and the robot's motion constraints to generate a smooth trajectory for the ZMP, which is essential to the robot's stability. The ZMP must remain within the robot's support polygon to avoid falling.

In this middle layer, an independent CoM-ZMP controller ensures that the robot's CoM and ZMP are properly tracked using a force torque sensor (F/T). This inner CoM-ZMP controller is presented in \parencite{4359259} and is based on the Kinematic Resolution of CoM Jacobian (KRCJ) method with embedded motion. KRCJ is a mathematical method for computing the robot's center of mass and its Jacobian matrix, which describes the relationship between the robot's joint angles and its CoM. 

This approach aims to enhance the robot's stability and balance during walking by adjusting its joint angles in real-time using the KRCJ method. The embedded motion technique allows the robot to adapt its movements to changes in the environment, such as uneven terrain or unexpected obstacles \parencite{1809.02167}.

\subsection{Whole Body QP Control}


The third layer of the control architecture implemented in this work is the WBQP control layer. WBQP is a common approach used in robotics for generating motion plans or control commands that optimize the performance of the robot's whole body motion while accounting for different constraints. Its main responsibility here is to track the desired CoM and foot trajectories, employing velocity and inverse kinematic controllers to ensure accurate and smooth movement control. The achievement of this control objective involves defining a cost function, which is minimized to obtain the desired robot velocity \parencite{1809.02167}.

\subsection{Implementation in the NAO robot}

The entire architecture was adapted to be used in the humanoid NAO. The NAO robot displays certain peculiarities observed in both simulations and the real system. The most significant issue is that the robot does not maintain a straight path when commanded to do so. This behaviour is illustrated in \autoref{fig:straight}, where it can be seen that the humanoid changes direction despite being commanded to walk a straight line.
%
\begin{figure}[!ht]
  \centering
   \includegraphics[width=\textwidth]{tex/contents/fig/c5/figure2.eps}
  \caption[Illustration of the NAO robot's inability to maintain a straight path.]{Illustration of the NAO robot's inability to maintain a straight path. The robot was commanded to walk in a straight line, but deviated from its intended path} \label{fig:straight}
\end{figure}

The issue of the robot deviating from a straight path is more prominent on slippery floors, but it also occurs on floors with a high friction coefficient. We suspect that the problem is related to the physical configuration of the pelvis joint \texttt{LHipYawPitch} and \texttt{RHipYawPitch}, which are driven by only one motor and, thus, cannot be controlled independently, with priority given to \texttt{LHipYawPitch}. It is possible that the controller has a glitch when sending the desired position for both joints, leading to the observed behaviour. Illustrative trajectories are depicted in \autoref{fig:plot0}, showcasing the desired straight trajectory and the actual trajectories of the humanoid.
%
\begin{figure}[!ht]
\centering
\begin{tikzpicture}
\begin{axis}[
    width=0.8\textwidth,
    height=5cm,
    xlabel={Forward distance (\si{m})}, 
    ylabel={Lateral deviation (\si{m})},
    legend pos=south west,
    legend style={
    	fill=white,
    	fill opacity=0.5,
    	draw opacity=1,
    	text opacity=1,
    	},
    yticklabel style={
        /pgf/number format/fixed,
        /pgf/number format/precision=3
        },
    xmin=0,
    xmax=2
        ]
\addplot[
    color=red
    ]
    table [x index=0, y index=1, col sep=comma] {tex/contents/fig/c5/data4.csv};
\addlegendentry{trajectory 1}
\addplot[
color=green
]
    table [x index=0,  y index=2, col sep=comma] {tex/contents/fig/c5/data4.csv};
\addlegendentry{trajectory 2}
\addplot[
    color=blue
    ]
    table [x index=0,  y index=3, col sep=comma] {tex/contents/fig/c5/data4.csv};
    \addlegendentry{trajectory 3}
\addplot[
    color=black,
    const plot,
    domain=0:2
] {0};
\addlegendentry{desired trajectory}
\end{axis}
\end{tikzpicture}
\caption{Visualizing humanoid locomotion behavior: trajectories illustrating straight walking command execution}
\label{fig:plot0}
\end{figure}

To enforce the locomotion along a straight path and correct the lateral deviations of the robot, the EYC control system was developed based on the measurement of robot’s heading using the onboard Inertial Measurement Unit (IMU). This controller dynamically adjusts the target set-point to continuously correct the robot's direction of motion by monitoring the humanoid's torso orientation and compensates for changes in direction that can occur when the robot slips while walking on very slippery floors. 

The effectiveness of this modification was also evaluated through experiments on the humanoid robot NAO, and the results showed that the EYC was able to significantly improve the robot's stability and reduce the impact of slips on its movements. A joint velocity limit was also added to the controller as a safety measure to ensure that the robot's joint velocity limits were not exceeded during movement. This modification was necessary to ensure the safety and stability of the robot's movements, especially during dynamic motions that require quick changes in joint velocities.  

To implement this architecture in the NAO robot, a detailed step-by-step process was followed. First, the necessary software dependencies for the walking module were installed, along with YARP and any required environmental variables. Next, the robot was modeled using both the Unified Robot Description Format (URDF) and the Simulation Description Format (SDF) files. This involved defining joint and link structures in the URDF, as well as specifying physical and environmental properties in the SDF, such as friction coefficients. With the robot model in place, the focus shifted to adapting the trajectory generation parameters to suit the specific requirements of the NAO. This involved setting limits for various gait parameters, such as step length, frequency, and height, among others, to ensure that the robot could walk smoothly and efficiently. Additionally, the trajectory generation parameters were fine-tuned to ensure that the robot's motion was stable and well-coordinated. Throughout the implementation process, all necessary adaptations were made to ensure that the model was comprehensive and incorporated all the joints and sensors needed to achieve optimal performance. To achieve a final implementation that is both robust and reliable, it was necessary to adapt numerous parameters and conduct extensive testing. Some of these adaptations are presented in \autoref{tab:NAOconfigs}:
%
\begin{table}[!ht]
\begin{tabular}{p{3.5cm}|m{8.5cm}}
\textbf{Item} & \textbf{Values} \\
\midrule
URDF &  Joints, links, and robot description.   \\
SDF & Model, physical properties, environmental and material properties (i.e. friction coefficients).  \\
Whole-body configs & Joints, frames, sensors, devices and others \\
Trajectory generation & Gait parameters, such as minimum and maximum step length, height, width, duration, landing velocity and others. \\
Logger & Joints position, DCM, CoM, ZMP, sensors, EYC inputs/outputs and others. \\
Walking controller configs & Inner ZMP parameters, forward and inverse kinematics, joint's PID and others\\
Gazebo & Physical environmental, such as solver and constraints parameters \\
\bottomrule
\end{tabular}
\caption{Points adapted in the original walking controller to fit the NAO requirements.}
\label{tab:NAOconfigs}
\end{table}

To measure the forces and torques that occur on the ankle of the NAO humanoid robot during the simulated experiments, a Force/Torque (F/T) sensor was added to the robot's ankle model. While this provided accurate measurements in the simulated environment, the real robot does not have this sensor. To overcome this limitation, we aim to utilize the instrumented shoe (ITshoe), as shown in \autoref{fig:ITshoe}, which was previously developed in our laboratory \parencite{almeida2018novel}.

\begin{figure}[!ht]
  \centering
   \includegraphics[width=0.5\textwidth]{tex/contents/fig/c5/figure3.eps}
  \caption[ITshoe schematic structure.]{ITshoe schematic structure. The red block (A) is the acquisition unit, the green block (B) is the streaming unit, and the blue block (C) is the sensing unit. At the top, the image shows the position of the eight force sensors and the reference axis used to decompose the tangential forces \parencite{9598809}.} \label{fig:ITshoe}
\end{figure}

The ITshoe is equipped with sensors that can measure the total ground reaction forces during walking. These measurements are essential to enhance the robot's interaction with the ground \parencite{leewholebody2021}, and they can be utilized to calculate the forces and torques acting on the ankle. To simulate the output of a F/T sensor in future real experiments,  the measured ground reaction forces have to be translated to the ankle location using the \autoref{eq:force} and \autoref{eq:torque}.
%
\begin{align}
\vec{F}_{\text{AZ}} = \vec{F}_{\mathrm{SZ}} + (m_{\mathrm{is}} + m_{\mathrm{rf}} + m_{\mathrm{aj}}) \cdot \vec{g},
\label{eq:force}
\end{align}
%
where $\vec{F}_{AZ}$ represents the total ankle force in the z direction, $\vec{F}_{SZ}$ the total force in the z direction measured by the ITShoe and $m_{is}$, $m_{rf}$ and $m_{aj}$ denote the masses of the components between the sensors and the robot's ankle: 
%
\begin{align}
\begin{bmatrix}
\vec{\tau}_x \\
\vec{\tau}_y \\
\vec{\tau}_z \\
\end{bmatrix}
= \sum_{i=1}^{n} 
\begin{bmatrix}
r_{iy} \cdot \vec{F}_{iz} + r_{iz} \cdot \vec{F}_{iy} \\
r_{iz} \cdot \vec{F}_{ix} + r_{ix} \cdot \vec{F}_{iz} \\
r_{ix} \cdot \vec{F}_{iy} + r_{iy} \cdot \vec{F}_{ix}
\end{bmatrix}
\label{eq:torque}\text{,}
\end{align}
%
where $\vec{\tau}_x$, $\vec{\tau}_y$ and $\vec{\tau}_z$ represent the total ankle torque in the corresponding x, y and z directions, $r_{ij}, \text{ for } j \in {x, y, z}$, are the distances between the ITShoe sensors and the robot's ankle, and $\vec{F}_{ij}, \text{ for } j \in {x, y, z}$, are the forces measured on the corresponding sensors in the ITshoe. 

Then, in the Gazebo simulator, the physical parameters, such as mass, friction coefficients, inertias, and joint damping, were fine-tuned and optimized to ensure that the simulated robot's behavior closely emulated the real-world physics and dynamics of the actual robot.

To capture and analyse the relevant data for each experiment, all the DCM based controller variables, along with the robot's joint, ZMP, CoM, F/T and IMU sensor data, and other essential variables were recorded within a \SI{10}{ms} controller cycle. By gathering this information, we were able to gain a comprehensive understanding of the robot's behaviour and performance in response to different slippery floors.  In the following sections, it is demonstrated how effectively this data was utilized and manipulated to draw meaningful conclusions about the effectiveness of the methods used.

The control architecture was implemented using YARP, an open-source robotics middle-ware, and programmed in C++ language. More details can be found at the walking controllers repository\footnote{https://github.com/robotology/walking-controllers}.

The layout to simulate the humanoid robot navigating on different types of floors was implemented using the Gazebo simulator, as illustrated in \autoref{fig:layout}.
%
\begin{figure}[!ht]
  \centering
  \input{tex/contents/fig/c5/figure4.tikz}
  \caption{Layout of the simulated environment featuring the NAO robot and various types of slippery floors in the Gazebo simulator.}
  \label{fig:layout}
\end{figure}

\subsubsection{EYC implementation}

The role of the Embedded Yaw Controller (EYC) is to continuously monitor the robot's orientation, specifically the YAW angle, during locomotion. When the EYC detects that the robot is deviating from the commanded trajectory, it calculates a new YAW angle using a digital PID formulation \parencite{ASTROM20011163}, as shown in Equation \ref{eq:pid}, in order to adapt the robot's trajectory accordingly.
%
\begin{equation}
u_0 = -K_{u1}u_1 - K_{u2}u_2 + K_{e0}e_0 + K_{e1}e_1 + K_{e2}e_2. \label{eq:pid}
\end{equation}

This controller relies on a set of carefully selected and tuned coefficients, which are defined in \autoref{eq:ku1} to \autoref{eq:b2}. These coefficients are used in the computation of the control input, $u_0$, which depends on the previous control inputs $u_1$ and $u_2$, as well as the error terms $e_0$, $e_1$, and $e_2$. The equation includes the derivative terms $K_{u1}$ and $K_{u2}$, and the proportional, integral, and derivative gains $K_{e0}$, $K_{e1}$, and $K_{e2}$, given by:
%
\begin{align}
K_{u1} &= \frac{a_0}{a_1 - a_2}\text{,} \label{eq:ku1}\\
K_{u2} &= \frac{a_0}{a_1 + a_2}\text{,} \label{eq:ku2}\\
K_{e0} &= a_0 b_0\text{,} \label{eq:ke0}\\
K_{e1} &= a_0 b_1\text{,} \label{eq:ke1}\\
K_{e2} &= a_0 b_2\text{,} \label{eq:ke2}
\end{align}
where
\begin{align}
a_0 &= 1 + NT_s \text{,}\label{eq:a0}\\
a_1 &= -(2 + NT_s) \text{,}\label{eq:a1}\\
a_2 &= 1 \text{,}\label{eq:a2}\\
b_0 &= K_p(1 + NT_s) + K_iT_s(1 + NT_s) + K_dN \text{,}\label{eq:b0}\\
b_1 &= -(K_p(2 + NT_s) + K_iT_s + 2K_dN)\text{,} \label{eq:b1}\\
b_2 &= K_p + K_dN\text{.} \label{eq:b2}
\end{align}

To trigger the controller, a timer interrupt service routine is used, and a set of global variables is defined, including the command input $r$, plant output $y$, error terms $e_0$, $e_1$, and $e_2$, control inputs $u_0$, $u_1$, and $u_2$, and the coefficients $a_0$, $a_1$, and $a_2$.
The error term is computed by taking the difference between the desired output and the current plant output. The proportional, integral, and derivative gains are initially set to $K_p = 1.00$, $K_i = 0.02$, and $K_d = 0.01$, respectively, while the filter coefficients are set to $N = 20$, and the sampling time is set to $T_s = \SI{0.01}{s}$.

These variables and parameters are critical to the operation of the PID controller, and have been empirically selected and tuned to ensure an initial effective stabilization of the robot's orientation on slippery floors. Further explanation will be provided in \autoref{sec:3} to elaborate on the specific process of how these variables and parameters were determined based on practical experimentation and observation.

To estimate the robot's orientation, data obtained from the NAO robot IMU sensor was utilized, which provided measurements of the robot's angular velocity and linear acceleration. To estimate the yaw angle, we applied an Extended Kalman Filter (EKF), which is a recursive algorithm that estimates the state of a system that is subject to uncertain and noisy measurements \parencite{Julier1997NewEO}.

The EKF uses a quaternion to represent the orientation of the system, where the scalar component represents the orientation of the system, and the three vector components represent the axis of rotation. The prediction stage of the filter propagates the quaternion forward in time using the system dynamics, while the update stage fuses the predicted state with new measurements. In the case of an IMU, new measurements include measurements of angular velocity. To update the state estimate with the new measurements, the filter models the measurement process as a linear function of the state, corrupted by additive Gaussian noise.
Finally, the EKF computes the optimal estimate of the state by minimizing the mean squared error between the predicted state and the measurements. By applying this algorithm, we were able to obtain an optimal estimate of the robot's torso YAW angle over time. This estimate was then used as input to the EYC controller to stabilize the robot's trajectory, taking into consideration not only the slippery condition of the floors, but also the peculiar issue related to the humanoid's non-straight walking patterns mentioned earlier. The EYC controller, utilizing the PID formulation, adjusts the robot's trajectory to ensure more stable and accurate locomotion, mitigating the effects of both slippery surfaces and the humanoid's unique build.

\section{Locomotion experiments}\label{sec:3}
%
In this section it is presented the experiments carried out to collect locomotion data in order to analyse it and improve the humanoid controller based on the slippery floor it is faced with. Firstly, we performed an experiment where we attempted to study the impact of the robot's step frequency on the different floors by measuring the amount of slippage occurred during these experiments. According to the information obtained from these experiments, it was found that the slowest step frequency was the most preferred option across all floors, rather than a specific frequency for each individual floor. While this insight provides valuable information for gait adaptation on slippery floors, it is inconclusive towards our goal of adapting the controller to the specific floor the robot is traversing. As a result, a second experiment was conducted where the optimized parameters for the PID controller specific to each floor were obtained.

Secondly, in order to evaluate the following experiment, performance metrics are defined, specifically, the time and energy spent on the task, and the stability of the robot during these tasks. Lastly, the experiments to obtain the optimized PID parameters that allow the robot to achieve the best performance on each floor individually to improve the overall experience that is when the robot walks on the four different floors are presented.
Four different slippery floors that were previously studied were used to test the stability and slip recovery ability of the robot \parencite{almeida2018novel}. The floors used in this study were characterized by their coefficient of friction when in contact with the humanoid robot's instrumented shoe (ITshoe). Specifically, the floors exhibited coefficients of friction of 0.33, 0.26, 0.20, and 0.11, respectively, when in contact with the ITshoe. 

\subsection{Step frequency experiments}
%
In this study, a series of experiments were conducted in a simulated environment to investigate the impact of humanoid locomotion on different slippery floors. The aim was to gain a deeper understanding of the relationship between the robot's step frequency, which refers to the time it takes for the robot to perform one step, and the friction coefficients of four different floors to identify the best humanoid gait for real-world settings. To achieve this, a controlled experiment was designed and implemented, in which the humanoid step frequency was varied and the humanoid CoM was measured under different types of slippery floors.

The experiment involved the humanoid robot walking five times for 60 seconds on each of the four different floors, using five different frequencies. The chosen frequencies were the maximum frequency of the default humanoid NAO, the minimum frequency, and three equally separated frequencies between the maximum and minimum frequencies: 0.43, 0.47, 0.51, 0.55, 0.59 \si{s/step}. After collecting data from 100 experiments (i.e., 4 floors $\times$ 5 frequencies $\times$ 5 repetitions), data manipulation was performed to quantify the extent of slippage of the robot on each floor.
%
To achieve this objective, the average absolute Y-position of the CoM for each experiment was calculated.

In the next step, the average change in the direction of the robot's feet at each step was computed. This was done by taking the derivative of the average CoM Y-position data points. Then, a second derivative was applied to obtain the values that represent how much the robot slipped on each step. To exclude small slip actions that may occur due to possible errors associated with the robot's joints, controller, and/or the simulator environment, a slip threshold was added to consider only significant slip actions. The optimal threshold was determined empirically by observing the various outputs of the second-order derivative and selecting the value that best matched the noticeable slip observed in the different experiences. Specifically, a threshold of \num{1e-6} \si{\meter\per\second\squared} was chosen. To normalize the results, the accumulated slip was divided by the number of steps in each experience since different step frequencies represent different amounts of steps. \autoref{eq:slipthreshold} describes the steps used to quantify the robot's slip in each experience.
%
\begin{equation} \label{eq:slipthreshold}
S(i) = \dv[2]{A(i)}{t} , \qquad
|S(i)| > \theta \Rightarrow T = \frac{\sum |S(i)|}{n} \text{,}
\end{equation}
%
where $S$ represents the second-order derivative of the discrete sequence $A(i)$, which is calculated as the difference between $A(i)$ and $A(i-1)$, and $A(i+1)$ and $A(i)$, i.e., $S(i)=\left(A(i)-A(i-1)\right) - \left(A(i+1)-A(i)\right) = 2A(i)-A(i-1)-A(i+1)$. This equation is used to estimate the rate of change of the CoM Y-position at each step, which is a key parameter for detecting slips. $\theta$ represents the slip threshold, $n$ represents the number of steps and $T$ represents the total slippage that occurred in a complete experience. It is important to note that the absolute value of each detected slip was summed since we did not distinguish the direction of the slip.

As an example of the procedure described, \autoref{fig:plot1} and \autoref{fig:plot2} depict the CoM Y curves obtained for three examples of the resulting lowest slip sum and three examples of the resulting highest slip sum, respectively.

%%
\begin{figure}[!ht]
\centering
\begin{tikzpicture}
\begin{axis}[
    width=0.8\textwidth,
    height=4.5cm,
    xlabel={steps},
    ylabel={CoM Y  (\si{m})}, 
    legend pos=north west,
    legend style={
    	fill=white,
    	fill opacity=0.5,
    	draw opacity=1,
    	text opacity=1,
    	},
    yticklabel style={
        /pgf/number format/fixed,
        /pgf/number format/precision=3
        }
        ]
\addplot[
    color=red
    ]
    table [x index=0, y index=4, col sep=comma] {tex/contents/fig/c5/data1.csv};
\addlegendentry{example 1}
\addplot[
color=green
]
    table [x index=0,  y index=5, col sep=comma] {tex/contents/fig/c5/data1.csv};
\addlegendentry{example 2}
\addplot[
    color=blue
    ]
    table [x index=0,  y index=6, col sep=comma] {tex/contents/fig/c5/data1.csv};
\addlegendentry{example 3}
\end{axis}
\end{tikzpicture}
\caption{Absolute centre of mass position in the Y-axis for three exemplary walking trials on a flat surface resulting in the least amount of slip}
\label{fig:plot1}
\end{figure}

\begin{figure}[!ht]
\centering
\begin{tikzpicture}
\begin{axis}[
    width=0.8\textwidth,
    height=4.5cm,
    xlabel={steps},
    ylabel={CoM Y (\si{m})},
    legend pos=north west, legend style={fill=white, fill opacity=0.5, draw opacity=1, text opacity=1},
    yticklabel style={
    /pgf/number format/fixed,
    /pgf/number format/precision=3
    }
    ]
\addplot[
    color=red
    ]
    table [x index=0, y index=4, col sep=comma] {tex/contents/fig/c5/data2.csv};
\addlegendentry{example 1}
\addplot[
    color=green
    ]
    table [x index=0,  y index=5, col sep=comma] {tex/contents/fig/c5/data2.csv};
\addlegendentry{example 2}
\addplot[
    color=blue
    ]
    table [x index=0,  y index=6, col sep=comma] {tex/contents/fig/c5/data2.csv};
\addlegendentry{example 3}
\end{axis}
\end{tikzpicture}
\caption{Absolute centre of mass position in the Y-axis for three exemplary walking trials on a flat surface resulting in the highest amount of slip}
\label{fig:plot2}
\end{figure}

The slip corresponding to the previous examples is illustrated in \autoref{fig:plot3} and \autoref{fig:plot4}, respectively. Among these examples, we selected floor 3 with the lowest frequency as the best representative and floor 1 with the highest frequency as the worst representative.

%%%
\begin{figure} [!ht]
\centering
\begin{tikzpicture}
\begin{axis}[
    width=0.99\textwidth,
    height=7cm,
    xlabel={steps},
    ylabel={Slip (\si{\meter\per\second\squared})},
    legend pos=north east,
    legend style={
        fill=white,
        fill opacity=0.5,
        draw opacity=1,
        text opacity=1,
        legend columns=-1,        
        },
    yticklabel style={
        /pgf/number format/fixed,
        /pgf/number format/precision=3
        },
    enlarge y limits=0.2,   
    enlarge x limits=false,   
        ]
\addplot[
    color=red,
    mark=square,
    ]
    table [x index=0, y expr=abs(\thisrowno{1}), col sep=comma] {tex/contents/fig/c5/data1.csv};
\addlegendentry{|e1|}
\addplot[    color=green,    mark=triangle,    ]
    table [x index=0, y expr=abs(\thisrowno{2}), col sep=comma] {tex/contents/fig/c5/data1.csv};
\addlegendentry{|e2|}
\addplot[    color=blue,    mark=triangle,    ]
    table [x index=0, y expr=abs(\thisrowno{3}), col sep=comma] {tex/contents/fig/c5/data1.csv};
\addlegendentry{|e3|}
\addplot[    dashed,    domain=-1:51,    samples=2,    color=black,    ]
    {1e-6};
\addlegendentry{Threshold}
\end{axis}
\end{tikzpicture}
\caption[Slip and threshold visualization for the top three experiences with the least amount of slip]{Slip and threshold visualization for the top three experiences with the least amount of slip (e1, e2, e3 represent examples 1, 2, 3)}
\label{fig:plot3}
\end{figure}
%%

\begin{figure}[!ht]
\centering
\begin{tikzpicture}
\begin{axis}[
    width=0.99\textwidth,
    height=7cm,
    xlabel={steps},
    ylabel={Slip (\si{\meter\per\second\squared})},
    legend pos=north east,
    legend style={
        fill=white,
        fill opacity=0.5,
        draw opacity=1,
        text opacity=1,
        legend columns=-1,
        },
    yticklabel style={
            /pgf/number format/fixed,
            /pgf/number format/precision=3
            },
            enlarge y limits=0.2,
            enlarge x limits=false,
    ]
\addplot[
    color=red,
    mark=square,
    ]
    table [x index=0, y expr=abs(\thisrowno{1}), col sep=comma] {tex/contents/fig/c5/data2.csv};
\addlegendentry{|e1|}
\addplot[
    color=green,
    mark=triangle,
    ]
    table [x index=0, y expr=abs(\thisrowno{2}), col sep=comma] {tex/contents/fig/c5/data2.csv};
\addlegendentry{|e2|}
\addplot[
    color=blue,
    mark=triangle,
    ]
    table [x index=0, y expr=abs(\thisrowno{3}), col sep=comma] {tex/contents/fig/c5/data2.csv};
\addlegendentry{|e3|}
\addplot[
    dashed,
    domain=-1:68,
    samples=2,
    color=black,
    ]
    {1e-6};
\addlegendentry{Threshold}
\end{axis}
\end{tikzpicture}
\caption[Slip and threshold visualization for the top three experiences with the highest amount of slip.]{Slip and threshold visualization for the top three experiences with the highest amount of slip (e1, e2, e3 represent examples 1, 2, 3)}
\label{fig:plot4}
\end{figure}

The overall results of the experiment are presented in  \autoref{fig:slippery_floors}. 

\begin{figure}[!ht]
\centering
\begin{tikzpicture}
\begin{axis}[    
    width=\textwidth, 
    height=8.75cm,
    ybar,  
    legend image code/.code=
        {\draw [#1] (0cm,-0.1cm) rectangle (0.1cm,0.2cm); },
    bar width=12pt,   
    legend style=
        {fill=white, fill opacity=0.5, draw opacity=1, text opacity=1,legend columns=-1},
    ylabel={Slip Sum ($10^{-6}$) (\si{\meter\per\second\squared})},    
    ymin=0,    
    ymax=5,    
    symbolic x coords= {Floor 1 $\mu=0.33$, Floor 2 $\mu=0.26$, Floor 3 $\mu=0.20$, Floor 4 $\mu=0.11$},    
    xtick=data,    
    nodes near coords,    
    nodes near coords align={vertical},
    %%point meta=explicit symbolic,
%    legend style={at={(1.01,0.99)}, anchor=north east, xshift=-1cm},
    legend image post style,
    enlarge x limits=0.2,
    ]
\addplot [fill=blue]
    coordinates {(Floor 1 $\mu=0.33$, 2.8) (Floor 2 $\mu=0.26$, 2.7)  (Floor 3 $\mu=0.20$, 2.5)  (Floor 4 $\mu=0.11$, 2.8) };
\addplot [fill=red]
    coordinates {(Floor 1 $\mu=0.33$, 3.2) (Floor 2 $\mu=0.26$, 3.3)  (Floor 3 $\mu=0.20$, 2.9)  (Floor 4 $\mu=0.11$, 2.8) };
\addplot [fill=green]
    coordinates {(Floor 1 $\mu=0.33$, 3.4) (Floor 2 $\mu=0.26$, 3.4)  (Floor 3 $\mu=0.20$, 3.4)  (Floor 4 $\mu=0.11$, 3.3)};
\addplot [fill=orange]
    coordinates {(Floor 1 $\mu=0.33$, 3.6) (Floor 2 $\mu=0.26$, 3.6)  (Floor 3 $\mu=0.20$, 3.4) (Floor 4 $\mu=0.11$, 3.5) };
\addplot [fill=purple]
    coordinates {(Floor 1 $\mu=0.33$, 4.2)  (Floor 2 $\mu=0.26$, 4.0) (Floor 3 $\mu=0.20$, 4.2)  (Floor 4 $\mu=0.11$, 4.0)}; 
\legend{nsd 0.58, nsd 0.54, nsd 0.51, nsd 0.47, nsd 0.43}
\end{axis}
\end{tikzpicture}
\caption[Comparison of slip sum for different step frequencies and slippery floors.]{Comparison of slip sum for different step frequencies and slippery floors, where 'st' denotes the step time in seconds for a robot's stride.}
\label{fig:slippery_floors}
\end{figure}

The study indicates that a higher nominal step frequency, which corresponds to the robot taking longer time durations per step, results in more favorable outcomes in terms of reduced slipping on all types of floors. Moreover, we observed a proportional relationship between step frequency and outcomes, with lower frequencies resulting in higher slip sums and vice versa. These findings demonstrate that, similar to humans, robots must adjust their gait to maintain stability on slippery surfaces. In our study, this involved reducing the step frequency to minimize the risk of slipping or falling.

Given that a specific step frequency for each floor was not identified, this study fell short of our goal of real-time adaptation of the controller to optimize walking on diverse surfaces. To address this limitation, we conducted a follow-up experiment focused on the EYC controller. The results of this study provided valuable insights into optimizing the controller's parameters to improve the robot's stability and mobility on various floors.


\subsection{EYC adaptive controller experiments}

For the EYC controller to adapt the humanoid's locomotion based on its orientation, the PID parameters that would yield the best results were investigated. To determine the suitable PID parameters for stabilizing the humanoid robot orientation on slippery floors, a series of experiments on gazebo simulator was performed. Before describing the experiment in detail, it is essential to define the metrics used to evaluate the robot's performance on different surfaces.

\subsubsection{Performance metrics}

In order to assess and compare the performance of the controller and define the best parameters, some metrics are proposed: task time duration ($T_D$), stability ($S_{\mathrm{idx}}$), and energy consumption ($E_C$). These metrics have been established and utilized in previous literature, as evidenced by \textcite{aller2019state}.

The task time duration refers to the time necessary for the humanoid robot to complete a given task, such as walking a certain distance on a slippery surface. This metric allows us to compare the efficiency of different control strategies in terms of completing tasks quickly and accurately.

The stability of the robot was measured using the root mean square error (RMSE) of the Center of Mass (CoM) and Zero Moment Point (ZMP) trajectories in relation to ideal straight line trajectories, where, for a generic quantity $A$:
%
\begin{equation} \label{eq:RMSE}
    \mathrm{RMSE}(A)=\frac{1}{N}\sum_{i}\sqrt{\left(A_{i}^{real} - A_{i}^{plan} \right)^2}.
\end{equation}% 

Each component of RMSE, including CoM in x and y directions and ZMP in x and y directions, was given equal weight, accounting for $\frac{1}{4}$ of the total weight in the calculation of RMSE. A lower RMSE indicates better stability, as the robot is better able to maintain its balance and avoid falling on the slippery surface. The stability index is defined as:
%
\begin{equation}\label{eq:stabilityindex_vs}
S_{\mathrm{idx}}=\frac{1}{4}\left(
\text{RMSE}_{{\mathrm{CoM}_x}} + \text{RMSE}_{{\mathrm{CoM}_y}} + \text{RMSE}_{{\mathrm{ZMP}_x}} +  \text{RMSE}_{{\mathrm{ZMP}_y}} \right).
\end{equation}
%

Finally, to evaluate the energy balance of the control strategies, the energy consumption of the different experiments was compared using a simplified metric. Given the relatively small and lightweight nature of the NAO humanoid robot, the contribution of friction and other energy losses was negligible in comparison to the energy consumed by the robot's actuators. Therefore, for simplicity and practicality, the energy consumption was approximated by integrating, for all time steps ($k={0,..., N_T}$), the product of the joint torque ($\tau_i$) with the angular velocity ($\omega_i$) for all the robot joints ($i={1,...,N_J}$), during each $\Delta t$. This allowed us to focus on the energy consumed by the joints as the main sources of energy consumption for the robot. The energy consumption is defined as:

\begin{equation}\label{eq:energyconsumption_vs}
E_C=\sum_{k=0}^{N_T} \sum_{i=1}^{N_J} \tau_i(k) \omega_i(k) \Delta t .
\end{equation}

This simplified metric enabled us to compare the performance of the different control strategies and identify the most energy-efficient approach for the tasks at hand, while disregarding other factors,  such as robot size, design, environment, and power source that would have contributed only marginally to the overall energy budget.

The performance of the implemented digital PID controller on four different slippery floors was evaluated using a combination of the three metrics, as shown in \autoref{eq:metrics}. The system's performance decreases as the value of $M$ increases. 

%\begin{equation} \label{eq:metrics}
%\text{M} = \frac{1}{3}(\text{Time} + \text{Energy} + \frac{1}{4}\sum_{i\in{x,y}}\sum_{j\in{\text{CoM},\text{ZMP}}}\text{RMSE}_{j,i})
%\end{equation}

\begin{equation} \label{eq:metrics}
M = \frac{1}{3} \left( \frac{T_D}{T_{D_{\mathrm{max}}}} + \frac{E_C}{E_{C_{\mathrm{max}}}} + \frac{S_{\mathrm{idx}}}{S_{\mathrm{idx}_{\mathrm{max}}}} \right),
\end{equation}
%
where $T_{D_{max}}$, $E_{C_{max}}$, and $S_{\mathrm{idx}_{max}}$ correspond to the maximum values obtained across all the experiments.

The equation calculates the overall performance metric $M$, which is a weighted sum of normalized duration, energy, and the average RMSE of the CoM and ZMP positions over both axes. The normalization was performed using the maximum value of each metric to respectively scale them to a common range.

%And if so, how are these "max" values established? And perhaps these normalizations should be included in their original formulas presented earlier! % _vs you had forgetten to coment this :-)
%

\subsubsection{Digital PID controller optimization}
%
To adjust the PID parameters, the initial setup was manually tuned to establish a baseline for comparison. Data was then collected on the robot's performance on four different slippery surfaces, systematically varying the P, I, and D gains. This allowed for the evaluation of the impact of each parameter on the robot's stability and mobility and identification of the optimal combination of parameters for each surface. By using this approach, the PID controller's parameters were fine-tuned to enhance the robot's performance on a variety of surfaces, ensuring optimal stability and mobility.

After each experiment, the results were evaluated using the defined metrics. Due to the complexity of the model, an analytical approach was not feasible, and an empirical approach was employed to identify the set of PID parameters that resulted in the best performance according to the metrics. Finally, the parameters that yielded the best performance across all experiments were selected for further analysis and comparison.

As will be demonstrated in this section, the optimized value of the integral parameter will be set to zero, effectively reducing the PID controller to a PD controller.

\paragraph{Optimized PID gains}
%
To illustrate the results of our experiments, we present three graphics showcasing the performance of the controller on the first floor, which has a coefficient of friction of 0.33. Chart in \autoref{graph1} displays the performance task results for five repetitions for each variation in the proportional gain while fixing the integral and derivative parameters. During the experiment, the controller was used while the robot walked 2 meters on the floor. Chart in \autoref{graph2} presents the performance results using the optimized proportional gain and the fixed derivative gain while varying the integral gain. Finally, Chart in \autoref{graph3} shows the results obtained with the optimized proportional and integral gains while varying the derivative gain.

\begin{figure}[!ht]
\centering
\begin{tikzpicture}
\begin{axis}[    
    width=0.9\textwidth,
    height=6.0cm,
    ybar,
    ymin=0.5,
    ymax=1.0,
 %   ytick={0.5,0.6,0.7,0.8,0.9,1.0},
    xticklabels={0.50, 0.90, 0.95, 0.96,0.97, 0.98, 0.99, 1.00, 1.01, 1.02, 1.10},
    xtick={1,2,3,4,5,6,7,8,9,10,11},
 %   xticklabel style={rotate=60,anchor=east},
    bar width=10pt,
    xlabel={Proportional gain},
    ylabel={Task result},
    nodes near coords,
    nodes near coords align={vertical},
]
\addplot[
    fill = cyan,
] coordinates {
    (1,0.9034)
    (2,0.9328)
    (3,0.8744)
    (4,0.8938)
    (5,0.8710)
    (6,0.8546)
    (7,0.8956)
    (8,0.8721)
    (9,0.9147)
    (10,0.8874)
    (11,0.9296)
};
\end{axis}
\end{tikzpicture}
\caption{Experiment proportional gain impact on the task performance.}
\label{graph1}
\end{figure}

\begin{figure}[!ht]
\centering
\begin{tikzpicture}
\begin{axis}[       
    width=0.9\textwidth,
    height=6.0cm,
    ybar,    
    ymin=0.5, 
    ymax=1.0,  
 %   ytick={0.5,0.6,0.7,0.8,0.9,1.0},  
    xticklabels={0.00,0.01,0.02,0.03,0.05,0.10,0.20},    
    xtick=data,    
    bar width=10pt,    
    xlabel={Integral gain},    
    ylabel={Task result},    
    nodes near coords,    
    nodes near coords align={vertical},    
    ]
\addplot[
fill = cyan,
] coordinates {
    (1,0.8492)
    (2,0.9124)
    (3,0.8612)
    (4,0.8787)
    (5,0.8856)
    (6,0.9113)
    (7,0.9248)
};
\end{axis}
\end{tikzpicture}
\caption{Impact of integral gain on task performance.}
\label{graph2}
\end{figure}

\begin{figure}[!ht]
\centering
\begin{tikzpicture}
\begin{axis}[       
    width=0.9\textwidth, 
    height=6.0cm,
    ybar,    
    ymin=0.5, 
    ymax=1.0,  
 %   ytick={0.5,0.6,0.7,0.8,0.9,1.0},  
    xticklabels={0.00, 0.01, 0.02, 0.03, 0.05, 0.10},    
    xtick=data,    
    bar width=10pt,    
    xlabel={Derivative gain},    
    ylabel={Task result},    
    nodes near coords,    
    nodes near coords align={vertical},
    ]
\addplot[
fill = cyan,
] coordinates {
    (1,0.9558)
    (2,0.8468)
    (3,0.9391)
    (4,0.8933)
    (5,0.9105)
    (6,0.9260)
};
\end{axis}
\end{tikzpicture}
\caption{Experiment derivative gain impact on the task performance.}
\label{graph3}
\end{figure}


The optimized digital PID gains were determined as P=0.98, I=0.00, and D=0.01 for the first floor, using it as an example for our task. The same procedure was repeated for each floor, resulting in the corresponding optimized PID gains, as shown in Table \ref{table:floor_pid}.

%% Problem with this table 1,1 it shows "2-5" % \cline it generating error ;-( replace my \cmidrule! vsantos
\begin{table}[!ht]
\centering
\setlength{\tabcolsep}{12pt} %vsantos
\begin{tabular}{c|*{4}{c}}
\multicolumn{1}{c}{} & \multicolumn{4}{c}{CoF} \\
%\cline{2-5} %failing for some undisclosed reason!
\cmidrule{2-5}
\multicolumn{1}{c}{} & \textbf{0.33} & \textbf{0.26} & \textbf{0.20} & \textbf{0.11} \\
\midrule
P & 0.98 & 0.99 & 1.01 & 1.04 \\
I & 0.00 & 0.00 & 0.00 & 0.00 \\
D & 0.01 & 0.01 & 0.01 & 0.01 \\
\bottomrule
\end{tabular}
\caption{Best PID gains for each floor}
\label{table:floor_pid}
\end{table}


As the floor becomes increasingly slippery, we observe that the proportional gain (P) of the controller increases to enhance its responsiveness. This is because a more slippery surface tends to induce slower responses from the system to changes in orientation, necessitating a higher P value to achieve the desired level of control. Our empirical analysis revealed that the optimal integral term for this controller is I=0, indicating that the system is able to compensate for any steady-state error without requiring the integral term. Furthermore, the derivative gain obtained was D=0.01 for all experiments, suggesting that the current level of derivative gain is appropriate and does not require adjustments in response to changes in floor slipperiness.

\paragraph{Performance evaluation: variable vs. fixed PD gains}

To demonstrate the effectiveness of the approach, a series of experiments were conducted in which the humanoid robot walked 2 meters on four different slippery floors, each \SI{50}{cm} long, and repeated the process five times. The performance of using a fixed-gain PD controller with the best gains for the first floor was compared against a variable-gain PD controller with optimized gains for each floor that the robot walked on. 
The results presented in Table \ref{tab:res} show that implementing the best PD gains for each floor led to a significant improvement in the robot's overall performance. On average, the robot achieved an approximately \SI{10}{\percent} increase in performance, with the most noticeable improvements observed on the last two floors, which had lower friction. The primary factor contributing to the improvement observed with the variable PD control method was the robot's resulting enhanced stability performance. Moreover, using the variable PD also resulted in lower energy consumption during task execution. However, the difference in task completion time between the two PD control methods was insignificant, with a slightly better performance observed for the fixed PD. Overall, when considering the three metrics with equal weight, the impact of the variable PD control method is evident, particularly on floors with reduced friction.
%
\begin{table}[!ht]
\centering
\setlength{\tabcolsep}{12pt}
\begin{tabular}{c|cc}
\multicolumn{1}{c}{}& \textbf{Variable PD per floor} & \textbf{Fixed PD on all floors} \\
\midrule
M floor 1 & 0.9997 & 0.9999 \\
M floor 2 & 0.9773 & 0.9996 \\
M floor 3 & 0.7568 & 0.9998 \\
M floor 4 & 0.8716 & 0.9987 \\ \midrule
M experience & 0.9013 & 0.9995 \\
\bottomrule
\end{tabular}
\caption[Experiment results by floor and overall experience, comparing the performance of the robot.]{Experiment results by floor and overall experience, comparing the performance of the robot using optimized PD gains for each floor versus using the same gains for all floors.}
\label{tab:res}
\end{table}

\autoref{fig:comparison} shows an example of one of the experiments CoM Y to illustrate the stability using a fixed-gain PD versus an adaptive-gain PD.

\begin{figure}[!ht]
\centering
\begin{tikzpicture}
\begin{axis}[
    ylabel={CoM y (\si{m})},
    legend style={
        at={(0.5,-0.19)},
        anchor=north,
        legend columns=-1,    
    },
    ymajorgrids=true,
    grid style=dashed,
    width=\textwidth,
    xlabel={time (\si{s})},
    xmin=0,
    xmax= 50,
    ymin=-5.2e-2,
    ymax=6e-2,  
    height=7cm  
]

\pgfplotstableread[col sep=comma, header=true]{tex/contents/fig/c5/data3.csv}{\datatable};

\addplot[
    no markers,
    color=blue,
    opacity=0.5
    ] table[x=x, y=z] {\datatable};
\addlegendentry{CoM y adaptive PD}

\addplot[
    no markers,
    color=red,
    opacity=0.5
    ] table[x=x, y=y] {\datatable};
\addlegendentry{CoM y non-variable PD}

\addplot[
    no markers,
    color=black,
    dashed,
    opacity=0.8
    ] table[x=x, y=ref] {\datatable};
\addlegendentry{Desired CoM y}

\draw[black, dashed] (12.5,-6e-2) -- (12.5,8e-2);
\draw[black, dashed] (25,-6e-2) -- (25,8e-2);
\draw[black, dashed] (37.5,-6e-2) -- (37.5,8e-2);

\node[anchor=west, text=red] at (axis cs:6,5e-2) {P=0.98};
\node[anchor=west, text=red] at (axis cs:18.5,5e-2) { P=0.98};
\node[anchor=west, text=red] at (axis cs:31,5e-2) { P=0.98};
\node[anchor=west, text=red] at (axis cs:43.5,5e-2) { P=0.98};

\node[anchor=west, text=blue] at (axis cs:0.1,5e-2) { P=0.98};
\node[anchor=west, text=blue] at (axis cs:12.6,5e-2) { P=0.99};
\node[anchor=west, text=blue] at (axis cs:25.1,5e-2) {P=1.01};
\node[anchor=west, text=blue] at (axis cs:37.6,5e-2) { P=1.04};

\node[anchor=west, text=black] at (axis cs:0.1,-4e-2) {CoF: 0.33};
\node[anchor=west, text=black] at (axis cs:12.6,-4e-2) {CoF: 0.26 };
\node[anchor=west, text=black] at (axis cs:25.0,-4e-2) {CoF: 0.20};
\node[anchor=west, text=black] at (axis cs:37.5,-4e-2) {CoF: 0.11};

\end{axis}
\end{tikzpicture}
\caption{Comparison of absolute centre of mass position in the Y-axis using an adaptive PD controller vs non-variable PD}
\label{fig:comparison}
\end{figure}

From the graph in \autoref{fig:comparison}, it can be observed that, initially, the pattern is similar for both the adaptive and fixed PD controllers. This can be attributed to the floors being less slippery and the proportional value being the same for both controllers in the beginning. However, as the experiment progresses towards more slippery floors, the adaptive PD controller exhibits a more effective response to the slippage caused by the lower friction of these floors. The controller's adaptability to the floor on which the robot is walking is attributed to our prior research, which involved the development of an ITShoe for measuring ground reaction force data, and the implementation of a Long-Short Term Memory (LSTM) network to identify the various floor types.

It is important to note that, for the defined performance metric, a lower value indicates better performance. In other words, achieving a smaller task time, lower energy consumption, and less stability error are desired outcomes.

This demonstrates the versatility and effectiveness of the controller used in this work to adapt to different slippery floor conditions.


The experimental results presented here are illustrated in a video available on YouTube\footnote{\url{https://youtu.be/aWqmWoWTbv8}}, which provides a better understanding of the problem and the observed behaviours.

\section{Conclusion}
\label{sec:4}

In this study, we have demonstrated the versatility and potential of the controller developed in \parencite{1809.02167} by successfully adapting and implementing it to control our humanoid robot. Our findings highlight that the integration of an Embedded Yaw Controller (EYC) has significantly enhanced the overall performance of the robot while walking on slippery floors. This improvement was particularly evident when the robot was exposed to different types of slippery surfaces, effectively mitigating the challenges posed by the varying conditions. Furthermore, the EYC has also successfully rectified the non-linear paths resulting from the robot's unconventional building technique, contributing to a more stable and controlled gait. It is worth noting that we assumed the robot's ability to identify the type of floor it is walking on, as this issue was resolved in a prior study \parencite{9598809} using the ITShoe and a LSTM. As part of future work, the plan is to conduct tests on the physical humanoid robot and make necessary adjustments to seamlessly integrate floor detection with the controller adaptation. This would involve transitioning from Robot Operating System (ROS) to Yet Another Robot Platform (YARP)  and translating the forces measured by the ITShoe to ankle forces and torques for the robot. 

\newpage
\thispagestyle{empty} % To remove headers and footers
