text:
\documentclass[12pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage{setspace}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{amsmath}
\usepackage{color}
\usepackage{hyperref}
\usepackage{multicol}
\usepackage{framed}
\usepackage{xcolor}
\usepackage{wrapfig}
\usepackage{float}
\usepackage{fancyhdr}
\usepackage{verbatim}
\usepackage{textcomp}
\usepackage{colortbl}
\usepackage{array, booktabs, caption}
\usepackage{makecell}

\pagestyle{fancy}
\lfoot{\textbf{Open Source Rover Mechanical Assembly Manual}}
\rfoot{Page \thepage}
\lhead{\textbf{\leftmark}}
\rhead{\textbf{\rightmark}}
\cfoot{}
\renewcommand{\footrulewidth}{1.8pt}
\renewcommand{\headrulewidth}{1.8pt}
\doublespacing
\setlength{\parindent}{1cm}
% Parts list tables
\renewcommand\theadfont{\bfseries}
\newcolumntype{I}{ >{\centering\arraybackslash} m{2cm} }  % part image
\newcolumntype{N}{ >{\centering\arraybackslash} m{3cm} }  % part name
\newcolumntype{Q}{ >{\centering\arraybackslash} m{0.75cm} }  % ref & qty

\begin{document}

\newcommand\partimg{\includegraphics[width=2cm,height=1.25cm,keepaspectratio]}

\title{Open Source Rover: Corner Steering Assembly Instructions}
\author{Authors: Michael Cox, Eric Junkins, Olivia Lofaro}

\makeatletter
\def\@maketitle{
\begin{center}
	\makebox[\textwidth][c]{ \includegraphics[width=0.8\paperwidth]{"Pictures/Corner Title".png}}
	{\Huge \bfseries \sffamily \@title }\\[3ex]
	{\Large \sffamily \@author}\\[3ex]
	\includegraphics[width=.65\linewidth]{"Pictures/JPL logo".png}
\end{center}}
\makeatother

\maketitle

\noindent {\footnotesize Reference herein to any specific commercial product, process, or service by trade name, trademark, manufacturer, or otherwise, does not constitute or imply its endorsement by the United States Government or the Jet Propulsion Laboratory, California Institute of Technology. \textcopyright  2018 California Institute of Technology. Government sponsorship acknowledged.}

% Introduction

\newpage

\tableofcontents

\section{3D printing}
First, print the 3D printed encoder mounts. The STL files for this are located in the Corner Steering Assembly folder, under 3D Printed Parts. If you do not have a 3D printer there are many online 3D printing services available. One such service is:

\begin{itemize}
	\item \href{https://www.makexyz.com}{https://www.makexyz.com}
\end{itemize}
To order these parts from Makexyz upload the STL file, select FDM under process, and PLA for Material, and then your desired color. \textbf{You will need a total of 4 of these encoder mount pieces}.

\section{Mechanical/Structural Assembly}
The Corner Steering assembly contains the steering motors which allow the rover to utilize Ackerman steering. One important aspect of this assembly is the use of the bearing blocks. These blocks help to take forces on the motor shaft against the gearbox and minimize lateral moments applied against the motor shaft. By using the bearing blocks, we help protect the motor and motor shaft from these forces that could otherwise damage the motor and its gearbox. The lever arm for the corner steering system is much farther away from the motor than at the drive motors, where we can get away with directly attaching the load path to the motor shaft.

\begin{table}[H]
    \centering
    \arrayrulecolor{lightgray}
    \sffamily\footnotesize
    \captionsetup{font={sf,bf}}
    \caption{Parts/Tools Necessary}
    \begin{tabular}{|N|Q|Q|I|N|Q|Q|I|}
        \hline
        \thead{Item} & \thead{Ref} & \thead{Qty} & \thead{Image} & \thead{Item} & \thead{Ref} & \thead{Qty} & \thead{Image} \\
        \hline
        3" Channel & S2 & 4 & \partimg{../../../images/parts_list/S2.jpg} & Motor (Corner Motor) & E6 & 4 & \partimg{../../../images/parts_list/E6.jpg} \\ \hline
        Motor Mount & S9 & 4 & \partimg{../../../images/parts_list/S9.jpg} & Absolute Encoder & E7 & 4 & \partimg{../../../images/parts_list/E7.jpg} \\ \hline
        0.25" Pillow Block & S10 & 8 & \partimg{../../../images/parts_list/S10.jpg} & \#6-32x1/4" Spacer & T1 & 16 & \partimg{../../../images/parts_list/T1.png} \\ \hline
        0.25" D-Shaft & S15 & 4 & \partimg{../../../images/parts_list/S15.jpg} & \#6-32 x 1.25" Threaded Standoff & T9 & 16 & \partimg{../../../images/parts_list/T9.jpg} \\ \hline
        0.25” to 6mm Clamping Shaft Coupler & S38 & 4 & \partimg{../../../images/parts_list/S38.jpg} & \#6-32x1/4" Button Head Screw & B1 & 24 & \partimg{../../../images/parts_list/B1.png} \\ \hline
        1/8” Bore Pinion Gear & S27 & 4 & \partimg{../../../images/parts_list/S27.jpg} & \#6-32x3/4" Button Head Screw & B5 & 16 & \partimg{../../../images/parts_list/B5.png} \\ \hline
        3D Printed Encoder Mount & S31 & 4 & \partimg{../../../images/parts_list/S31.png} & Allen Key Set & D2 & & \partimg{../../../images/parts_list/D2.jpeg} \\ \hline
    \end{tabular}
\end{table}

\begin{enumerate}
\item \textbf{Motor Mount:} Begin by mounting the motor mount \textbf{S9} to the motor \textbf{E6} using the screws procured with the mount. Once completed,
insert the \textbf{B5} screws that will be used to connect the mount through the 3-inch channel. Due to the orientation of the motor inside of the 3-inch channel,
adding these screws later is difficult. See Figure \ref{corner steering step 1}.

\begin{figure}[H]
  \centering
  \begin{minipage}[b]{0.45\textwidth}
    \includegraphics[width=\textwidth]{"Pictures/CornerSt Step 1".PNG}
  \end{minipage}
  \hfill
  \begin{minipage}[b]{0.45\textwidth}
    \includegraphics[width=\textwidth]{"Pictures/CornerSt Step 2".PNG}
  \end{minipage}
  \caption{Corner Steering Motor Mount attachment (left) and \textbf{B5} screw insertion (right)}
  \label{corner steering step 1}
\end{figure}

\item \textbf{3-inch Channel Attachment:} Attach the motor and motor mount to the 3-inch channel using the threaded standoffs \textbf{T9} as seen in Figure \ref{corner steering 2}.

\begin{figure}[H]
  \centering
  \begin{minipage}[b]{0.45\textwidth}
    \includegraphics[width=\textwidth]{"Pictures/CornerSt Step 3".PNG}
  \end{minipage}
  \caption{Slide the \textbf{B5} screws through the 3-inch channel and screw down the standoffs. Note the motor is "inside" the channel.}
  \label{corner steering 2}
\end{figure}

\item \textbf{Shaft Coupler/Standoffs Attachment:} Using the shaft coupler \textbf{S38}, attach the motor shaft to the 0.25 inch D-shaft \textbf{S15}.
Figure \ref{corner steering 3}

\begin{figure}[H]
  \centering
  \begin{minipage}[b]{0.45\textwidth}
    \includegraphics[width=\textwidth]{"Pictures/CornerSt Step 4".PNG}
  \end{minipage}
  \caption{Shaft coupler installation}
  \label{corner steering 3}
\end{figure}

\item \textbf{Encoder Mount:} The size and tolerance of the holes will vary slightly based on different 3D printers and materials. Press the 0.25 inch
spacers \textbf{T1} into the 3D printed encoder mount \textbf{S31}. If they do not fit easily, tapping them with a small hammer may help.
If the wholes are still too small, you can drill or file out the holes slightly until the spacers fit as shown in Figure \ref{encoder mount 1}.

\begin{figure}[H]
  \centering
  \begin{minipage}[b]{0.45\textwidth}
    \includegraphics[width=\textwidth]{"Pictures/CornerSt Step 5".PNG}
  \end{minipage}
  \caption{Shaft coupler installation}
  \label{encoder mount 1}
\end{figure}

Next, attach the 0.25 inch pillow bearing blocks \textbf{S10} and encoder mount \textbf{S31} using the \textbf{B5} screws into the threaded standoffs \textbf{T3} as seen in
Figure \ref{encoder mount 2}.

\begin{figure}[H]
  \centering
  \begin{minipage}[b]{0.45\textwidth}
    \includegraphics[width=\textwidth]{"Pictures/CornerSt Step 6".PNG}
  \end{minipage}
  \hfill
  \begin{minipage}[b]{0.45\textwidth}
    \includegraphics[width=\textwidth]{"Pictures/CornerSt Step 6b".PNG}
  \end{minipage}
  \caption{Encoder mount installation}
  \label{encoder mount 2}
\end{figure}

\item \textbf{Encoder:} Attach the encoder \textbf{E7} to the encoder mount \textbf{S31} and then attach the 12-tooth gear \textbf{S27} to
the encoder shaft as shown in Figure \ref{corner steering 4}. We will worry about its exact position later on.

\begin{figure}[H]
  \centering
  \begin{minipage}[b]{0.45\textwidth}
    \includegraphics[width=\textwidth]{"Pictures/CornerSt Step 7".PNG}
  \end{minipage}
  \caption{Encoder and gear installed}
  \label{corner steering 4}
\end{figure}

You should now have one finished corner steering assembly. Repeat the
steps above to build the other 3 corner steering assemblies. \textbf{Note: unlike other assemblies, this assembly
isn't identical for all four. You will need to build two versions (one for the left side of the rover, one for the
right side) where the encoder mount is mirrored left to right.  The absolute encoder should be on the 'outside' of
the rover in all cases (see Figure \ref{corner steering 5} for an example).}

\begin{figure}[H]
  \centering
  \begin{minipage}[b]{0.45\textwidth}
    \includegraphics[width=\textwidth]{"Pictures/CornerSt Final".PNG}
  \end{minipage}
  \caption{Mirrored steering assemblies}
  \label{corner steering 5}
\end{figure}

\end{enumerate}

\end{document}

max_stars_repo_path: Mechanical/Corner Steering/Latex Docs/Corner Steering Build Doc.tex


text:
%!TEX root = ../../dissertation.tex

\section{Comparison using a new Keynesian model}

In this section, we solve a stylized medium-scale Keynesian model using equivalent codes implemented
in Julia, Matlab, and Python. The model was previously analyzed in \cite{MM2015}. It features
Calvo-type price frictions and a Taylor rule with a zero lower bound on the nominal interest rate.

\subsection{The model}

To save on space, we present the model in Appendix B.

\paragraph{First-order conditions.}

Here, we summarize the model by showing the set of optimality conditions
used to construct the numerical solutions:

\begin{eqnarray}
  S_{t} &=&\frac{\exp \left( \eta _{u,t}+\eta _{L,t}\right) }{\exp \left( \eta_{a,t}\right) }L_{t}^{\vartheta }Y_{t}+\beta \theta E_{t}\left \{ \pi_{t+1}^{\varepsilon }S_{t+1}\right \} ,  \label{NK1} \\
  F_{t} &=&\exp \left( \eta _{u,t}\right) C_{t}^{-\gamma }Y_{t}+\beta \theta E_{t}\left \{ \pi _{t+1}^{\varepsilon -1}F_{t+1}\right \} ,  \label{NK2} \\
  \frac{S_{t}}{F_{t}} &=&\left[ \frac{1-\theta \pi _{t}^{\varepsilon -1}}{1-\theta }\right] ^{\frac{1}{1-\varepsilon }},  \label{NK3} \\
  \Delta _{t} &=&\left[ \left( 1-\theta \right) \left[ \frac{1-\theta \pi _{t}^{\varepsilon -1}}{1-\theta }\right] ^{\frac{\varepsilon }{\varepsilon -1}}+\theta \frac{\pi _{t}^{\varepsilon }}{\Delta _{t-1}}\right] ^{-1}, \label{NK4} \\
  C_{t}^{-\gamma } &=&\beta \frac{\exp \left( \eta _{B,t}\right) }{\exp \left(\eta _{u,t}\right) }R_{t}E_{t}\left[ \frac{C_{t+1}^{-\gamma }\exp \left(\eta _{u,t+1}\right) }{\pi _{t+1}}\right] ,  \label{NK5} \\
  Y_{t} &=&\exp \left( \eta _{a,t}\right) L_{t}\Delta _{t}  \label{NKs1} \\
  C_{t} &=&\left( 1-\frac{\overline{G}}{\exp \left( \eta _{G,t}\right) }\right) Y_{t}  \label{NKs2} \\
  R_{t} &=&\max \left \{ 1,R_{\ast }\left( \frac{R_{t-1}}{R_{\ast }}\right)^{\mu }\left[ \left( \frac{\pi _{t}}{\pi _{\ast }}\right) ^{\phi _{\pi}}\left( \frac{Y_{t}}{Y_{N,t}}\right) ^{\phi _{y}}\right] ^{1-\mu }\exp
  \left( \eta _{R,t}\right) \right \} ,  \label{NK6}
\end{eqnarray}

where $S_{t}$ and $F_{t}$ are supplementary variables reflecting profit
maximizing conditions of firms; $\Delta _{t}$ is a measure of price dispersion
across firms; $C_{t}$, $Y_{t}$, $L_{t}$ are consumption, output and labor,
respectively; $\pi _{t}$ and $R_{t}$ are inflation and interest rate,
respectively; $\pi {\ast }$ and $R{\ast } = \frac{\pi {\ast }}{\beta }$ are
the inflation target and the steady state interest rate, respectively;
$Y_{N,t}=\left[ \frac{\exp \left( \eta _{a,t}\right) ^{1+\vartheta }}{\left[\exp \left( \eta _{G,t}\right) \right] ^{-\gamma }\exp \left( \eta_{L,t}\right) }\right] ^{\frac{1}{\vartheta +\gamma }}$
is the natural level of
output. The parameters are $\beta$ (discount factor), $\theta$ (fraction of non-reoptimizing firms), $\varepsilon$ (inverse of
the elasticity of substitution in the final-good production), $\vartheta$ and $\gamma$ (utility-function
parameters), $\overline{G}$ (steady-state government spending), and $\mu$, $\phi_{y}$ and $\phi_{\pi}$ (Taylor-rule parameters).
Each exogenous variable $\eta_{z,t} \in \left \{ \eta_{u,t},\eta_{L,t}, \eta_{a,t}, \eta_{u,t}, \eta_{B,t}, \eta_{G,t} \right \} $ follows an
AR(1) process $\eta_{z,t+1}=\rho_{z}\eta_{z,t}+\epsilon_{z,t+1}$ with
$\epsilon_{z,t+1}\sim \mathcal{N}\left( 0,\sigma _{z}^{2}\right) $, $\sigma_{z}>0$ and $\rho _{z}\in \left( -1,1\right) $.

\paragraph{Parameterization and implementation details.}

We parameterize the model by $\beta =0.99$, $\gamma =1$, $\vartheta =2.09$, $
\varepsilon =4.45$, $\theta =0.83$ and $\overline{G}=0.23$. The autocorrelation
coefficients in six exogenous variables are $\rho _{a}=0.95$ , $\rho
_{B}=0.22$, $\rho _{R}=0.15$, $\rho _{u}=0.92$, $\rho _{G}=0.95$, $ \rho
_{L}=0.25$, and the corresponding standard deviations are $\sigma _{u}=0.54\%$,
$\sigma _{G}=0.38\%$, $\sigma _{L}=18.21\%$ $\sigma _{a}=0.45\% $, $\sigma
_{B}=0.23\%$ and $\sigma _{R}=0.28\%$. The parameters in the Taylor rule are
$\phi _{y}=0.07$, $\phi _{\pi }=2.21$, and $\mu =0.82$ . These values are used
in \cite{MM2015} and are in line with the estimates in \cite{DSSW2007} and
\cite{SW2007}.

As a solution domain, we use random and quasi-random grids constructed inside
an 8-dimensional hypercube; we describe the grid construction in Section 4.2.
To approximate the equilibrium policy rules, we use a family of ordinary
polynomials up to degree 5. To compute conditional expectations in Euler
equations (\ref{NK1}), (\ref{NK2}) and (\ref{NK5}), we use a monomial
integration rule (either a formula with $2N$ nodes or the one with $2N^{2}+1$
nodes); see \cite{JMM2011} for a detailed description of the monomial
integration formulas. To solve for the polynomial coefficients, we use fixed
point iteration. Again, Julia, Matlab, and Python software can be found in the
corresponding notebooks submitted on QuantEcon\footnote{
\href{http://notes.quantecon.org/submission/5b53cd9117fb4900153deafe}{Matlab notebook},
\href{http://notes.quantecon.org/submission/5b53cdaf17fb4900153deaff}{Python notebook},
\href{http://notes.quantecon.org/submission/5b53cd6917fb4900153deafd}{Julia notebook}}.

\paragraph{Computational method.}

We now outline the Euler equation algorithm used to solve the neoclassical
model. An extended description of this algorithm is provided in Appendix B.

\begin{equation*}
\begin{tabular}{l}
\hline \hline
\textbf{Algorithm 8. Euler equation algorithms for the new Keynesian model. }
\\ \hline
Given $S\left( {\Delta ,R,\eta _z }\right) $, $F\left( {\Delta ,R,\eta _z }\right)
$ and $C\left( {\Delta ,R,\eta _z }\right) $ for each point $\left( {\Delta
,R,\eta _z }\right) $, define the following recursion: \\

\quad i). Find ${\pi }$ {from} $\frac{{S}}{{F}}{=}\left[ \frac{{1-\theta \pi
}^{\varepsilon -1}}{{1-\theta }}\right] ^{\frac{1}{1-\varepsilon }}${\ and }$
{\Delta }^{\prime }{=}\left[ \left( {1-\theta }\right) \left[ \frac{{
1-\theta \pi }^{\varepsilon -1}}{{1-\theta }}\right] ^{\frac{\varepsilon }{
\varepsilon -1}}{+\theta }\frac{{\pi }^{\varepsilon }}{{\Delta }}\right] ^{{
-1}}${;} \\

\quad -- ${Y}=\left( {1}-\frac{\overline{G}}{\exp \left( \eta _{G}\right) }
\right) ^{{-1}}{C}${, and }${L}={Y}\left[ {\exp }\left( {\eta }_{{a}}\right)
{\Delta }^{{\prime }}\right] ^{-1}${;} \\
\quad --{\ }${Y}_{{N}}=\left[ \frac{{\exp }\left( {\eta }_{a}\right)
^{1+\vartheta }}{\left[ {\exp }\left( {\eta }_{{G}}\right) \right] ^{-\gamma
}{\exp }\left( {\eta }_{{L}}\right) }\right] ^{\frac{1}{\vartheta +\gamma }}$
{;} \\

{\quad }--{\ }${R}^{{\prime }}={\max }\left \{ {1,R}_{\ast }\left( \frac{R}{
R_{\ast }}\right) ^{{\mu }}\left[ \left( \frac{\pi }{\pi _{\ast }}\right) ^{{
\phi }_{\pi }}\left( \frac{Y}{Y_{N}}\right) ^{{\phi }_{y}}\right] ^{{1-\mu }}
{\exp }\left( {\eta }_{{R}}\right) \right \} .$ \\

\quad ii). Find $S\left( {\Delta }^{\prime }{,R}^{\prime }{,\eta_z }^{\prime
}\right) $, $F\left( {\Delta }^{\prime }{,R}^{\prime }{,\eta_z }^{\prime
}\right) $ and $C\left( {\Delta }^{\prime }{,R}^{\prime }{,\eta_z }^{\prime
}\right) ${;} \\

\quad iii). Find ${\pi }^{{\prime }}${\ from }$\frac{{S}^{\prime }}{{F}
^{\prime }}{=}\left[ \frac{{1-\theta }\left( \pi ^{^{\prime }}\right)
^{\varepsilon -1}}{{1-\theta }}\right] ^{\frac{{1}}{{1-\varepsilon }}}${;}
\\

\quad -- $\widehat{{S}}\left( {\Delta ,R,\eta_z }\right) {=}\frac{{\exp }
\left( {\eta }_{{u}}{+\eta }_{{L}}\right) }{{\exp }\left( {\eta }_{{a}
}\right) }{L}^{{\vartheta }}{Y+\beta \theta }E\left \{ \left( {\pi }^{{
\prime }}\right) ^{{\varepsilon }}{S}^{{\prime }}\right \} ;$ \\

\quad -- $\widehat{{F}}\left( {\Delta ,R,\eta_z }\right) ={\exp }\left( {\eta }
_{{u}}\right) {C}^{{-\gamma }}{Y+\beta \theta }E\left \{ \left( {\pi }
^{^{\prime }}\right) ^{{\varepsilon -1}}{F}^{{\prime }}\right \} {;}$ \\

\quad -- $\widehat{{C}}\left( {\Delta ,R,\eta_z }\right) {=}\left \{ \frac{{
\beta \exp }\left( \eta _{{B}}\right) {R}^{{\prime }}}{{\exp }\left( {\eta }
_{{u}}\right) }E\left[ \frac{\left( {C}^{\prime }\right) ^{{-\gamma }}{\exp }
\left( {\eta }_{{u}}^{{\prime }}\right) }{{\pi }^{{\prime }}}\right] \right
\} ^{-1/\gamma }.$ \\

Iterate on i)-iii) until convergence $\widehat{F}=F$, $\widehat{S}=S$, $
\widehat{C}=C$. \\ \hline \hline
\end{tabular}
\end{equation*}

\subsection{Grid techniques for high dimensional applications}

Tensor product grids can be successfully used for analyzing small-scale
applications but their cost increases exponentially with the number of the
state variables (curse of dimensionality). In particular, tensor product grid
are expensive even for moderately-large models like our model with 8 state
variables. There is a number of alternative grid techniques that do not rely on
tensor products and that ameliorate the curse of dimensionality; see
\cite{MM2014} for a survey.

To solve the model (\ref{NK1})-(\ref{NK6}),
\cite{MM2015} construct the grid on the high-probability area of the state
space which is approximated by stochastic simulation. However, crude simulated points are not uniformly spaced, in particular, many
simulated points are situated close to one another and are redundant for the
purpose of the grid construction. \cite{MM2015} introduce two techniques for
selecting a roughly uniformly-spaced subset of simulated points. One technique
is clustering analysis: the simulated points are grouped into clusters and the
centers of the clusters are used as a grid. Another technique is an
$\varepsilon $-\textit{distinguishable set} (EDS) method that selects a subset
of points situated at the distance of at least $ \varepsilon $ from one
another. As an example, in Figure \ref{fig:eps_dist_grid} we show a
stochastic-simulation grid and epsilon-distinguishable set grid.

\cite{MM2015} construct the EDS or cluster grids iteratively. In particular,
they (i) guess policy functions and use them to simulate the time series
solution; (ii) build an EDS or cluster grid; (iii) solve the model on this
grid; (iv) then use the new solution to form a new grid. This procedure is
repeated until the solution and grid both remain constant on successive
iterations. The advantage of this approach is that it focuses on the right area
of the state space -- a high probability set. However, it requires to have
initial guess for the solution (the paper uses linearization solution from
Dynare) and it reconstructs the EDS or cluster grid iteratively, which leads to
larger running times. Finally, the code is more complicated.

In the present paper, we modify the grid construction relative to the method in
\cite{MM2015}. We specifically replace the EDS and cluster grids with random
and quasi-random grids covering a fixed multi-dimensional hypercube. To
construct the hypercube, we choose the interval $\left[ -\frac{2\sigma
_{z}}{\sqrt{1-\rho _{z}^{2}}},\frac{2\sigma _{z}}{\sqrt{1-\rho _{z}^{2}}}
\right] $ for each of six exogenous variable $\eta _{z}\in \left \{ \eta
_{u},\eta _{L},\eta _{a},\eta _{u},\eta _{B},\eta _{G}\right \} $, where $
\sigma _{z}$ and $\rho _{z}$ are standard deviation and auto-correlation
coefficient. For endogenous state variables $R$ and $\Delta $, we chose
intervals that cover the high probability set, $\Delta \in \left[ 0.95,1
\right] $ and $R\in \left[ 1,1.05\right] $.

We consider two alternative grid techniques in the constructed fixed hypercube.
One is a \textit{random grid} obtained by drawing an 8-dimensional set of
random uncorrelated uniformly distributed points. The other is
\textit{quasi-random grids} (also known as \textit{quasi-Monte Carlo } sequence
or \textit{low discrepancy sequence}). Uniformly distributed random draws
converge to an evenly spaced grid as a number of draws increases but the
convergence rate is low; in turn, low disrepancy sequences are constructed to
be evenly spaced and their convergence rate is much faster; see \cite{MM2015}
for a discussion. We use Sobol low discrepancy sequence for constructing the
grid but there are a variety of other low discrepancy sequences that can be used
for this purpose; see \cite{niederreiter1992}. The random and quasi-random grids
are shown in Figure \ref{fig:rand_sobol_grid}.

Using random grids has its advantages and disadvantages. Unlike the EDS and
cluster grids used in \cite{MM2015}, the random and quasi-random grids operate
on a fixed hypercube and do not benefit from the domain reduction. However, the
random and quasi-random grids are much faster and easier to construct than the
EDS and cluster grids. By constructing grids on predefined intervals, we did
not have to write our own rough solution routine or rely on external software
like Dynare to construct a preliminary solution to the model as we would with
cluster grid or EDS techniques and we do not need to re-construct the grids
iteratively. The MATLAB code accompanying the present paper achieves an almost
a 60-time speed up over the original code in \cite{MM2015}, while still
producing highly accurate solutions.

\subsubsection{Numerical results}

We have provided an implementation of this algorithm in the Matlab, Python, and Julia programming
languages. In this section we discuss our experience with the three languages and report our results
in Table \ref{clmm:Table3}.

We report the solution for two parameterizations that are previously analyzed in \cite{MM2015}. To
save on space, we report the solution only for the quasi-random (Sobol) grid. The solution for the
random grid is similar (although slightly less accurate). Our two parameterizations differ in the
value of the inflation target $\pi _{\ast }$. In our first experiment, we use $\pi _{\ast }=1.0598$,
which corresponds to long term average as estimated in \cite{DSSW2007}, while in the second
experiment, we use $\pi _{\ast }=1.$ For the second experiment, we report results when we solve the
model both when the ZLB is and is not imposed (in the first experiment, ZLB is never active).

The computational cost increases rapidly with a polynomial degree. The number of points in the grid
must be at least as large as the number of the polynomial coefficients to identify such
coefficients. In particular, for the polynomial degrees 1, 2, 3, 4 and 5, we construct 20,100, 300,
1000 and 2000 grid points respectively to identify 9, 45, 165, 495 and 1287 coefficients (we use
about 50 percent more of grid points than the polynomial coefficients to enhance the numerical
stability of the algorithm). The cost of second-order polynomial approximations is about 1-3 seconds
depending on specific parameterization used. It is fast enough to repeatedly solve the model inside
an estimation procedure.

Concerning the accuracy, in our first experiment, the inflation target is relatively high and the
probability of reaching a zero lower bound (ZLB) on nominal interest rates is so low that it is
never observed in finite simulation (unless we use the initial condition that leads to ZLB). In the
absence of binding ZLB, the accuracy of our numerical solutions increases considerably with the
degree of polynomial, in particular, the maximum residuals across the model's equations decrease
from $-1.94$ to $-5.47$ when the polynomial order increases from 1 to 5 respectively. The accuracy
of the solutions is surprisingly high given that we assume very large volatility of labor shock of
$18\%$. If we reduce the size of the labor shock to $5\%$, the residuals in the table decrease by
nearly 2 orders of magnitude and the accuracy levels will be comparable to those we obtained for the
neoclassical growth model.

In our second experiment, the inflation target is low and the probability of reaching the ZLB
increases to about 2\%. When we do not impose the ZLB, the accuracy of the solution looks very
similar to our first parameter set. However, with the ZLB imposed, the results are different.
Relatively small average residuals indicate that the solution is sufficiently accurate in most of
the domain and large maximum residuals show that the accuracy declines sharply in the ZLB area. As
this example shows, even the global solution methods might still be insufficiently accurate in the
presence of active ZLB because smooth polynomials functions are not well suitable for approximating
the ZLB kink. \cite{ACS2017} and \cite{MM2015} show that the accuracy can be slightly increased by
using piecewise linear and locally adaptive approximations, respectively, but these extensions lie
beyond the scope of our analysis.

ext: tex


text:
\section{Voting Protocols}
There is a semi-trusted \emph{dealer} $D$ who offers indelible write-only storage to enable the protocol
execution for a distinct run of the voting protocol identified by $\mathbf{E}$.
At the beginning of the vote, the dealer chooses and broadcasts $m$ primes $p_1\ldots p_m$
corresponding to the $m$ voting choices, a random number $N$, as well as
a large prime $P$ where ${\displaystyle P > p_j \forall p_j \in \{p_1\ldots p_m\}}$.

\subsection{Basic non-threshold non-private voting protocol}
Then the voting protocol proceeds as follows:
\begin{enumerate}
\item{
$D$ publishes the signed message $\{\mathbf{E},N, P, p_1, \ldots, p_k\}_D$ onto
the indelible storage.
This message is visible to all the participants and announces the existence of an election.
}
\item{
Every voter $V_i$ privately saves its vote $p_{i}$ and a random integer $s$.
The voter also publishes its commitment $c_i \equiv  H(\mathbf{E},V_i,s,p_{i}^N \bmod P)$
about its vote by writing the message
$\{ \mathbf{E} , V_i , c_i \}$ onto the indelible storage.
}
\item{
After a quorum of vote comittments have been written, each voter $V_i$ now
writes the message
$\{ \mathbf{E},V_i,s,p_{i}^N \bmod P \}$
onto the indelible storage. This message is related to the previously created comittment as it
contains the message which was used to create the committment.
}
%\item{
%$V_i$ sends $\{x_i \equiv n p_i  \bmod P\}_i$ to $D$.  This message is either signed with the public key of $V_i$ or is secured through a third-party token as long as it establishes that only
%$V_i$ is the source of the message.
%}
\item{
$D$ waits for votes and then computes the product ${\displaystyle T = \prod_i p_{i}^N \bmod P }$.
}
\item{
Check if $T$ is a multiple of $p_i^{mN} \bmod P$.  If so, you have $m$ votes for option $C_i$.  There will be a
largest divisor which will provide the total votes for the given option.  Since all primes by definition can
not be factors of each other, none of the votes for one choice can influence the count for other choices.
}
\end{enumerate}

The voting protocol correctly counts the votes by virtue of the Chinese remainder theorem.  The vote computation
is also publicly verifiable as long as the writing to indelible storage can avoid impersonation.  Finally,
the protocol ensures that the voting choices are not disclosed unless a quorum of participants have comitted their vote.
\subsection{Adding privacy to the voting protocol}
The voting protocol

max_stars_repo_name: newlibertie/voting-protocol

max_issues_repo_name: newlibertie/voting-protocol

max_forks_repo_name: newlibertie/voting-protocol


text:
\chapter{Directed Graphs and Conditional Independence}

\begin{ex}
\end{ex}

\begin{ex}
\end{ex}

\begin{ex}
\end{ex}

\begin{ex}
\end{ex}

\begin{ex}
\end{ex}

\begin{ex}
\end{ex}

\begin{ex}
\end{ex}

\begin{ex}
\end{ex}

\begin{ex}
\end{ex}

max_stars_repo_name: dtrifuno/all-of-stats-solutions

max_issues_repo_name: dtrifuno/all-of-stats-solutions

max_forks_repo_name: dtrifuno/all-of-stats-solutions


text:
\subsection{Example of using the rootfinder API}

To use the bisection method, you provide a function that computes
$f(x)$, and you provide an initial bracket $(x_L..x_R)$ in which the
root is known to lie.  An example of using the bisection method to
compute a root of the quadratic function $ax^2 + bx + c = 0$ for
$a=5$, $b=2$ and $c=-1$ (note that this function has two roots, one
$<0$ and one $>0$; the bracket $0..100$ makes the example find only
the positive root):

\input{cexcerpts/rootfinder_example}

To use the Newton/Raphson method, you provide a function that computes
$f(x)$ and its first derivative $df(x)/dx$, and you provide an initial
guess for the root $x$. An example of using the Newton/Raphson method
to compute the root of the same function above (which has a derivative
$df(x)/dx = 2ax + b$) is:

\input{cexcerpts/rootfinder_example2}

In this example, because the initial guess was negative, the other
root gets found.

Currently, just these two rootfinding algorithms are implemented.  The
bisection method does not require derivative information, and it
requires the caller to provide an interval $(x_L..x_R)$ in which the
root lies ($f(x_L)$ and $f(x_R)$ have opposite signs). Newton/Raphson
uses derivative information, and it only needs an initial guess for
$x$, not an interval. Thus there are two different \ccode{\_Create*()}
routines, \ccode{esl\_rootfinder\_CreateBracketer()} for initializing
a bisection method, and \ccode{esl\_rootfinder\_CreatePolisher()} for
initializing a Newton/Raphson method. The reason for the more general
names (\ccode{CreateBracketer()} and \ccode{CreatePolisher()} is that
I expect other rootfinding algorithms (if we ever implement any) will
group similarly: bracketing methods without derivative information,
and ``polishing'' methods that use derivative information. But this
may be misguided, and may change in the future.


text:
\chapter{Computing}

This library provides a conversion that does rewrite and
$\beta$-reduce any term, using a call by value strategy.

%% Document CBV_CONV, from_list, add_clauses, new_rws

\section{Strategy}

The \ml{CBV\_CONV} conversion rewrites the equations in a call-by-value
strategy, that is completely evaluates the arguments before the
``function call'' (the application of a rewrite which left-hand side
has this constant in its head). The reduction is weak, which means
that reduction under abstractions are delayed as long as
possible. However, when we know that an abstraction will never be
applied, reductions are performed under it, so that we can actually
reach the full normal form.

The strategy is intentionally close to that of ML. This allows one to
think \HOL\ has a programming language, and \ml{CBV\_CONV} is an
evaluator which have the same complexity (with a large slow down factor,
though) as usual compiled ML programs.

The strategy differs from ML for abstractions: $\beta$-redexes are
reduced in call by need. The usual call by value strategy can be
achieved by replacing abstractions \verb#\x. e# by
\verb#LET (\x. e)#, and reducing \ml{LET} with equation
\verb#LET f x = f x#.

The reason is to allow the evaluation of conditional expressions
without evaluating both alternatives. We could use the weak reduction
strategy to fake call by need:
\begin{eqnarray*}
\ml{COND'~T~x~y} & = & \ml{x()} \\
\ml{COND'~F~x~y} & = & \ml{y()}
\end{eqnarray*}
but this is a bit of overhead, and not very natural. Here, instead of
rewriting equation \verb#COND T x y = x#, we use
\verb#COND T = \x y. x#. The advantage of the second statement, is
that only the condition is evaluated strictly, while in the first
case, the two alternatives are also evaluated. Doing this
transformation is not useful only in the case we need to evaluate
arguments lazily, as shown above. It may be an improvement since
$\beta$-reduction has been optimized, while pattern-matching is not a
primitive notion in \HOL, and is slower.

\section{Simplification sets}

The \ml{compute} library has its own type of simplification sets, that
can be as usual built from a list of theorems. These theorems must be
conjunctions of possibly quantified equations, whose left-hand sides
satisfy some condition to be defined below. Conjuncts not in the
requested form are not used.

Left-hand sides must be a constant applied to a list of
patterns. Patterns are either a variable or a constant applied to
other patterns. Abstractions cannot appear in patterns.
\begin{eqnarray*}
P & ::= & x \mid c~P_1 \ldots P_n
\end{eqnarray*}
This corresponds to the usual definition scheme by pattern-matching,
slightly extended. Patterns need not be linear. If a variable occurs
several times, it is checked that the instantiations are
$\alpha$-convertibles. Beware, that only the weakly reduced forms are
compared. For instance, reflexivity fails to solve the folowing example:
\begin{verbatim}
(\x. x) = (\x. (\y.y) x)
\end{verbatim}

Simplification sets are mutable objects: one creates an empty set and
then adds lists of theorems to it. Function \ml{new\_rws} returns a
new empty simplification set. Function \ml{add\_clauses} adds a list
of theorems to a simplification set. It returns the list of rules that
have been recognized, but it is mainly to check that everything was
all right. Creation of a new simplification set and addition of a list
of theorems can be combined using \ml{from\_list}.

max_stars_repo_name: dwRchyngqxs/HOL

max_issues_repo_name: dwRchyngqxs/HOL

max_forks_repo_name: dwRchyngqxs/HOL


text:
\begin{flushleft}

\chapter{Experiments - The fun part}

At this stage you must have installed the necessary software required to work on the kinect sensor on your platform. So without further delay lets begin the experiments with kinect.
\medskip

\textbf{The following sections showcase the experiments designed on the windows platform :}

\ref{4.1} Depth tracking on screen

\ref{4.2} Depth tracking with firbird

\ref{4.3} Camera fundamentals

\ref{4.4} Skeleton tracking fundamentals

\ref{4.5} Skeleton tracking with firebird (left and right)

\ref{4.6} Skeleton tracking with firebird (front and back)

\ref{4.7} Skeleton tracking (angle between joints)

\ref{4.8} Skeleton tracking (Hover Button)

\ref{4.9} Skeleton tracking complete

\ref{4.10} Voice recognition

\ref{4.11} Tilt Demo

\medskip

\textbf{The following sections showcase the experiments designed on the linux platform :}

\ref{4.12} Depth tracking on screen

\ref{4.13} Depth tracking with firebird

\ref{4.14} Tilt demo

\medskip

In the following pages the experiments will be discussed in detail.

Refer to \cite{skeleton1} \cite{video} \cite{serial} \cite{skeleton2} \cite{skeleton3} \cite{skeleton4} \cite{audio1} \cite{audio2}.
\newpage

\addcontentsline{toc}{section}{\textbf{ Experiments on the windows platform}}
\medskip
\section{\textbf{ Depth tracking on screen}}
\label{4.1}

\medskip
\subsection{\textbf{ Aim of the experiment}}
The aim of this experiment is to obtain the depth information of every pixel in the frame captured by the kinect.
\medskip

\subsection{\textbf{ Components required}}
\begin{itemize}
\item Kinect sensor.
 \end{itemize}
\medskip

\subsection{\textbf{ Experiment description}}
This experiment obtains the depth value of every pixel in the frame. Based on this obtained information a color coding scheme is designed. If the pixel is at a distance of less than 900mm (and greater than 800mm) it is assigned the color Blue. If the pixel is at a distance greater than 900mm and less than 200mm the color assigned to it is Green. If the pixel is at a distance greater than 2000mm then it is assigned the color Red. Thus the output frame comprises of Blue Green or Red colored pixels depending upon its distance from the kinect.
The distance of the center pixel of the frame is displayed on the screen for simplicity and validity of the experiment.

\medskip
The experiment is available in the folder \textbf{E1\_Depth\_Tracking\_on\_screen} provided.
\medskip

\subsection{\textbf{ Instructions}}
\begin{enumerate}

\item Click on the 'start' button to run the program.
\item Make sure that the background doesnot contain windows because sunlight (or any source of light) is interpreted being within the 900mm range. The violation of this step, however, will not affect the functionality of this experiment.
\item The user must stand at a distance of atleast 800mm from the kinect. This is the lower threshold of the kinect itself, to get depth data.
\item When done experimenting either close the main window or click on the 'Stop' button to stop the execution of the code.

\end{enumerate}
\medskip
\subsection{\textbf{ Experiment Outputs}}

\medskip

\includegraphics[scale = 0.5]{e11}

\medskip
\includegraphics[scale = 0.5]{e12}
\medskip

\subsection{\textbf{ Conclusion}}
The experiment was successfuly conducted to obtain the depth information of every pixel in the frame captured by the kinect and the depth value of the center pixel was obvserved.
\medskip

\newpage
\medskip

\section{\textbf{ Depth tracking on firebird}}
\label{4.2}

\medskip
\subsection{\textbf{ Aim of the experiment}}
The aim of this experiment is to obtain the depth information of every pixel in the frame captured by the kinect and send appropriate commands to the firebird 5 robot based on it.
\medskip

\subsection{\textbf{ Components required}}
\begin{itemize}
\item Kinect sensor
\item Firebird V Robot
\item Zigbee Modules (2 nos.)
\item Zigbee USB adapter
\end{itemize}

\subsection{\textbf{ Experiment description}}
This experiment obtains the depth value of every pixel in the frame. Based on this obtained information a color coding scheme is designed. If the pixel is at a distance of less than 900mm (and greater than 800mm) it is assigned the color Blue. If the pixel is at a distance greater than 900mm and less than 200mm the color assigned to it is Green. If the pixel is at a distance greater than 2000mm then it is assigned the color Red. Thus the output frame comprises of Blue Green or Red colored pixels depending upon its distance from the kinect.
The distance of the center pixel of the frame is displayed on the screen. If the user moves towards the kinect, the command "58" is sent through the zigbee module, '5' for 'stop' and '8' for 'forward'. If the user moves away from the kinect, the command "52" is sent through the zigbee module, '55' for 'stop' and '2' for 'reverse'.

\medskip
The experiment is available in the folder \textbf{E2\_Depth\_Tracking\_on\_firebird} provided.
\medskip

\subsection{\textbf{ Instructions}}
\begin{enumerate}
\item Click on the 'start' button to run the program.
\item Turn on the firebird 5 robot loaded with the zigbee serial interfacing code and establish unicast connection between two zigbee modules as described in the manual.
\item Make sure that the background doesnot contain windows because sunlight (or any source of light) is interpreted being within the 900mm range. The violation of this step, however, will not affect the functionality of this experiment.
\item The user must stand at a distance of atleast 800mm from the kinect. This is the lower threshold of the kinect itself, to get depth data.
\item Move towards the kinect to make the firebird move forward and away from the kinect to make it move in reverse.
\item When done experimenting either close the main window or click on the 'Halt' button to stop the execution of the code.
\end{enumerate}

\medskip
\subsection{\textbf{ Experiment Outputs}}
\includegraphics[scale = 0.5]{e21}

\medskip
\includegraphics[scale = 0.5]{e22}
\medskip
\subsection{\textbf{ Conclusion}}
\begin{itemize}
\item The experiment was successfuly conducted to obtain the depth information of every pixel in the frame captured by the kinect.
\item The depth value of the center pixel was obvserved, and the appropriate commands were sent to the firebird V robot based on it.
\end{itemize}
\medskip
\newpage

\section{\textbf{ Camera Fundamentals}}
\label{4.3}

\medskip
\subsection{\textbf{ Aim of the experiment}}
The aim of this experiment is to obtain the live stream of the kinect camera on screen in 320x240 resolution.
\medskip

\subsection{\textbf{ Components required}}
\begin{itemize}
\item Kinect sensor
\end{itemize}
\medskip

\subsection{\textbf{ Experiment description}}
This experiment obtains the live video stream from the kinect camera and display it on the screen.

\medskip
The experiment is available in the folder \textbf{E3\_Camera\_Fundamentals} provided.
\medskip

\subsection{\textbf{ Instructions}}
\begin{enumerate}
\item Click on the 'start' button to run the program.
\item You will see the live camera stream from the kinect camera in 320x240 resolution.
\item When done experimenting either close the main window or click on the 'Halt' button to stop the execution of the code.
\end{enumerate}
\medskip
\subsection{\textbf{ Experiment Outputs}}
\includegraphics[scale = 0.5]{e31}

\medskip
\includegraphics[scale = 0.5]{e32}
\medskip
\subsection{\textbf{ Conclusion}}
\begin{itemize}
\item The experiment was successfuly conducted to obtain the live camera stream captured by the kinect camera and to display it on screen.
\end{itemize}
\newpage

\section{\textbf{ Skeleton Tracking Fundamentals}}
\label{4.4}

\medskip
\subsection{\textbf{ Aim of the experiment}}
The aim of this experiment is to obtain the joint information of 20 joints of the body in the frame captured by the kinect and display them on screen as a skeleton.
\medskip

\subsection{\textbf{ Components required}}
\begin{itemize}
\item Kinect sensor
\end{itemize}
\medskip

\subsection{\textbf{ Experiment description}}
This experiment obtains the joint data of 20 joints corresponding to the user in the view of the kinect camera and display them on screen in form of a skeleton. The green dots represent the joints. The joints are connected by light green lines. If the skeleton goes out of the frame, it is indicated by a red brush in that direction.

\medskip
The experiment is available in the folder \textbf{E4\_Skeleton\_Tracking\_Fundamentals} provided.
\medskip

\subsection{\textbf{ Instructions}}
\begin{enumerate}
\item Click on the 'start' button to run the program.
\item The user must stand at a distance such that the full skeleton is visible on screen.
\item You will see a skeleton corresponding to the user on the screen. The green dots represent the joints. The joints are connected by light green lines. If the skeleton goes out of the frame, it is indicated by a red brush in that direction.
\item When done experimenting either close the main window or click on the 'Halt' button to stop the execution of the code.
\end{enumerate}
\medskip
\subsection{\textbf{ Experiment Outputs}}
\includegraphics[scale = 0.5]{e41}

\medskip
\includegraphics[scale = 0.5]{e42}

\medskip
\subsection{\textbf{ Conclusion}}
\begin{itemize}
\item The experiment was successfuly conducted to obtain the joint data of the user in the frame captured by the kinect and display a skeleton corresponding to it on screen.
\end{itemize}

\medskip
\newpage

\section{\textbf{ Skeleton Tracking Firebird Left Right}}
\label{4.5}

\medskip
\subsection{\textbf{ Aim of the experiment}}
The aim of this experiment is to make the firebird move based on the position of the right elbow.
\medskip

\subsection{\textbf{ Components required}}
\begin{itemize}
\item Kinect sensor
\item Firebird V Robot
\item Zigbee Modules (2 nos.)
\item Zigbee USB adapter
\end{itemize}
\medskip

\subsection{\textbf{ Experiment description}}
This experiment obtains the joint data of 20 joints corresponding to the user in the view of the kinect camera and display them on screen in form of a skeleton. The green dots represent the joints. The joints are connected by light green lines. If the skeleton goes out of the frame, it is indicated by a red brush in that direction. Then based on the coordinates of the right elbow, the firebird is sent a command via zigbee such that if the right elbow is in the right half of the image, the firebird moves right("56" is sent, '5' for stop, '6' for right), and if it is in the left half of the image, the firebird moves left("54" is sent, '5' for stop, '4' for left).

\medskip
The experiment is available in the folder \textbf{E5\_Skeleton\_Tracking\_Firebird\_Left\_Right} provided.
\medskip

\subsection{\textbf{ Instructions}}
\begin{enumerate}
\item Click on the 'start' button to run the program.
\item Turn on the firebird 5 robot loaded with the zigbee serial interfacing code and establish unicast connection between two zigbee modules as described in the manual.
\item The user must stand at a distance such that the full skeleton is visible on screen.
\item You will see a skeleton corresponding to the user on the screen. The green dots represent the joints. The joints are connected by light green lines. If the skeleton goes out of the frame, it is indicated by a red brush in that direction.
\item Move your right elbow to and fro between the right and left halves of the image and watch the firebird move right("56") and left("54").
\item When done experimenting either close the main window or click on the 'Halt' button to stop the execution of the code.
\end{enumerate}
\medskip
\subsection{\textbf{ Experiment Outputs}}
\includegraphics[scale = 0.4]{e51}

\medskip
\includegraphics[scale = 0.4]{e52}
\medskip
\subsection{\textbf{ Conclusion}}
\begin{itemize}
\item The experiment was successfuly conducted to obtain the joint data of the user in the frame captured by the kinect and display a skeleton corresponding to it on screen.
\item The right elbow joint coordinates were tracked in realtime and based on it, commands were sent to the firebird V.
\end{itemize}

\medskip
\newpage

\section{\textbf{ Skeleton Tracking Firebird Front Back}}
\label{4.6}

\medskip
\subsection{\textbf{ Aim of the experiment}}
The aim of this experiment is to make the firebird move based on the change in position of the hip center joint.
\medskip

\subsection{\textbf{ Components required}}
\begin{itemize}
\item Kinect sensor
\item Firebird V Robot
\item Zigbee Modules (2 nos.)
\item Zigbee USB adapter
\end{itemize}
\medskip

\subsection{\textbf{ Experiment description}}
This experiment obtains the joint data of 20 joints corresponding to the user in the view of the kinect camera and display them on screen in form of a skeleton. The green dots represent the joints. The joints are connected by light green lines. If the skeleton goes out of the frame, it is indicated by a red brush in that direction. Then based on the motion of the hip center joint, the firebird is sent a command via zigbee such that if the hip center moves towards the kinect, the firebird moves forward("58" is sent, '5' for stop, '8' for forward), and if it moves away from the kinect, the firebird moves away("52" is sent, '5' for stop, '2' for reverse).

\medskip
The experiment is available in the folder \textbf{E6\_Skeleton\_Tracking\_Firebird\_Front\_Back} provided.
\medskip

\subsection{\textbf{ Instructions}}
\begin{enumerate}
\item Click on the 'start' button to run the program.
\item Turn on the firebird 5 robot loaded with the zigbee serial interfacing code and establish unicast connection between two zigbee modules as described in the manual.
\item The user must stand at a distance such that the full skeleton is visible on screen.
\item You will see a skeleton corresponding to the user on the screen. The green dots represent the joints. The joints are connected by light green lines. If the skeleton goes out of the frame, it is indicated by a red brush in that direction.
\item Move towards and away from the kinect and watch the firebird move forward("58") and reverse("52").
\item When done experimenting either close the main window or click on the 'Halt' button to stop the execution of the code.
\end{enumerate}
\medskip
\subsection{\textbf{ Experiment Outputs}}
\includegraphics[scale = 0.4]{e61}

\medskip
\includegraphics[scale = 0.4]{e62}
\medskip
\subsection{\textbf{ Conclusion}}
\begin{itemize}
\item The experiment was successfuly conducted to obtain the joint data of the user in the frame captured by the kinect and display a skeleton corresponding to it on screen.
\item The motion of the hip center joint was tracked in realtime and based on it, commands were sent to the firebird V.
\end{itemize}
\medskip

\newpage

\section{\textbf{ Skeleton Tracking angle between joints}}
\label{4.7}

\medskip
\subsection{\textbf{ Aim of the experiment}}
The aim of this experiment is to obtain the angle between 3 body joints in the frame captured by the kinect.
\medskip

\subsection{\textbf{ Components required}}
\begin{itemize}
\item Kinect sensor.
 \end{itemize}
\medskip

\subsection{\textbf{ Experiment description}}
This experiment is used to determine the angle between 3 body joints and displayed on the screen. For the sake of simplicity the experiment is designed for right elbow, right wrist and right shoulder. However, the user can change this to any 3 joints of choice. To get the angle, Vector algebra in 3D is used for the purpose. The right elbow is used a fulcrum. The absolute x, y and z coordinates of the joints obtainted. Their relative distance is calculated. This gives us 2 vectors. Lets call them A and B. Then the angle between the 2 vectors is calculated using dot product concept:
        angle cos(x) = A.B / mod(A) x mod(B)

\medskip
The experiment is available in the folder \textbf{E7\_Skeleton\_Tracking\_angle\_between\_joints} provided.
\medskip

\subsection{\textbf{ Instructions}}
\begin{enumerate}
\item Click on the 'start' button to run the program.
\item The user must stand at a viable distance from the kinect so that the entire body is captured in the frame. In case any part of the skeleton is out of frame the indication is given by a red brush on that side.
\item The user can change the 3 joints to any sensible combination.
\item The experiment tracks the nearest skeleton in the frame hence in case of multiple users the response will be given to the nearest one to the kinect.
\item When done experimenting either close the main window or click on the 'stop' button to stop the execution of the code.

\end{enumerate}

\medskip
\subsection{\textbf{ Experiment Outputs}}
\includegraphics[scale = 0.5]{e71}

\medskip
\includegraphics[scale = 0.5]{e72}
\medskip
\subsection{\textbf{ Conclusion}}
 The experiment was successfuly conducted to obtain the angle between 3 body joints - rightelbow, rightwrist and rightshoulder.
\medskip
\newpage

\section{\textbf{ Skeleton Tracking Hoverbutton Firebird}}
\label{4.8}

\medskip
\subsection{\textbf{ Aim of the experiment}}
The aim of this experiment is to make the firebird move based on the selected button on screen using the hand as a cursor.
\medskip

\subsection{\textbf{ Components required}}
\begin{itemize}
\item Kinect sensor
\item Firebird V Robot
\item Zigbee Modules (2 nos.)
\item Zigbee USB adapter
\end{itemize}
\medskip

\subsection{\textbf{ Experiment description}}
This experiment has an interface in which the pointer can be controlled by motion of the hand. Then based on the position of the cursor, the firebird is sent a command via zigbee such that if the right arrow button is selected, the firebird moves right("56" is sent, '5' for stop, '6' for right), if left arrow button is selected, the firebird moves left("54" is sent, '5' for stop, '4' for left), if the up arrow button is selected, the firebird moves forward("58" is sent, '5' for stop, '8' for forward), and if the down arrow button is selected, the firebird moves in reverse("52" is sent, '5' for stop, '2' for reverse). If the stop button is selected, the firebird stops("5" is sent to stop the firebird).

\medskip
The experiment is available in the folder \textbf{E8\_Skeleton\_Tracking\_Hoverbutton\_Firebird} provided.
\medskip

\subsection{\textbf{ Instructions}}
\begin{enumerate}
\item Click on the 'start' button to run the program.
\item Turn on the firebird 5 robot loaded with the zigbee serial interfacing code and establish unicast connection between two zigbee modules as described in the manual.
\item The user must stand at a distance such that the full skeleton is in the frame of the kinect.
\item You will see a pointer on screen which moves in accordance with the movement of the right arm.
\item Select various buttons by hovering on them, right arrow button makes the firebird move right("56" is sent), left arrow button makes the firebird move left("54" is sent), up arrow button makes the firebird move forward("58" is sent), down arrow button makes the firebird move down("52" is sent), stop button makes the firebird stop("5" is sent).
\item When done experimenting either close the main window or click on the 'Halt' button to stop the execution of the code.
\end{enumerate}
\medskip
\subsection{\textbf{ Experiment Outputs}}

\includegraphics[scale = 0.5]{e81}

\medskip
\includegraphics[scale = 0.5]{e82}

\medskip
\medskip
\subsection{\textbf{ Conclusion}}
\begin{itemize}
\item The experiment was successfuly conducted to operate the pointer based on hand motion and interacting with the GUI with the pointer, then sending various commands to the firebird based on it.
\end{itemize}
\medskip
\newpage

\section{\textbf{ Skeleton Tracking Complete}}
\label{4.9}
\medskip
\subsection{\textbf{ Aim of the experiment}}
The aim of this experiment is to demonstrate a simple application in which firebird follows human gesture
\medskip

\subsection{\textbf{ Components required}}
\begin{itemize}
\item Kinect sensor.
\item Firebird V robot.
\item Zigbee Modules (2 nos.)
\item Zigbee USB adapter.
\end{itemize}
\medskip

\subsection{\textbf{ Experiment description}}
This experiment is used for simple gesture recognition by tracking the angles between the various body joints. The gestures are as follows :
 \begin{itemize}
\item stand still - stop gesture
\item raise right hand - turn right gesture
\item raise left hand - turn left gesture
\item lean forward - move forward gesture
\item raise both hands - move back gesture
 \end{itemize}
 The commands transmitted serially to the firebird are as follows :
 \begin{itemize}

 \item 2 - backward
 \item 4 - left
 \item 5 - stop
 \item 6 - right
 \item 8 - forward
 \item 9 - buzzer on
 \end{itemize}
\medskip

The experiment is available in the folder \textbf{E9\_Skeleton\_Tracking\_Complete} provided.
\medskip

\subsection{\textbf{ Instructions}}
\begin{enumerate}
\item Click on the 'start' button to run the program.
\item Turn on the Firebird V robot loaded with \textbf{Interfacing\_Kinect\_To\_Firebird\_Using\_Zigbee} program provided.
\item The user must stand at a viable distance from the kinect so that the entire body is captured in the frame. In case any part of the skeleton is out of frame the indication is given by a red brush on that side.
\item The user can change the 3 joints to any sensible combination.
\item The experiment tracks the nearest skeleton in the frame hence in case of multiple users the response will be given to the nearest one to the kinect.
\item Perform the gestures as mentioned in the theory above and observe the response on the Firebird V robot.
\item When done experimenting either close the main window or click on the 'stop' button to stop the execution of the code.

\end{enumerate}
\medskip
\subsection{\textbf{ Experiment Outputs}}
\includegraphics[scale = 0.5]{e91}

\medskip
\includegraphics[scale = 0.5]{e92}
\medskip
\subsection{\textbf{ Conclusion}}
The experiment was successfuly completed and the response of Firebird V robot was observed for the various gestures performed.
\medskip
\newpage

\section{\textbf{ Speech Recognition}}
\label{4.10}

\medskip
\subsection{\textbf{ Aim of the experiment}}
The aim of this experiment is to make the Firebird V robot responsive to the speech commands of the user.
\medskip

\subsection{\textbf{ Components required}}
\begin{itemize}
\item Kinect sensor.
\item Firebird V robot.
\item Zigbee Modules (2 nos.)
\item Zigbee USB adapter.
\end{itemize}

\medskip
\subsection{\textbf{ Experiment description}}
 This experiment is designed for voice recognition and deciphering the commands given by the user. This is followed by interfacing to firbird V to follow the commands.
  The commands include speaking :
  \begin{itemize}

 \item "Forward" - To move the robot forward
 \item "Back"    - To move the robot backward
 \item "Left"    - To move the robot left
 \item "Right"   - To move move the robot right
   \end{itemize}
\begin{itemize}

 \item 2 - backward
 \item 4 - left
 \item 5 - stop
 \item 6 - right
 \item 8 - forward
 \item 9 - buzzer on
 \end{itemize}
\medskip
The experiment is available in the folder \textbf{E10\_Voice\_Recognition\_firebird} provided.
\medskip

\subsection{\textbf{ Instructions}}
\begin{enumerate}

\item Click on the 'start' button to run the program.
\item Turn on the Firebird V robot loaded with \textbf{Interfacing\_Kinect\_To\_Firebird\_Using\_Zigbee} program provided.
\item The user can modify the existing grammer available in the \textbf{SpeechGrammer.xml file}.
\item Speak the commands mention in the Theory and observe the response on the Firebird V.
\item The commands need to be spoken with confidence (threshold = 0.25) and must be pronounced correctly.
\item The experiment works with multiple users. However, multiple users giving simultaneous commands can lead to unpredictable results.
\item Background noise must be minimal or avoided if possible.
\item When done experimenting either close the main window or click on the 'stop' button to stop the execution of the code.
\medskip
\end{enumerate}
\subsection{\textbf{ Experiment Outputs}}
\includegraphics[scale = 0.5]{e101}

\medskip
\includegraphics[scale = 0.5]{e102}
\medskip
\subsection{\textbf{ Conclusion}}
The experiment was successfully completed to make the Firebird V robot responsive to simple voice commands given by the user.
\newpage

\section{\textbf{ Tilt Demo}}

\label{4.11}
\medskip
\subsection{\textbf{ Aim of the experiment}}
The aim of this experiment is to change the elevation angle of the kinect.
\medskip

\subsection{\textbf{ Components required}}
\begin{itemize}
\item Kinect sensor
\end{itemize}
\medskip

\subsection{\textbf{ Experiment description}}
This experiment changes the elevation angle of the kinect in the range -27 degrees to +27 degrees based on user input.

\medskip
The experiment is available in the folder \textbf{E11\_Tilt\_Demo} provided.
\medskip

\subsection{\textbf{ Instructions}}
\begin{enumerate}
\item Click on the 'start' button to run the program.
\item Set the desired elevation angle on the slider and click the "set tilt" button to set the kinect's elevation angle to that value.
\item When done experimenting either close the main window or click on the 'Halt' button to stop the execution of the code.
\end{enumerate}
\medskip
\subsection{\textbf{ Experiment Outputs}}

\includegraphics[scale = 0.5]{e111}

\medskip
\includegraphics[scale = 0.5]{e112}

\medskip
\subsection{\textbf{ Conclusion}}
\begin{itemize}
\item The experiment was successfuly conducted to change the kinect's elevation angle to a desired value.
\end{itemize}
\medskip

\medskip
\newpage
\textbf{Note : }
The next section deals with Experiments designed on linux.
Before starting the experiments navigate to \textbf{examples} folder in the \textbf{libfreenect} directory and copy the code files of the 3 experiments (E12, E13 and E14) in the same. Open the \textbf{CMakeLists.txt} file and make the following changes in the respective sections :

\begin{itemize}
\item file(GLOB SRC\_STANDARD chunkview.c glview.c hiview.c regview.c  E12\_Depth\_Tracking\_on\_screen.c E13\_Depth\_Tracking\_on\_Firebird.c E14\_Tilt\_demo.c)
\item add\_executable(freenect-E12\_Depth\_Tracking\_on\_screen E12\_Depth\_Tracking\_on\_screen.c)
\item add\_executable(freenect-E13\_Depth\_Tracking\_0n\_Firebird E13\_Depth\_Tracking\_on\_Firebird.c)
\item add\_executable(freenect-E14\_Tilt\_demo E14\_Tilt\_demo.c)
\item target\_link\_libraries(freenect-E13\_Depth\_Tracking\_on\_Firebird freenect)
\item target\_link\_libraries(freenect-E12\_Depth\_Tracking\_on\_screen freenect)
\item target\_link\_libraries(freenect-E14\_Tilt\_demo freenect freenect\_sync)
\item target\_link\_libraries(freenect-E12\_Depth\_Tracking\_on\_screen freenect \${OPENGL\_LIBRARIES} \${GLUT\_LIBRARY} \${CMAKE\_THREAD\_LIBS\_INIT} \${MATH\_LIB})
\item target\_link\_libraries(freenect-E13\_Depth\_Tracking\_on\_Firebird freenect \${OPENGL\_LIBRARIES} \${GLUT\_LIBRARY} \${CMAKE\_THREAD\_LIBS\_INIT} \${MATH\_LIB})
\item target\_link\_libraries(freenect-E14\_Tilt\_demo freenect\_sync \${CMAKE\_THREAD\_LIBS\_INIT} \${MATH\_LIB})
\item install (TARGETS freenect-glview freenect-regview freenect-hiview freenect-chunkview freenect-E12\_Depth\_Tracking\_on\_screen freenect-E13\_Depth\_Tracking\_on\_Firebird
  DESTINATION bin)
\item install (TARGETS freenect-glpclview freenect-E14\_Tilt\_demo
      DESTINATION bin)
\end{itemize}
\newpage
\addcontentsline{toc}{section}{\textbf{ Experiments on the linux platform}}
\section{\textbf{ Depth tracking on screen}}
\label{4.12}

\medskip
\subsection{\textbf{ Aim of the experiment}}
The aim of this experiment is to obtain the depth information of every pixel in the frame captured by the kinect.
\medskip

\subsection{\textbf{ Components required}}
\begin{itemize}
\item Kinect sensor.
 \end{itemize}
\medskip

\subsection{\textbf{ Experiment description}}
This experiment obtains the depth value of every pixel in the frame. Based on this obtained information a color coding scheme is designed. If the pixel is at a distance of less than 900mm (and greater than 800mm) it is assigned the color Red. If the pixel is at a distance greater than 900mm and less than 200mm the color assigned to it is Green. If the pixel is at a distance greater than 2000mm then it is assigned the color Blue. Thus the output frame comprises of Blue Green or Red colored pixels depending upon its distance from the kinect.
The experiment displays the live stream video along side the depth output window for simplicity.

\medskip
The experiment is available in the folder \textbf{E12\_Depth\_Tracking\_on\_screen\_linux} provided.
\medskip

\subsection{\textbf{ Instructions}}
\begin{enumerate}

\item Open a new terminal and navigate to the \textbf{build} folder in the \textbf{libfreenect}.
\item type the following sequence of commands :
\framebox{\parbox{\dimexpr\linewidth-2\fboxsep-2\fboxrule}{cmake ..}}
\framebox{\parbox{\dimexpr\linewidth-2\fboxsep-2\fboxrule}{make}}
\framebox{\parbox{\dimexpr\linewidth-2\fboxsep-2\fboxrule}{sudo make install}}
\framebox{\parbox{\dimexpr\linewidth-2\fboxsep-2\fboxrule}{sudo freenect-E12\_Depth\_Tracking\_on\_screen\_linux}}
\item Make sure that the background doesnot contain windows because sunlight (or any source of light) is interpreted being within the 900mm range. The violation of this step, however, will not affect the functionality of this experiment.
\item The user must stand at a distance of atleast 800mm from the kinect. This is the lower threshold of the kinect itself, to get depth data.

\end{enumerate}
\medskip
\subsection{\textbf{ Experiment Outputs}}
\includegraphics[scale = 0.5]{e121}

\medskip
\includegraphics[scale = 0.5]{e122}
\medskip
\subsection{\textbf{ Conclusion}}
The experiment was successfuly conducted to obtain the depth information of every pixel in the frame captured by the kinect.
\medskip
\newpage

\section{\textbf{ Depth tracking with firebird}}

\label{4.13}
\medskip
\subsection{\textbf{ Aim of the experiment}}
The aim of this experiment is to obtain the depth information of every pixel in the frame captured by the kinect and to make Firebird V responsive to the variation of the depth of the center pixel in the frame.
\medskip

\subsection{\textbf{ Components required}}
\begin{itemize}
 \item Kinect sensor.
 \item Firebird V robot.
\item Zigbee Modules (2 nos.)
\item Zigbee USB adapter.
 \end{itemize}
\medskip

\subsection{\textbf{ Experiment description}}
This experiment obtains the depth value of every pixel in the frame. Based on this obtained information a color coding scheme is designed. If the pixel is at a distance of less than 900mm (and greater than 800mm) it is assigned the color Red. If the pixel is at a distance greater than 900mm and less than 200mm the color assigned to it is Green. If the pixel is at a distance greater than 2000mm then it is assigned the color Blue. Thus the output frame comprises of Blue Green or Red colored pixels depending upon its distance from the kinect. Based on the distance of the center pixel from the kinect a command is sent to the Firebird V robot to move forward or backward based on the movement of the center pixel in the frame.
 The commands transmitted serially to the firebird are as follows :
 \begin{itemize}
 \item 2 - backward
 \item 8 - forward
 \item 5 - Stop
 \end{itemize}

\medskip
The experiment is available in the folder \textbf{E13\_Depth\_Tracking\_on\_firebird\_linux} provided.
\medskip

\subsection{\textbf{ Instructions}}
\begin{enumerate}

\item Open a new terminal and navigate to the \textbf{build} folder in the \textbf{libfreenect}.
\item type the following sequence of commands :
\framebox{\parbox{\dimexpr\linewidth-2\fboxsep-2\fboxrule}{cmake ..}}
\framebox{\parbox{\dimexpr\linewidth-2\fboxsep-2\fboxrule}{make}}
\framebox{\parbox{\dimexpr\linewidth-2\fboxsep-2\fboxrule}{sudo make install}}
\framebox{\parbox{\dimexpr\linewidth-2\fboxsep-2\fboxrule}{sudo freenect-E13\_Depth\_Tracking\_on\_firebird\_linux}}
\item Make sure that the background doesnot contain windows because sunlight (or any source of light) is interpreted being within the 900mm range. The violation of this step, however, will not affect the functionality of this experiment.
\item The user must stand at a distance of atleast 800mm from the kinect. This is the lower threshold of the kinect itself, to get depth data.
\item Observe the response of Firebird V robot with the variation of distance of teh center pixel in the frame.

\end{enumerate}
\medskip
\subsection{\textbf{ Experiment Outputs}}

\includegraphics[scale = 0.5]{e131}

\medskip
\subsection{\textbf{ Conclusion}}
The experiment was successfuly conducted to obtain the depth information of every pixel in the frame captured by the kinect. The response of the Firebird V robot with the movement of the center pixel in the frame was observed.
\medskip
\newpage

\section{\textbf{ Tilt Demo}}
\label{4.14}

\medskip
\subsection{\textbf{ Aim of the experiment}}
The aim of this experiment is to obtain the depth information of every pixel in the frame captured by the kinect and to make Firebird V responsive to the variation of the depth of the center pixel in the frame.
\medskip

\subsection{\textbf{ Components required}}
\begin{itemize}
 \item Kinect sensor.
 \end{itemize}
\medskip

\subsection{\textbf{ Experiment description}}
This experiment takes the angle of tilt as an input from the user and tilts the KInect sensor by that much angle (perpendicular to the ground). The tilt angle can be anywhere between -27 degrees to 27 degrees. Any invalid input outside this range is immediately prompted to the user.

\medskip
The experiment is available in the folder \textbf{E14\_Tilt\_Demo\_linux} provided.
\medskip

\subsection{\textbf{ Instructions}}
\begin{enumerate}
\item Open a new terminal and navigate to the \textbf{build} folder in the \textbf{libfreenect}.
\item type the following sequence of commands :
\framebox{\parbox{\dimexpr\linewidth-2\fboxsep-2\fboxrule}{cmake ..}}
\framebox{\parbox{\dimexpr\linewidth-2\fboxsep-2\fboxrule}{make}}
\framebox{\parbox{\dimexpr\linewidth-2\fboxsep-2\fboxrule}{sudo make install}}
\framebox{\parbox{\dimexpr\linewidth-2\fboxsep-2\fboxrule}{sudo freenect-E14\_Tilt\_demo\_linux}}
\item Enter a value between -27 to 27 degrees and observe the tilting of the kinect.

\end{enumerate}
\medskip
\subsection{\textbf{ Experiment Outputs}}
\includegraphics[scale = 0.5]{e141}

\medskip
\includegraphics[scale = 0.5]{e142}
\medskip
\subsection{\textbf{ Conclusion}}
The experiment was successfuly conducted to tilt the kinect in the specified angle within the valid range.
\medskip

\end{flushleft}

max_stars_repo_path: Kinect Based Module Development/Reference Material/Latex Files/Ch4-Experiments.tex


text:
\documentclass[././main.tex]{subfiles}

\begin{document}
\section{Episode Two}
\subsection{A Pitched Battle}
\subsection{A Friendly Face}
\subsection{Deep Wounds}
\subsection{Day Becomes Night}
\end{document}

max_stars_repo_name: Noah-Houghton/Eldritch-Apocalypse

max_issues_repo_name: Noah-Houghton/Eldritch-Apocalypse

max_forks_repo_name: Noah-Houghton/Eldritch-Apocalypse


text:
\documentclass[a4paper]{scrartcl}

\usepackage{fontspec}
\usepackage[linenumbers,spacing=1,tt,singlebracket]{conan}
\usepackage{covington}
%\usepackage{showframe}

\begin{document}

\title{ConAn}
\subtitle{Typeset Conversation Analysis}
\author{Clemens Horch}

\maketitle

\section{Examples}

Example \ref{conan1} is a numbered conversation analysis example:

\begin{conan}[speaker=Anton,marker]
	\alone{Anton}{Lorem ipsum dolor sit amet, consetetur sadipscing elitr, }
	\alone{}{sed diam nonumy eirmod tempor invidunt ut labore et dolore }
	\simul{}{magna aliquyam erat, [ sed diam ] >>voluptua.}{Zita}{[ ero eos et ] }
	\label{conan1}
\end{conan}

\texttt{conan} environments can easily be mixed with \texttt{example} environments from the \texttt{covington} package. Both use the equation counter for numbering.

\begin{example}
Covington Example
\label{covington1}
\end{example}

The next example is a \texttt{conan*} environment without numbering and custom line numbers.

\setcounter{conanline}{2345}
\begin{conan*}[maxline=2345]
	\alone{A}{Lorem ipsum dolor sit amet, consetetur sadipscing elitr, }
	\alone{}{sed diam nonumy eirmod tempor invidunt ut labore et dolore }
	\simul{}{magnaaliquyam erat, [ sed diam ] voluptua.}{B}{[ ero eos et ] }
\end{conan*}

It is recommended to use ConAn with the conan.py preprocessor. (\ref{example1.conan}) is an example for an automatically processed file.

\input{example1.conan}

\end{document}

max_stars_repo_name: clorch/conan

max_issues_repo_name: clorch/conan

max_forks_repo_name: clorch/conan


text:
\section{Education}

\outerlist{

\entrybig
{\textbf{Singapore Polytechnic}}{Singapore, SGP}
{Diploma in Games Design \& Development}{2017\textendash 2020}

\entrybig
{\textbf{ITE College Central}}{Singapore, SGP}
{Nitec in Social Media \& Web Development}{2015\textendash 2017}
% \innerlist{
% 	\entry{Thesis: "Title of The Master's Thesis"}
% }

}

max_stars_repo_name: darkdread/Simple-CV

max_issues_repo_name: darkdread/Simple-CV

max_forks_repo_name: darkdread/Simple-CV


text:
\chapter{Reflection Fitting}
\section{First pass at a reflection fit}\label{sec:reflection_fit_procedure}
The measured reflected power  is modeled as
\begin{equation}
  %\abs{\Gamma}^2 = C-\left(\frac{f_0}{2Q}\right)^2\frac{\Delta y}{(f-f_0)^2+\left(\frac{f_0}{2Q}\right)^2}
  \abs{\Gamma}^2 = C-\frac{\delta y}{1+4\Delta^2}; \hspace{1cm} \Delta \equiv Q\frac{f-f_0}{f_0}
		\label{eqn:reflection_model}
\end{equation}
where $\Gamma$ reflection coefficient, $f_0$ ($Q$) is the resonant frequency (quality factor) of the cavity, C is some constant offset, and $\delta y$ is the depth of the Lorentzian. One can check that $\Gamma(f_0) = C-\delta y$ and $\Gamma(f_0 - \delta f/2)=C-\delta y/2$, where the bandwidth $\delta f = f_0/Q$.
To obtain the resonant frequency and Q of the cavity, we fit Equation~\ref{eqn:reflection_model} to the measured reflected power, as shown in Figure~\ref{fig:reflection_fitting}.
\begin{figure}[!htbp]
    \centering
    \includegraphics[width=0.8\textwidth]{main_reflection_fit_20191108.pdf}
		\caption{The process of fitting a Lorentzian to the reflection coefficient to extract the resonant frequency and quality factor. The blue curve is the square of the measured reflected coefficient. The orange line is the initial guess of the Lorentzian. The green line is the curve fit, which tries to minimize the $\chi^2$.}
    \label{fig:reflection_fitting}
\end{figure}
%
Non-linear fits are often sensitive to the initial guess of fit parameters, so the initial guesses should be close to the correct answer (aim for an order of magnitude). One can come up with reasonable guesses from abstracting features of the reflected power. Below is a list of methods to obtain the initial guesses.

\newcommand{\gu}{\text{guess}}

\begin{enumerate}
	\item $f_{0,\gu}$: Find the frequency that corresponds to $\Gamma^2_{min}$

	\item $C_{\gu}$: Take the median of the upper 2/3 of the $\abs{\Gamma}^2$ values. The lower 1/3 probably corresponds to the reflection on resonance.

	\item $\delta y_{\gu} = C_{\gu} - \abs{\Gamma}^2_{\text{min}}$

	\item $Q_{\gu}$: Find bandwidth $\delta f$ by determining frequencies where $\Gamma = C_{\gu} - \delta y_{\gu}/2$, i.e., find the full-width-half-max. $Q_{\gu} = f_{0,\gu}/\delta f$.\\
    Of course, if you already roughly know the Q of the system, then you can manually put in that guess.
\end{enumerate}

\FloatBarrier
Now let us extract the antenna coupling coefficient $\beta$. In later sections, I derive that the reflection coefficient of the cavity is $\Gamma_{c} = \frac{\frac{1-\beta}{1+\beta} +2i\Delta}{1+2i\Delta} $. Figure~\ref{fig:gamma_angle} shows the phase response for an undercoupled cavity ($\beta<1$), overcoupled cavity ($\beta>1$), and critically-coupled cavity ($\beta=1$). We can check the phase of the measured IQ data around resonance to determine if we are undercoupled or overcoupled. As one option, one can check if $\angle \Gamma(f_0^+) > \angle \Gamma(f_0^-)$ to check if the cavity is undercoupled.
\begin{figure}[!htbp]
    \centering
    \includegraphics[width=0.8\textwidth]{reflection_phase_functional_form.png}
  \caption{The phase change of the reflection coefficient for the undercoupled case (blue), critically-coupled case (green), and overcoupled case (orange). The derivative on resonance is positive for the undercoupled case and negative for the overcoupled case.}
    \label{fig:gamma_angle}
\end{figure}

We can calculate the coupling coefficient from the reflected power. It's best to use the value from the fitted function since the measured values at low power tend to be noisy.

\begin{align}
 \beta =
  \begin{cases}
   \frac{1-{\abs{\Gamma_c(f_0)}}}{1+\abs{\Gamma_c(f_0)}} & \text{if } \beta \leq 1 \\
   \frac{1+\abs{\Gamma_c(f_0)}}{1-\abs{\Gamma_c(f_0)}} & \text{if } \beta \geq 1
  \end{cases}
\end{align}

But we do not measure the cavity reflection coefficient directly. The signal is amplified and then attenuated by cables. To estimate $\abs{\Gamma_c(f_0)}$, we note that the cavity acts like a reflector off resonance, so $\abs{\Gamma_c(\Delta)} \rightarrow 1$ for large $\Delta$. After normalizing the reflected power to estimate $\abs{\Gamma_c(\Delta)}^2$, we can calculate $\abs{\Gamma_c(f_0)}$ using the fitted parameters $\abs{\Gamma_c(f_0)} = \sqrt{1-\frac{\delta y}{C}}$.I

\FloatBarrier
A proper chi-square minimization requires inputting accurate relative uncertainties of each datapoint in the reflected power. The uncertainty of each data point can be derived as $\sigma_P^2 = 4 \sigma_V^2 P$, where $\sigma_V $ is the uncertainty of the IQ voltages. $\sigma_V$ depends on the VNA settings such as the number of averages and the IF bandwidth. $\sigma_V $ can be estimated by measuring the standard deviation of the recorded IQ voltages from the VNA noise floor.

The derivation for the uncertainty in reflected power follows:
\begin{proof}
	\begin{align*}
		P &\propto V_{I}^2 + V_{R}^2
	\end{align*}
	Let $Re \equiv V_{R}^2$ and $Im \equiv V_{I}^2$.

	\begin{align*}
		P &\propto R + I \\
		\sigma_P^2 &= \sigma_{R}^2 + \sigma_{I}^2\\
		\left(\frac{\sigma_{R}^2}{R}\right)^2 &= \left(\frac{2\sigma_{V_{R}}}{V_{R}}\right)^2\\
		\sigma_{R}^2 &= (2V_{R}\sigma_{V_{R}})^2
	\end{align*}
	Similarly
	\begin{align*}
		\sigma_{I}^2 &= (2V_{I}\sigma_{V_{I}})^2\\
		\sigma_{P}^2 &= (2V_{R}\sigma_{V_{R}})^2 + (2V_{I}\sigma_{V_{I}})^2\\
		\sigma_{V_R} &= \sigma_{V_I} \equiv \sigma_V\\
		\sigma_{P}^2 &= (2\sigma_V)^2 (V_R^2 + V_I^2)\\
		\sigma_{P}^2 &= 4\sigma_V^2 P
	\end{align*}

\end{proof}

\section{Deriving the reflection off of the cavity}\label{sec:reflection_derivation}
In this section, we derive why the reflected power off a cavity follows a Lorentzian profile.

A cavity can be modeled as a series RLC circuit (Pozar 4th ed. Ch. 6), and the cavity impedance $Z_c$ is
\begin{align*}
  Z_c &= R + \frac{1}{i\omega C} + i\omega L \\
      &= R + \frac{1-\omega^2 L C }{i \omega C}
\end{align*}

For an RLC circuit, $\omega_o = \frac{1}{LC}$. Define $\omega \equiv \omega_o - \delta \omega$. Then $\omega_o^2 \approx \omega_o^2-2\omega_o\delta\omega$.

\begin{align*}
  Z_c-R &\approx  \frac{1-\frac{1}{\omega_o^2}(\omega_o^2 -2\omega_o\delta\omega)}{i \omega_o C} \\
          &= \frac{-2\frac{\delta\omega}{\omega_o}}{i\omega_o^2 C}
\end{align*}

Define $Q_o \equiv \frac{1}{\omega_o R C} = \frac{1}{R}{\sqrt{\frac{L}{C}}} = \frac{\omega_o L}{R}$.

\begin{align*}
  Z_c = R\left(1+2i\frac{\delta\omega Q_o}{\omega_o}\right)
\end{align*}

Let's connect the cavity to a load with impedance $Z_o=R_o$. Assume that the transmission line connecting the cavity to the load is impedance-matched to the load. Then the reflection coefficient, from Pozar 4th ed. Equation~2.35, is
\begin{align*}
  \Gamma_{c}=\frac{Z_c-Z_o}{Z_c+Z_o}
\end{align*}

Define an antenna coupling coefficient $\beta=\frac{Q_o}{Q_e} = \frac{Z_o}{R}$.
\begin{align*}
  \frac{1}{Q_L} &= \frac{1}{Q_o}+\frac{1}{Q_e}\\
  \frac{1}{Q_L} &= \frac{1}{Q_o}\left(1+\frac{Q_o}{Q_e}\right)\\
  Q_L &= \frac{Q_o}{1+\beta}
\end{align*}

On resonance, $Z_c = R$ and the magnitude of the reflection coefficient depends on the coupling coefficient.
\begin{align}
  \Gamma_{c}(f_o) &= \frac{1-\frac{Z_o}{R}}{1+\frac{Z_o}{R}} \nonumber\\
  \Gamma_{c}(f_o) &= \frac{1-\beta}{1+\beta}
\end{align}

Let's now solve for the reflection coeffient around the resonance.
\begin{align*}
  \Gamma_{c} &= \frac{Z_c-Z_o}{Z_c+Z_o}\\
   &= \frac{1+2i\frac{\delta\omega Q_o}{\omega_o}-\frac{Z_o}{R}}{1+2i\frac{\delta\omega Q_o}{\omega_o}+\frac{Z_o}{R}}\\
   &= \frac{1+2i\frac{\delta\omega Q_o}{\omega_o}-\beta}{1+2i\frac{\delta\omega Q_o}{\omega_o}+\beta}\\
   &= \frac{1+2i\frac{\delta\omega Q_o}{\omega_o}-\beta}{1+2i\frac{\delta\omega Q_o}{\omega_o}+\beta}\times\left(\frac{1+\beta}{1+\beta}\right)\\
  \Gamma_{c} &= \frac{\frac{1-\beta}{1+\beta} +2i\frac{\delta\omega Q_L}{\omega_o}}{1+2i\frac{\delta\omega Q_L}{\omega_o}}\\
\end{align*}
Define $\Delta \equiv Q_L \frac{\delta \omega}{\omega_o}$
\begin{align}
  \Gamma_{c} &= \frac{\frac{1-\beta}{1+\beta} +2i\Delta}{1+2i\Delta}
  \label{eqn:reflection_coefficient}
\end{align}

The reflected power is the magnitude-squared of the reflection coefficient.
\begin{align*}
  |\Gamma_{c}|^2 = \frac{\frac{1-\beta}{1+\beta}^2 + 4\Delta^2}{1+4\Delta^2}\\
  \frac{4\Delta^2}{1+4\Delta^2} = 1-\frac{1}{1+4\Delta^2}\\
  |\Gamma_{c}|^2 = 1-\frac{\frac{4\beta}{(1+\beta)^2}}{1+4\Delta^2}\\
\end{align*}
Let $L(f) \equiv \frac{1}{1+4\Delta^2}$. This is the functional form of the Lorentzian. Then
\begin{align}
  |\Gamma_{c}|^2 = 1 - \frac{4\beta}{(\beta+1)^2}L(f)
\end{align}

\FloatBarrier
\section{Model of a resonator connected to directional coupler and amplifier}\label{sec:reflection_coupler}
In the previous section, we modeled a cavity connected to a load, and the transmission line was impedance-matched to the load. More realistically, the transmission line is composed of many components with various sources of impedance mismatches.

Figure~\ref{fig:orpheus_reflection_measurement} demonstrates the reflection measurement off of the Orpheus cavity. The VNA sends a signal to port 3 of the directional coupler. The signal travels to port 1 and reflects off the cavity. Then the signal travels from port 1 to port 2, and then through the amplifier and back to the VNA. However, the amplifier could be mismatched, allowing for standing waves to form in the transmission path. Furthermore, there might be additional crosstalk-like effects when one considers the directivity and isolation of the coupler.

\begin{figure}[!htbp]
    \centering
  \includegraphics[height=0.3\textheight]{directional_coupler.png}
  \caption{The reflection measurement off of the Orpheus cavity. The VNA sends a signal to port 3 of the directional coupler. The signal travels to port 1 and reflects off the cavity. Then the signal travels from port 1 to port 2, and then through the amplifier and back to the VNA.}
  \label{fig:orpheus_reflection_measurement}
\end{figure}

To simplify the analysis, I've simplified the reflection model in Figure~\ref{fig:orpheus_reflection_measurement} to Figure~\ref{fig:coupling_math_model}. Our VNA measures $\frac{V_{out}}{V_{in}}$. Let $V_1$ be the voltage reflected off of the cavity heading towards the amplifier, and let $\Gamma_a$ be the reflection coefficient of the amplifier. Furthermore, let $V_x$ represent the crosstalk-like effects of the directional coupler that are abstracted away. $V_{out} \propto V_{in}$, so let's solve for $V_{in}$

\begin{figure}[!htbp]
    \centering
  \includegraphics[height=0.3\textheight]{simplified_reflection_model.png}
  \caption{A simplified mathematical model for a reflection measurement. A signal is injected into the cavity. $V_1$ is the signal reflected off the cavity heading towards the direction of the amplifier. $V_1$ reaches the amplifier and is partially reflected back to the cavity. That signal is then reflected again off the cavity and is added to $V_1$. There is an additional $V_x$ term that represents the complications from the injected signal interacting with the four different ports in the directional coupler.}
  \label{fig:coupling_math_model}
\end{figure}

\begin{align*}
  V_1 = V_{in}\Gamma_c + V_1 e^{i\theta}\Gamma_c \Gamma_a + V_x\\
  \frac{V_1}{V_{in}} = \frac{\Gamma_c + \frac{V_x}{V_{in}}}{1-e^{i\theta}\Gamma_c \Gamma_a}\\
  \end{align*}

  The denominator is reminiscent of the mismatched generator problem in Pozar 4th ed. 2.6. Let's say $\frac{V_x}{V_{in}}=e^{i\phi}\chi$ and assume that $\chi$ is constant across the resonance of the cavity.

  Now, let's assume that the amplifier is matched well enough that reflections are minimal and set $\Gamma_c=0$

\begin{align*}
  \frac{V_1}{V_{in}} \approx \Gamma_c + e^{i\phi}\chi\\
\end{align*}

We want to see how this additional term perturbs the reflected power away from the Lorentzian.

\begin{align*}
  \abs{\frac{V_1}{V_{in}}}^2 = \abs{\Gamma_c}^2 + \abs{\chi}^2 + \chi (\Gamma_c e^{-i\phi} + \Gamma_c^* e^{i\phi})\\
\end{align*}

By using Equation~\ref{eqn:reflection_coefficient} and expanding, one can show
\begin{align}
  \Gamma_c e^{-i\phi} + \Gamma_c^* e^{i\phi} = 2\cos\phi - \frac{4\beta}{1+\beta}\cos\phi L(f) + \frac{8\beta}{1+\beta}\sin\phi\Delta L(f)
  \label{eqn:complex_expansion}
\end{align}

Using Equation~\ref{eqn:complex_expansion}, we get

\begin{align}
  \abs{\frac{V_1}{V_{in}}}^2 &= 1 - \frac{4\beta}{(\beta + 1)^2}L(f) + \abs{\chi}^2 + 2\chi\cos\phi - \frac{4\chi\beta}{1+\beta}\cos\phi L(f) + 8\chi\sin\phi\frac{\beta}{1+\beta}\Delta L(f)\nonumber\\
                             &= 1 + \abs{\chi}^2 + 2\chi\cos\phi - 4\left(\frac{\beta}{(\beta + 1)^2} + \frac{\chi\beta}{1+\beta}\cos\phi \right)L(f) + 8\chi\sin\phi\frac{\beta}{1+\beta}\Delta L(f)
\end{align}

Let $C\equiv 1-2\chi^2\cos\phi+\chi^2$, $D\equiv \chi \cos\phi$, $F\equiv 8\chi\sin\phi$.
\begin{align*}
  \abs{\frac{V_1}{V_{in}}}^2 = C - 4\left(\frac{\beta}{(\beta + 1)^2} + D\frac{\beta}{1+\beta}\right)L(f) + F\frac{\beta}{1+\beta}\Delta L(f)
\end{align*}
Finally,
\begin{align}
  \abs{\frac{V_{out}}{V_{in}}}^2 = A\left(C - 4\left(\frac{\beta}{(\beta + 1)^2} + D\frac{\beta}{1+\beta}\right)L(f) + F\frac{\beta}{1+\beta}\Delta L(f)\right)
  \label{eqn:complicated_fit}
\end{align}
where $A$ represents the amplification of the amplifier and the attenuation from the amplifier to the VNA.

If we had not set $\Gamma_a=0$, then Equation~\ref{eqn:complicated_fit} becomes
\begin{align*}
  \abs{\frac{V_{out}}{V_{in}}}^2 = A\left(\frac{C - 4\left(\frac{\beta}{(\beta + 1)^2} + D\frac{\beta}{1+\beta}\right)L(f) + F\frac{\beta}{1+\beta}\Delta L(f)}{1+\Gamma_a(2\cos\theta-4\frac{\beta}{\beta+1}(\cos\theta+\Delta\sin\theta)) + \Gamma_a^2 \left(1-\frac{4\beta}{(\beta+1)^2}L(f)\right)}\right)
\end{align*}

Equation~\ref{eqn:complicated_fit} is a promising candidate to fit reflected powers that deviate from the standard Lorentzian shape. This model fits Orpheus data better than a Lorentzian (Figure~\ref{fig:complicated_fit}) and more accurately extracts the Q parameter, as evident by the fact that the reflection $Q_L$ matches the transmission $Q_L$ (Figure~\ref{fig:fitted_qs}). Unfortunately, there is a large degeneracy between $\beta$, $\chi$, and $\phi$. The resulting elements in the covariance matrix are huge. So Equation~\ref{eqn:complicated_fit} hasn't proved useful for extracting $\beta$. One may be able to make progress by constraining $\chi$ to be appropriately small.

\begin{figure}[ht]
    \centering
  \includegraphics[height=0.4\textheight]{measurement_9.png}
  \caption{The fitted transmitted (standard Lorentzian fit) and reflected power (perturbed Lorentzian fit, Equation~\ref{eqn:complicated_fit}).}
  \label{fig:complicated_fit}
\end{figure}

\begin{figure}[ht]
    \centering
  \includegraphics[height=0.4\textheight]{20210404180209_loaded_q_slanted_reflection.png}
  \caption{The fitted loaded quality factors for transmission (standard Lorentzian fit) and reflection (perturbed Lorentzian fit, Equation~\ref{eqn:complicated_fit}).}
  \label{fig:fitted_qs}
\end{figure}

\FloatBarrier
\section{Axion coupling sensitivity to uncertainty in antenna coupling coefficient}
A resonators sensitivity to the axion is related to the antenna coupling coefficient

\begin{align*}
  g_{a\gamma \gamma} \propto \left(\frac{\beta+1}{\beta}\right)^{1/2}
\end{align*}

The uncertainty in $g_{a\gamma \gamma}$ is related to the uncertainty in $\beta$ by
\begin{align*}
  \Delta g_{a\gamma\gamma} &= \abs{\pdv{g_{a\gamma\gamma}}{\beta}} \Delta\beta\\
  \pdv{g_{a\gamma\gamma}}{\beta} &= -\frac{1}{2\beta^2\sqrt{\frac{\beta+1}{\beta}}}
\end{align*}

$\pdv{g_{a\gamma\gamma}}{\beta}$ is plotted in Figure~\ref{fig:dgamma_dbeta}. This suggests that near critical-coupling, the uncertainty in axion sensitivity is insensitive to the uncertainty in antenna coupling. Then it becomes very sensitive when we are weakly coupled.

\begin{figure}[!htbp]
    \centering
  \includegraphics[height=0.3\textheight]{dgamma_dbeta.png}
  \caption{The derivative of the axion-photon coupling constant vs antenna coupling coefficient. This relationship determines how the uncertainty in $\beta$ affects the uncertainty in $g_{a\gamma\gamma}$.}
  \label{fig:dgamma_dbeta}
\end{figure}

\section{Magnet Design}\label{appendix:magnet}
Seth Kimes and Richard Ottens designed the magnet. The planned dipole magnet has dimensions $44\times18.5\times18$ \SI{}{cm^3}. The NbTi superconducting is from Supercon, Inc. The model is 56S53, the diameter is \SI{0.30}{mm} bare and \SI{0.33}{mm} with the insulation. The critical current is \SI{125}{A} at \SI{3}{T}. Each dipole side will have 57 layers of winding, and each layer will have 57 turns. The dipole magnet will run \SI{103}{A} to produce a \SI{1.5}{T} field inside the detector volume. The magnetic field profile is shown in Figure~\ref{fig:magnet_field}. The force between the wires of the dipole magnet, depending on the direction, is $\mathcal{O}(\SI{2000}{lbs.})$ of force. Seth Kimes designed the vacuum vessel to withstand that force with a certain safety factor.
\begin{figure}
  \centering
  \subfloat[Along the axis of the cavity]{\includegraphics[height=0.25\textheight]{Orpheus_B_Field_Optical_Axis.pdf}}\hfil
  \subfloat[XY Plane]{\includegraphics[height=0.25\textheight]{Orpheus_B_Field_XY_plane.pdf}}\\
  \subfloat[XZ Plane]{\includegraphics[height=0.25\textheight]{Orpheus_B_Field_XZ_plane.pdf}}\hfil
  \subfloat[YZ Plane]{\includegraphics[height=0.25\textheight]{Orpheus_B_Field.pdf}}
  \caption{Calculated magnetic field of the planned Orpheus magnet. For this calculation, Z is the axis of the magnet, X is along the long side of the dipole magnet, and Y is along the short side of the dipole magnet.}
  \label{fig:magnet_field}
\end{figure}

We are currently in the process of winding the superconducting dipole magnet. James Sinnis spent the Summer of 2021 practicing the winding and potting technique, and the results in Figure~\ref{fig:magnet_winding} look satisfactory. We are now waiting for cryogenic epoxy to arrive, but the supply chains are currently in chaos.
\begin{figure}
  \centering
  \subfloat[]{\includegraphics[height=0.2\textheight]{copper_magnet_core.jpg}}\hfil
  \subfloat[]{\includegraphics[height=0.2\textheight]{wire_cross_section_corner_of_magnet.jpg}}
  \caption{Practicing Orpheus magnet widning with copper wire.}
  \label{fig:magnet_winding}
\end{figure}

max_stars_repo_name: raphaelcervantes/UWThesis

max_issues_repo_name: raphaelcervantes/UWThesis

max_forks_repo_name: raphaelcervantes/UWThesis


text:
% Copyright (c) 2016 William Wennerström
%
% Permission is hereby granted, free of charge, to any person obtaining a copy
% of this software and associated documentation files (the "Software"), to deal
% in the Software without restriction, including without limitation the rights
% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
% copies of the Software, and to permit persons to whom the Software is
% furnished to do so, subject to the following conditions:
%
% The above copyright notice and this permission notice shall be included in
% all copies or substantial portions of the Software.
%
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
% SOFTWARE.

% Using A4 paper as standard and two sided documents.
\documentclass[a4paper,twoside]{article}

% These are the packages that are usually used, remove unused yourself.
\usepackage[utf8]{inputenc}
\usepackage[swedish]{babel}
\usepackage{dirtree}
\usepackage{listings}
\usepackage{float}
\usepackage{color}
\usepackage{fancyhdr}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{csvsimple}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{afterpage}
\usepackage[margin=0.8in]{geometry}

% Standard colors for the code syntax highlighting.
\definecolor{pblue}{rgb}{0.13,0.13,1}
\definecolor{pgreen}{rgb}{0,0.5,0}
\definecolor{pred}{rgb}{0.9,0,0}
\definecolor{pgrey}{rgb}{0.46,0.45,0.48}

% Define author information
\newcommand{\authors}{Student Studentson, Elev Elevberg}
\newcommand{\authorsinfo}{
    Student Studentson$^1$ \thanks{$^1$E-post: \texttt{stustu-#@student.ltu.se}} \\
    Elev Elevberg$^2$ \thanks{$^2$E-post: \texttt{eleele-#@student.ltu.se}} \\
}

% Define group name
\newcommand{\groupname}{Group name here}

% Define course information
\newcommand{\coursename}{Course name here}
\newcommand{\coursecode}{\#\#\#\#\#\#}

% Define project name
\newcommand{\projectname}{Project name here}

% Define information about the school/university
\newcommand{\schoolinfo}{Institutionen för system- och rymdteknik \\
                         Luleå tekniska universitet \\
                         971 87 Luleå, Sverige
}

% Define hhrule
\newcommand{\hhrule}{\midrule\midrule}

% Define Y colymntype
\newcolumntype{Y}{>{\centering\arraybackslash}X}

% Define blankpage macro
\newcommand\blankpage{
    \null
    \thispagestyle{empty}
    \addtocounter{page}{-1}
    \newpage}

% Header for each page (except first)
\pagestyle{fancy}
\fancyhf{}
\fancyhead[L]{\authors} % Authors on left side
\fancyhead[R]{\coursecode} % Course code on right side
\fancyfoot[R]{\thepage} % Page numbering on right side

% Code style formatting
\lstset{showspaces=false,
        showtabs=false,
        breaklines=true,
        showstringspaces=false,
        breakatwhitespace=false,
        commentstyle=\color{pgreen},
        keywordstyle=\color{pblue},
        stringstyle=\color{pred},
        basicstyle=\ttfamily,
        captionpos=t,
        basicstyle=\scriptsize,
        numbers=left,
        numbersep=9pt,
        numberstyle=\scriptsize\color{pggray},
        frame=L,
        rulecolor=\color{black},
        tabsize=2,
        moredelim=[il][\textcolor{pgrey}]{\$\$},
        moredelim=[is][\textcolor{pgrey}]{\%\%}{\%\%}
}

\title{\coursename{} --- \coursecode{} \break{}
  \projectname{}
  \author{\Large{\groupname{}} \\
  	\authorsinfo{}}
  \break{}
  \bigskip{} \break{}
  \schoolinfo{}}
\renewcommand\footnotemark{}
\date{\today}

\begin{document}

\maketitle
\thispagestyle{empty}
\afterpage{\blankpage} % Create blank page

\newpage
\tableofcontents

\newpage
\section{Introduction}
\lorem

\newpage
\section{Result}
\lorem
\subsection{A subheading}
\lorem

\newpage
\section{Discussion}
\lorem

\clearpage

\begin{appendices}
\newpage
\section{Some very advanced code}
\label{app:Code}
\lstinputlisting[language=Python]{a_very_advanced_script.py}
\end{appendices}

% What follows is some example code, don't forget to remove \iffalse & \fi
\iffalse% Remove this.
\section{First section}
\subsection{First subsection}
\lstinputlisting[language=python]{code1.py}
\large Large text
\lstinputlisting[language=VHDL]{code2.vhd}
\subsection{Sub section with table}
\csvautotabular[separator=semicolon]{table.csv}
\subsection{Sub section with image}
\includegraphics[width=\textwidth]{animage.png}
\newpage
\subsection{Sub section with maths for $f$}
\large{\bf{Some maths}} \\
    $f = a+b$ \\
\newpage
\begin{tabularx}{\linewidth}{Y Y}
  \toprule

  Header 1 & Header 2 \\

  \hhrule{}

  Data 1 & Data 2 \\

  \bottomrule
\end{tabularx}
\fi% And remove this.

\end{document}

max_stars_repo_name: willeponken/ltu-latex-template

max_issues_repo_name: willeponken/ltu-latex-template

max_forks_repo_name: willeponken/ltu-latex-template