\documentclass[10pt]{beamer}

\usetheme[everytitleformat=regular]{m}
\usepackage[percent]{overpic}
\usepackage{booktabs}
\usepackage[scale=2]{ccicons}
\usepackage[outdir=./gfx/]{epstopdf}
\usepackage{pgfplots}
\usepackage{multimedia}
\usepackage{graphicx}
\usepackage{epsfig}
\usepackage{psfrag}
\usepackage{color}
\usepackage{caption}
\usepackage{transparent}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{algorithm}
\usepackage{algpseudocode}
\setbeamerfont{caption}{size=\tiny}
\setbeamertemplate{caption}{\raggedright\insertcaption\par}

\makeatletter
\renewcommand{\ALG@beginalgorithmic}{\scriptsize}
\renewcommand{\alglinenumber}{\scriptsize}
\makeatother

\graphicspath{{./gfx/}}

\usepgfplotslibrary{dateplot}

\definecolor{pro}{HTML}{198c19}
\definecolor{con}{HTML}{CB410B}

% Costumizing the m-theme here
\setbeamertemplate{footline}[text line]{%
    \parbox{\linewidth}{
        \vspace*{-35pt}\insertpagenumber
        \hfill\inserttitle
        \hspace*{-30pt}  
        \hfill\includegraphics[width=0.20\textwidth]{gfx/logo_orange}
        \hspace*{-30pt}
    }
  }
  
\definecolor{mBGColor}{HTML}{FAFAFA}
\definecolor{mWhite}{HTML}{FFFFFF}
\definecolor{mOrange}{HTML}{e84e25}   
\setbeamercolor{frametitle}{%
  use=mWhite,
  fg=mWhite,
  bg=mOrange
}
\setbeamercolor{alerted text}{%
  fg=mOrange
}
% End Costumizing

\usepackage{amsmath}
\renewcommand{\vec}[1]{\boldsymbol{#1}}
\newcommand{\mat}[1]{\boldsymbol{#1}}
%\renewcommand{\hat}[1]{\oldhat{\mathbf{#1}}}

\newcommand{\SI}[2]{\ensuremath{#1}\text{\,#2}}
\newcommand{\SIrange}[3]{\ensuremath{#1} to \ensuremath{#2}\text{\,#3}}
\newcommand{\cm}{cm}
\newcommand{\meter}{m}
\newcommand{\per}{/}
\newcommand{\milli}{m}
\newcommand{\second}{s}
\newcommand{\giga}{G}
\newcommand{\hertz}{Hz}
\newcommand{\dBm}{dBm}
\newcommand{\percent}{\%}
\newcommand{\decibel}{dB}
\newcommand{\dB}{dB}
\newcommand{\degree}{\ensuremath{^{\circ}}}


\newcommand{\R}{\mathbb{R}}
\newcommand{\N}{\mathbb{N}}
\newcommand{\NDist}{\mathcal{N}}
\newcommand{\UDist}{\mathcal{U}}


\newcommand{\qTurn}{\theta}
\newcommand{\qBaro}{\hat\rho_{\text{rel}}}


\newcommand{\oWifi}{s_{\text{wifi}}}
\newcommand{\oBeacons}{s_{\text{beacons}}}
\newcommand{\oStep}{n_\text{step}}
\newcommand{\oTurn}{\Delta\theta}
\newcommand{\oBaro}{\rho_{\text{rel}}}

\newcommand{\ispace}{\vspace{2mm}}

\newcommand{\vecB}[2]{\begin{pmatrix} #1\\ #2 \end{pmatrix}}
\newcommand{\matD}[4]{\begin{bmatrix} #1 & #2 \\ #3 & #4 \end{bmatrix}}

\title{On Monte Carlo Smoothing in Multi Sensor Indoor Localisation}
\date{\today}
\newcommand{\insertmail}{toni.fetzer@fhws.de}
\author{T. Fetzer$^\star$, F. Ebner$^\star$, F. Deinzer$^\star$, L. K\"oping$^\dagger$, M. Grzegorzek$^\dagger$}
\date{\today}
\institute{ $^\star$ University of Applied Sciences W\"urzburg - Schweinfurt \\
            $^\dagger$ University of Siegen - Pattern Recognition Group}


%\input{misc/keywords}
%\input{misc/functions}

\begin{document}

\maketitle

\begin{frame}
  \frametitle{Table of Contents}
  \setbeamertemplate{section in toc}[sections numbered]
  \tableofcontents[hideallsubsections]
\end{frame}

\section{General Idea \& Motivation}

\begin{frame}[fragile]
  \frametitle{Indoor Localisation System}

  \begin{figure}
	\centering
	\includegraphics[width=\linewidth]{gfx/info_graphic}
  \end{figure}%  
  
  
\end{frame}

\begin{frame}[fragile]
  \frametitle{Multimodal Distribution}

  \begin{figure}
	\centering
	\def\svgwidth{0.9\columnwidth}
  \input{gfx/multimodalpath.eps_tex}
  \end{figure}%  
  
\end{frame}

\begin{frame}[fragile]
  \frametitle{Research Objectives}
	  \textbf{Goal:} Provide and discuss Monte-Carlo smoothing methods in the context of indoor localisation. 
	  \newline  
	  \newline 
	  \textbf{General Assumptions:}
	  \begin{itemize}
	  \item A time-sequential, non-linear and non-Gaussian state-space
	  \newline $\rightarrow$ Monte-Carlo methods for approximation
	  \item A given indoor localisation system based on a statistical sensor fusion
	  \item No multi-target tracking (more than one person)
    \end{itemize}

\end{frame}

%Section: Transition Model
\section{Forward Propagation}

		\begin{frame}
				\frametitle{Recursive Density Estimation}
				\begin{itemize}
					\item<1->	Current State\\
								$\vec{q} = (x,y,z, \qTurn, \qBaro)^T, \enskip{}
									\overbrace{x,y,z \in \R}^{\text{position}}, \enskip 
									\overbrace{\qTurn \in \R}^{\text{heading}},\enskip{}
									\overbrace{\qBaro \in \R}^{\text{rel. pressure}}
								$	\\
								$\vec{q}_0 = $ uniformly distributed, $\qBaro = 0$
								\ispace
					\item<2->	Observation\\
								$\vec{o} = (\vec{\oWifi}, \vec{\oBeacons}, \oStep, \oTurn, \oBaro, \Omega)$
								\ispace
					\item<3->	\small$
									\underbrace{ p(\vec{q}_t\mid \vec{o}_{1:t})}_{\text{estimation}}
									\propto %
									\underbrace{ p(\vec{o}_t \mid \vec{q}_t) }_{\text{evaluation}}%
									\int
									\underbrace{ p(\vec{q}_t \mid \vec{q}_{t-1}, \vec{o}_{t-1}) }_{\text{transition}}%
									\underbrace{ p(\vec{q}_{t-1} \mid \vec{o}_{1:t-1})}_{\text{recursion}}%
									d\vec{q}_{t-1}%
								$
				\end{itemize}
			\end{frame}
		
			\begin{frame}
				\frametitle{Observation}
				\begin{itemize}
					\item<1->	a location's probability based on the current sensor readings
								\begin{equation*}
									\begin{split}
									p(\vec{o}_t \mid \vec{q}_t) =&\\
									&p(\vec{o}_t \mid \vec{q}_t)_{\text{wifi}} \\
									&p(\vec{o}_t \mid \vec{q}_t)_{\text{beacons}} \\
									&p(\vec{o}_t \mid \vec{q}_t)_{\text{baro}} \\
									\end{split}
								\end{equation*}
								\ispace
					\item<1->	assuming statistical independence
					\item<1->	\textit{step- and turn detection are used within the transition}
				\end{itemize}
			\end{frame}
			
			
			\begin{frame}
				\frametitle{Observation - Wi-Fi/iBeacons}
				\begin{itemize}
					
					%\only<1>{
						\item<1->
							$p(\vec{o}_t \mid \vec{q}_t)_\text{wifi}=$
							$p(\vec{\oWifi} \mid \vec{q}_t) = \prod_{\oWifi} \NDist(s_i \mid \overbrace{P_r(d_i, \Delta f_i)}^\text{model prediction}, \sigma_{\text{wifi}}^2)$,\\
							\ispace
							\only<1>{%
								\small{\textit{probability to measure all currently received signal-strengths $\vec{\oWifi}$ at a location $\vec{q}_t$, by comparing them with corresponding estimations from a prediction model}}%
								%\vspace{2.9cm}%
							}
							
					%}
					
					\item<2->
						3D signal strength prediction\\\ispace
								$
									P_r(d,\Delta f) = 
									\underbrace{P_0}_{\text{reference}}\enskip
									\underbrace{- 10 \gamma \cdot \log_{10}(\tfrac{d}{d_0})}_{\text{attenuation per meter}}\enskip
									\underbrace{+ \Delta f \lambda}_\text{floor attenuation}
									\underbrace{+ X}_{\text{  noise  }}
								$
								%\\\ispace$
								%	X \sim \NDist(0,\sigma^2_{\text{wifi}}),\enskip
								%	\underbrace{\Delta f \in \N}_{\text{number of floors}},\enskip
								%	\underbrace{\lambda \approx -8}_{\text{attenuation per floor}}
								%$
								%\ispace
						\newline
						\raisebox{5.0cm}{
						%\only<2>{ \vspace{4.0cm} }
						\only<3>{ \includegraphics[width = 0.35\textwidth]{gfx/wifi1.png} }%
						\only<4->{ \includegraphics[width = 0.35\textwidth]{gfx/wifi2.png} }%
						\only<5>{ \includegraphics[width = 0.35\textwidth]{gfx/wifi3.png} }%
						\only<6->{ \includegraphics[width = 0.35\textwidth]{gfx/wifi4.png} }%
						}
						%\vspace{6mm}
						
			\end{itemize}
			\end{frame}
		
			
			\begin{frame}
				\frametitle{Observation - Barometer}
				\begin{itemize}
					\item<1->
						$p(\vec{o}_t \mid \vec{q}_t)_{\text{baro}} = $
						$\NDist(o_t^{\oBaro} \mid q_t^{\qBaro}, \sigma_{\text{baro}}^2)$\\
						\ispace
						\small{\textit{probability to measure the pressure $o_t^{\oBaro}$ (relative to the start) at a location $\vec{q}_t$}, by comparing it with the corresponding prediction}
						
					\item<2->
						each transition performs a relative pressure prediction:\\
						\ispace
						$q_t^{\qBaro} = q_{t-1}^{\qBaro} + \Delta z \cdot b$, \enskip
						$\underbrace{\Delta z = q_{t-1}^z - q_{t}^z}_{\text{height change}}$, \enskip
						$\underbrace{b \in \R}_{\text{pressure change / meter}}$\\
								%
								\vspace{5mm}
								\begin{figure}
									\centering
									\includegraphics[width = 0.4\textwidth]{gfx/baroChange}
								\end{figure}
								
				\end{itemize}
			\end{frame}
			

			\begin{frame}
				\frametitle{Transition - Floorplan}
					\only<1>{%
						1) start with the building's floorplan\\%
						\includegraphics[width = 1.0\textwidth]{gfx/step1}%
					}%
					\only<2>{%
						2) divide into cells and remove those intersecting with walls\\%
						\includegraphics[width = 1.0\textwidth]{gfx/step2}%
					}%
					\only<3>{%
						3) add edges to all (available) adjacent cells\\%
						\includegraphics[width = 1.0\textwidth]{gfx/step3}%
					}%
					\only<4>{%
						4) add stairs and remove unreachable cells\\%
						\includegraphics[width = 1.0\textwidth]{gfx/step4}%
					}%
			\end{frame}
					
			\newcommand{\leHeading}{\theta_{\text{walk}}}
			%\newcommand{\leDistance}{d_{\text{walk}}}
			\newcommand{\leDistance}{d}
				
			\begin{frame}
				\frametitle{Transition - Random Walk}
				\begin{minipage}{0.49\textwidth}
					$p(\vec{q}_t \mid \vec{q}_{t-1}, \vec{o}_{t-1})$:
					\begin{enumerate}
						\item get node $\vec{q}_{t-1}$ belongs to
						\item draw distance $\leDistance$ to walk%\\ \textit{depends on the number of detected steps}
						\item repeat until $\leDistance$ is reached
						\begin{enumerate}
							\item draw edge $e_{i,j}$ according to its probability $p(e_{i,j})$
							\item walk along the edge
							\item $\leDistance = \leDistance - \|e_{i,j}\|$
						\end{enumerate}
					\end{enumerate}
				\end{minipage}
				\begin{minipage}{0.49\textwidth}
					\begin{figure}
						\includegraphics[width = 1.0\textwidth]{gfx/walk}
					\end{figure}
				\end{minipage}
			\end{frame}
						
						
					
			\begin{frame}
				\frametitle{Transition - Random Walk}
				\begin{itemize}
								
					\item<1-> distance to walk\\
						\ispace
						$%
							\leDistance =
							\underbrace{{o}_{t-1}^{\oStep}}_\text{steps detected} \cdot
							\underbrace{s_\text{step}}_\text{step size} + 
							\underbrace{\mathcal{N}(0, \sigma^2_{\leDistance})}_\text{uncertainty}
						$\newline\newline
					
					\item<2->	pedestrian's heading\\
								\ispace
								$p(e_{i,j})_\text{turn} = p(e_{i,j} \mid \leHeading) = \NDist(\angle e_{i,j} \mid \leHeading, \sigma^2_{\text{dev}} )$\\
								\ispace
								$%
									\underbrace{\leHeading = {q}_{t}^{\qTurn}}_\text{current heading} = 
									\underbrace{{q}_{t-1}^{\qTurn}}_\text{previous heading} +
									\underbrace{{o}_{t-1}^{\oTurn}}_\text{sensor readings} + 
									\underbrace{\mathcal{N}(0, \sigma^2_{\leHeading})}_\text{uncertainty}
								$\\
								
					
				\end{itemize}
			\end{frame}

\begin{frame}
				\frametitle{Transition - Activity Recognition}
		\begin{itemize}
	\item additionally activity detection with\\
				\ispace
			$\Omega \in \{ \tt{unknown}, \tt{standing}, \tt{walking}, \tt{stairs\_up}, \tt{stairs\_down} \}$\newline

	\item edges $e_{i,j}$ matching the currently detected
			activity are favoured using $p(e_{i,j})_\text{act} = 0.8$ and $0.2$ otherwise

	\end{itemize}		
\end{frame}

%Section: Backward Propagation
\section{Backward Propagation}  

\begin{frame}[fragile]
  \frametitle{Basics of Particle Smoothing}  
  \begin{figure}
	\centering
	\def\svgwidth{0.9\columnwidth}
  \input{gfx/basicssmoothing.eps_tex}
  \end{figure}%  
\end{frame}

\begin{frame}[fragile]
  \frametitle{Forward-Backward Smoothing}  
\begin{algorithm}[H]
    \caption{Forward-Backward Smoother}
    \label{alg:forward-backwardSmoother}
    \begin{algorithmic}[1] % The number tells where the line numbering should start
		\Statex{\textbf{Input:} Prior $\mu(\vec{X}^i_1)$}
		\Statex{~}
			\For{$t = 1$ \textbf{to} $T$} \Comment{Filtering}
				\State{Perform particle filtering to obtain the weighted trajectories $ \{ W^i_t, \vec{X}^i_t\}^N_{i=1}$}
			\EndFor
			\For{ $i = 1$ \textbf{to} $N$} \Comment{Initialization}
				\State{Set $W^i_{T \mid T} = W^i_T$} 
			\EndFor
			\For{$t = T-1$ \textbf{to} $1$} \Comment{Smoothing}
				\For{$i = 1$ \textbf{to} $N$}
					\State{Compute the weights
\fcolorbox{mOrange}{mBGColor}{					
$
W^i_{t \mid T} = W^i_t \left[ \sum^N_{j=1} W^j_{t+1 \mid T} \frac{p(\vec{X}^j_{t+1} \mid \vec{X}^i_t)}{\sum^N_{k=1} W^k_t ~ p(\vec{X}^j_{t+1} \mid \vec{X}^k_t)} \right] 
$} 
}
				\EndFor	
			\EndFor
    \end{algorithmic}
\end{algorithm}
\end{frame}

\begin{frame}[fragile]
  \frametitle{Backward Simulation}  
  
  \begin{algorithm}[H]
    \caption{Backward Simulation Smoothing}
    \label{alg:backwardSimulation}
    \begin{algorithmic}[1] % The number tells where the line numbering should start
		\Statex{\textbf{Input:} Prior $\mu(\vec{X}^i_1)$}
		\Statex{~}
			\For{$t = 1$ \textbf{to} $T$} \Comment{Filtering}
				\State{Perform particle filtering to obtain the weighted trajectories $ \{ W^i_t, \vec{X}^i_t\}^N_{i=1}$}
			\EndFor
			\For{ $k = 1$ \textbf{to} $N_{\text{sample}}$} 
				\State{Choose $\tilde{\vec{q}}^k_T = \vec{X}^i_T$ with probability $W^i_T$} \Comment{Initialize realization}
			
				\For{$t = T-1$ \textbf{to} $1$} \Comment{Smoothing}
					\For{$j = 1$ \textbf{to} $N$}
						\State{Compute the weights \fcolorbox{mOrange}{mBGColor}{$W^j_{t \mid t+1} = W^j_t ~ p(\tilde{\vec{q}}_{t+1} \mid \vec{X}^j_{t})$}}
					\EndFor	
				\State{\fcolorbox{mOrange}{mBGColor}{Choose $\tilde{\vec{q}}^k_t = \vec{X}^j_t$ with probability $W^j_{t\mid t+1}$}}
				\EndFor
				\State{$\tilde{\vec{q}}^k_{1:T} = (\tilde{\vec{q}}^k_1, \tilde{\vec{q}}^k_2, ..., \tilde{\vec{q}}^k_T)$ is one approximate realization from $p(\vec{q}_{1:T} \mid \vec{o}_{1:T})$}
			\EndFor
    \end{algorithmic}
\end{algorithm}
\end{frame}


\begin{frame}[fragile]
  \frametitle{Backward Transition} 
  
  \begin{columns}[T,onlytextwidth] 
    \column{0.55\textwidth}
  Very simple model for calculating the state transition $p(q_{t+1} \mid q_{t})$:
  \begin{itemize}
	\setlength{\itemindent}{-0.5cm}
	\item Linear distance: $p(\vec{q}_{t+1} \mid \vec{q}_t)_{\text{step}} = $\\
	\ispace	
	$%
	\mathcal{N}(\Delta d_t \mid \mu_{\text{step}}, \sigma_{\text{step}}^2)
	$\newline

	\item Heading change: $p(\vec{q}_{t+1} \mid \vec{q}_t, \vec{o}_t)_{\text{turn}} = $\\
	\ispace
	$%
	 \mathcal{N}(\Delta\alpha_t \mid \oTurn, \sigma^2_{\text{turn}})
	$\newline

	\item Height change: $p(\vec{q}_{t+1} \mid \vec{q}_t, \vec{o}_t)_{\text{baro}} = $\\
	\ispace
	$
	\mathcal{N}(\Delta z \mid \mu_z, \sigma^2_{z}) 
	$

  \end{itemize}
 
  %\column{0.05\textwidth}   

  \column{0.60\textwidth}

  \centering
  \input{gfx/backwardTransition.eps_tex}{}

  \end{columns}
  
\end{frame}

			\begin{frame}
				\frametitle{Backward Transition}
				\begin{itemize}
					\item<1->	the probability density of the smoothing transition is then given by
	\begin{equation*}
			\arraycolsep=1.2pt
			\begin{array}{ll}
				p(\vec{q}_{t+1} \mid \vec{q}_t, \vec{o}_t) = 
				&p(\vec{q}_{t+1} \mid \vec{q}_t)_{\text{step}}\\ 
				&p(\vec{q}_{t+1} \mid \vec{q}_t, \vec{o}_t)_{\text{turn}}\\
				&p(\vec{q}_{t+1} \mid \vec{q}_t, \vec{o}_t)_{\text{baro}}  
			\end{array}
	\enspace .
	\end{equation*}
								\ispace
					\item<1->	assuming again statistical independence
					\item<1->	important: to do all this, we need to save all particles and their weight at each time step while filtering.
				\end{itemize}
			\end{frame}

%Section Evaluation
\section{Evaluation}

\begin{frame}[fragile]
  \frametitle{Test Environment}  

\begin{figure}
\centering
	\scalebox{1.2}{
	\input{gfx/paths}}
\end{figure}
%
 
\end{frame}


\begin{frame}[fragile]
  \frametitle{Fixed-interval Smoothing - Path 2}  

\begin{figure}
\centering
	\scalebox{1.2}{
	\input{gfx/path2_interval_compare}}
	%\caption{a) Exemplary results for path 2 where BS (blue) and filtering (green) using 2500 particles and 500 sample realisations. b) A situation where smoothing provides a worse error in regard to the ground truth, but obviously a more realistic path.}
	%\label{fig:int_path2}
\end{figure}
%
 
\end{frame}

\begin{frame}[fragile]
  \frametitle{Fixed-interval Smoothing - UAH (This building)}  

\begin{figure}
\centering
	\includegraphics[width=0.8\textwidth]{gfx/uah_live.png}
\end{figure}
%
 
\end{frame}

\begin{frame}[fragile]
  \frametitle{Fixed-lag Smoothing - Path 4}  
  
\begin{figure}
	\centering	
	\scalebox{1.2}{
	\input{gfx/path4_lag_comp}}
	%\caption{Estimation results on path 4 for the filter and both smoothers using fixed-lag smoothing with $\tau = 5$. For a better visualisation, the segments are divided using an outline of alternating grey levels. The corresponding segment-error can be seen in fig. \ref{fig:lag_error_path4}.}
	%\label{fig:lag_comp_path4}
\end{figure}
 
\end{frame}

\begin{frame}[fragile]
  \frametitle{Fixed-lag Smoothing - Path 4}  
  
\begin{figure}
	\centering	
	\scalebox{1.2}{
		\input{gfx/error_timed}}
	%\caption{Estimation results on path 4 for the filter and both smoothers using fixed-lag smoothing with $\tau = 5$. For a better visualisation, the segments are divided using an outline of alternating grey levels. The corresponding segment-error can be seen in fig. \ref{fig:lag_error_path4}.}
	%\label{fig:lag_comp_path4}
\end{figure}
 
\end{frame}

\begin{frame}[fragile]
  \frametitle{Overall Results}  

Overall estimation results for all paths on 10 MC runs:

\centering
\begin{tabular}{ |l |c |c |}
  \hline
	  									& Galaxy S5 		& Nexus 6 \\ \hline
	Filtering 					& \SI{7.92}{m} 	& \SI{5.50}{m} \\\hline
  Forwards-Backward 	& \SI{6.48}{m} 	& \SI{4.47}{m} \\\hline
  Backward Simulation & \SI{6.68}{m} 	& \SI{4.80}{m} \\
	\hline
\end{tabular}

\begin{itemize}
	\item even with 50 particles backward simulation is still able to provide good results.
	\item bigger lags improve the results with increasing temporal error
\end{itemize}
 
\end{frame}


%Section Conclusion
\section{Conclusion}

\begin{frame}[fragile]
  \frametitle{Conclusion} 
		\textcolor{mLightBrown}{What you have seen:} 
		\begin{itemize}
		\item Successful use of \textbf{different smoothing algorithm} in context of indoor localisation
		\item A \textbf{very simple} backward transition model
		\item \textbf{Practical} and \textbf{theoretical comparison} between the single approaches
		\end{itemize}
	\begin{columns}[T,onlytextwidth]
		\column{0.5\textwidth}

		\textcolor{pro}{What's good:}
		\begin{itemize}
			\item Realistic paths and good error compensation
			\item \textbf{Low computational cost} and \textbf{low complexity} by using backward simulation
		\end{itemize}	
		\column{0.05\textwidth}
		\column{0.5\textwidth}

		\textcolor{con}{What's future work?}
		\begin{itemize}
			\item Dynamic-lag smoothing
			\item Prediction of future observations to reduce the estimation lag
		\end{itemize}		
	\end{columns}

\end{frame}


\begin{frame}[fragile]{}
    \setbeamercolor{frametitle}{use=mDarkTeal,fg=mDarkTeal, bg=mWhite}
    \vfill
    \begin{center}
    \vspace{1em}
    \usebeamerfont{section title}
    Thank you. Any questions?
    \end{center}
    \vfill
    
    Toni Fetzer \\
    \insertmail \\
    University of Applied Sciences W\"urzburg - Schweinfurt
\end{frame}


%\begin{frame}[allowframebreaks]

%  \frametitle{References}

%  \bibliography{demo}
%  \bibliographystyle{abbrv}

%\end{frame}

\end{document}
