\section{aversive\_\-10-03-12/modules/devices/robot/position\_\-manager/position\_\-manager.h File Reference}
\label{position__manager_8h}\index{aversive\_\-10-03-12/modules/devices/robot/position\_\-manager/position\_\-manager.h@{aversive\_\-10-03-12/modules/devices/robot/position\_\-manager/position\_\-manager.h}}
{\tt \#include $<$math.h$>$}\par
{\tt \#include $<$robot\_\-system.h$>$}\par
\subsection*{Data Structures}
\begin{CompactItemize}
\item 
struct {\bf robot\_\-physical\_\-params}
\item 
struct {\bf xya\_\-position}
\item 
struct {\bf xya\_\-position\_\-s16}
\item 
struct {\bf robot\_\-position}
\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
void {\bf position\_\-init} (struct {\bf robot\_\-position} $\ast$pos)
\item 
void {\bf position\_\-set} (struct {\bf robot\_\-position} $\ast$pos, int16\_\-t x, int16\_\-t y, int16\_\-t {\bf a})
\item 
void {\bf position\_\-use\_\-ext} (struct {\bf robot\_\-position} $\ast$pos)
\item 
void {\bf position\_\-use\_\-mot} (struct {\bf robot\_\-position} $\ast$pos)
\item 
void {\bf position\_\-set\_\-physical\_\-params} (struct {\bf robot\_\-position} $\ast$pos, double track\_\-cm, double distance\_\-imp\_\-per\_\-cm)
\item 
void {\bf position\_\-set\_\-related\_\-robot\_\-system} (struct {\bf robot\_\-position} $\ast$pos, struct {\bf robot\_\-system} $\ast$rs)
\item 
void {\bf position\_\-manage} (struct {\bf robot\_\-position} $\ast$pos)
\item 
int16\_\-t {\bf position\_\-get\_\-x\_\-s16} (struct {\bf robot\_\-position} $\ast$pos)
\item 
int16\_\-t {\bf position\_\-get\_\-y\_\-s16} (struct {\bf robot\_\-position} $\ast$pos)
\item 
int16\_\-t {\bf position\_\-get\_\-a\_\-deg\_\-s16} (struct {\bf robot\_\-position} $\ast$pos)
\item 
double {\bf position\_\-get\_\-x\_\-double} (struct {\bf robot\_\-position} $\ast$pos)
\item 
double {\bf position\_\-get\_\-y\_\-double} (struct {\bf robot\_\-position} $\ast$pos)
\item 
double {\bf position\_\-get\_\-a\_\-rad\_\-double} (struct {\bf robot\_\-position} $\ast$pos)
\end{CompactItemize}


\subsection{Function Documentation}
\index{position\_\-manager.h@{position\_\-manager.h}!position\_\-get\_\-a\_\-deg\_\-s16@{position\_\-get\_\-a\_\-deg\_\-s16}}
\index{position\_\-get\_\-a\_\-deg\_\-s16@{position\_\-get\_\-a\_\-deg\_\-s16}!position_manager.h@{position\_\-manager.h}}
\subsubsection[position\_\-get\_\-a\_\-deg\_\-s16]{\setlength{\rightskip}{0pt plus 5cm}int16\_\-t position\_\-get\_\-a\_\-deg\_\-s16 (struct {\bf robot\_\-position} $\ast$ {\em pos})}\label{position__manager_8h_5a6051ebeb08dce16dfa6920fabd2813}


returns current alpha 

Definition at line 214 of file position\_\-manager.c.

References xya\_\-position\_\-s16::a, and robot\_\-position::pos\_\-s16.\index{position\_\-manager.h@{position\_\-manager.h}!position\_\-get\_\-a\_\-rad\_\-double@{position\_\-get\_\-a\_\-rad\_\-double}}
\index{position\_\-get\_\-a\_\-rad\_\-double@{position\_\-get\_\-a\_\-rad\_\-double}!position_manager.h@{position\_\-manager.h}}
\subsubsection[position\_\-get\_\-a\_\-rad\_\-double]{\setlength{\rightskip}{0pt plus 5cm}double position\_\-get\_\-a\_\-rad\_\-double (struct {\bf robot\_\-position} $\ast$ {\em pos})}\label{position__manager_8h_5648bb685ebdd3fb39d07b1d888d8ca9}


returns current alpha 

Definition at line 240 of file position\_\-manager.c.

References xya\_\-position::a, and robot\_\-position::pos\_\-d.

Referenced by \_\-\_\-trajectory\_\-goto\_\-d\_\-a\_\-rel(), trajectory\_\-a\_\-abs(), trajectory\_\-goto\_\-d\_\-a\_\-rel(), trajectory\_\-goto\_\-xy\_\-rel(), trajectory\_\-turnto\_\-xy(), and trajectory\_\-turnto\_\-xy\_\-behind().\index{position\_\-manager.h@{position\_\-manager.h}!position\_\-get\_\-x\_\-double@{position\_\-get\_\-x\_\-double}}
\index{position\_\-get\_\-x\_\-double@{position\_\-get\_\-x\_\-double}!position_manager.h@{position\_\-manager.h}}
\subsubsection[position\_\-get\_\-x\_\-double]{\setlength{\rightskip}{0pt plus 5cm}double position\_\-get\_\-x\_\-double (struct {\bf robot\_\-position} $\ast$ {\em pos})}\label{position__manager_8h_215458c6c79e46ec0eb8731cc12e0df5}


returns current x 

Definition at line 224 of file position\_\-manager.c.

References robot\_\-position::pos\_\-d, and xya\_\-position::x.

Referenced by \_\-\_\-trajectory\_\-goto\_\-d\_\-a\_\-rel(), trajectory\_\-goto\_\-d\_\-a\_\-rel(), trajectory\_\-goto\_\-xy\_\-rel(), trajectory\_\-turnto\_\-xy(), and trajectory\_\-turnto\_\-xy\_\-behind().\index{position\_\-manager.h@{position\_\-manager.h}!position\_\-get\_\-x\_\-s16@{position\_\-get\_\-x\_\-s16}}
\index{position\_\-get\_\-x\_\-s16@{position\_\-get\_\-x\_\-s16}!position_manager.h@{position\_\-manager.h}}
\subsubsection[position\_\-get\_\-x\_\-s16]{\setlength{\rightskip}{0pt plus 5cm}int16\_\-t position\_\-get\_\-x\_\-s16 (struct {\bf robot\_\-position} $\ast$ {\em pos})}\label{position__manager_8h_3c8a5c1a3cf931275583b60e644461a2}


returns current x 

Definition at line 198 of file position\_\-manager.c.

References robot\_\-position::pos\_\-s16, and xya\_\-position\_\-s16::x.\index{position\_\-manager.h@{position\_\-manager.h}!position\_\-get\_\-y\_\-double@{position\_\-get\_\-y\_\-double}}
\index{position\_\-get\_\-y\_\-double@{position\_\-get\_\-y\_\-double}!position_manager.h@{position\_\-manager.h}}
\subsubsection[position\_\-get\_\-y\_\-double]{\setlength{\rightskip}{0pt plus 5cm}double position\_\-get\_\-y\_\-double (struct {\bf robot\_\-position} $\ast$ {\em pos})}\label{position__manager_8h_0a15766ca7ca1496948d4e1ace8513fb}


returns current y 

Definition at line 232 of file position\_\-manager.c.

References robot\_\-position::pos\_\-d, and xya\_\-position::y.

Referenced by \_\-\_\-trajectory\_\-goto\_\-d\_\-a\_\-rel(), trajectory\_\-goto\_\-d\_\-a\_\-rel(), trajectory\_\-goto\_\-xy\_\-rel(), trajectory\_\-turnto\_\-xy(), and trajectory\_\-turnto\_\-xy\_\-behind().\index{position\_\-manager.h@{position\_\-manager.h}!position\_\-get\_\-y\_\-s16@{position\_\-get\_\-y\_\-s16}}
\index{position\_\-get\_\-y\_\-s16@{position\_\-get\_\-y\_\-s16}!position_manager.h@{position\_\-manager.h}}
\subsubsection[position\_\-get\_\-y\_\-s16]{\setlength{\rightskip}{0pt plus 5cm}int16\_\-t position\_\-get\_\-y\_\-s16 (struct {\bf robot\_\-position} $\ast$ {\em pos})}\label{position__manager_8h_65575ea47043b4212548b18b52931cfb}


returns current y 

Definition at line 206 of file position\_\-manager.c.

References robot\_\-position::pos\_\-s16, and xya\_\-position\_\-s16::y.\index{position\_\-manager.h@{position\_\-manager.h}!position\_\-init@{position\_\-init}}
\index{position\_\-init@{position\_\-init}!position_manager.h@{position\_\-manager.h}}
\subsubsection[position\_\-init]{\setlength{\rightskip}{0pt plus 5cm}void position\_\-init (struct {\bf robot\_\-position} $\ast$ {\em pos})}\label{position__manager_8h_64e69af9004bfd45c7606cd593c13df6}


initialization of the \doxyref{robot\_\-position}{p.}{structrobot__position} pos, everthing is set to 0 

Definition at line 29 of file position\_\-manager.c.

References IRQ\_\-LOCK, and IRQ\_\-UNLOCK.\index{position\_\-manager.h@{position\_\-manager.h}!position\_\-manage@{position\_\-manage}}
\index{position\_\-manage@{position\_\-manage}!position_manager.h@{position\_\-manager.h}}
\subsubsection[position\_\-manage]{\setlength{\rightskip}{0pt plus 5cm}void position\_\-manage (struct {\bf robot\_\-position} $\ast$ {\em pos})}\label{position__manager_8h_25b82dc23a6c005e85a2eb07e41c6940}


Process the absolute position (x,y,a) depending on the delta on virtual encoders since last read, and depending on physical parameters.

Process the absolute position (x,y,a) depending on the delta on virtual encoders since last read, and depending on physical parameters. The processed position is in cm. 

Definition at line 112 of file position\_\-manager.c.

References a, xya\_\-position\_\-s16::a, xya\_\-position::a, rs\_\-polar::angle, rs\_\-polar::distance, robot\_\-physical\_\-params::distance\_\-imp\_\-per\_\-cm, robot\_\-system::flags, IRQ\_\-LOCK, IRQ\_\-UNLOCK, robot\_\-position::phys, robot\_\-position::pos\_\-d, robot\_\-position::pos\_\-s16, robot\_\-position::prev\_\-encoders, robot\_\-position::rs, rs\_\-get\_\-ext\_\-angle(), rs\_\-get\_\-ext\_\-distance(), robot\_\-physical\_\-params::track\_\-cm, robot\_\-position::use\_\-ext, xya\_\-position::x, xya\_\-position\_\-s16::x, xya\_\-position::y, and xya\_\-position\_\-s16::y.\index{position\_\-manager.h@{position\_\-manager.h}!position\_\-set@{position\_\-set}}
\index{position\_\-set@{position\_\-set}!position_manager.h@{position\_\-manager.h}}
\subsubsection[position\_\-set]{\setlength{\rightskip}{0pt plus 5cm}void position\_\-set (struct {\bf robot\_\-position} $\ast$ {\em pos}, \/  int16\_\-t {\em x}, \/  int16\_\-t {\em y}, \/  int16\_\-t {\em a})}\label{position__manager_8h_73913fda19e1f93d2be31ee230bbdb43}


Set a new robot position 

Definition at line 38 of file position\_\-manager.c.

References xya\_\-position\_\-s16::a, xya\_\-position::a, IRQ\_\-LOCK, IRQ\_\-UNLOCK, robot\_\-position::pos\_\-d, robot\_\-position::pos\_\-s16, xya\_\-position::x, xya\_\-position\_\-s16::x, xya\_\-position::y, and xya\_\-position\_\-s16::y.\index{position\_\-manager.h@{position\_\-manager.h}!position\_\-set\_\-physical\_\-params@{position\_\-set\_\-physical\_\-params}}
\index{position\_\-set\_\-physical\_\-params@{position\_\-set\_\-physical\_\-params}!position_manager.h@{position\_\-manager.h}}
\subsubsection[position\_\-set\_\-physical\_\-params]{\setlength{\rightskip}{0pt plus 5cm}void position\_\-set\_\-physical\_\-params (struct {\bf robot\_\-position} $\ast$ {\em pos}, \/  double {\em track\_\-cm}, \/  double {\em distance\_\-imp\_\-per\_\-cm})}\label{position__manager_8h_5715163ad3482be9dfe3f567bbf925f4}


Set the physical parameters of the robot :\begin{itemize}
\item distance between wheels (track, in cm)\item number of impulsions for 1 cm (distance)\end{itemize}


Set the physical parameters of the robot :\begin{itemize}
\item number of impulsions for 1 cm (distance)\item number of impulsions for 1 degree (angle) \end{itemize}


Definition at line 69 of file position\_\-manager.c.

References robot\_\-physical\_\-params::distance\_\-imp\_\-per\_\-cm, IRQ\_\-LOCK, IRQ\_\-UNLOCK, robot\_\-position::phys, and robot\_\-physical\_\-params::track\_\-cm.\index{position\_\-manager.h@{position\_\-manager.h}!position\_\-set\_\-related\_\-robot\_\-system@{position\_\-set\_\-related\_\-robot\_\-system}}
\index{position\_\-set\_\-related\_\-robot\_\-system@{position\_\-set\_\-related\_\-robot\_\-system}!position_manager.h@{position\_\-manager.h}}
\subsubsection[position\_\-set\_\-related\_\-robot\_\-system]{\setlength{\rightskip}{0pt plus 5cm}void position\_\-set\_\-related\_\-robot\_\-system (struct {\bf robot\_\-position} $\ast$ {\em pos}, \/  struct {\bf robot\_\-system} $\ast$ {\em rs})}\label{position__manager_8h_0e5b0ad02fbda099c4f9eea8c42011a4}


Save in pos structure the pointer to the associated \doxyref{robot\_\-system}{p.}{structrobot__system}. The \doxyref{robot\_\-system}{p.}{structrobot__system} structure is used to get values from virtual encoders that return angle and distance. 

Definition at line 56 of file position\_\-manager.c.

References IRQ\_\-LOCK, IRQ\_\-UNLOCK, and robot\_\-position::rs.\index{position\_\-manager.h@{position\_\-manager.h}!position\_\-use\_\-ext@{position\_\-use\_\-ext}}
\index{position\_\-use\_\-ext@{position\_\-use\_\-ext}!position_manager.h@{position\_\-manager.h}}
\subsubsection[position\_\-use\_\-ext]{\setlength{\rightskip}{0pt plus 5cm}void position\_\-use\_\-ext (struct {\bf robot\_\-position} $\ast$ {\em pos})}\label{position__manager_8h_599166e89842766306b633c3cd6d9860}




Definition at line 79 of file position\_\-manager.c.

References rs\_\-polar::angle, rs\_\-polar::distance, IRQ\_\-LOCK, IRQ\_\-UNLOCK, robot\_\-position::prev\_\-encoders, robot\_\-position::rs, rs\_\-get\_\-ext\_\-angle(), rs\_\-get\_\-ext\_\-distance(), and robot\_\-position::use\_\-ext.\index{position\_\-manager.h@{position\_\-manager.h}!position\_\-use\_\-mot@{position\_\-use\_\-mot}}
\index{position\_\-use\_\-mot@{position\_\-use\_\-mot}!position_manager.h@{position\_\-manager.h}}
\subsubsection[position\_\-use\_\-mot]{\setlength{\rightskip}{0pt plus 5cm}void position\_\-use\_\-mot (struct {\bf robot\_\-position} $\ast$ {\em pos})}\label{position__manager_8h_3883eb1cbf4d1a2a022a29bf5c1a8b04}


