Motion Planning Optimization


Motion Planning Optimization

Hope
Welcome back to CS 287. Before we move into new material, let’s catch up on two motion-planning topics from the end of the previous lecture: LQR trees and shortcutting. They’re useful ideas, but they’re not the main focus of today’s class.

Michael
Let’s start with LQR trees. The basic motivation is that sampling-based motion planners tend to explore locally, while LQR can describe a region of attraction around a solution. Combining motion planning with LQR can make a planner more efficient by using those ideas together.

Hope
The other idea is shortcutting. A sampling-based planner may produce a jagged path with small detours. If you can safely replace a section of that path with a simpler connection—often a straight line—you can shorten it.

Michael
But that depends on the system’s dynamics. A straight-line shortcut is only appropriate if the system can follow that path and there’s no obstacle in the way. For systems with more particular dynamics, you can’t assume that any straight line is feasible. And a controller may be run afterward to smooth the path and make it locally optimal.

Hope
Now we’re shifting to the other half of the course. So far, we’ve focused on choosing actions to optimize expected reward. Now we’ll ask how a robot can make sense of noisy sensory readings, estimate what state it might be in, and then act using that estimate.

Michael
That means probability becomes central. We’ll begin with discrete Bayes filters, where both the state and observations have discrete possibilities, and then use Gaussians to work with continuous states. The larger goal is to combine state estimation with action and reward; that leads to partially observable Markov decision processes, or POMDPs.

Hope
Why does a robot need probability in the first place? Often, its state and the state of its environment are unknown, and its sensors are noisy. Probability gives us a way to combine those readings into a distribution over the possible states, rather than pretending we know the exact state.

Michael
There’s a second reason: the robot’s dynamics can also be stochastic. An action doesn’t necessarily lead to one guaranteed outcome, so we may need to reason about a distribution over outcomes. Later, we’ll bring these ideas together by considering actions that actively seek information about the world.

Hope
Take a helicopter. Its state might include position, orientation, velocity, and angular rate. But there isn’t one sensor that simply reports all of those perfectly. GPS gives a noisy estimate of position, sometimes velocity, and it may only be accurate to within a couple of meters.

Michael
A three-axis gyroscope measures angular rate around the helicopter’s three main axes. An accelerometer is subtler: in free fall it measures zero, while an accelerometer on the ground measures the force opposing gravity—about 9.81 meters per second squared. So accelerometers often help estimate orientation by revealing the direction of gravity, not just acceleration in the everyday sense.

Hope
A three-axis magnetometer measures the magnetic field in the sensor’s frame. Since Earth’s field has a known direction, that can also provide orientation information. But nearby magnets, electrical currents, or power lines can disturb the measurement, so it may not reflect Earth’s field cleanly.

Michael
And even the helicopter’s motion is uncertain: wind adds noise, and the engine, servos, and blades have dynamics that may not be fully modeled. Put all that together, and the sensible result is a likely estimate—or a distribution around a likely state—not a claim that the state is known exactly.

Hope
A mobile robot in a building has a similar problem. Its state might be just its position and heading if it moves slowly enough that velocity isn’t important. Wheel encoders provide odometry by measuring how much the wheels turn, but the robot might slip or encounter an uneven floor, so wheel rotation doesn’t translate perfectly into distance traveled.

Michael
A laser range finder gives another kind of information: it sends out a beam and measures the returning signal to estimate how far away a surface is. Mirrors and glass can cause trouble because the beam may reflect away instead of returning. And wheel slippage or bumps make the robot’s motion uncertain even when its encoder readings are available.

Hope
Those examples make the point: robots get measurements related to the state, not a perfect state reading. Probability gives us a systematic way to turn that sensory information into beliefs about what the state could be.

Michael
Let’s review the basic probability rules. We describe possible outcomes using events, and the probability of an event is a number between zero and one. The event that includes every possible outcome, often written as omega, has probability one; the empty event has probability zero.

Hope
For two events, A and B, the probability that either occurs is the probability of A plus the probability of B, minus the probability of their intersection. We subtract the intersection because otherwise outcomes where both A and B occur would be counted twice.

Michael
That rule also gives a useful result about complements. A and its complement together cover all possible outcomes, and they don’t overlap. So their probabilities add to one: the probability of not-A is one minus the probability of A.

Hope
A random variable is a way to describe some property of an outcome. For a discrete variable, it has a finite or countable set of possible values, and we assign probability mass to those values. A coin flip is a simple example: heads and tails each have probability one-half.

Michael
For a continuous variable, there are infinitely many possible values along a continuum, so we don’t assign a nonzero probability to each individual value. Instead, we use a probability density function. The probability that X falls between A and B is the area under the density curve from A to B—the integral over that interval.

Hope
The key idea for robotics is often not a distribution over one variable, but a joint distribution over two or more. For example, we want to relate a robot’s state to a sensor reading, or relate its state now to its state after an action.

Michael
A joint distribution tells us the probability of particular values occurring together. If X and Y are independent, then the joint probability factors into the probability of X times the probability of Y. In that case, knowing X tells us nothing about Y. That can simplify calculations, though a sensor independent of the system state would not tell us anything useful about that state.

Hope
Conditional probability asks about X in the case where we already know Y. For discrete variables, the probability of X given Y is the joint probability of X and Y divided by the probability of Y. Equivalently, the joint can be written as the probability of Y times the probability of X given Y.

Michael
That factorization is useful when we know the distribution of Y and have a model for how X depends on Y. For instance, a model of the transition from one state to the next can help us construct their joint distribution. If X and Y are independent, then knowing Y does not change the distribution of X: the conditional distribution reduces to the marginal distribution of X.

Hope
Two rules will show up repeatedly. First is the law of total probability: to get the probability of X, sum the joint probability of X with each possible value of Y over all those values. You’re essentially summing out a variable you no longer need.

Michael
If you already know some other information, say Z, you can use the conditioned version: sum over Y of the probability of Y given Z times the probability of X given Y and Z. The important thing is to carry the condition Z through every part of the calculation. For continuous variables, the sum becomes an integral.

Hope
The second rule is Bayes’ rule. It lets us reverse the direction of a probability relationship: the probability of X given Y is the probability of Y given X, times the prior probability of X, divided by the probability of Y.

Michael
That reversal matters because sensor models are usually easiest to describe in the causal direction: if the state is X, what readings might the sensor produce? But the question we want answered is diagnostic: given the reading Y, what states X are plausible? Bayes’ rule combines the sensor model with the prior over states to answer that.

Hope
The pieces have familiar names. The probability of X before seeing the measurement is the prior. The probability of the measurement given X is the likelihood. The probability of the measurement itself is the evidence, which normalizes the result so the probabilities over X add up to one.

Michael
In practice, for each possible state X, we multiply its prior by the likelihood of the observed reading. Those products might not add up to one, but they’re all missing the same normalization factor. Divide every entry by their total, and you have the posterior distribution.

Hope
Bayes’ rule also works when we’re already conditioning on earlier information. If we have evidence Z and then observe Y, we can update the distribution over X while consistently keeping Z in the equations. That’s how we combine new evidence with what we already knew.

Michael
A related idea is conditional independence. X and Y can be dependent overall, but become independent once we know Z. Formally, given Z, their joint distribution factors into the distribution of X given Z times the distribution of Y given Z.

Hope
A simple illustration is rain, umbrellas, and wet pavement. Rain can make umbrellas more likely and pavement wet. Once we know it’s raining, whether someone carries an umbrella and whether the pavement is wet can be treated as conditionally independent in this model: their connection is explained by their shared cause.

Michael
In robotics, a common approximation is that sensor readings are independent of one another once we know the true state. That lets us simplify the math, but it’s an assumption, not a universal fact. Independence assumptions are useful when they’re reasonable; they can also make an otherwise difficult calculation tractable.

Hope
Let’s make Bayes’ rule concrete with a door sensor. Suppose Z is a particular sensor reading. The sensor reports Z with probability 0.6 when the door is open, and with probability 0.3 when it isn’t. If our prior says the door is open with probability one-half, observing Z should raise our belief that it’s open.

Michael
Applying Bayes’ rule gives a posterior probability of about 0.67 that the door is open. Notice what we did: we used the easier-to-model probability of a reading given the door state, plus our prior, to find the probability of the state given the reading.

Hope
Now suppose we get a second reading, Z2, that’s more likely when the door is closed. We can apply Bayes’ rule again, conditioning on what we already observed. Since the new reading favors the door being closed, we expect our probability that it’s open to decrease—and the calculation confirms that.

Michael
If sensor readings are conditionally independent given the state, we can update repeatedly. The posterior is proportional to the prior multiplied by the likelihood of each reading given the state. That means we need a sensor model for each reading given the state, rather than a separate model for every reading given all the others.

Hope
But be careful: repeated readings aren’t automatically independent. Two nearby laser beams might encounter the same interference. Or a sensor read twice without any meaningful change in the world might produce highly related readings.

Michael
If we treat copies of one reading as ten independent pieces of evidence, we multiply its likelihood ten times. The result is an overconfident belief: a reading that should move us from one-half to about two-thirds might, if repeated as though it were independent many times, push us toward 99 percent.

Hope
That can happen with physical sensors, too. A gyroscope may need time to settle, so readings taken extremely rapidly may not be independent. If we count thousands of correlated readings as thousands of independent observations, we can become wildly overconfident. Always ask whether the readings really provide separate information.

Michael
Now let’s turn from evidence to actions. Actions also involve uncertainty: a robot might try to close a door and fail, or its motion might be affected by wheel slip. We can represent that with a dynamics model: the probability of the next state, X prime, given the current state X and the action U.

Hope
If we already have a distribution over the current state, the law of total probability gives us a distribution over the next state. Multiply the current-state belief by the transition probability for each possible next state, then sum over the old state. In other words, account for every possible starting state that could lead to the next one.

Michael
A Bayes filter combines those action updates with sensor updates. We assume a prior distribution to start, a model of how actions change the state, and a model of how states produce observations. The goal is a running belief: a distribution over the system’s state at each time.

Hope
The standard Bayes-filter picture makes a few assumptions. The next state depends on the previous state and the action, and the observation depends on the current state. Those are first-order Markov assumptions: once the current state is known, earlier states and readings aren’t needed to predict the next state or observation.

Michael
In practice, the state we use may not capture everything about the world, so those assumptions might only be approximate. If important history is missing, the model may need to include more of it. Choosing how much history to include is a trade-off between representing the system well and keeping the computation manageable.

Hope
Here’s the filter’s update logic. First, when a new observation arrives, use Bayes’ rule: multiply the predicted state belief by the likelihood of that observation given each possible state, then normalize. That incorporates the latest measurement.

Michael
To predict through an action, use the transition model and the law of total probability: combine the old belief with the probability of each next state under the action, then sum over the old states. The result is the belief before incorporating the next observation.

Hope
Put those steps together and the filter runs recursively. Start with the belief at time T minus one, predict forward using the action, then update using the observation at time T. You don’t need to recompute everything from scratch at every step; the current belief summarizes what the filter has already used.

Michael
That summary is sometimes called a belief state. It’s shorthand for the distribution over the current state given the history of observations and actions. The notation doesn’t mean the history was ignored; it means its relevant information has been carried forward into the belief.

Hope
For a mobile robot localizing in a mapped building, imagine it has noisy sensors that check for walls in different directions. At first, it might assign equal probability to all possible locations. A wall reading then rules out or downweights some locations and makes others more plausible.

Michael
When the robot moves, uncertainty can spread because its motion is noisy. Another measurement can then shrink the distribution again. Repeating prediction and measurement updates may let the robot localize itself over time—but this example depends on having a map to compare its readings against.

Hope
So far, we’ve described the probability rules and the discrete Bayes filter. The next step is to represent uncertainty in continuous spaces using Gaussians. A univariate Gaussian is the familiar bell-shaped density, centered at its mean, mu, with standard deviation sigma.

Michael
About 68 percent of the probability mass lies within one standard deviation of the mean. The density falls away on either side, and its exact formula includes a normalization factor of one over sigma times the square root of two pi, which ensures that the total area under the curve is one.

Hope
The mean of a Gaussian is mu, and its variance—the expected squared distance from the mean—is sigma squared. Those quantities describe the center and spread of the distribution, which makes Gaussians a compact way to represent uncertainty.

Michael
There’s also a deeper reason Gaussians appear so often: the central limit theorem. Roughly, if you add up many independent random variables with the same finite mean and variance, center and rescale the sum, its distribution approaches a standard Gaussian as the number of variables grows.

Hope
That means a quantity influenced by many independent factors may be approximately Gaussian, even if the individual factors aren’t Gaussian themselves. So Gaussians are useful not only because their math is manageable, but also because they can be a reasonable model of how uncertainty arises.

Michael
For several variables, a multivariate Gaussian uses a vector of means and a covariance matrix. The covariance matrix describes how each variable varies and how pairs of variables move together. It is symmetric, and its diagonal entries describe each variable’s variance.

Hope
An off-diagonal covariance is positive when two variables tend to be above their means together, or below their means together. It’s negative when one tends to be above its mean while the other is below. If there’s no linear relationship of that kind, the covariance is zero.

Michael
A useful way to picture the covariance matrix is to imagine rotating into a coordinate system where it is diagonal. In those coordinates, the Gaussian has independent directions with their own variances. In the original coordinates, the same distribution may look like a tilted ellipse.

Hope
That’s what the contour plots show. If two coordinates are positively correlated, the density stretches along the diagonal where both are above or both below their means. Stronger positive correlation makes that stretch more pronounced. Negative correlation tilts the ellipse the other way.

Michael
Changing the diagonal variances changes the spread in each direction: smaller variance makes the distribution narrower and taller, while larger variance spreads it out. And shifting the mean moves the center of the distribution without changing that basic shape.

Hope
That brings us to the point of today’s lecture: probability lets us represent uncertainty, Bayes’ rule lets us update beliefs from observations, and dynamics models let us predict how actions change those beliefs. Bayes filters combine those steps over time, and Gaussians will help extend the same ideas to continuous state spaces.

Michael
One last reminder: probability backgrounds vary, so take time to review if the pace felt fast. The rules we’ll keep using are the law of total probability, Bayes’ rule, and conditional independence. Getting comfortable with those will make the upcoming Gaussian calculations and continuous-state filters much easier to follow.

Ask anything
We've read this whole study set, so questions about it get the best answers.