\documentclass[11pt]{article}
\usepackage{latexsym}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{epsfig}
\usepackage[tight]{subfigure}

\newcommand{\handout}[5]{
  \noindent
  \begin{center}
  \framebox{
    \vbox{
      \hbox to 5.78in { {#1} \hfill #2 }
      \vspace{4mm}
      \hbox to 5.78in { {\Large \hfill #5  \hfill} }
      \vspace{2mm}
      \hbox to 5.78in { {\em #3 \hfill #4} }
    }
  }
  \end{center}
  \vspace*{4mm}
}

\newcommand{\lecture}[5]{\handout{#1}{#2}{#3}{#4}{#5}}

\newtheorem{theorem}{Theorem}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{observation}[theorem]{Observation}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{definition}[theorem]{Definition}
\newtheorem{claim}[theorem]{Claim}
\newtheorem{fact}[theorem]{Fact}
\newtheorem{assumption}[theorem]{Assumption}

% 1-inch margins, from fullpage.sty by H.Partl, Version 2, Dec. 15, 1988.
\topmargin 0pt
\advance \topmargin by -\headheight
\advance \topmargin by -\headsep
\textheight 8.9in
\oddsidemargin 0pt
\evensidemargin \oddsidemargin
\marginparwidth 0.5in
\textwidth 6.5in

\parindent 0in
\parskip 1.5ex
%\renewcommand{\baselinestretch}{1.25}

\begin{document}

\lecture{Statistical Techniques in Robotics (16-831, F09)}{Lecture \#3 (09/01/2009)}{Lecturer: Drew Bagnell}{Scribe: Mehmet R. Dogar}{Sensor Models / Occupancy Mapping / Density Mapping}

\section{Sensor Models}

\subsection{Beam Model of Range Finders}

\begin{figure}[h!t]
  \centering
  \includegraphics[width=10cm]{img/sensorModel1.eps}
  \caption{Components of the range finder sensor model.}
  \label{fig:sensorModel1}
\end{figure}

The measurement model for range finders is a combination of different components:

\begin{itemize}
\item[-] Correct range with local measurement noise (Fig.~\ref{fig:sensorModel1}-a). 
\item[-] Unexpected objects (Fig.~\ref{fig:sensorModel1}-b).
\item[-] Failures to get any readings, e.g. specular reflections, sensing black, light-absorbing objects. (Fig.~\ref{fig:sensorModel1}-c).
\item[-] Random measurements (Fig.~\ref{fig:sensorModel1}-d).
\end{itemize}

\begin{figure}[h!t]
  \centering
  \includegraphics[width=7cm]{img/sensorModel2.eps}
  \caption{Resulting mixture density.}
  \label{fig:sensorModel2}
\end{figure}

These individual densities are combined we have a resulting mixture density that looks like Fig~\ref{fig:sensorModel2}.

\begin{figure}[h!t]
  \centering
  \includegraphics[width=7cm]{img/sensorModel3.eps}
  \caption{Approximation of the beam model based on real laser data.}
  \label{fig:sensorModel3}
\end{figure}

When we want to use our own range finder, we can collect data and then fit the data to the model and find the parameters for our sensor (Fig.~\ref{fig:sensorModel3}).

In practice, when we are using this model we can do ray-tracing on our map, find the nearest obstacle, and use this to find the density function of our sensor for the given state. But all of these are for just one beam. As an example, a SICK laser range finder throws 181 beams in one cycle. How are we going to combine these?

We make independence assumption between the beams:

\begin{equation}
p(\vec{z} | x) = \prod_{i} p(z_{i}|x)
\end{equation}

where $\vec{z}$ is the vector of all observations/beams, $z_{i}$'s are individual beams, and $x$ is the location of the robot for a given map.

But, \emph{can the independence assumption between the beams be justified?}

This can be justified for random noise, but not always. E.g. reflectivity of surfaces, calibration errors make neighboring observations dependent on each other. \footnote{A similar argument can be made in the time domain. We generally make temporal independence assumptions, but there is actually temporal correlation in the observation data. E.g. a person walking in front of the robot will create a temporal obstacle.}

How to fix this problem?
\begin{itemize}
\item[-] If we really want to fix this problem, we shall make a new sensor model that associates beams close to each other.
\item[-] To ``hack'' the problem, we can:
\begin{itemize}
\item[*] Subsample the measurements: this makes us less susceptible to correlated noise in adjacent measurements.
\item[*] Smooth the observation model: For example we can take the cube root of the model shown in Fig.~\ref{fig:sensorModel2} to smooth it. This method makes the measurements less informative. But still this is usually better than the first option since we are not completely throwing away any data.
\end{itemize}
\end{itemize}

In HW2 we will probably need to do something like this. If we use all sensor measurements directly the robot will get overconfident about its location. Therefore we will need to either throw away some data or oversmooth the sensor model to get better results.

\section{Occupancy Mapping}
Instead of doing localization, we will try to solve the opposite problem: Given the position of the robot, find the map of the world.

What will be the state $x$ if we don't have a given map? The state will be the whole map!

We will partition the world into cells, with each being one of two states: filled or not.  The individual grid cells are $m_i$, and $\vec{m}$ is the vector of all grid cells.  Unfortunately, the curse of dimensionality prevents us from filtering $\vec{m}$.  Instead, we will filter each cell independently, assuming that they are in fact independent.  In truth, this is a very bad assumption to make, but it is practical.

This is called ``occupancy mapping''.

\subsection{Derivation}

Let $x$ represent the state of grid cell $m_i$ (essentially $x \gets m_i$). In the following, also assume that $x$ means `the grid cell is empty'; and $\bar{x}$ means `the grid cell is filled'.

\begin{eqnarray}
  p(x|z_{1:t}) & = & \frac{p(z_t|x,z_{1:t-1})p(x|z_{1:t-1})}{p(z_t|z_{1:t-1})}
\end{eqnarray}

We make the Markov assumption $p(z_t|x,z_{1:t-1}) = p(z_t|x)$ (This should worry us!). Hence:

\begin{eqnarray}
  p(x|z_{1:t}) & = & \frac{p(z_t|x)p(x|z_{1:t-1})}{p(z_t|z_{1:t-1})}
\end{eqnarray}

Doing the Bayes rule over $p(z_t|x)$ once again:

\begin{eqnarray}
p(x|z_{1:t}) & = & \frac{p(x|z_t) p(z_t)}{p(x)} \frac{p(x|z_{1:t-1})}{p(z_t|z_{1:t-1})} \\
\end{eqnarray}

Here we need to use a trick because we have many nasty terms that are hard to calculate.  We will start by computing (by analogy) the likelihood for the opposite event $\bar{x}$
\begin{equation}
  p(\bar{x}|z_{1:t}) = \frac{p(\bar{x}|z_t) p(z_t)}{p(\bar{x})} \frac{p(\bar{x}|z_{1:t-1})}{p(z_t|z_{1:t-1})},
\end{equation}
and then divide the two:
\begin{equation}
  \frac{p(x|z_{1:t})}{p(\bar{x}|z_{1:t})} = \left[ \frac{p(x|z_t)}{p(\bar{x}|z_t)} \right] \left[ \frac{p(\bar{x})}{p(x)} \right]
\left[ \frac{p(x|z_{1:t-1})}{p(\bar{x}|z_{1:t-1})} \right]
\end{equation}

The second term on the right may seem counter-intuitive, but if we rearrange the terms, it makes sense:

\begin{equation}
  \frac{p(x|z_{1:t})}{p(\bar{x}|z_{1:t})} = \left[ \frac{p(x|z_t)}{p(x)} \right] \left[ \frac{p(\bar{x})}{p(\bar{x}|z_t)} \right]
\left[ \frac{p(x|z_{1:t-1})}{p(\bar{x}|z_{1:t-1})} \right]
\label{eqn_oddratio}
\end{equation}

If the probability of $\bar{x}$ decreases with the observation $z_t$: $p(\bar{x}) > p(\bar{x}|z_t)$, it causes the belief on $x$ to increase relative to $\bar{x}$.

The next step is to take the log of~\eqref{eqn_oddratio} to get the log odds of the belief $bel_t(x)$, denoted as $l_t(x)$:

\begin{equation}
  l_t(x) = l_{t-1}(x) + log\frac{p(x|z_t)}{p(x)} + log\frac{p(\bar{x})}{p(\bar{x}|z_t)}
\label{logodds2_eqn}
\end{equation}

Here we need only $p(x|z_t)$ and $p(x)$ to be specified, and we can get the others by subtracting these from 1.

An example $z_{t}$ here can be pass-through / hit information.

The algorithm derived above uses the \emph{inverse sensor model} $p(x|z_{t})$, instead of the familiar forward model $p(z_{t}|x)$. The inverse sensor model specifies a distribution over the (binary) state variable as a function of the measurement $z_{t}$.

\subsection{Problems with this Derivation}

\begin{figure}[h!t]
  \centering
  \includegraphics[width=10cm]{img/occGrid.eps}
  \caption{}
  \label{fig:occGrid}
\end{figure}

At the beginning of this derivation we make the Markov assumption and say that: $p(z_t|x,z_{1:t-1}) = p(z_t|x)$. This would have been a reasonable assumption if $x$ were to represent the state of the complete map. But we should not forget that $x$ in occupancy map represents the state of a single grid cell. Hence, Markov assumption does not really make sense: we can not say that the observation data is independent of everything else if we know the state of a single cell. Fig.~\ref{fig:occGrid} presents an example case where this assumption can be problematic.

\section{Density Mapping}

In occupancy grid mapping every grid cell is either filled or empty. 
But there may be cases when we want a cell to be partially filled. 
This can happen in different ways; we may want the density of a cell to represent when some part of the grid cell is filled and the rest is empty; or when the objects that ``fill'' the grid cell have different characteristics: we may want a grid filled with tree branches to be ``less filled'' than a grid filled with a solid rock.

For this we use a real number between $[0,1]$, representing the density of a grid cell.
Beta distributions are usually used for this purpose:

\begin{equation}
Beta(\alpha_{1}, \alpha_{2})
\end{equation}

\begin{figure}[h!t]
  \centering
  \includegraphics[width=10cm]{img/beta.eps}
  \caption{}
  \label{fig:beta}
\end{figure}

Some examples of Beta distributions are shown in Fig.~\ref{fig:beta}.

One good way to parametrize the Beta distribution can be:

%\begin{equation}
\begin{flalign}
\alpha_{1}& = \text{number of hits} \\
\alpha_{2}& = \text{number of pass-throughs}
\end{flalign}
%\end{equation}

The density of a cell can be represented as:

\begin{equation}
\frac{\alpha_{1}}{\alpha_{1} + \alpha_{2}}
\end{equation}

\end{document}

