\documentclass[12pt]{article}


\usepackage[pdftex,pdfpagelabels,bookmarks,hyperindex,hyperfigures]{hyperref}


\usepackage[margin=1in]{geometry}
\usepackage{float}
\usepackage{adjustbox}
\usepackage[table]{xcolor}
\usepackage{cite}
\usepackage{amsmath,amssymb,amsfonts}
\usepackage{algorithmic}
\usepackage{graphicx}
\usepackage{textcomp}
\usepackage{xcolor}
\usepackage{pgfplots}
\usepackage{fancyhdr}

\setlength{\parskip}{1em} % Add spacing between paragraphs
\setlength{\parindent}{0em} % Remove indentation at the start of paragraphs


\pagestyle{fancy}
\fancyhf{} % Clear all headers/footers
\lhead{Bobot}
\rfoot{\thepage}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0pt}

% --- Title and TOC ---

\begin{document}

\title{4P78 Project Documentation}
\author{
    Parker TenBroeck 7376726\\
    pt21zs@brocku.ca
    \and
    Brett \\
    brett@brocku.ca
}
\date{\today}

\makeatletter
\begin{titlepage}
	\def \LOGOPATH {brock.jpg}
	\def \UNIVERSITY {Brock University}
	\def \FACULTY {Faculty of Mathematics \& Science}
	\def \DEPARTMENT {Department of Computer Science}
	\def \COURSETITLE {COSC 4P78: Robotics}
	\def \SUPERVISOR {Earl Foxwell}
	
	
	\vfill
	\begin{center}
		\includegraphics[width=0.6\textwidth]{brock.jpg}
		\fontsize{14pt}{14pt}\selectfont
		\vfill
		\UNIVERSITY \\
		\FACULTY \\
		\DEPARTMENT \\
		\vfill
		\fontsize{18pt}{18pt}\selectfont
		\textbf{\COURSETITLE} \\[0.5cm]
		\textbf{\@title}
		\vfill
		\fontsize{14pt}{14pt}\selectfont
		Prepared By: \\[0.5cm]
		
		\begin{tabular}[t]{c}
			\@author
		\end{tabular}\par
	
	    \vfill
		Instructor: \\
		\SUPERVISOR
		\vfill
		\@date
	\end{center}
\end{titlepage}
\makeatother

\tableofcontents
\newpage

\section{Introduction}
What if you wanted to make a robot to map out a room but you only had two wheels and two motors at your disposal? Well we have the perfect solution for you! Introducing the Bobot, a two wheeled robot which is more of a circus act than useful. \\
With only two wheels its purely dynamically stable, will fall over due to its own stupidity but its very cute while it does so! This little guy can wiz around at the speed of a snail your house and (poorly) map out a room to your hearts desire

\section{Instructions}
\begin{itemize}
	\item Hold robot in a vertical upright position clear of obsticals
	\item Place battery in top compartment
	\item Plug battery in and wait for robot to initialize
	\item Once robot has booted let go and step away
	\item Connect computer to network \texttt{MEOW}
	\item launch vidualization and control software
\end{itemize}

\section{Problem Set}

\subsection{Balancing}
We have a vertical two wheeled robot I hope its fairly obvious when I say that it is only dynamically stable. This presents a challance because we need some system which keeps the system upright in a variaty of situations and responds dynamically to changes it cannot predict.
\subsection{Odometry}
Because we intend to map an area with the robot we need to know where we are. This issue is made slightly more challanging due to the fact we are in nearly constant motion keeping ourself upright.
\subsection{Target Positions}
The problem of target positions like odometry is made more challenging due to the fact we are almost constantly in motion. We simply cannot "not move" when we are in the location we want to be as we'd fall over. This means the target position will need to be a "best effort" battle to keep in the same place as best as we can.
\subsection{Communication}
The only source of computation used is a single \texttt{ESP8266} microcontroller, this in combination with the strict timing requirements on the duration of the control loop means the communication between the robot and the control/mapping software needs to be quick and efficient.

\section{Approaches}


\subsection{Balancing}
\subsection{Odometry}
\subsection{Target Positions}
The target position 
\subsection{Communication}

\section{Challanages}

\subsection{Balancing}
Balancing took the longest out every task combined. It required research on not only PID control loops but also on different libraries and calibration requirements for our \texttt{MPU6050} gyroscope. These difficulties were compounded by the fact that we did not know which part/section would cause the robot to "randomly flail about and violently crash into the wall/floor". 

\subsection{Odometry}
We origionally didn't have encoders to keep track of our position and instead attempted to use the accelerometer to calculate displacement to save money on parts. This however, did not pan out. The first problem we ran into was our heading drifting. We knew it was going to be an issue after reading docs but tried a good old fassion "how bad could it possibly be" and oh boy did it drift fast. The second issue was "double integration over a noisy inaccurate signal" lead to our calculated position quickly exiting the stratosphere. These issues very quickly lead us to just get encoders.

\subsection{Target Positions}
Using the bias towards a direction by setting the target angle was not the first approach we used. We originally directly added a movement speed to the motors like we do for turning. This however caused the robot to become unstable in certain situations. We eventually abandoned the approach in favor of the one used currently.

\subsection{Communication}
Since we have limited processing power/time per loop iteration we need to be smart in how we receive and transmit data to our mapping software. For this reason we designed a stateless UDP based network protocol overtop the esp8266 Wifi \& UDP libraries. \cite{wifi_lib}\\

We originally used a TCP+Webserver based library for this as it allowed us to use HTML+JS to display information but it continually had processing requirements the controller could not meet.

\section{Resources Used}
\begin{itemize}
	\item ESP8266 core libraries to note the Wifi and UDP libraries. \cite{wifi_lib}
	\item \texttt{PID\_V1} The PID library of choice. \cite{pid_lib}
	\item Adafruit VL53L0X was used the library used to interface with the time of flight sensor used for mapping. \cite{dist_lib}
	\item The AS5600 library was used to interface with the AS5600 magnetic encoders on each wheel. \cite{enc_lib}
	\item The MPU6050 library was used to interface and interpret the accelerometer and gyroscope data. \cite{gyro_lib}. It required modification to work with our hardware as it was a knockoff and the device ID was different than what it was expecting.
	\item A blog by the author of the PID library used was very helpful when tuning and configuring the PID controls in the robot. \cite{pid_help}
	\item A paper on odometry for robots with differential steering which we based our odometry system off of. \cite{odom_help}
\end{itemize}


\nocite{*}
\bibliographystyle{IEEEtran}
\bibliography{references}

\end{document}
