\subsection{Obstacle Avoidance}\label{oaalgo}

Obstacle Avoidance assistance has been largely modelled on the technique used by Yanco (2000) as it provides a simplistic approach to shared control. Hence it was considered suitable for the scope of this project, particularly given the time-constraints. Sub-routines in the algorithm offer various corrective measures depending on the location of the obstacles. After describing some key considerations, the sub-routines are explained in the order in which they are run by the shared controller.

\textit{Assumptions}: It is assumed there are no pits or sudden drop-offs and that the heights of the obstacles are such that they can be detected by the sonar sensors.

\textit{Thresholds}: The shared control technique relies on fixed thresholds set according to the velocity of the wheelchair to determine risk of collision with an obstacle. This is in line with the implementation by Petry et al (2010), where the risk of collision is considered as a function of both distance to obstacle and speed as mentioned in \hyperref[litreview]{Section 2.2}. Considering that sensor data are updated every second, it was reasoned that the safety threshold for obstacles to the front and corners of the wheelchair be at least twice its velocity (in metres per second). This enables appropriate corrective measures to be undertaken by the controller within the next second while not bringing the wheelchair too close to the obstacle. An offset was added to this value to compensate for the distance of the sonar sensors from the periphery of the wheelchair (about 20cm from the edge of the foot). Final adjustments were made empirically. The side thresholds were set at half the front threshold in the interest of not being too far from obstacles on the sides. 

\textit{Memory}: The state requested by the user is stored in memory so that after a corrective action is made, the wheelchair can be set back to that state. This strategy proposes to minimise user intervention after the wheelchair has altered its movement.

\textit{Turning radius}: The degree of deflection of the wheelchair to avoid an obstacle was determined empirically, taking into consideration both velocity of the wheelchair and the location of obstacles in its vicinity. For instance, for turning sharply to the left, the L value (or mean of L and R values) was decremented more than that required for a small deflection as discussed in \hyperref[modstatecontrol]{Section 3.3.4}.

\textit{Categorisation of obstacles}: Obstacles have been categorised into three types and handled accordingly. The first and second categories include \textquoteleft{large}' and \textquoteleft{small}' obstacles situated to the front of the wheelchair, respectively. An obstacle is said to be \textquoteleft{large}' with respect to the wheelchair if all its front and corner sonar sensors are obstructed by it. A \textquoteleft{small}' obstacle obstructs only one or two of the middle three sensors. The terms \textquoteleft{large}' and \textquoteleft{small}' can be quantified by considering the arrangement of the sonar sensors at the front and corners of the wheelchair. Five sensors have been placed at the front, at a distance of 10cm from one another. Additionally, one sensor has been mounted at each front corner, oriented at 28° from the front-back axis of the wheelchair and at a distance of 4cm away from the adjacent front sensor. Hence a \textquoteleft{large}' obstacle is wider than approximately 50cm or completely obstructs an area spanning 120° in front of the wheelchair. A \textquoteleft{small}' obstacle is not wider than 30cm. The third category includes objects obstructing the corners of the wheelchair. \\

\noindent
\textit{Obstacle Avoidance routines}:
\begin{enumerate}[i]%small roman
\item Corner Navigation - This functionality is active only in the Wall Following mode, which allows a wheelchair that has been following a wall to negotiate a corner. When a corner is detected, the wheelchair makes a large deflection away from it. However, the logic used here is still rudimentary and does not take into consideration the angle of inclination of the wheelchair to the wall, which   would determine the amount of deflection required. The routine can be improvised by appropriately handling different inclinations. Currently, the corner is negotiated properly if the front of the wheelchair is almost parallel to the wall in front and is within safe distance for negotiating the turn without hitting the wall in the process.  

\item Large obstacles in front - If the wheelchair is completely blocked by an obstacle or numerous obstacles in the front and both right and left corners, as in \hyperref[fig:FrontBigOb]{Figure 4.1}, it is brought to a halt and the driver is expected to issue a left or right command. The reasoning is that the user would wish to decide which way to proceed rather than the wheelchair being set by default to move either right or left. Hence the control strategy differs from Yanco (2000), where an obstacle in front causes the wheelchair to move right by default if that side is unobstructed. The wheelchair comes to a stop only if both sides are blocked. However, if the user had intended to go left and was not quick enough to stop the wheelchair before it turned right, he or she would then have to swing around to go in their direction of choice, which could be cumbersome to do all the time.

\begin{figure}[t]
\centering
\includegraphics[width=0.3\textwidth]{FrontBigObstacle}
\caption[Obstacle Avoidance - Large obstacle ahead]{Wheelchair will come to a halt if it is completely obstructed at the front}
\label{fig:FrontBigOb}
\end{figure}

\item Small obstacles in front - If the wheelchair is partially blocked in front by an obstacle, it turns away in the other direction, provided that corner is free. If this safety check is not satisfied, the wheelchair will stop. In the example shown in \hyperref[fig:PartialOb]{Figure 4.2}, an obstacle blocking the left part of the wheelchair causes it to turn right. If the obstacle is very small and located right in front of the wheelchair, the wheelchair moves to the right by default. If the right side is not clear, it moves to the left. In this case, the default behaviour does not cause the user to make any major deflections to get back to the desired path as compared to that required to avoid a large obstacle. For instance, if the initial state had been \textquoteleft{Forward}', the wheelchair would turn away from the obstacle and continue forward by memory. If the initial state had been \textquoteleft{Right}', the right turn made by the wheelchair causes a larger deflection to the right. It can be assumed that the driver had miscalculated the distance at which the right turn had to be made, causing the wheelchair to be brought into the vicinity of the obstacle. Hence deflecting it further to the right by the assistive behaviour would compensate for the erroneous decision made by the user.

\begin{figure}[t]
\centering
\subfloat[Small obstacle at the front]{\label{fig:SmallOb}\includegraphics[width=0.5\textwidth]{FrontSmallObstacle}}
\subfloat[Obstacle at the corner]{\label{fig:CornerOb}\includegraphics[width=0.5\textwidth]{CornerObstacle}}
\caption[Obstacle Avoidance - Partial obstructions]{Wheelchair navigating away from obstacles partially obstructing its front or those obstructing its corners. The curve of the arrow indicates the turning radius - a larger deflection is required to successfully avoid an obstacle in the front as that for an obstacle at the corners.}
\label{fig:PartialOb}
\end{figure}

\item Obstacles at the corners - If only one corner is obstructed, the wheelchair turns to the other side if it is devoid of immediate obstacles as indicated by the side sensors; else it stops. If both corners are obstructed, the wheelchair turns to the side where obstacles are more distant if the corresponding side sensor shows clear; else it stops.  

\end{enumerate}

