\documentclass[journal,twoside,web]{ieeecolor}
\usepackage{jsen}
%\IEEEoverridecommandlockouts
%The preceding line is only needed to identify funding in the first footnote. If that is unneeded, please comment it out.
\usepackage{hyperref}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{csquotes} %vs. Recommended to avoid warnings
\usepackage{amsmath,amssymb,amsfonts}
\usepackage{xcolor}
\usepackage{wrapfig}
\usepackage{mwe}
\usepackage{booktabs}
\newcommand\solidrule[1][1cm]{\rule[0.5ex]{#1}{.4pt}}
\newcommand\dashedrule{\mbox{%
  \solidrule[1mm]\hspace{1mm}\solidrule[1mm]\hspace{1mm}\solidrule[1mm]}}
%\usepackage[noadjust]{cite} %vs commented - incompatible with biblatex
\usepackage{algorithmic}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{matrix,backgrounds,calc,shapes}
\usepackage[
backend=bibtex,
style=numeric, %numeric is easier to read, unless template requires differently
sorting=none %%%% ynt -> ordered by year-name-t, "none" = All entries are processed in citation order.
]{biblatex}
%
\renewcommand*{\bibfont}{\small}
\addbibresource{ref.bib}
%
% \usepackage{float}
% \usepackage{fixltx2e}
%\usepackage{stfloats} % to allow fullwidth figure at the bottom of a two column document!
%\usepackage{dblfloatfix} %better than previous?
\usepackage{balance}
%\usepackage{flushend} %does this work better than previous?
\usepackage{ifthen}
\usepackage{pgfplots}
\pgfplotsset{compat=1.3}
\usepackage{pgfplotstable}
\usepackage{textcomp}
\usepackage{siunitx}
\let\labelindent\relax
\usepackage{enumitem}
\graphicspath{ {./Images/} }
\sisetup{detect-all}
\sisetup{separate-uncertainty = true}
\widowpenalty=5000  %to reduce effect of widow lines
%
\def\BibTeX{{\rm B\kern-.05em{\sc i\kern-.025em b}\kern-.08em
    T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}}
%
\definecolor{abstractbg}{rgb}{0.89804,0.94510,0.83137}
\setlength{\fboxrule}{0pt}
\setlength{\fboxsep}{0pt}
%
\newcommand{\vsr}[1]{\textcolor{red}{#1}}  %annotate with red text
\newcommand{\vsb}[1]{\textcolor{blue}{#1}}  %annotate with blue text
%
\begin{document}
%\title{Real-time LSTM-RNN Classification of Floors with Different Friction Coefficients for a Walking Humanoid Robot using a Wearable 3D Force System}
\title{Real-time LSTM-RNN Classification of Floors with Different Friction Coefficients for a Walking Humanoid Robot Wearing a 3D Force System}
\author{Luís Almeida, Vítor Santos, and João Ferreira
%not sure if "of, with, for a, using a" should also be written with an uppercase letter
\thanks{The Fundação para a Ciência e Tecnologia (FCT) is gratefully acknowledged for funding this work with the grant SFRH/BD/136680/2018.}% and PTDC/EEI-AUT/5141/2014 (Automatic Adaptation of a Humanoid Robot Gait to Different Floor-Robot Friction Coefficients) and Project UIDB/00127/2020. The authors also acknowledge the COMPETE 2020 program for the financial support with the PTDC/EEI-AUT/5141/2014.}
\thanks{Luís Almeida is with the Institute of Electronics and Informatics Engineering of Aveiro (IEETA), Portugal (luis93.pa@gmail.com).}
\thanks{Vítor Santos is with the Institute of Electronics and Informatics Engineering of Aveiro (IEETA) and with the Department of Mechanical Engineering, Aveiro, Portugal (vitor@ua.pt).}
\thanks{João Ferreira is with the Department of Electrical Engineering, Superior Institute of Coimbra and with the Institute of Systems and Robotics (ISR), Coimbra, Portugal (ferreira@isec.pt).}}
%
\IEEEtitleabstractindextext{%
\fcolorbox{abstractbg}{abstractbg}{%
\begin{minipage}{\textwidth}%
\begin{wrapfigure}[15]{r}{3in}%
\includegraphics[width=3in, height=1.8in]{Images/abstract_almei.jpg}%
% 
\end{wrapfigure}%
\begin{abstract}
In the study of biped humanoid robots it is crucial to achieve high precision and robustness in locomotion. Humanoid robots that operate in real world environments need to be able to physically recognize different grounds to best adapt their gait without losing their dynamic stability. This work proposes a technique to classify in real time the type of floor from a set of possibilities learnt off-line. Hence, the paper describes the collection and preparation of a dataset of contact forces, obtained with a wearable instrumented system, mixed with the information of the robot internal inertial sensor to classify the type of underlying surface of a walking humanoid robot. For this classification, the data are acquired for four different slippery floors at a rate of \SI{100}{\hertz} and it is used as input for a long short-term memory (LSTM) recurrent neural network (RNN). After testing different learning models architectures and tuning the models parameters, a good mapping between inputs and targets is achieved with a test classification accuracy greater than \SI{92}{\percent}. A real time experiment is presented to demonstrate the suitability of the proposed approach for the multi-classification problem addressed.
\end{abstract}
%
\begin{IEEEkeywords}
Computational Intelligence Techniques, Floor classification, Humanoid Robot locomotion, Wearable Instrumented System, LSTM 
\end{IEEEkeywords}
\end{minipage}}}
\maketitle
\section{Introduction}
The study of humanoids increasingly contributes to several scientific areas of which it is possible to extrapolate improvements to our lives, such as in walking rehabilitation, dangerous works, or elderly assistance. To achieve a robot capable of servicing and assisting people, first it has to be able to perform fundamental locomotion tasks such as balancing and walking \cite{pratt2010toward}. Despite the progress and efforts made in the past years, humanoid locomotion is still a challenging problem without definitive solution. Developing a good system that allows a biped robot to walk on unknown and diversified floors, e.g. slippery floors, requires the system to be intelligent and autonomous to adapt in real time so that the robot can successfully overcome the barriers found during locomotion tasks \cite{siciliano2016springer}. In most of the bipedal locomotion
approaches, hard contacts with the ground are assumed, although, in real life scenarios this is normally not accurate. Despite the several developments over the years, there are no explicit implementations which deal with the changing floor properties \cite{hopkins2015design}. This oversight may lead to disastrous consequences, e.g. the biped robot falls while walking on a non-modeled ground, most of the times preventing the robot to continue its locomotion tasks. \\
\indent Having an intelligent algorithm that allows the robot to identify the terrain with good accuracy, using force sensors installed on its feet or assembled under it, will give the possibility to eliminate most of the falls while walking on different surfaces \cite{walas2016terrain, multi_axis_review}. The increasing progresses made in the areas of artificial intelligence and machine learning, lead to a significant impact in
this field. With the rise of techniques such as neural networks, recurrent neural networks (RNNs), deep learning and reinforcement learning, humanoids can now perform tasks that previously seemed far-fetched.\\
%
\indent In this work, the capabilities of a Long Short-term Memory Recurrent Neural Network (LSTM-RNN) (first presented in \cite{schmidhuber1997long}) were analysed to classify the underlying surface of a walking robot. To feed the network, a wearable instrumented system assembled to a robot foot was used to measure the ground reaction forces (GRFs), and the internal robot inertial sensors were used to measure the body accelerations and inclinations on different slippery floors. The choice of this type of network was mainly due to its feedback loop which serves as a kind of memory. This means that the past inputs leave a footprint on the model that is expected to be an asset, e.g., when the humanoid robot moves from one floor to another. These networks are capable of recognizing temporal encrypted patterns from dynamic data, which is what happens between the interaction of the humanoid's foot and the different floors; indeed, humanoid walking can be considered a time-dependent task. Additionally, our approach does not require a time window for offline processing, hence, the classification can be done online at every new robot step. The main contribution of our work is the classification of slippery floors using a novel instrumented system that can be adapted to different humanoid robots. This classification will provide knowledge of the characteristics of different floors on which the robot walks to the humanoid controller, thus allowing it to adapt the robot gait according to the different slippery floors requirements.   \\
%
\indent Several published works in the field of humanoid robots show the applicability and capabilities of the LSTM-RNN \cite{Yu20201335, Ko20201200, Lobos-Tsunekawa20183247,Kerzel2019,Bhattacharjee2018,chalvatzaki2019lstm, bi_lstm}. For example, in \cite{how2014multiple} a LSTM-RNN model was used to classify six different robot behaviours based on ten robot joint time sequences. In \cite{zhao2018collaborative} it was used to generate a robotic motion from the observations of the human movements to achieve fast and responsive human robot collaborative tasks, avoiding the trouble of solving an inverse kinematics or motion planning problem. In \cite{yu2020walking} kinect sensors were used to obtain walking information of the human body under different slopes, and the data collected are used to feed a LSTM neural network to learn the degrees of freedom of multiple lower limb joints, classify and recognize the different slopes and to compensate the robot's ankle joints based on the slope inclination. The results show a robot NAO able to walk on different slopes. In another example \cite{li2018mobile}, the authors used a LSTM network to classify motor fault in mobile robots achieving an accuracy of \SI{87}{\percent}. 
\indent In \cite{li_sequential_2021} the authors used the robot's foot soles pressure sensors and inertial measurement unit (IMU) to feed a LSTM network. They used the sensors to calculate two-directions center of pressure (CoP) and the IMU to obtain two-direction acceleration. The authors report that the robot walking process based on the LSTM output is better than when using a fixed gait. Another example using pressure sensors data and a LSTM network is addressed in \cite{zhang_fingervision_2018}. The authors used these sensors to collect data while interacting with different daily objects. The developed LSTM presented a 97.62\% accuracy on the test dataset, being that the authors expect that this good slippery classification can improve the robot grasping skills, leading to a better contact and smoother interaction/manipulation. \\
%
\indent Different LSTM architectures and their combination with other networks have also been increasingly studied and applied in the humanoid field. In \cite{9292620} the authors used a bidirectional LSTM-based network which makes use of historical measurements of system states to predict humanoid fall probability in real-time. In \cite{farazi2017online} a deep LSTM network was trained with simulated data and fine-tuned on a set of real data to track and identify Robots with identical appearance. Since the analysed data are transmitted via Wi-Fi, some delay or even data loss are expected, hence the importance of using a LSTM. Similarly, in \cite{zhen_walking_2019} a deep network LSTM was also used, but here the authors fed the network with acceleration signals and used it to detect gait-phases of a walking human, presenting a F-score higher than 92\%. In \cite{li_cnn_2019} a LSTM network was combined with a convolutional neural network (CNN) to improve the human-robot interaction. The CNN was used to extract visual features and the LSTM network was used to find the relationship between these features and six basic emotions. The humanoid is able to adapt its response based on the human emotion classified with the LSTM model. \\
%
\indent Our approach is comparable to the floor classification problem addressed by \cite{wang2020situ} since a LSTM network is explored to solve the problem, but the approaches differ because \cite{wang2020situ} uses the humanoid foot sinking state and the force reads from a load cell embedded in the robot's ankle to classify deformable terrains, whereas we combine data from the robot inertial sensor and eight force sensors to classify different slippery floors. They achieved \SI{95}{\percent} accuracy on average during experiments.\\
%
\indent The remainder of this work is divided as follows. Section II presents the materials and methods for the data collection and manipulation. The LSTM network implementation, tuning and online experimental results are presented in Section III. Lastly, Section IV presents the conclusions and future challenges.
%
\section{Materials and methods}

In previous research activities \cite{almeida2018novel}, an instrumented system was developed to be seamlessly assembled on the walking humanoid robot NAO to measure real-time vertical and horizontal ground reaction forces (GRFs). The GRFs are divided into total normal force (vGRFs) and total horizontal force (hGRFs). The developed system is a cost-effective, lightweight and wirelessly instrumented shoe (ITshoe). The ITshoe used on this work is presented in Fig. \ref{fig:itshoe}.

\begin{figure}[!h]
    \centering
    \includegraphics[width=\columnwidth]{almei1.png}
    \caption{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.}
    \label{fig:itshoe}
\end{figure}
%
The hGRFs can be represented in the sagittal and transverse plane, as depicted in Fig. \ref{fig:itshoe}, and calculated as follows:
%
\begin{align}
Fh_{st} &= \frac{\sqrt2}{2} \cdot[(S1_{45} + S2_{45}) - (S3_{45}+S4_{45})]\\ 
Fh_{tt} &= \frac{\sqrt2}{2} \cdot[(S2_{45} + S4_{45}) - (S1_{45}+S3_{45})] \text{,}
\end{align}
%
where $Fh_{st}$ is the total horizontal force in the sagittal plane, $Fh_{tt}$ is the total horizontal force in the transverse plane and $S1_{45}$ to $S4_{45}$ are the four Flexiforce sensors, positioned at \ang{45}, used to measure the tangential forces.\\
%
The ITshoes are divided into three units (see Fig. \ref{fig:itshoe}):
%
\begin{description}[labelindent=\parindent, labelwidth=2.5em, labelsep=8pt]
\item [Sensing unit -] Composed of eight piezo-resistive A301 flexiforce sensors;
\item [Acquisition unit -] Deals with the electrical conditioning and power supply;
\item [Streaming unit -] Receives the data across a serial communication with the micro-controller and forwards it to the server, through the ESP8266 Wi-Fi module.
\end{description}
%
The robot NAO also communicates with the server through Wi-Fi and its main software is used to make it walk. The high-level functions allow to define the walking distance and gait configuration parameters, such as, step length, height, frequency and torso translation along the X and Y axis. The server runs the open-source system ROS that deals with all the data flow and communications with the ITshoes and the Robot (for further details, see \cite{almeida2018novel}).
%
The dataset used for this work were recorded using the ITshoes sensors and the humanoid robot NAO internal sensors at a frequency of 100 Hz. 
%
\subsection{Floor multi-classification problem}
%
This work extends the study presented in \cite{almeida2020learning} to classify different slippery floors on which the humanoid robot NAO has to walk while wearing the ITshoes. Our hypothesis is that each floor has a particular characteristic when identified by the ITshoes force sensors together with the robot NAO inertial unit, which is positioned in the center of the body of the humanoid NAO, namely data from its 3-axis gyroscope, acceleration and body inclination.  
Fig. \ref{fig:layout} shows the layout used to collect data for the addressed multi-classification problem. 

\begin{figure}[!h]
    \centering
    \includegraphics[width=\columnwidth, height=4cm]{almei2}
    \caption{Layout for data collection with four different floors.}
    \label{fig:layout}
\end{figure}
%
The system \mbox{NAO+ITshoes} is used to collect data while the humanoid NAO walks on four different slippery floors: Polytetrafluoroethylene (PTFE); Aluminium; Polyethylene high-density (PE-HD); and Melamine floor. We only focused on the slippery characteristic of these floors since the forces that the humanoid NAO exert on these rigid and flat floors while walking are not significant and do not produce meaningful elastic or permanent deformation. However, our classification can be associated with different material properties, and can also be used to classify different floors such as deformable floors. Table \ref{t:cof} presents the coefficient of friction (CoF) for the different materials used as the walking floors. Acrylic is the base material of the ITshoes.

\begin{table}[h] %[!t]
	\centering
	\caption{Floor-Shoe coefficient of friction}
	\begin{tabular}{lcl}	
		\toprule
		Material  & \multicolumn{2}{c}{Coefficient of Friction}  \\ 		\midrule
		Acrylic-Polytetrafluoroethylene (PTFE)    & \multicolumn{2}{c}{0.11} \\
		Acrylic-Aluminium   & \multicolumn{2}{c}{0.20} \\
		Acrylic-Polyethylene high-density (PE-HD) & \multicolumn{2}{c}{0.26} \\
		Acrylic-Melamine  & \multicolumn{2}{c}{0.33}  \\ \bottomrule
	\end{tabular}
	\label{t:cof}
\end{table}
%

%
\subsection{Data manipulation}
%
Before classifying the floors using the LSTM-RNN, it is necessary to pre-process the raw data. The following procedure describes the developed algorithmic methodology to extract the data that corresponds to the humanoid robot steps, and to format its representation to be used as inputs for the learning approach. The algorithm reads the recorded raw data from the database and outputs only the data that corresponds to moments when the robot's foot is in contact with the floor. The main steps of the algorithm are as follows:
%
\begin{enumerate}[label=(\alph*)]
\item Use the calibration curves to convert each sensor ($S(i)$) raw data into forces, as given by:
\begin{equation}
F(i) = -\frac{b(i)}{R(i)\left(\frac{1023}{S(i)}-1\right)} \frac{1}{m(i)}, \quad
i \in \left \{1,...,8 \right \} 
\label{123}\text{,}
\end{equation}
%
where $R(i)$ is the voltage divider resistor, $m(i)$ and $b(i)$ are the calibration curve slope and y-interception respectively, and 1024 ($2^{10}$) refers to a 10-bit analog to digital converter (ADC);
%
\item Obtain the start and end of each step: the points where $Fn(i) \approx 0$ (normal force $\approx 0$, robot foot is in the air);
%
\item Use the indices $i$ for which $Fn(i) \neq 0$ to filter the data points for all the recorded variables;
\item Normalize each data point to be in the range [-1,1] ;
%
\item Reshape the data according to the LSTM model needs.
\end{enumerate}
%
\subsection{Data for LSTM training, validation and testing}
%
\label{subsectionLSTM}
%
The resulting dataset for this work includes 27800 labeled sequences. Each input sequence consists of 11 features, each composed of 50 samples. Despite the fact that the measured vertical forces are crucial for the data collection and manipulation, these were not used as features to train the network due to the dynamics involved in the robot step being so small that the variability of the normal force sensors are of limited use \cite{almeida2020learning}. 
The 11 selected features to represent the robot's behaviour on the different studied floors are as follows:
%
\begin{description}[labelindent=\parindent, labelwidth=2.5em, labelsep=8pt]
\item [$Fh_{st}$] Horizontal force in the sagittal plane (\si{N});
\item [$Fh_{tt}$] Horizontal force in the transverse plane (\si{N});
\item [$G_{x}$] Gyroscope X axis (\si{rad/s});
\item [$G_{y}$] Gyroscope Y axis (\si{rad/s});
\item [$G_{z}$] Gyroscope Z axis (\si{rad/s});
\item [$Acc_{x}$] Accelerometer X axis (\si{m/s^2});
\item [$Acc_{y}$] Accelerometer Y axis (\si{m/s^2});
\item [$Acc_{z}$] Accelerometer Z axis (\si{m/s^2});
\item [$BI_{x} $] Body inclination X axis (\si{rad});
\item [$BI_{y}$] Body inclination Y axis (\si{rad});
\item [$BI_{z}$] Body inclination Z axis (\si{rad}).
\end{description}
%
The data are prepared and randomly divided into three subsets: the training set (\SI{60}{\percent}), which is used for computing the gradient and updating the network weights and biases; the validation set (\SI{20}{\percent}) to measure network generalization and to halt training when generalization stops improving, and the test set (\SI{20}{\percent}) that is used to compare the different LSTM networks, as well as evaluate the ability of the network to correctly classify the floors. To make the classification process more accurate and less biased, a 10-fold cross validation is applied to the data so that the LSTM model is trained 10 times, each time with a different train/test split. Table \ref{t:matricesdim} shows the final dimensions of the input and target matrices.

\begin{table}[h] %[!t] %vs
\centering
\caption{Dimensions of the input and target matrices} 
\begin{tabular}{lcc}
\toprule
           & Input    & Target \\
\midrule
Training   & (16680, 50, 11) & (16680, 1, 4) \\
Validation & (5560, 50, 11)  & (5560, 1, 4)  \\
Testing    & (5560, 50, 11)  & (5560, 1, 4)  \\
\bottomrule
\end{tabular}
\label{t:matricesdim}
\end{table}

Fig. \ref{fig:stepusage} illustrates the 50 chosen samples of the normal force component from a full humanoid robot step. All the selected features for this classification problem use also 50 samples corresponding to the same time steps.  

\tikzset{
  step normal/.style={
            black,
    },
    special an/.style={
        right,
        color=black,
        font=\sffamily\footnotesize
    },
       step size/.style={
            black,
            mark=o,%x
    },
    step fifty/.style={
    black,
    mark=*,%o
    }
}
\begin{figure} [h] %[!t] %vs
	\centering
    \begin{tikzpicture}[font=\small]
      \begin{axis}[
          width=\linewidth, % Scale the plot to \linewidth
          height=5cm,
          grid=major, % Display a grid
          grid style={dashed,gray!30}, % Set the style
          xmin= 0,
          xmax = 310,
          ymin= -1,
          ymax= 51,
          xticklabels={},
          ylabel=Normal Force (\si{\newton}),
        ]
        \addplot  [step normal]
        table[x=x,y=y,col sep=comma] {data/almei_data1.csv}; 
        \addplot [step size] 
        table[x=x,y=y,col sep=comma] {data/almei_data2.csv}; 
        \addplot [step fifty] coordinates {(112,28.48)}
        	node[pos=0](teste){} ;
        	\node [special an] at (teste) {50};
       \addplot [step fifty] coordinates {(124,0.7538)}
        	node[pos=0](teste){} ;
        	\node [special an] at (teste) {62};
       \addplot [step fifty] coordinates {(174,31.59)}
        	node[pos=0](teste){} ;
        	\node [special an] at (teste) {50};
        \addplot [step fifty] coordinates {(186,0.7538)}
        	node[pos=0](teste){} ;
        	\node [special an] at (teste) {62};
        \addplot [step fifty] coordinates {(236,29.58)}
        	node[pos=0](teste){} ;
        	\node [special an] at (teste) {50};
        \addplot [step fifty] coordinates {(248,0.7538)}
        	node[pos=0](teste){} ;
        	\node [special an] at (teste) {62};
        	%
        	\end{axis}
    \end{tikzpicture}
    \caption{Illustration of the 50 chosen samples of the normal force of a robot step to be used on the classification of the robot walking floor.}
    \label{fig:stepusage}
\end{figure}

\section{LSTM-RNN experimental results}
Recurrent Neural networks (RNNs) are the feed-backward version of the conventional feed-forward neural networks.  They have a cyclic connection architecture that allows them to update their current state based on past states and current input data. The standard RNN topology suffers from the vanishing gradient \cite{graves_supervised_2012}.
%%%% vs commented this figure and minor text adjustments
% problem illustrated in Fig. \ref{fig:VanishPro}.
% \begin{figure}[!h]
%     \centering
%     \begin{tikzpicture}[font={\sffamily\scriptsize},scale=1.2]
%         \foreach \x/\n in {100/1,84/2,68/3,52/4,36/5,20/6,4/7}
%         {
%             \node [draw,fill=black!\x,circle,minimum size=14pt] at (10-\x/20,0) (A) {};
%             \node [draw,fill=black!\x,circle,minimum size=14pt] at (10-\x/20,+30pt) (B) {};
%             \ifthenelse{\n=1}{\def\fc{black}}{\def\fc{white}}
%             \node [draw,fill=\fc,circle,minimum size=14pt] at (10-\x/20,-30pt) (C) {};
%             \draw [->,>=stealth, ] (A) -- (B);
%             \draw [->,>=stealth, ] (C) -- (A);
%             \ifthenelse{\n=7}{}{\draw [->,>=stealth, ] (A) -- ++(16pt,0);}
%             \node at (10-\x/20,-45pt) (X) {\n};
%         }
%         \node [anchor=west,text width=1cm] at (100pt,0) () {Hidden layer};
%         \node [anchor=west] at (100pt,-30pt) () {Inputs};
%         \node [anchor=west] at (100pt,30pt) () {Outputs};
%         \node [anchor=west] at (100pt,-45pt) () {Time};
%     \end{tikzpicture}
%     \caption{Vanishing gradient problem\cite{graves_supervised_2012}.}
%     \label{fig:VanishPro}
% \end{figure}
% %
% As can be seen in Fig. \ref{fig:VanishPro}, the information extracted by the RNN at the first iteration starts to vanish as time moves forward.
To overcome this problem, Schmidhuber and Hochreiter \cite{schmidhuber1997long} developed the Long Short Term Memory (LSTM) unit presented in Fig. \ref{fig:LSTMcell}.

\begin{figure}[h] %[!t] %vs
\centering
%    \includegraphics[width=0.45\textwidth]{LSTMcell.png}
%The next provides better quality :-), vs
\begin{tikzpicture}[scale=1,transform shape]
\tikzset{empty node/.style={draw=none,fill=none}}
\makeatletter
\def\tikz@lib@matrix@empty@cell{\iftikz@lib@matrix@empty\node[name=\tikzmatrixname-\the\pgfmatrixcurrentrow-\the\pgfmatrixcurrentcolumn,empty node]{};\fi}
\makeatother
%
%These are the colors of the original image. Adapt at will :-)
\definecolor{colCnodeF}{HTML}{91A3B0}
\definecolor{colRnodeF}{HTML}{BEBEBE}
\definecolor{colBOXnodeF}{HTML}{DCDCDC}
\definecolor{colCnodeD}{HTML}{91A3B0}
\definecolor{colRnodeD}{HTML}{848482}
\definecolor{colBOXnodeD}{HTML}{848482}
%
\matrix (MyBlock)[
	matrix of nodes,
	nodes={draw,very thick,font=\sffamily},
	nodes in empty cells,
	column sep=8pt,
	row sep=12pt,
	row 1/.style={nodes={circle,draw=colCnodeD,fill=colCnodeF, inner sep=2pt}},
	row 2/.style={nodes={circle,draw=colCnodeD,fill=colCnodeF, inner sep=2pt}},
	row 3/.style={nodes={draw=colRnodeD,fill=colRnodeF, 
		inner sep=4pt,
		minimum height=14pt,
		minimum width=20pt,
		text height=5pt, %to ensure a correct vertical alignment
		}
		},
	]
	{
$\times$ &          & $+$               &          &          & \\
         &          & $\times$          &          & $\times$ & \\
$\sigma$ & $\sigma$ & \scriptsize{tanh} & $\sigma$ &          & \\
         &          &                   &          &          & \\ 
	};
%
%Insert that small block squeezed between the other two	
\coordinate (PETH) at ($(MyBlock-1-5)!0.35!(MyBlock-2-5)$);
\node [ellipse,draw=colCnodeD,fill=colCnodeF, inner sep=1pt,font=\sffamily] at (PETH) (TH) {\scriptsize{tanh}};
%
%Create coordinates for external labels points
\coordinate (CT1) at ($(MyBlock-1-1)-(40pt,0)$);
\coordinate (HT1) at ($(MyBlock-4-1)-(40pt,0)$);
\coordinate (CT) at ($(MyBlock-1-6)+(40pt,2.5pt)$);
\coordinate (HT) at ($(MyBlock-4-6)+(40pt,0)$);
\coordinate (HTT) at ($(MyBlock-1-6)+(0,40pt)$);
\coordinate (XT) at ($(MyBlock-4-1)-(10pt,30pt)$);
%
%and put the labels there
\node [above]  at (CT1) () {$ C_{t-1} $};
\node [above]  at (HT1) (){$ h_{t-1} $};
\node [above] at (CT) (){$ C_t $};
\node [above] at (HT) (){$ h_t $};
\node [left,yshift=3pt] at (XT) (){$ x_t $};
\node [left,yshift=-3pt] at (HTT) (){$ h_t $};
%
%draw the lines with the appropriate styles and labels
\tikzset{bLine/.style={line width=2.5pt,->,>=stealth}}
\draw [bLine] (HT1) -| (MyBlock-3-1) -- node [midway,left]{$ f_t $}(MyBlock-1-1);
\draw [bLine,>=] (HT1) -| (MyBlock-3-2);
\draw [bLine,rounded corners=4pt] (MyBlock-3-2) |- node [midway,left]{$ i_t $}(MyBlock-2-3) ;
\draw [bLine] (HT1) -| (MyBlock-3-3) -- node [midway,left]{$ \widetilde{C}_t $}(MyBlock-2-3) -- (MyBlock-1-3) ;
\draw [bLine,rounded corners=4pt] (HT1) -| (MyBlock-3-4) |- node [midway,left]{$ O_t $}(MyBlock-2-5);
%
\draw [bLine] (CT1) --(MyBlock-1-1) -- (MyBlock-1-3) -- (CT);
\draw [bLine,rounded corners=4pt,>=] (XT) |- (MyBlock-4-1);
\draw [bLine,rounded corners=4pt] ($(MyBlock-1-5)+(0,3pt)$) -- (TH) -- (MyBlock-2-5) |- (HT);
\draw [bLine,rounded corners=4pt] ($(MyBlock-4-6)-(5pt,0)$) -| (MyBlock-1-6)++(0,8pt) -- (HTT);
%
%Draw the involving rectangle behind all	
\begin{scope}[on background layer]	
\draw [fill=colBOXnodeF,rounded corners=20pt, draw=colBOXnodeD,ultra thick] ($(MyBlock.south west)-(10pt,10pt)$) rectangle ($(MyBlock.north east)+(10pt,10pt)$);
\end{scope}
\end{tikzpicture}
%
    \caption{LSTM cell structure\cite{varsamopoulos2018designing}.}
    \label{fig:LSTMcell}
\end{figure}
%
The LSTM unit, also known as "memory block" enables the network with the capacity to store and access information over long periods of time. LSTMs achieve this through their 3-gate architecture, which consists of an input, forget and output gates. The input gate decides which input information will be used to update the memory state. The forget gate decides which information to keep or erase from the memory block. Finally, the output gate decides based on the current input and the stored memory which information to output. 
%
The LSTM models developed in this work were built using the open source neural network library Keras, running on top of the machine learning platform TensorFlow. The API Keras is written in Python. Several LSTM networks configurations were implemented to classify the different floors from the input layer of 11 features and 50 time steps.
%
The base model used to start training was a LSTM layer with a sigmoid activation function and 50 hidden neurons, a fully-connected output layer with activation function \mbox{"softmax"}, and 4 hidden neurons corresponding to the four floors to be classified. The optimizer used in all the training trials was the Adam optimizer \cite{kingma2014adam} because of its ability to converge quickly while traditionally performing better than most other optimizers \cite{chang2018effective,wang2020power}. Additionally, an early stop strategy is applied to the training process to halt it when the loss of the model stops improving.
%
The loss of the model was evaluated using a categorical cross-entropy function, calculated according to \eqref{eq:ent}
%
\begin{equation}\label{eq:ent}
L=-\sum_{c=1}^My_{o,c}\log(p_{o,c})
\end{equation}
%
where $M$ is the number of classes (different floors), $y_{o,c}$ indicates if the class label $c$ is the correct classification for the observation $o$, and $p_{o,c}$ is the predicted probability of the observation $o$ is of class $c$. 
%
Before tuning the LSTM model hyper parameters, a dropout layer was added to the model since it is commonly used to fight over-fitting and to improve the model performance. This layer is used as a regularization method were input and recurrent connections to LSTM units are probabilistically excluded from activation and weights updates while training a network. 
It randomly sets input units to 0 with a chosen frequency $f_d$ (fraction of the input units to drop) at each step during training time. Inputs not set to zero are scaled up by $1\div(1 - f_d)$ 
such that the sum over all inputs is unchanged. Fig. \ref{fig:dropout} exemplifies the dropout behaviour for a standard neural network with two hidden layers.

\begin{figure}[h] %[!t] %vs
    \centering
    \includegraphics[width=0.7\columnwidth]{almei3}
    \caption{Dropout behaviour. On the left it is visible a standard neural network and on the right an example of the same network after applying dropout. The units presented with a cross have been dropped \cite{srivastava2014dropout}.}
    \label{fig:dropout}
\end{figure}
%
Multiple LSTM models architectures were implemented and trained with a varying number of hidden neurons, different activation functions, batch sizes, learning rates and dropout probabilities. Table \ref{t:parameters} shows the evaluated range for some of these parameters as well as the chosen value that produced the overall best results.

\begin{table}[!h]  % vs was t
\centering
\caption{Range of network parameters evaluated.} 
\begin{tabular}{lcc}
\toprule
                    & Range          & Best   \\
\midrule
Hidden neurons      & 50 - 500       & 300    \\
Learning rate       & 0.00001 - 0.1  & 0.0001 \\
Batch size          & 10 - 500       & 256  \\ 
Dropout probability & 0.1 - 0.5      & 0.2   \\
\bottomrule
\end{tabular}
\label{t:parameters}
\end{table}

Fig. \ref{fig:modelflow} shows the optimized model obtained for this multi-classification problem using the chosen best parameters. This model has three layers: a LSTM layer with 300 hidden neurons and "tanh" activation functions, a dropout 0.2 layer and a fully-connected layer with four hidden neurons and \mbox{"softmax"} activation functions. 

\begin{figure}[!h] % vs was t
    \centering
    \begin{tikzpicture}[
        font={\sffamily\scriptsize},
        node distance=2.25cm,
        text width=1.75cm,
        inner sep=2pt,
        align=center,
        minimum height=2.75em,
        minimum width=1.5cm,
%        thick,
        every node/.style={fill=gray!20}, % change if other fill values
        ]
        \node [draw] (L) {LSTM 300 (tanh)};
        \node [draw,right of=L] (D) {Dropout 0.2};
        \node [draw,right of=D] (D4) {Dense 4 (softmax)};
        \draw [->,>=stealth] (L)--(D);
        \draw [->,>=stealth] (D)--(D4);
        \node [left of=L,anchor=east,text width=1cm,node distance=0.75cm,inner sep=0,fill=none] (IL) {Input Layer};
        \node [right of=D4,anchor=west,text width=1cm,node distance=0.75cm,inner sep=0,fill=none] (OL) {Ouput Layer};
    \end{tikzpicture}    
    \caption{Optimized LSTM model.}
    \label{fig:modelflow}
\end{figure}

Figure \ref{fig:modelacc} presents the optimized model accuracy/epochs. This model presents a \SI{96.31}{\percent} and \SI{89.63}{\percent} training and validation accuracy, respectively.
%
%
\tikzset{
  step normal/.style={
            red,
    },
       step size/.style={
            blue,
    }
}
\begin{figure}[!h]
	\centering
    \begin{tikzpicture}[font=\small]
      \begin{axis}[ %was semilogyaxis, why?
          width=\linewidth, % Scale the plot to \linewidth
          height=4cm,
          %grid=major, % Display a grid
          %grid style={dashed,gray!30}, % Set the style
          %xmin= 0,
          %xmax =22,
          %ymin= 0.25,
          %ymax= 1,
 %         ymode=log, %% vs commented
          %yticklabels={0,0.25, 0.63, 1.00},
          ylabel=Accuracy (\%),
          xlabel=Epochs,
          legend style ={legend pos=south east},
 yticklabel={\pgfmathparse{\tick*100}\pgfmathprintnumber{\pgfmathresult}},
          %
        ]
        \addplot  [step normal]
        table[x=x,y=y,col sep=comma] {data/almei_data19.csv}; 
        \addlegendentry{Training};
        \addplot [step size] 
        table[x=x1,y=y1,col sep=comma] {data/almei_data19.csv};
        \addlegendentry{Validation};
        	%
        	\end{axis} %was semilogyaxis, why?
    \end{tikzpicture}
    \caption{LSTM model, Accuracy vs Epochs.}
    \label{fig:modelacc}
\end{figure}
%

Table \ref{t:classreport} presents the classification report of this LSTM model where the metrics Precision, Recall and F1-score are used to evaluate the model's capability of correctly classifying the different floors. 

\begin{table}[!t]  %vs was t
\centering
\caption{LSTM model Classification report.} 
\begin{tabular}{l*{4}c}
\toprule
                  & Precision & Recall & F1-score & Samples \\ \midrule
Acrylic-PTFE      & 0.98      & 1.00   & 0.99     & 1620    \\
Acrylic-Aluminium & 0.88      & 0.92   & 0.90     & 1510    \\
Acrylic-PE-HD  & 0.93      & 0.84   & 0.89     & 1290    \\
Acrylic-Melamine     & 0.93      & 0.89   & 0.91     & 1140    \\ \bottomrule
\end{tabular}
\label{t:classreport}
\end{table}

Figure \ref{fig:conf_matrix} presents the confusion matrix obtained the applying the network to the testing set. From there it can be seen that the model was able to correctly classify \SI{92.09}{\percent} of the test set data (confusion matrix true positives plus true negatives divided by total of samples), which are data never presented to the network before. Overall, the differences between the high scores achieved for the first class compared to the other classes can be justified not only because of the uneven distribution of the four classes, but also because the floor properties, more specifically the CoF of the first class differs more from the remainder. The gap between the CoF for the remainder classes is similar and, as it can be seen, the results for these classes are very balanced.
%
\begin{figure}[h] %[!t]  %vs was t %vs
    \centering
%    \includegraphics[width=0.45\textwidth]{conf_matrix}
% Next figure has better quality
%======= BEGIN OF ALTERNATIVE IMAGE IN TIKZ =======
\def\myScale{1} % 1.5 is a good scale. Values under 1 may need smaller fonts!
\begin{tikzpicture}[
	scale = \myScale,
	%font={\scriptsize}, %for smaller scales, even \tiny may be useful
	font={\scriptsize\sffamily},
	]
%The matrix in numbers
%Horizontal target class
%Vertical output class
\def\myConfMat{{
{1620,  30,  60,   0},  %row 1
{   0,1390, 110,  80},  %row 2
{   0,  40,1090,  40},  %row 3
{   0,  50,  30,1020},  %row 4
}}

\def\classNames{{"PTFE","Alum.","PE-HD","Melam."}} %class names. Adapt at will
\def\numClasses{4} %number of classes. Could be automatic, but you can change it for tests.

\tikzset{vertical label/.style={rotate=90,anchor=east}}   % usable styles for below
\tikzset{diagonal label/.style={rotate=45,anchor=north east}}

 \foreach \y in {1,...,\numClasses} %loop vertical starting on top
 {
 	% Add class name on the left
    \node [anchor=east] at (0.4,-\y) {\pgfmathparse{\classNames[\y-1]}\pgfmathresult}; 
    
   	\foreach \x in {1,...,\numClasses}  %loop horizontal starting on left
    {
%---- Start of automatic calculation of totSamples for the column ------------   
    \def\totSamples{0}
    \foreach \ll in {1,...,\numClasses}
    {
     	\pgfmathparse{\myConfMat[\ll-1][\x-1]}   %fetch next element
     	\xdef\totSamples{\totSamples+\pgfmathresult} %accumulate it with previous sum
     	%must use \xdef fro global effect otherwise lost in foreach loop!
    }
    \pgfmathparse{\totSamples} \xdef\totSamples{\pgfmathresult}  % put the final sum in variable
%---- End of automatic calculation of totSamples ----------------
    
    \begin{scope}[shift={(\x,-\y)}]
        \def\mVal{\myConfMat[\y-1][\x-1]} % The value at index y,x (-1 because of zero indexing)
        \pgfmathtruncatemacro{\r}{\mVal}   %
        \pgfmathtruncatemacro{\p}{round(\r/\totSamples*100)}
        \pgfmathtruncatemacro{\pd}{round(\r/\totSamples*1000)} 
        \pgfmathparse{\pd*0.1}\xdef\d{\pgfmathresult}
        \coordinate (C) at (0,0);
        \ifthenelse{\p<50}{\def\txtcol{black}}{\def\txtcol{white}} %decide text color for contrast
        \node[
	       	%draw,                 %draw lines
        	text=\txtcol,         %text color (automatic for better contrast)
        	align=center,         %align text inside cells (also for wrapping)
        	fill=black!\p,        %intensity of fill (can change base color)
        	minimum size=\myScale*10mm,    %cell size to fit the scale and integer dimensions (in cm)
        	inner sep=0,          %remove all inner gaps to save space in small scales
        	] (C) {\pgfmathprintnumber[assume math mode,fixed zerofill=true,precision=1]{\d}\%\\\r};     %text to put in cell (adapt at will)
        %Now if last vertical class add its label at the bottom
        \ifthenelse{\y=\numClasses}{
        \node [] at ($(C)-(0,0.75)$) % can use vertical or diagonal label as option
        {\pgfmathparse{\classNames[\x-1]}\pgfmathresult};}{}
    \end{scope}
    }
}
%Now add x and y labels on suitable coordinates
\coordinate (yaxis) at (-0.8,0.5-\numClasses/2);  %must adapt if class labels are wider!
\coordinate (xaxis) at (0.5+\numClasses/2, -\numClasses-1.25); %id. for non horizontal labels!
\node [vertical label] at (yaxis) {Output Class};
\node []               at (xaxis) {Target Class};
\draw [thick] (0.5,-0.5) rectangle(\numClasses+0.5,-\numClasses-0.5);
\end{tikzpicture}
%======= END OF ALTERNATIVE IMAGE IN TIKZ =======

    \caption{Confusion matrix of the testing dataset.}
    \label{fig:conf_matrix}
\end{figure}

\section{Online experiment}
%
After training and improving the LSTM network, a real-time experiment of the NAO robot walking on different floors, as illustrated in Fig. \ref{fig:NAOexperimentLayoutt}, was carried out to validate the model. The gait parameters for the walk are as follows: \SI{0.02}{\meter} step length; \SI{0.02}{\meter} step height; 50\% of robot's maximum step frequency; and \SI{0.1}{\radian} torso rotation around Y.

\begin{figure}[!h]  %vs was t
\centering
\begin{tikzpicture}
\tikzset{mylabel/.style={
	inner sep=1pt
	}
}
    \node[anchor=south west,inner sep=0] (image) at (0,0) {\includegraphics[width=\columnwidth]{almei5}};
    \begin{scope}[x={(image.south east)},y={(image.north west)},font=\sffamily]
        \node [mylabel,anchor=west] at (0.14,0.65) {NAO};
        \node [mylabel] at (0.2,0.22) {PTFE};
        \node [mylabel,text=white] at (0.39,0.2) {Aluminium};
        \node [mylabel] at (0.6,0.18) {PE-HD};
        \node [mylabel] at (0.85,0.15) {Melamine};
    \end{scope}
\end{tikzpicture}
    \caption{Layout for the real-time on-line experiment.}
    \label{fig:NAOexperimentLayoutt}
\end{figure}
%
%More details about the experiment are shown ahead, but a summary of the results is given at once to make it easier to compare with the testing dataset.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Figure \ref{fig:NAOexperiment} plots the classification results of the LSTM network, and at the top, some snapshots of the experiment 

% Some style definitions to use on the pgfplots that follow
\tikzset{
    right foot/.style={
                blue,
                only marks,
                mark=*,%o,
                mark size=1.5pt
        },
    left foot/.style={
            red,
            only marks,
            mark=o,%x
    },
    right foot forty/.style={
                blue,
                only marks,
                mark=square*,
                mark size=1.5pt
        },
    left foot forty/.style={
            red,
            only marks,
            mark=square,%x
    },
    right foot thirty/.style={
                blue,
                only marks,
                mark=triangle*,
                mark size=1.5pt
        },
    left foot thirty/.style={
            red,
            only marks,
            mark=triangle,%x
    },
    special annotation/.style={
        below,
        color=black,
        font=\sffamily\footnotesize %was \tiny (but too small)
    }
}
\begin{figure*}[!t]  %was [!ht] %vs
	\centering
	\includegraphics[width=\textwidth]{almei6}
    \begin{tikzpicture}[font=\small]
      \begin{axis}[
          width=\linewidth, % Scale the plot to \linewidth
          height=0.15\textheight,
          grid=major, % Display a grid
          grid style={dashed,gray!30}, % Set the style
          xmin= 0,
          xmax = 50,
          xticklabels={},
          ylabel=PTFE(\si{\percent}),
          ytick={ 0, .25, .5, .75, 1},
          yticklabels={0,25, 50, 75, 100},
        ]
        \addplot [left foot]
        table[x=x,y=y,col sep=comma] {data/almei_data3.csv}; 
        \addplot [mark = none] coordinates {(0.5460,0.9996)} 						           node[pos=0](teste){} ;
        \node [special annotation] at (teste) {a};
        \addplot [mark = none] coordinates {(1.1020,0.4583)}
        	node[pos=0](teste){} ;
        \node [special annotation] at (teste) {b};
     	\addplot [mark = none] coordinates {( 9.8129,0.5391)}
        	node[pos=0](teste){} ;
        \node [special annotation] at (teste) {c};
     	\addplot [mark = none] coordinates {( 10.3677,0.5391)}
        	node[pos=0](teste){} ;
        \node [special annotation] at (teste) {d};
        	%
        \addplot [right foot]
        table[x=x,y=y,col sep=comma] {data/almei_data4.csv};
        \addplot[color=black] coordinates {(0,0.5) (50,0.50) }
		node[pos=0.1](teste){} ;
		\addplot [right foot forty]
        table[x=x,y=z,col sep=comma] {data/almei_data4.csv};  
        \addplot [left foot forty]
        table[x=x,y=z,col sep=comma] {data/almei_data3.csv};  
        \addplot [right foot thirty]
        table[x=x,y=w,col sep=comma] {data/almei_data4.csv};  
        \addplot [left foot thirty]
        table[x=x,y=w,col sep=comma] {data/almei_data3.csv};  
      \end{axis}
      \begin{axis}[
      	 width=\linewidth, % Scale the plot to \linewidth
      	 height=0.15\textheight,
         grid=major, % Display a grid
         grid style={dashed,gray!30}, % Set the style
 		 axis y line*=right,
  		 axis x line=none,
  		 xmin= 0,
         xmax = 50,
  		 ytick={ 0, 1},
         yticklabels={0, 1},
		 ]
	  \addplot[dashed,black]
  		table[x=x,y=y, col sep=comma] {data/almei_data5.csv};
		\end{axis}
    \end{tikzpicture}
%2nd graph 
    \begin{tikzpicture}[font=\small]
      \begin{axis}[
          width=\linewidth, % Scale the plot to \linewidth
          height=0.15\textheight,
          grid=major, % Display a grid
          grid style={dashed,gray!30}, % Set the style
          ylabel=Aluminium(\si{\percent}),
          xmin= 0,
          xmax = 50,
          xticklabels={},          
          ytick={ 0, .25, .5, .75, 1},
          yticklabels={0,25, 50, 75, 100},
        ]
        \addplot [left foot]
        table[x=x,y=y,col sep=comma] {data/almei_data6.csv}; 
        \addplot [mark = none] coordinates {( 13.0441  ,  0.48 )}
        	node[pos=0](teste){} ;
        	\node [special annotation, above] at (teste) {e};
        \addplot [mark = none] coordinates {( 13.5825  ,  0.9597 )}
        	node[pos=0](teste){} ;
        	\node [special annotation] at (teste) {f};
    	\addplot [mark = none] coordinates {( 18.4932 ,   0.7643 )}
        	node[pos=0](teste){} ;
        	\node [special annotation] at (teste) {g};
        \addplot [mark = none] coordinates {(  19.0393 ,   0.9961 )}
        	node[pos=0](teste){} ;
        	\node [special annotation] at (teste) {h};
        	%
        \addplot [right foot]
        table[x=x,y=y,col sep=comma] {data/almei_data7.csv};
        \addplot[color=black] coordinates {	(0,0.5)	(50,0.50) }
		node[pos=0.1](teste){} ;
        \addplot [right foot forty]
        table[x=x,y=z,col sep=comma] {data/almei_data7.csv};  
        \addplot [left foot forty]
        table[x=x,y=z,col sep=comma] {data/almei_data8.csv};  
        \addplot [right foot thirty]
        table[x=x,y=w,col sep=comma] {data/almei_data7.csv};  
        \addplot [left foot thirty]
        table[x=x,y=w,col sep=comma] {data/almei_data8.csv};  
      \end{axis}
      \begin{axis}[
      	 width=\linewidth, % Scale the plot to \linewidth
      	 height=0.15\textheight,
         grid=major, % Display a grid
         grid style={dashed,gray!30}, % Set the style
 		 axis y line*=right,
  		 axis x line=none,
  		 xmin= 0,
         xmax = 50,
         xticklabels={},         
  		 ytick={ 0, 1},
         yticklabels={0, 1},
		 ]
	  \addplot[dashed,black]
  		table[x=x,y=y, col sep=comma] {data/almei_data9.csv};
		\end{axis}
    \end{tikzpicture}
%3rd graph
     \begin{tikzpicture}[font=\small]
      \begin{axis}[
          width=\linewidth, % Scale the plot to \linewidth
          height=0.15\textheight,
          grid=major, % Display a grid
          grid style={dashed,gray!30}, % Set the style
          ylabel=PE-HD(\si{\percent}),
          xmin= 0,
          xmax = 50,
          xticklabels={},          
          ytick={ 0, .25, .5, .75, 1},
          yticklabels={0,25, 50, 75, 100},
        ]
        \addplot [left foot]
        table[x=x,y=y,col sep=comma] {data/almei_data10.csv}; 
        \addplot [mark = none] coordinates {(26.5646,0.9998)}
        	node[pos=0](teste){} ;
        	\node [special annotation] at (teste) {i};
        \addplot [mark = none] coordinates {(27.1020,0.5543)}
        	node[pos=0](teste){} ;
        	\node [special annotation] at (teste) {j};
        \addplot [mark = none] coordinates {(30.8775,0.9974)}
        	node[pos=0](teste){} ;
        	\node [special annotation] at (teste) {k};
        \addplot [mark = none] coordinates {(31.4061,0.9049 )}
        	node[pos=0](teste){} ;
        	\node [special annotation] at (teste) {l};
        \addplot [right foot]
        table[x=x,y=y,col sep=comma] {data/almei_data11.csv};
        \addplot[color=black] coordinates {(0,0.5)(50,0.50) } node[pos=0.1](teste){} ;
        \addplot [right foot forty]
        table[x=x,y=z,col sep=comma] {data/almei_data11.csv};  
        \addplot [left foot forty]
        table[x=x,y=z,col sep=comma] {data/almei_data12.csv};  
        \addplot [right foot thirty]
        table[x=x,y=w,col sep=comma] {data/almei_data11.csv};  
        \addplot [left foot thirty]
         table[x=x,y=w,col sep=comma] {data/almei_data12.csv};  
      \end{axis}
      \begin{axis}[
      	 width=\linewidth, % Scale the plot to \linewidth
      	 height=0.15\textheight,
         grid=major, % Display a grid
         grid style={dashed,gray!30}, % Set the style
 		 axis y line*=right,
  		 axis x line=none,
  		 xmin= 0,
         xmax = 50,
  		 ytick={ 0, 1},
         yticklabels={0, 1},
		 ]
	  \addplot[dashed,black]
  		table[x=x,y=y, col sep=comma] {data/almei_data13.csv};
		\end{axis}
    \end{tikzpicture}
%4th graph
     \begin{tikzpicture}[font=\small]
      \begin{axis}[
          width=\linewidth, % Scale the plot to \linewidth
          height=0.15\textheight,
          grid=major, % Display a grid
          grid style={dashed,gray!30}, % Set the style
          xlabel=Time(\si{\second}), % Set the labels
          ylabel=Melamine(\si{\percent}),
          xmin= 0,
          xmax = 50,
          ytick={ 0, .25, .5, .75, 1},
          yticklabels={0,25, 50, 75, 100},
        ]
        \addplot [left foot]
        table[x=x,y=y,col sep=comma] {data/almei_data14.csv}; 
		\addplot [mark = none] coordinates {(40.6346,0.9999)}
        	node[pos=0](teste){} ;
        	\node [special annotation] at (teste) {m};
        \addplot [mark = none] coordinates {(41.1795,0.6515)}
        	node[pos=0](teste){} ;
        	\node [special annotation] at (teste) {n};
        \addplot [mark = none] coordinates {(48.7926,0.0838)}
        	node[pos=0](teste){} ;
        	\node [special annotation] at (teste) {o};	
        \addplot [right foot]
        table[x=x,y=y,col sep=comma] {data/almei_data15.csv};
        \addplot[color=black] coordinates {(0,0.5) (50,0.50) }		node[pos=0.1](teste){} ;
        \addplot [right foot forty]
        table[x=x,y=z,col sep=comma] {data/almei_data15.csv};  
        \addplot [left foot forty]
        table[x=x,y=z,col sep=comma] {data/almei_data16.csv};  
        \addplot [right foot thirty]
        table[x=x,y=w,col sep=comma] {data/almei_data15.csv};  
        \addplot [left foot thirty]
        table[x=x,y=w,col sep=comma] {data/almei_data16.csv};  
      \end{axis}
      \begin{axis}[
      	 width=\linewidth, % Scale the plot to \linewidth
      	 height=0.15\textheight,
         grid=major, % Display a grid
         grid style={dashed,gray!30}, % Set the style
 		 axis y line*=right,
  		 axis x line=none,
  		 xmin= 0,
         xmax = 50,
  		 ytick={ 0, 1},
         yticklabels={0, 1},
		 ]
	     \addplot[dashed,black]
  		    table[  x=x,y=y, col sep=comma] {data/almei_data17.csv};
	  \end{axis}
    \end{tikzpicture}
    \caption{Individual results on floor classification of NAO walking experiment in real-time using 50, 40 and 30 timesteps. At the top, some snapshots of NAO walking on the different surfaces are presented, and their corresponding output is presented, at the bottom, on the charts for each foot/shoe. \textcolor{red}{$\circ$} Left ITshoe(50); \textcolor{blue}{$\bullet$} Right ITshoe(50); \textcolor{red}{$\square$} Left ITshoe(40); \textcolor{blue}{$\blacksquare$} Right ITshoe(40); \textcolor{red}{$\triangle$} Left ITshoe(30); \textcolor{blue}{$\blacktriangle$} Right ITshoe(30); \textcolor{black}{\protect\dashedrule} Real floor on which the robot walks (it is 1 when walking on the current floor). }
    \label{fig:NAOexperiment}
%  \end{center}
\end{figure*}
%
are shown. In this experiment, the robot walked 1.80 meters on the four floors starting on the PTFE floor and ending on the melamine surface. It is important to mention that we considered as being the correct floor on which the robot walks when the front part of the robot foot is at least \SI{0.04}{\meter} over that floor. The detailed results show that the network, although not always with \SI{100}{\percent} certainty, classified correctly (with a confidence always larger than \SI{50}{\percent}) the different floors for the vast majority of the robot's steps. 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Fig. \ref{fig:conf_matrix1} presents the confusion matrix for this experiment, where the LSTM model classified correctly 87 of the 90 ($\approx$\SI{97}{\percent}) robot steps.
%
\begin{figure}[!h]  %vs was t
    \centering
%    \includegraphics[width=0.45\textwidth]{conf_matrix}
% Next figure has better quality
%======= BEGIN OF ALTERNATIVE IMAGE IN TIKZ =======
\def\myScale{1} % 1.5 is a good scale. Values under 1 may need smaller fonts!
\begin{tikzpicture}[
	scale = \myScale,
	%font={\scriptsize}, %for smaller scales, even \tiny may be useful
	font={\scriptsize\sffamily},
	]
%The matrix in numbers
%Horizontal target class
%Vertical output class
\def\myConfMat{{
{19,  0,  0,   0},  %row 1
{   0,23, 0,  1},  %row 2
{   0,  2,25,  0},  %row 3
{   0,  0,  0,20},  %row 4
}}

\def\classNames{{"PTFE","Alum.","PE-HD","Melam."}} %class names. Adapt at will
\def\numClasses{4} %number of classes. Could be automatic, but you can change it for tests.

\tikzset{vertical label/.style={rotate=90,anchor=east}}   % usable styles for below
\tikzset{diagonal label/.style={rotate=45,anchor=north east}}

 \foreach \y in {1,...,\numClasses} %loop vertical starting on top
 {
 	% Add class name on the left
    \node [anchor=east] at (0.4,-\y) {\pgfmathparse{\classNames[\y-1]}\pgfmathresult}; 
    
   	\foreach \x in {1,...,\numClasses}  %loop horizontal starting on left
    {
%---- Start of automatic calculation of totSamples for the column ------------   
    \def\totSamples{0}
    \foreach \ll in {1,...,\numClasses}
    {
     	\pgfmathparse{\myConfMat[\ll-1][\x-1]}   %fetch next element
     	\xdef\totSamples{\totSamples+\pgfmathresult} %accumulate it with previous sum
     	%must use \xdef fro global effect otherwise lost in foreach loop!
    }
    \pgfmathparse{\totSamples} \xdef\totSamples{\pgfmathresult}  % put the final sum in variable
%---- End of automatic calculation of totSamples ----------------
    
    \begin{scope}[shift={(\x,-\y)}]
        \def\mVal{\myConfMat[\y-1][\x-1]} % The value at index y,x (-1 because of zero indexing)
        \pgfmathtruncatemacro{\r}{\mVal}   %
        \pgfmathtruncatemacro{\p}{round(\r/\totSamples*100)}
        \pgfmathtruncatemacro{\pd}{round(\r/\totSamples*1000)} 
        \pgfmathparse{\pd*0.1}\xdef\d{\pgfmathresult}
        \coordinate (C) at (0,0);
        \ifthenelse{\p<50}{\def\txtcol{black}}{\def\txtcol{white}} %decide text color for contrast
        \node[
	       	%draw,                 %draw lines
        	text=\txtcol,         %text color (automatic for better contrast)
        	align=center,         %align text inside cells (also for wrapping)
        	fill=black!\p,        %intensity of fill (can change base color)
        	minimum size=\myScale*10mm,    %cell size to fit the scale and integer dimensions (in cm)
        	inner sep=0,          %remove all inner gaps to save space in small scales
        	] (C) {\pgfmathprintnumber[assume math mode,fixed zerofill=true,precision=1]{\d}\%\\\r};     %text to put in cell (adapt at will)
        %Now if last vertical class add its label at the bottom
        \ifthenelse{\y=\numClasses}{
        \node [] at ($(C)-(0,0.75)$) % can use vertical or diagonal label as option
        {\pgfmathparse{\classNames[\x-1]}\pgfmathresult};}{}
    \end{scope}
    }
}
%Now add x and y labels on suitable coordinates
\coordinate (yaxis) at (-0.8,0.5-\numClasses/2);  %must adapt if class labels are wider!
\coordinate (xaxis) at (0.5+\numClasses/2, -\numClasses-1.25); %id. for non horizontal labels!
\node [vertical label] at (yaxis) {Output Class};
\node []               at (xaxis) {Target Class};
\draw [thick] (0.5,-0.5) rectangle(\numClasses+0.5,-\numClasses-0.5);
\end{tikzpicture}
%======= END OF ALTERNATIVE IMAGE IN TIKZ =======
    
    \caption{Confusion matrix of the real-time experiment.}
    \label{fig:conf_matrix1}
\end{figure}
%
Indeed, the network correctly classified all the steps on the PTFE and PE-HD floors, and misclassified only two steps on the aluminium floor and one step on the melamine floor. Overall, it can be seen that the LSTM model is suitable for this multi-classification problem. 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
The model presented requires approximately 541 milliseconds to classify one input in real time (from data collection to obtaining a network output). Since the data are recorded at \SI{100}{Hz} and we are using the first 50 data points (500 milliseconds) to feed the model, it means that the model classification time (41 milliseconds) represents only \SI{7.5}{\percent} of the total time required for this multi-classification problem. Basically, after one robot step we need to wait 41 milliseconds before taking the procedures to optimize the next step. In the future, if we need to decrease the overall required time, we can focus on strategies to reduce the data points used to feed the model. We tested the LSTM network's ability to classify correctly the different slippery floors using less timesteps and the results are shown in Fig. \ref{fig:timesteps}. We observed for example that the network test accuracy exhibits a loss of less than \SI{4}{\percent} and \SI{9}{\percent} when using 40 and 30 timesteps, respectively.  In Fig. \ref{fig:NAOexperiment} it is visible that the network was still able to correctly classify most of the steps during the online experiment, using the 40 and 30 timesteps model, although with less confidence when compared with the 50 timesteps model. Fig. \ref{fig:conf_matrix40} and \ref{fig:conf_matrix30} show the confusion matrices for these two networks with less timesteps. The LSTM model with 40 timesteps classified correctly 86 of 90 robot steps, that is, one more misclassified step when compared to the 50 timesteps model, and the LSTM model using 30 timesteps only classified correctly 80 of 90, seven less than the original 50 timesteps model. In conclusion, it is possible to reduce the timesteps used to classify the different floors and still have a model able to classify correctly most of the robot's steps. 
%
\tikzset{
  step normal/.style={
            black,
    },
    special an/.style={
        right,
        color=black,
        font=\sffamily\footnotesize 
    },
       step size/.style={
            black,
            mark=o,%x
    },
    step fifty/.style={
    black,
    mark=*,%o
    mark size=1pt,
    }
}
\begin{figure}[!ht]  %vs was t
	\centering
    \begin{tikzpicture}[font=\small]
      \begin{axis}[
          width=\linewidth, % Scale the plot to \linewidth
          height=6cm,
          grid=major, % Display a grid
          grid style={dashed,gray!30}, % Set the style
          xmin= 0,
          xmax = 51,
          ymin= 0.2,
          ymax= 1,
        yticklabel=\pgfmathparse{100*\tick}\pgfmathprintnumber{\pgfmathresult},
%        yticklabel style={/pgf/number format/.cd,fixed,precision=2},
          xtick={1,5,10,...,50},
          ylabel=Test Accuracy (\si{\percent}),
          xlabel=Timesteps,
        ]
        \addplot[step fifty, color =black, error bars/.cd, y dir=plus, y explicit]
        table[x=x,y=y, y error=w, col sep=comma] {data/almei_data18.csv}; 
        \addplot[step fifty,color =black,error bars/.cd, y dir=minus, y explicit]
        table[x=x,y=y,y error=z, col sep=comma]{data/almei_data18.csv};
      \end{axis}
    \end{tikzpicture}
    \caption{LSTM network testing accuracy using different sizes of timesteps. }
    \label{fig:timesteps}
\end{figure}
%
\begin{figure}[!ht] %vs was t
    \centering
%    \includegraphics[width=0.45\textwidth]{conf_matrix}
% Next figure has better quality
%======= BEGIN OF ALTERNATIVE IMAGE IN TIKZ =======
\def\myScale{1} % 1.5 is a good scale. Values under 1 may need smaller fonts!
\begin{tikzpicture}[
	scale = \myScale,
	%font={\scriptsize}, %for smaller scales, even \tiny may be useful
	font={\scriptsize\sffamily},
	]
%The matrix in numbers
%Horizontal target class
%Vertical output class
\def\myConfMat{{
{19,  1,  0,   0},  %row 1
{   0,22, 0,  1},  %row 2
{   0,  2,25,  0},  %row 3
{   0,  0,  0,20},  %row 4
}}

\def\classNames{{"PTFE","Alum.","PE-HD","Melam."}} %class names. Adapt at will
\def\numClasses{4} %number of classes. Could be automatic, but you can change it for tests.

\tikzset{vertical label/.style={rotate=90,anchor=east}}   % usable styles for below
\tikzset{diagonal label/.style={rotate=45,anchor=north east}}

 \foreach \y in {1,...,\numClasses} %loop vertical starting on top
 {
 	% Add class name on the left
    \node [anchor=east] at (0.4,-\y) {\pgfmathparse{\classNames[\y-1]}\pgfmathresult}; 
    
   	\foreach \x in {1,...,\numClasses}  %loop horizontal starting on left
    {
%---- Start of automatic calculation of totSamples for the column ------------   
    \def\totSamples{0}
    \foreach \ll in {1,...,\numClasses}
    {
     	\pgfmathparse{\myConfMat[\ll-1][\x-1]}   %fetch next element
     	\xdef\totSamples{\totSamples+\pgfmathresult} %accumulate it with previous sum
     	%must use \xdef fro global effect otherwise lost in foreach loop!
    }
    \pgfmathparse{\totSamples} \xdef\totSamples{\pgfmathresult}  % put the final sum in variable
%---- End of automatic calculation of totSamples ----------------
    
    \begin{scope}[shift={(\x,-\y)}]
        \def\mVal{\myConfMat[\y-1][\x-1]} % The value at index y,x (-1 because of zero indexing)
        \pgfmathtruncatemacro{\r}{\mVal}   %
        \pgfmathtruncatemacro{\p}{round(\r/\totSamples*100)}
        \pgfmathtruncatemacro{\pd}{round(\r/\totSamples*1000)} 
        \pgfmathparse{\pd*0.1}\xdef\d{\pgfmathresult}
        \coordinate (C) at (0,0);
        \ifthenelse{\p<50}{\def\txtcol{black}}{\def\txtcol{white}} %decide text color for contrast
        \node[
	       	%draw,                 %draw lines
        	text=\txtcol,         %text color (automatic for better contrast)
        	align=center,         %align text inside cells (also for wrapping)
        	fill=black!\p,        %intensity of fill (can change base color)
        	minimum size=\myScale*10mm,    %cell size to fit the scale and integer dimensions (in cm)
        	inner sep=0,          %remove all inner gaps to save space in small scales
        	] (C) {\pgfmathprintnumber[assume math mode,fixed zerofill=true,precision=1]{\d}\%\\\r};     %text to put in cell (adapt at will)
        %Now if last vertical class add its label at the bottom
        \ifthenelse{\y=\numClasses}{
        \node [] at ($(C)-(0,0.75)$) % can use vertical or diagonal label as option
        {\pgfmathparse{\classNames[\x-1]}\pgfmathresult};}{}
    \end{scope}
    }
}
%Now add x and y labels on suitable coordinates
\coordinate (yaxis) at (-0.8,0.5-\numClasses/2);  %must adapt if class labels are wider!
\coordinate (xaxis) at (0.5+\numClasses/2, -\numClasses-1.25); %id. for non horizontal labels!
\node [vertical label] at (yaxis) {Output Class};
\node []               at (xaxis) {Target Class};
\draw [thick] (0.5,-0.5) rectangle(\numClasses+0.5,-\numClasses-0.5);
\end{tikzpicture}
%======= END OF ALTERNATIVE IMAGE IN TIKZ =======
    
    \caption{Confusion matrix of the testing dataset using 40 timesteps.}
    \label{fig:conf_matrix40}
\end{figure}
%

\begin{figure}[!ht]  %vs was t
    \centering
%    \includegraphics[width=0.45\textwidth]{conf_matrix}
% Next figure has better quality
%======= BEGIN OF ALTERNATIVE IMAGE IN TIKZ =======
\def\myScale{1} % 1.5 is a good scale. Values under 1 may need smaller fonts!
\begin{tikzpicture}[
	scale = \myScale,
	%font={\scriptsize}, %for smaller scales, even \tiny may be useful
	font={\scriptsize\sffamily},
	]
%The matrix in numbers
%Horizontal target class
%Vertical output class
\def\myConfMat{{
{17,  2,  0,   0},  %row 1
{   2,21, 1,  1},  %row 2
{   0,  2,23,  1},  %row 3
{   0,  0,  1,19},  %row 4
}}

\def\classNames{{"PTFE","Alum.","PE-HD","Melam."}} %class names. Adapt at will
\def\numClasses{4} %number of classes. Could be automatic, but you can change it for tests.

\tikzset{vertical label/.style={rotate=90,anchor=east}}   % usable styles for below
\tikzset{diagonal label/.style={rotate=45,anchor=north east}}

 \foreach \y in {1,...,\numClasses} %loop vertical starting on top
 {
 	% Add class name on the left
    \node [anchor=east] at (0.4,-\y) {\pgfmathparse{\classNames[\y-1]}\pgfmathresult}; 
    
   	\foreach \x in {1,...,\numClasses}  %loop horizontal starting on left
    {
%---- Start of automatic calculation of totSamples for the column ------------   
    \def\totSamples{0}
    \foreach \ll in {1,...,\numClasses}
    {
     	\pgfmathparse{\myConfMat[\ll-1][\x-1]}   %fetch next element
     	\xdef\totSamples{\totSamples+\pgfmathresult} %accumulate it with previous sum
     	%must use \xdef fro global effect otherwise lost in foreach loop!
    }
    \pgfmathparse{\totSamples} \xdef\totSamples{\pgfmathresult}  % put the final sum in variable
%---- End of automatic calculation of totSamples ----------------
    
    \begin{scope}[shift={(\x,-\y)}]
        \def\mVal{\myConfMat[\y-1][\x-1]} % The value at index y,x (-1 because of zero indexing)
        \pgfmathtruncatemacro{\r}{\mVal}   %
        \pgfmathtruncatemacro{\p}{round(\r/\totSamples*100)}
        \pgfmathtruncatemacro{\pd}{round(\r/\totSamples*1000)} 
        \pgfmathparse{\pd*0.1}\xdef\d{\pgfmathresult}
        \coordinate (C) at (0,0);
        \ifthenelse{\p<50}{\def\txtcol{black}}{\def\txtcol{white}} %decide text color for contrast
        \node[
	       	%draw,                 %draw lines
        	text=\txtcol,         %text color (automatic for better contrast)
        	align=center,         %align text inside cells (also for wrapping)
        	fill=black!\p,        %intensity of fill (can change base color)
        	minimum size=\myScale*10mm,    %cell size to fit the scale and integer dimensions (in cm)
        	inner sep=0,          %remove all inner gaps to save space in small scales
        	] (C) {\pgfmathprintnumber[assume math mode,fixed zerofill=true,precision=1]{\d}\%\\\r};     %text to put in cell (adapt at will)
        %Now if last vertical class add its label at the bottom
        \ifthenelse{\y=\numClasses}{
        \node [] at ($(C)-(0,0.75)$) % can use vertical or diagonal label as option
        {\pgfmathparse{\classNames[\x-1]}\pgfmathresult};}{}
    \end{scope}
    }
}
%Now add x and y labels on suitable coordinates
\coordinate (yaxis) at (-0.8,0.5-\numClasses/2);  %must adapt if class labels are wider!
\coordinate (xaxis) at (0.5+\numClasses/2, -\numClasses-1.25); %id. for non horizontal labels!
\node [vertical label] at (yaxis) {Output Class};
\node []               at (xaxis) {Target Class};
\draw [thick] (0.5,-0.5) rectangle(\numClasses+0.5,-\numClasses-0.5);
\end{tikzpicture}
%======= END OF ALTERNATIVE IMAGE IN TIKZ =======
    
    \caption{Confusion matrix of the testing dataset using 30 timesteps.}
    \label{fig:conf_matrix30}
\end{figure}
%

In order to assess the relative importance of the variables involved in this process of floor identification, different training strategies were done using different sets of input variables, namely with horizontal forces only, robot own IMU only, and the combination of both. Fig. \ref{fig:features} shows the average test accuracy of the LSTM model when using only the horizontal forces (HFs), only the IMU data and lastly, both together (HFs+IMU) as was used throughout this work. We can already observe that the data coming from the ITShoes has a much larger performance in the classification than the IMU data alone, but we also observed that when we put together the data coming from the ITshoes and the IMU, the classification results further improve about \SI{8}{\percent}. 
%

\tikzset{ %adapted the axis below so you no longer need this! %vs
    special a/.style={
        above,
        color=black,
        font=\tiny %was \tiny (but too small)
    }
}
\begin{figure}[!ht]  %vs was t
  \centering
  \begin{tikzpicture}
    \begin{axis}[
        /pgf/number format/1000 sep={},
        width=0.8\linewidth,
        height=3cm,
        %at={(0.758in,0.981in)},
        scale only axis,
        clip=false,
        separate axis lines,
        %axis on top,
        grid=major,
        grid style={dashed,gray!30},
        xmin=0,
        xmax=6,
        xtick={1,3,5},
        x tick style={draw=none},
        xticklabels={HFs,IMU,HFs+IMU},
        %ytick={0,0.25,0.5,0.75,1},
        ytick={0,25,50,75,100},        
        ymin=0,
%        ymax=1,
        ylabel=Test Accuracy (\si{\percent}),
        every axis plot/.append style={
          ybar,
          bar width=20,
          bar shift=0pt,
          fill
        },
        nodes near coords={\pgfmathprintnumber\pgfplotspointmeta\%}, %use this instead of manual nodes %vs
        enlarge y limits={value=0.2,upper}, %and this to get more upper space %vs
      ]
    %   \addplot[black]coordinates{(5,0.9171)};
    %   \addplot[black]coordinates{(1,0.8363)};
    %   \addplot[black]coordinates{(3,0.5793)};
      \addplot[black]coordinates{(5,92)};
      \addplot[black]coordinates{(1,84)};
      \addplot[black]coordinates{(3,58)};
     %
    % vs commented the 6 lines below! 
    %   \addplot [mark = none] coordinates {(5,0.9171)} node[pos=0](teste){} ;
    %   \node [special a] at (teste) {0.92};
    %   \addplot [mark = none] coordinates {(1,0.8363)} node[pos=0](teste){} ;
    %   \node [special a] at (teste) {0.84};
    %   \addplot [mark = none] coordinates {(3,0.5793)} node[pos=0](teste){} ;
    %   \node [special a] at (teste) {0.58};
    \end{axis}
  \end{tikzpicture}
    \caption{LSTM average test accuracy when using only the Horizontal Forces (HFs), only the data coming from the robot's IMU and all the features (HFs+IMU) as described in sub-section \ref{subsectionLSTM}.}
    \label{fig:features}
\end{figure}

\section{Conclusions}
%
This work addresses a multi-classification problem using a LSTM recurrent neural network model based on the ITshoes force data together with the robot internal inertial sensor data. A dataset of 27800 labelled steps of a walking biped robot over four different floors were collected and used to train, validate and test the multiple learning models. After several attempts to optimize the LSTM base model, and after tuning its parameters, we achieved a network capable of classifying the different floors with an accuracy of approximately \SI{92}{\percent}. The developed online experiment also validated the LSTM-RNN approach to this classification problem, as it correctly classified 87 out of 90 robot's steps. 
%
For future work we will develop a thorough study of the impact of the data coming from the ITShoes and the IMU to validate the importance of the wearable instrumented system. 
%
Additionally, in the future it is expected to use this classification to optimize the humanoid robot controller, since it will be easier to achieve an efficient and stable humanoid gait if its controller has information about the floor where it walks on. Following this idea, we also expect that this network can be adapted to be used with different classes by analysing how close a new input will be from one of the studied classes. In fact, we observed that even in cases where classification shows smaller confidence in one material, the next best option is, most often, a material with a neighbor friction coefficient. This shows that this solution is able to detect properly the closest friction coefficient from the set of possibilities trained. So, if enough materials are used to represent the required resolution of friction coefficients, the robot will be able to assess with adequate accuracy the interval of values for the friction coefficient where it is walking on, thus allowing the decision of measures to take to improve walking control. Although this classification is focused on the friction property of the materials, we will also consider to study other characteristics such as damping and stiffness not only to have a richer set of parameters to adapt the robot controller but also to broaden the possibility to detect different floors, i.e deformable floors. 

When we classify the different but known floors we know in advance the floor properties/characteristics and the main challenge where more characteristics of the floors can be handy will be in the future when we try to interpolate this known properties with the classification of unknown floors.  
% 
\printbibliography
\balance
%\eject
%\vspace{-1.5cm}
\begin{IEEEbiography}[{\includegraphics[width=1in,height=1.25in,clip,keepaspectratio]{Images/almei.png}}]{Luís Almeida} obtained a 5-year degree in Mechanical Engineering in 2016, at the University of Aveiro, Portugal, where he later, started to pursue his PhD in Mechanical Engineering in 2018. He participated in a research project and some conferences in the area of humanoid robotics. His current research interests include humanoid robots locomotion and control, human-robot interaction and computational intelligent techniques.
\end{IEEEbiography}
%\vspace{-1.5cm}
\begin{IEEEbiography}[{\includegraphics[width=1in,height=1.25in,clip,keepaspectratio]{Images/santo.png}}]{Vítor Santos} obtained a 5-year degree in Electronics Engineering and Telecommunications in 1989, at the University of Aveiro, Portugal, where he later obtained a PhD in Electrical Engineering in 1995, and the Habilitation in Mechanical Engineering in 2018. He was awarded fellowships to pursue research in mobile robotics during 1990-1994 at the Joint Research Center, Italy. He his currently Associate Professor at the University of Aveiro and lectures courses related to advanced perception and robotics, and has carried out research activity on mobile robotics, advanced perception and humanoid robotics. At the University of Aveiro he has coordinated the ATLAS project for mobile robot competition that achieved 6 first prizes in the annual Autonomous Driving competition and has coordinated the development of ATLASCAR the first real car with autonomous navigation capabilities in Portugal. He is one of the founders of the Portuguese Robotics Open in 2001 and also co-founder of the Portuguese Society of Robotics. His interests extend to humanoid robotics and the application of techniques from perception and mobile robotics to autonomy and safety in Autonomous Driving and Driving Assistance systems.
\end{IEEEbiography}
%\vspace{-1.5cm}
\begin{IEEEbiography}[{\includegraphics[width=1in,height=1.25in,clip,keepaspectratio]{Images/Ferre.jpg}}]{João P. Ferreira} received his BSc degree in Electrical Engineering in 1999, Master in Industrial Automation in 2002 and PhD in Instrumentation and Control in 2010 from the Univ. of Coimbra. Currently, he is a Professor of the Electrical Engineering Department at the Superior Institute of Engineering of Coimbra, Coordinator of specialization course of Industrial Automation, Robotics and Maintenance and Researcher at the Institute of Systems and Robotics of Univ. of Coimbra. He has coordinated and participated in several funding projects in the area of humanoid and medical rehabilitation robotics, with more than sixty scientific publications in international journals/conferences, over two hundred participations as a reviewer of scientific manuscripts and have a national patent (nº. 108143). His research interests include humanoid robots, human gait, rehabilitation robotics and artificial intelligence and its application.
\end{IEEEbiography}
\end{document}