\section{aversive\_\-10-03-12/modules/devices/robot/obstacle\_\-avoidance/obstacle\_\-avoidance.h File Reference}
\label{obstacle__avoidance_8h}\index{aversive\_\-10-03-12/modules/devices/robot/obstacle\_\-avoidance/obstacle\_\-avoidance.h@{aversive\_\-10-03-12/modules/devices/robot/obstacle\_\-avoidance/obstacle\_\-avoidance.h}}
\subsection*{Data Structures}
\begin{CompactItemize}
\item 
struct {\bf \_\-ext\_\-point}
\item 
struct {\bf \_\-point}
\item 
struct {\bf \_\-line}
\item 
struct {\bf \_\-poly}
\item 
struct {\bf obstacle\_\-avoidance}
\end{CompactItemize}
\subsection*{Defines}
\begin{CompactItemize}
\item 
\#define {\bf MAX\_\-POLY}~3
\item 
\#define {\bf MAX\_\-PTS}~10
\item 
\#define {\bf MAX\_\-RAYS}~100
\item 
\#define {\bf MAX\_\-CHKPOINTS}~5
\item 
\#define {\bf PLAYGROUND\_\-X\_\-MIN}~0
\item 
\#define {\bf PLAYGROUND\_\-X\_\-MAX}~300
\item 
\#define {\bf PLAYGROUND\_\-Y\_\-MIN}~0
\item 
\#define {\bf PLAYGROUND\_\-Y\_\-MAX}~210
\end{CompactItemize}
\subsection*{Typedefs}
\begin{CompactItemize}
\item 
typedef struct {\bf \_\-ext\_\-point} {\bf oa\_\-ext\_\-point\_\-t}
\item 
typedef struct {\bf \_\-point} {\bf oa\_\-point\_\-t}
\item 
typedef struct {\bf \_\-line} {\bf oa\_\-line\_\-t}
\item 
typedef struct {\bf \_\-poly} {\bf oa\_\-poly\_\-t}
\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
void {\bf oa\_\-init} (void)
\item 
void {\bf oa\_\-start\_\-end\_\-points} (int32\_\-t st\_\-x, int32\_\-t st\_\-y, int32\_\-t en\_\-x, int32\_\-t en\_\-y)
\item 
{\bf oa\_\-poly\_\-t} $\ast$ {\bf oa\_\-new\_\-poly} (uint8\_\-t size)
\item 
void {\bf oa\_\-poly\_\-set\_\-point} ({\bf oa\_\-poly\_\-t} $\ast$pol, int32\_\-t x, int32\_\-t y, uint8\_\-t {\bf i})
\item 
int8\_\-t {\bf oa\_\-process} (void)
\item 
{\bf oa\_\-point\_\-t} $\ast$ {\bf oa\_\-get\_\-path} (void)
\item 
uint8\_\-t {\bf is\_\-point\_\-in\_\-poly} ({\bf oa\_\-poly\_\-t} $\ast$pol, int16\_\-t x, int16\_\-t y)
\end{CompactItemize}


\subsection{Define Documentation}
\index{obstacle\_\-avoidance.h@{obstacle\_\-avoidance.h}!MAX\_\-CHKPOINTS@{MAX\_\-CHKPOINTS}}
\index{MAX\_\-CHKPOINTS@{MAX\_\-CHKPOINTS}!obstacle_avoidance.h@{obstacle\_\-avoidance.h}}
\subsubsection[MAX\_\-CHKPOINTS]{\setlength{\rightskip}{0pt plus 5cm}\#define MAX\_\-CHKPOINTS~5}\label{obstacle__avoidance_8h_3e8730fcc08f66c80811a84b6f6051c4}




Definition at line 59 of file obstacle\_\-avoidance.h.

Referenced by get\_\-path().\index{obstacle\_\-avoidance.h@{obstacle\_\-avoidance.h}!MAX\_\-POLY@{MAX\_\-POLY}}
\index{MAX\_\-POLY@{MAX\_\-POLY}!obstacle_avoidance.h@{obstacle\_\-avoidance.h}}
\subsubsection[MAX\_\-POLY]{\setlength{\rightskip}{0pt plus 5cm}\#define MAX\_\-POLY~3}\label{obstacle__avoidance_8h_b269fe99d4621fe004db233d25550f09}




Definition at line 56 of file obstacle\_\-avoidance.h.

Referenced by dijkstra(), and oa\_\-new\_\-poly().\index{obstacle\_\-avoidance.h@{obstacle\_\-avoidance.h}!MAX\_\-PTS@{MAX\_\-PTS}}
\index{MAX\_\-PTS@{MAX\_\-PTS}!obstacle_avoidance.h@{obstacle\_\-avoidance.h}}
\subsubsection[MAX\_\-PTS]{\setlength{\rightskip}{0pt plus 5cm}\#define MAX\_\-PTS~10}\label{obstacle__avoidance_8h_ee924ef71b44dac1501d13e25ac2743f}




Definition at line 57 of file obstacle\_\-avoidance.h.

Referenced by oa\_\-new\_\-poly().\index{obstacle\_\-avoidance.h@{obstacle\_\-avoidance.h}!MAX\_\-RAYS@{MAX\_\-RAYS}}
\index{MAX\_\-RAYS@{MAX\_\-RAYS}!obstacle_avoidance.h@{obstacle\_\-avoidance.h}}
\subsubsection[MAX\_\-RAYS]{\setlength{\rightskip}{0pt plus 5cm}\#define MAX\_\-RAYS~100}\label{obstacle__avoidance_8h_ac4cd1862ceb77b39631694e0ace5430}




Definition at line 58 of file obstacle\_\-avoidance.h.\index{obstacle\_\-avoidance.h@{obstacle\_\-avoidance.h}!PLAYGROUND\_\-X\_\-MAX@{PLAYGROUND\_\-X\_\-MAX}}
\index{PLAYGROUND\_\-X\_\-MAX@{PLAYGROUND\_\-X\_\-MAX}!obstacle_avoidance.h@{obstacle\_\-avoidance.h}}
\subsubsection[PLAYGROUND\_\-X\_\-MAX]{\setlength{\rightskip}{0pt plus 5cm}\#define PLAYGROUND\_\-X\_\-MAX~300}\label{obstacle__avoidance_8h_b3ec46878addddfb917f51fa04ef2fb9}




Definition at line 62 of file obstacle\_\-avoidance.h.\index{obstacle\_\-avoidance.h@{obstacle\_\-avoidance.h}!PLAYGROUND\_\-X\_\-MIN@{PLAYGROUND\_\-X\_\-MIN}}
\index{PLAYGROUND\_\-X\_\-MIN@{PLAYGROUND\_\-X\_\-MIN}!obstacle_avoidance.h@{obstacle\_\-avoidance.h}}
\subsubsection[PLAYGROUND\_\-X\_\-MIN]{\setlength{\rightskip}{0pt plus 5cm}\#define PLAYGROUND\_\-X\_\-MIN~0}\label{obstacle__avoidance_8h_09261377f27e1720eb7e217feeaaa5b3}




Definition at line 61 of file obstacle\_\-avoidance.h.\index{obstacle\_\-avoidance.h@{obstacle\_\-avoidance.h}!PLAYGROUND\_\-Y\_\-MAX@{PLAYGROUND\_\-Y\_\-MAX}}
\index{PLAYGROUND\_\-Y\_\-MAX@{PLAYGROUND\_\-Y\_\-MAX}!obstacle_avoidance.h@{obstacle\_\-avoidance.h}}
\subsubsection[PLAYGROUND\_\-Y\_\-MAX]{\setlength{\rightskip}{0pt plus 5cm}\#define PLAYGROUND\_\-Y\_\-MAX~210}\label{obstacle__avoidance_8h_26bffbdc662885d371656d036af8901b}




Definition at line 65 of file obstacle\_\-avoidance.h.\index{obstacle\_\-avoidance.h@{obstacle\_\-avoidance.h}!PLAYGROUND\_\-Y\_\-MIN@{PLAYGROUND\_\-Y\_\-MIN}}
\index{PLAYGROUND\_\-Y\_\-MIN@{PLAYGROUND\_\-Y\_\-MIN}!obstacle_avoidance.h@{obstacle\_\-avoidance.h}}
\subsubsection[PLAYGROUND\_\-Y\_\-MIN]{\setlength{\rightskip}{0pt plus 5cm}\#define PLAYGROUND\_\-Y\_\-MIN~0}\label{obstacle__avoidance_8h_4534ed4f7668dc90147079e908981072}




Definition at line 64 of file obstacle\_\-avoidance.h.

\subsection{Typedef Documentation}
\index{obstacle\_\-avoidance.h@{obstacle\_\-avoidance.h}!oa\_\-ext\_\-point\_\-t@{oa\_\-ext\_\-point\_\-t}}
\index{oa\_\-ext\_\-point\_\-t@{oa\_\-ext\_\-point\_\-t}!obstacle_avoidance.h@{obstacle\_\-avoidance.h}}
\subsubsection[oa\_\-ext\_\-point\_\-t]{\setlength{\rightskip}{0pt plus 5cm}typedef struct {\bf \_\-ext\_\-point}  {\bf oa\_\-ext\_\-point\_\-t}}\label{obstacle__avoidance_8h_59a71e6676ced7e23d44e208db159ef2}


\index{obstacle\_\-avoidance.h@{obstacle\_\-avoidance.h}!oa\_\-line\_\-t@{oa\_\-line\_\-t}}
\index{oa\_\-line\_\-t@{oa\_\-line\_\-t}!obstacle_avoidance.h@{obstacle\_\-avoidance.h}}
\subsubsection[oa\_\-line\_\-t]{\setlength{\rightskip}{0pt plus 5cm}typedef struct {\bf \_\-line}  {\bf oa\_\-line\_\-t}}\label{obstacle__avoidance_8h_2f282612010332d55e4160f079ba476b}


\index{obstacle\_\-avoidance.h@{obstacle\_\-avoidance.h}!oa\_\-point\_\-t@{oa\_\-point\_\-t}}
\index{oa\_\-point\_\-t@{oa\_\-point\_\-t}!obstacle_avoidance.h@{obstacle\_\-avoidance.h}}
\subsubsection[oa\_\-point\_\-t]{\setlength{\rightskip}{0pt plus 5cm}typedef struct {\bf \_\-point}  {\bf oa\_\-point\_\-t}}\label{obstacle__avoidance_8h_84f21129753fd00e9d68d67fe2efb9bd}


\index{obstacle\_\-avoidance.h@{obstacle\_\-avoidance.h}!oa\_\-poly\_\-t@{oa\_\-poly\_\-t}}
\index{oa\_\-poly\_\-t@{oa\_\-poly\_\-t}!obstacle_avoidance.h@{obstacle\_\-avoidance.h}}
\subsubsection[oa\_\-poly\_\-t]{\setlength{\rightskip}{0pt plus 5cm}typedef struct {\bf \_\-poly}  {\bf oa\_\-poly\_\-t}}\label{obstacle__avoidance_8h_cf29a9ca268f01c8e9853b69d075de61}




\subsection{Function Documentation}
\index{obstacle\_\-avoidance.h@{obstacle\_\-avoidance.h}!is\_\-point\_\-in\_\-poly@{is\_\-point\_\-in\_\-poly}}
\index{is\_\-point\_\-in\_\-poly@{is\_\-point\_\-in\_\-poly}!obstacle_avoidance.h@{obstacle\_\-avoidance.h}}
\subsubsection[is\_\-point\_\-in\_\-poly]{\setlength{\rightskip}{0pt plus 5cm}uint8\_\-t is\_\-point\_\-in\_\-poly ({\bf oa\_\-poly\_\-t} $\ast$ {\em pol}, \/  int16\_\-t {\em x}, \/  int16\_\-t {\em y})}\label{obstacle__avoidance_8h_33e3c882ea312186a0a263d572f506a1}


return 

Definition at line 361 of file obstacle\_\-avoidance.c.

References \_\-ext\_\-point::x, and \_\-ext\_\-point::y.\index{obstacle\_\-avoidance.h@{obstacle\_\-avoidance.h}!oa\_\-get\_\-path@{oa\_\-get\_\-path}}
\index{oa\_\-get\_\-path@{oa\_\-get\_\-path}!obstacle_avoidance.h@{obstacle\_\-avoidance.h}}
\subsubsection[oa\_\-get\_\-path]{\setlength{\rightskip}{0pt plus 5cm}{\bf oa\_\-point\_\-t}$\ast$ oa\_\-get\_\-path (void)}\label{obstacle__avoidance_8h_47b3874400276592eacaa416aade0dc5}


get the result after a call to \doxyref{oa\_\-process()}{p.}{obstacle__avoidance_8c_40b4deae6ef3d9969c6d51908b16427e} 

Definition at line 112 of file obstacle\_\-avoidance.c.

References obstacle\_\-avoidance::res, and obstacle\_\-avoidance::u.\index{obstacle\_\-avoidance.h@{obstacle\_\-avoidance.h}!oa\_\-init@{oa\_\-init}}
\index{oa\_\-init@{oa\_\-init}!obstacle_avoidance.h@{obstacle\_\-avoidance.h}}
\subsubsection[oa\_\-init]{\setlength{\rightskip}{0pt plus 5cm}void oa\_\-init (void)}\label{obstacle__avoidance_8h_22d755b846db66d149dbdc994e886815}


Init the oa structure

Init the oa structure. Note: In the algorithm, the first polygon is a dummy one, and is used to represent the START and END points (so it has 2 vertices) 

Definition at line 42 of file obstacle\_\-avoidance.c.

References \_\-poly::l, oa\_\-start\_\-end\_\-points(), obstacle\_\-avoidance::points, obstacle\_\-avoidance::polys, and \_\-poly::pts.\index{obstacle\_\-avoidance.h@{obstacle\_\-avoidance.h}!oa\_\-new\_\-poly@{oa\_\-new\_\-poly}}
\index{oa\_\-new\_\-poly@{oa\_\-new\_\-poly}!obstacle_avoidance.h@{obstacle\_\-avoidance.h}}
\subsubsection[oa\_\-new\_\-poly]{\setlength{\rightskip}{0pt plus 5cm}{\bf oa\_\-poly\_\-t}$\ast$ oa\_\-new\_\-poly (uint8\_\-t {\em size})}\label{obstacle__avoidance_8h_a3f707513be2570f65a5fac7b1d1d3e1}


Create a new obstacle polygon. Return NULL on \doxyref{error}{p.}{structerror}. 

Definition at line 84 of file obstacle\_\-avoidance.c.

References obstacle\_\-avoidance::cur\_\-poly\_\-idx, obstacle\_\-avoidance::cur\_\-pt\_\-idx, \_\-poly::l, MAX\_\-POLY, MAX\_\-PTS, obstacle\_\-avoidance::points, obstacle\_\-avoidance::polys, and \_\-poly::pts.\index{obstacle\_\-avoidance.h@{obstacle\_\-avoidance.h}!oa\_\-poly\_\-set\_\-point@{oa\_\-poly\_\-set\_\-point}}
\index{oa\_\-poly\_\-set\_\-point@{oa\_\-poly\_\-set\_\-point}!obstacle_avoidance.h@{obstacle\_\-avoidance.h}}
\subsubsection[oa\_\-poly\_\-set\_\-point]{\setlength{\rightskip}{0pt plus 5cm}void oa\_\-poly\_\-set\_\-point ({\bf oa\_\-poly\_\-t} $\ast$ {\em pol}, \/  int32\_\-t {\em x}, \/  int32\_\-t {\em y}, \/  uint8\_\-t {\em i})}\label{obstacle__avoidance_8h_230340c441b04e8947dc7efa59650b0b}


set a point of the polygon.

Add a point to the polygon. 

Definition at line 101 of file obstacle\_\-avoidance.c.

References DEBUG, E\_\-OA, \_\-poly::pts, \_\-ext\_\-point::valid, \_\-ext\_\-point::weight, \_\-ext\_\-point::x, and \_\-ext\_\-point::y.\index{obstacle\_\-avoidance.h@{obstacle\_\-avoidance.h}!oa\_\-process@{oa\_\-process}}
\index{oa\_\-process@{oa\_\-process}!obstacle_avoidance.h@{obstacle\_\-avoidance.h}}
\subsubsection[oa\_\-process]{\setlength{\rightskip}{0pt plus 5cm}int8\_\-t oa\_\-process (void)}\label{obstacle__avoidance_8h_40b4deae6ef3d9969c6d51908b16427e}


process the path from start to end. Return 0 on sucess. 

Definition at line 687 of file obstacle\_\-avoidance.c.

References calc\_\-rays(), calc\_\-rays\_\-weight(), obstacle\_\-avoidance::cur\_\-poly\_\-idx, DEBUG, dijkstra(), E\_\-OA, get\_\-path(), obstacle\_\-avoidance::polys, \_\-poly::pts, obstacle\_\-avoidance::ray\_\-n, obstacle\_\-avoidance::rays, obstacle\_\-avoidance::u, obstacle\_\-avoidance::weight, \_\-ext\_\-point::x, and \_\-ext\_\-point::y.\index{obstacle\_\-avoidance.h@{obstacle\_\-avoidance.h}!oa\_\-start\_\-end\_\-points@{oa\_\-start\_\-end\_\-points}}
\index{oa\_\-start\_\-end\_\-points@{oa\_\-start\_\-end\_\-points}!obstacle_avoidance.h@{obstacle\_\-avoidance.h}}
\subsubsection[oa\_\-start\_\-end\_\-points]{\setlength{\rightskip}{0pt plus 5cm}void oa\_\-start\_\-end\_\-points (int32\_\-t {\em st\_\-x}, \/  int32\_\-t {\em st\_\-y}, \/  int32\_\-t {\em en\_\-x}, \/  int32\_\-t {\em en\_\-y})}\label{obstacle__avoidance_8h_04bcd822062597b78e8a6ef0f7263ebc}


Set the start and destination point.

Set the start and destination point. Return 0 on sucess 

Definition at line 56 of file obstacle\_\-avoidance.c.

References obstacle\_\-avoidance::cur\_\-poly\_\-idx, obstacle\_\-avoidance::cur\_\-pt\_\-idx, obstacle\_\-avoidance::points, \_\-ext\_\-point::valid, \_\-ext\_\-point::weight, \_\-ext\_\-point::x, and \_\-ext\_\-point::y.

Referenced by oa\_\-init().