Skip to the lesson
FixTheRobot Explore Robotics / Probability for Robotics / M5 Probabilistic Motion and Observation Models / M5-T1

Probability for Robotics · Theory · M5

M5-T1 — State, Controls, Measurements and the Markov Assumption

Before a filter can run, someone must decide what the state is. The Markov assumption says the state must summarise the past well enough that the past can be forgotten.

  • Lesson 1 of 4
  • Intermediate
  • Module 5: Probabilistic Motion and Observation Models
  • Theory
  • About 16 minutes to read

Every probabilistic filter in this course rests on a small set of modelling decisions: which quantities make up the state, what counts as a control and what as a measurement, and the assumption that the state is complete. This lesson names the objects, draws the structure that connects them, derives the factorization of the joint distribution that follows, and shows with a simulation what it means for a state to be incomplete and how to repair it.

Learning objectives

After this lesson, you should be able to:

  • Distinguish the state, the controls and the measurements of a robot, and give a state for a ground robot, a drone and a humanoid.
  • Draw the dynamic Bayes network of a robot and name its two conditional distributions, the motion model and the measurement model.
  • State the Markov assumption and derive the factorization of the joint distribution that it gives.
  • Test whether a state is complete from data, and repair an incomplete state by adding variables.

The intuition

Three kinds of quantity appear in every robot filter, and keeping them apart avoids a great deal of confusion.

  • The state xtx_t is what the robot needs to know in order to predict what happens next: its pose, and often its velocity, sensor biases, or the positions of landmarks. It is hidden: nothing measures it directly, and the filter keeps a belief about it.
  • The controls utu_t are what the robot does: a commanded speed and turn rate, or the wheel-encoder increments between two moments. They are known (though not exact), and they are the input of the motion model.
  • The measurements ztz_t are what the sensors report: ranges, bearings, images, GNSS fixes. They are known, and they depend on the state.

The structure that links them is the same for a vacuum robot and a spacecraft, and is drawn below. Time runs from left to right. The new state depends on the previous state and the control, and the measurement depends on the current state. Nothing else is connected: in particular there are no arrows from old states or old measurements straight into the new state.

The dynamic Bayes network of a robot: states, controls and measurementsA chain of four state circles x0 to x3 connected by arrows from left to right. Above each state after the first, a control circle u1, u2, u3 sends an arrow into the state. Below each state after the first, a measurement circle z1, z2, z3 receives an arrow from the state. A bracket on the horizontal arrows reads motion model, probability of the new state given the previous state and the control. A label under the vertical arrows reads measurement model, probability of the measurement given the state. The only link between one time step and the next goes through the state.x₀x₁x₂x₃u₁u₂u₃z₁z₂z₃ motion model p(xₜ | xₜ₋₁, uₜ) measurement model p(zₜ | xₜ) controls ucommands or odometrystates xwhat the robot must knowmeasurements zsensor readings
The dynamic Bayes network behind every filter. Each state depends on the one before it and on the control; each measurement depends on the state it was taken at. The two conditional distributions, the motion model and the measurement model, are all a filter needs.

The missing arrows are a claim about the world, the Markov assumption: once the current state is known, the past (earlier states, controls and measurements) carries no further information about the future. It is a statement about the choice of state. If the robot's next position depends on how fast it is going, and the speed is not in the state, then the assumption is false: the previous position also matters, because it reveals the speed. The repair is to put the speed in the state.

What goes in the state?

Typical states
RobotA typical stateWhy each part is there
Slow indoor ground robot(x,y,θ)(x, y, \theta)Its pose. Velocity is neglected because the wheels stop and start quickly.
Fast car-like robot(x,y,θ,v,ω)(x, y, \theta, v, \omega)Speed and turn rate matter: the vehicle cannot change them instantly, so the next pose depends on them.
Drone with an IMUposition, velocity, orientation, gyro bias, accelerometer biasBiases drift slowly and corrupt the dead reckoning; they must be estimated, so they belong in the state.
Humanoidbase pose and velocity, joint angles and rates, foot contact statesWhether a foot is on the ground decides what the next step does.
SLAMrobot pose plus the positions of landmarks (or the whole trajectory)The map is unknown and shapes every measurement.

The state is a modelling choice with one test: does knowing it make the past irrelevant for predicting the future? If not, something is missing from it.

Definitions

State xtx_t
The collection of quantities that, if known, would make the future independent of the past. Not directly observed.
Control utu_t
The action or its measured effect between time t−1t-1 and tt. Treated as a known input, although a command is not what the robot actually did.
Measurement ztz_t
The sensor data at time tt.
Motion model p(xt∣xt−1,ut)p(x_t \mid x_{t-1}, u_t)
The distribution of the new state given the old state and the control: the physics, with its uncertainty.
Measurement model p(zt∣xt)p(z_t \mid x_t)
The distribution of the reading given the state: the sensor, with its noise. Also called the observation or sensor model. As a function of xtx_t with the reading fixed it is the likelihood of the last module.
Complete state
A state such that xtx_t alone summarises everything in the past that is relevant for the future. Also called a Markov state.
Markov assumption for the motion
p(xt∣x0:t−1, z1:t−1, u1:t)=p(xt∣xt−1, ut)p(x_t \mid x_{0:t-1},\, z_{1:t-1},\, u_{1:t}) = p(x_t \mid x_{t-1},\, u_t)
Given the previous state and the control, the earlier history adds nothing.
Markov assumption for the measurement
p(zt∣x0:t, z1:t−1, u1:t)=p(zt∣xt)p(z_t \mid x_{0:t},\, z_{1:t-1},\, u_{1:t}) = p(z_t \mid x_t)
Given the current state, the reading does not depend on the earlier history or on the earlier readings (conditional independence of the readings, last module).
The joint distribution of a whole run
p(x0:t, z1:t∣u1:t)=p(x0)  ∏k=1t  p(xk∣xk−1,uk)   p(zk∣xk)p(x_{0:t},\, z_{1:t} \mid u_{1:t}) = p(x_0)\; \prod_{k=1}^{t}\; p(x_k \mid x_{k-1}, u_k)\;\, p(z_k \mid x_k)
A prior over the starting state, and then one motion model and one measurement model per step. Every filter and smoother in this course is a way of computing with this one product.

Derivation: the factorization of a robot run

The joint distribution of everything a robot does and sees looks hopeless: it has one variable per state, per reading, for every moment of a run. The Markov assumptions collapse it into a product of small pieces. The derivation is the chain rule with some terms dropped.

  1. p(x0:t,z1:t∣u1:t)=p(x0)  ∏k=1t  p(xk∣x0:k−1,z1:k−1,u1:t)   p(zk∣x0:k,z1:k−1,u1:t)p(x_{0:t}, z_{1:t} \mid u_{1:t}) = p(x_0)\; \prod_{k=1}^{t}\; p(x_k \mid x_{0:k-1}, z_{1:k-1}, u_{1:t})\;\, p(z_k \mid x_{0:k}, z_{1:k-1}, u_{1:t})

    The chain rule (the joint-probability lesson), ordering the variables in time: first x0x_0, then for each step the new state followed by the new measurement, each conditioned on everything before it.

  2. p(xk∣x0:k−1,z1:k−1,u1:t)=p(xk∣xk−1,uk)p(x_k \mid x_{0:k-1}, z_{1:k-1}, u_{1:t}) = p(x_k \mid x_{k-1}, u_k)

    Markov assumption for motion. The new state depends on the previous state and the current control only. In particular it does not depend on later controls uk+1:tu_{k+1:t}: what the robot will do next cannot affect where it is now.

  3. p(zk∣x0:k,z1:k−1,u1:t)=p(zk∣xk)p(z_k \mid x_{0:k}, z_{1:k-1}, u_{1:t}) = p(z_k \mid x_k)

    Markov assumption for measurement. The reading depends on the state at that moment only.

  4. p(x0:t,z1:t∣u1:t)=p(x0)  ∏k=1t  p(xk∣xk−1,uk)   p(zk∣xk)p(x_{0:t}, z_{1:t} \mid u_{1:t}) = p(x_0)\; \prod_{k=1}^{t}\; p(x_k \mid x_{k-1}, u_k)\;\, p(z_k \mid x_k)

    Substitute. The joint is a product of one prior and 2t2t small conditional distributions, each over one or two variables.

Two consequences are worth stating, because they are what the filters of the next modules exploit.

  • Recursion. To update the belief about xtx_t you need only the belief about xt−1x_{t-1}, the new control and the new measurement. The history can be thrown away. This is what makes the filter a loop of constant cost per step.
  • Conditional independence. Given the state, the readings of different times are independent, which is exactly what allows the product of likelihoods of M3-T3: Independence and Conditional Independence.

Testing completeness

If the state is complete, then adding more of the past to the conditioning does not sharpen the prediction: p(xt∣xt−1,xt−2)=p(xt∣xt−1)p(x_t \mid x_{t-1}, x_{t-2}) = p(x_t \mid x_{t-1}). So a practical test from logged data is to predict the next state from the last state alone and from the last two, and compare the errors. A large improvement means the past still carries information, and the state is incomplete. The worked example does exactly this.

The Markov assumption is a design decision about the state, not a law of nature. A state is complete when its past is irrelevant, and you make it complete by adding the variables through which the past still acts.

A worked example

A robot drives along a line. Its speed vv is about 1.2 m/s and drifts slowly (a random change of 0.02 m/s per step); the position follows the speed with a little extra noise, time step 0.1 s. We simulate 2000 steps and ask: is the position alone a complete state?

  1. Predict from the last position only. The best guess for the next position is the last one, which ignores that the robot is moving. The root-mean-square error is 0.1220.122 m: about one step of travel, v Δt=0.117v\,\Delta t = 0.117 m.
  2. Predict from the last two positions. The difference of the last two positions is an estimate of the velocity. Extrapolating with it, x^t=2xt−1−xt−2\hat{x}_t = 2x_{t-1} - x_{t-2}, gives an error of 0.0034 m, 36 times smaller.
  3. Predict from position and speed. With the true speed in the state, the error is 0.0028 m, hardly better than the two-position predictor, which has already recovered the speed from the history.
  4. The verdict. Adding one earlier position shrank the error by a factor of 36, so the position alone is not a complete state: the past still matters, through the speed. The cure is to add the speed to the state, and then the history is no longer needed (the third predictor). This is why the constant-velocity filter of module 7 has the state (position, velocity).
import math
from robotprob import Rng

rng = Rng(14)
dt, n = 0.1, 2000
x, v = 0.0, 1.0
xs, vs = [], []
for _ in range(n):
    v += rng.gauss(0.0, 0.02)                 # the speed drifts slowly
    x += v * dt + rng.gauss(0.0, 0.002)       # the position follows the speed, plus a little noise
    xs.append(x)
    vs.append(v)

def rms(e):
    return math.sqrt(sum(a * a for a in e) / len(e))

e_last = [xs[t] - xs[t - 1] for t in range(2, n)]                      # predict x_t = x_{t-1}
e_vel = [xs[t] - (2 * xs[t - 1] - xs[t - 2]) for t in range(2, n)]     # extrapolate with the last step
e_state = [xs[t] - (xs[t - 1] + vs[t - 1] * dt) for t in range(2, n)]  # use position and speed
print('prediction error of the next position (rms, metres):')
print('  from the last position only        :', round(rms(e_last), 4))
print('  from the last two positions        :', round(rms(e_vel), 4))
print('  from position and the true speed   :', round(rms(e_state), 4))
print('mean speed', round(sum(vs) / n, 3), ' so the first number is about speed * dt =', round(sum(vs) / n * dt, 4))
prediction error of the next position (rms, metres):
  from the last position only        : 0.122
  from the last two positions        : 0.0034
  from position and the true speed   : 0.0028
mean speed 1.174  so the first number is about speed * dt = 0.1174
The speed is hidden state: in a real system only the positions would be measured, and the speed would be estimated by the filter.

In robotics

Choosing the state is the first design step of a filter

Writing a localizer starts with a list: which quantities does the next pose depend on, and which of them are not directly measured? An omnidirectional base that can change velocity instantly can use the pose alone. A heavy delivery robot with wheel-speed controllers has dynamics (acceleration limits, slip) that a velocity belongs in the state to capture. A drone's attitude estimate needs the gyroscope biases as states, because they would otherwise appear as an unexplained slow drift. The UAV course derives such a state in Error-State Kalman Filter and PX4 state estimation and EKF2.

Controls are not exact

The control in the motion model is what the robot is believed to have done, with noise. Many robots use the wheel-encoder increments from the last step as the “control” (the odometry motion model of M5-T2: Odometry and Velocity Motion Models), because they are a better description of the motion than the commanded velocity. A commanded velocity is not what the wheels did: slip, acceleration limits and latency all intervene. Treating either as exact makes the filter overconfident.

Where the assumption fails in practice

  • Unmodelled dynamics and latency. A command that takes 100 ms to act means the state at time t depends on the control at time t − 3: the past still matters unless the delay is modelled (state augmentation).
  • Correlated sensor errors. If the error of a GNSS fix persists for seconds, the measurement at time t depends on earlier readings beyond the state, as in M3-T3: Independence and Conditional Independence. Add a slowly varying error term (a bias) to the state.
  • Dynamic environments. A person walking through the scan makes the measurement depend on something outside the state. Treat it as an outlier component of the measurement model, or track the person as part of the state.
  • Map errors. A localizer that treats the map as given is Markov only if the map is correct. SLAM adds the map to the state to remove this assumption.

More state is not free

Each added variable costs computation (the cost of a Kalman update grows as the cube of the number of states) and needs to be observable, meaning the measurements must contain information about it. An added state that no measurement can see just drifts; module 7 discusses observability. The aim is the smallest state that makes the past irrelevant.

Common misconceptions

“Markov means the robot has no memory.”

The robot’s memory is its belief about the state. The Markov assumption says that this state is enough, not that the robot forgets everything. A state with velocity, biases and a map is a lot of memory; what is dropped is the history of how the state came to be.

“The state is whatever the sensors measure.”

The state is what needs to be known; sensors give only noisy, partial views of it. A robot has no sensor that reads its pose, and a gyroscope bias is never measured at all, yet both are states that filters estimate.

“The control is exact because we commanded it.”

A command is an intention. The wheels slip, the motors lag and the floor is not flat, so the motion model must treat the control as uncertain. In practice measured odometry is a better control than the command.

“If the filter works, the Markov assumption holds.”

Filters often work well enough with an incomplete state, at the price of tuning the noise up to cover what is missing. A filter that needs a very large process noise to stay consistent is telling you that the state is incomplete.

Key takeaways

  1. The state is what the robot needs to know to predict the future (hidden); the controls are its actions or odometry (known, noisy); the measurements are the sensor data, which depend on the state.
  2. A robot run is described by a prior p(x₀) and, per step, a motion model p(xₜ | xₜ₋₁, uₜ) and a measurement model p(zₜ | xₜ).
  3. The Markov assumption: given the current state, the past adds nothing. It turns the joint distribution into p(x₀) Π p(xk | xk−1, uk) p(zk | xk) and makes the filter recursive.
  4. A state is complete when predicting from its past does not improve with more history. Test it by comparing predictors that use one and two past values.
  5. An incomplete state is repaired by adding variables (speed, biases, delays, the map). Each addition costs computation and must be observable.

References and further reading

Each source is marked free or paid. Free to read does not mean free to reuse: the course resources page lists every source with its licence.

Knowledge check

Three questions. Write an answer, then reveal the explanation. Your answers stay in your browser.

Question 1

A mobile robot’s controller applies a commanded wheel speed that takes about 0.3 s to take effect, and the filter runs at 10 Hz with the state (x, y, θ). Is the Markov assumption satisfied? What would you change?

Explanation

No. With a 0.3 s lag, the motion over the last step depends on the command issued about three steps ago, which is not a function of the current pose and the current command. Predicting the next pose from (xt−1, ut) will be wrong whenever the commands have changed recently, and the errors will be correlated in time. Fixes: add the actual wheel speeds (or the last three commands) to the state so that the motion model sees what is really in force; or use the measured odometry as the control; or, as a last resort, inflate the process noise, which hides the problem and loses accuracy.

Question 2

You log the pose of a robot at 20 Hz and compare predictors of the next position: the last position, and a linear extrapolation from the last two positions. The extrapolation has an error 15 times smaller. What does this tell you about the state (x, y) and what is the next step?

Explanation

The past still carries information that the last position alone does not, namely the velocity, so the state (x, y) is not complete: the process is not Markov in position. The next step is to add velocity (vx, vy), or speed and turn rate, to the state and give the filter a motion model that moves the position by velocity × Δt with a small noise on the velocity. After that, a test with two lags of the augmented state should show almost no improvement over one lag, which is the sign that the state is now adequate.

Question 3

A teammate proposes adding every sensor reading of the last second to the state “to make the filter more accurate”. Give two reasons it is a bad idea in a Kalman filter, and say what to do if a sensor has errors that persist over a second.

Explanation

First, cost: a Kalman update grows with the cube of the state size, so hundreds of extra states make the filter far slower, and many of them would be unobservable (no measurement distinguishes them), which makes the covariance matrix ill-conditioned or singular. Second, the readings are not the state: they are noisy functions of it, and keeping them just reproduces the past without summarising it. For a sensor error that persists, add one variable for the persistent error itself (a bias or a first-order Gauss-Markov process) and estimate it. That is the compact summary of what the past says about the next reading.

What’s next

With the structure fixed, the next lesson builds the first of the two conditional distributions: the motion model, in its two standard forms, with the noise that makes the uncertainty of a dead-reckoned pose grow.

Next lesson

M5-T2 — Odometry and Velocity Motion Models

Write the odometry motion model with its noise parameters, sample from it, and explain the banana-shaped spread of a dead-reckoned pose.

Nothing below is required to finish this lesson.

Other courses on this site treat neighbouring topics from their own angle: