In this chapter, the main conclusions that have come from the work done in this dissertation will be presented, along with proposals of future work in the area that can be integrated into \gls{phua}.

\section{Conclusions}
%At the beginning of this dissertation, estimating verticality using inertial data was one of its objectives, although one with less importance (as explained in section \ref{sec:obj}). Since all the other tasks took more time than was expected, it was not possible to do an estimation of verticality using only inertial data. However, to test if the inertial sensors were still working properly in case this is to be addressed in a future work, the Arduino board was connected to the computer and the relevant \gls{ros} nodes developed previously in \cite{rafeiro_rede_2013} were compiled. The Arduino code which would read the sensor's values was also uploaded to the board and it was possible to visualize the inertial readings in real-time on the computer screen.

Regarding the accomplishment of this dissertation's objectives, it can be said that only some of them were accomplished. When it comes to estimating the direction of the gravity vector using both visual and inertial data, the first main objective of this dissertation, more focus was put into using visual data, as was planned. However, to test if the inertial sensors were still working properly in case this is to be addressed in a future work, the Arduino board was connected to the computer and the relevant \gls{ros} nodes developed previously in \cite{rafeiro_rede_2013} were compiled. The Arduino code which would read the sensor's values was also uploaded to the board and it was possible to visualize the inertial readings in real-time on the computer screen. 

Both the roll and tilt components of the gravity vector were estimated successfully, by using two methods based on tracking an object present in the image frame.

The first method used (referred to as the line tracking method), tracks a line formed by the squares of a chessboard who was placed in front of the camera mounted in the \gls{rtu} (humanoid head). This method is able to provide the angle of this line, which in turn allows the estimation of the roll component of the gravity vector, provided that the orientation of the chessboard in relation to the environment is known.

The second method used (referred to as the pose estimation method), estimates the pose (position and orientation) of the chessboard mentioned in the previous paragraph in relation to the \gls{rtu}, which provides both the roll and tilt components of the gravity vector, if the pose of the chessboard relative to the environment is known. 

The second objective of this dissertation, which was to develop computational tools which would act on the \gls{rtu}, based on the previously estimated verticality and allowing it to remain stable, was also fulfilled. The final solution involved a \gls{pd} controller whose control variable was the position of the servo responsible for the roll angle of the \gls{rtu} and a \gls{pd} controller whose control variable was the speed of the servo responsible for the tilt angle of the \gls{rtu}. Although stabilization for both the roll and tilt components of the \gls{rtu} could not be performed at the same time, it was successfully done separately. This is because the existing infrastructure was not suitable for this purpose (more details in section \ref{sec:stabilization} - Fig. \ref{fig:composite_movement}), as it was thought to be in the beginning of this work.

Concerning the third and final objective of the dissertation, which was to explore and demonstrate the benefits of head stabilization when trying to achieve a humanoid robot's balance, it can be said that it was not completely fulfilled. Although the benefits of head stabilization were explored, they could not be demonstrated since the \gls{phua} platform was not functional at the time of this work. The humanoid robot was undergoing repairs by volunteers at \gls{lar}, but these were not finished in time to allow the demonstration of the benefits of head stabilization.

The experiments carried out during the dissertation helped show the progressive tuning of each of the \gls{pd} controller's parameters and allowed for the evaluation of the line tracking method. Thinking back, if a change was to be made to the experiments, it would be the addition of a new experiment to evaluate the pose estimation method. Since this method was implemented after experiments regarding the \gls{rtu}'s stabilization had begun, the importance of such an experiment was overlooked. As a final remark to the experiment's results, it was also possible to conclude that when stabilization was done using the line tracking method to estimate the gravity vector's roll component, results were slightly better than when using the pose estimation method. This was thought to be due to the decreased update rate of the pose estimation method when compared to the line tracking method.

One of the biggest challenges surpassed during this dissertation was to gather and apply all the knowledge and methods used in previous works, which dated back to the creation of \gls{lar} and the \gls{phua} project itself. Another topic that should be mentioned is the possible inadequacy of the camera's frame rate to perform tracking operations. Although the camera used has a great resolution, a maximum frame rate of 15 frames per second is too low to perform real-time stabilization of a humanoid robot. The servomotors used also did not perform fully as expected, as one of them showed problems when returning its current angular position when requested.

As a final note, it is important to say that the FANUC robotic manipulator used proved invaluable when providing a ground truth for the experiments that were carried out.

\section{Future work}

This dissertation allowed the development of the work started in previous theses on a vision-based balance system. However, there are many more tasks that need to be done in order to integrate this new balance system into the \gls{phua} project, and some are listed below:

\begin{itemize}
\item Analyze if the pose estimation tool of the \gls{visp} library can be used more effectively (i.e. increase its update rate);
\item Combine the estimation of the gravity vector using visual data with an estimation using inertial data when it is not plausible to use visual data (e.g. poor lighting, movements that are too sudden, etc.)
\item Further tune the \gls{pd} controller's parameters used to stabilize the humanoid head.
\item Obtain a camera which is more suitable for stabilization purposes (i.e. higher frame rate) and install it in the humanoid head.
\item Verify if it is viable to install a mini-computer on the \gls{phua} robot (e.g Raspberry Pi), which would perform all calculations regarding its balance, and other operations, thus making the robot more autonomous.
\item Demonstrate the benefits of head stabilization when trying to achieve a humanoid robot's balance.
\end{itemize}
