Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Semantic Mode Evidence for Hybrid Smoothing

In HybridInference the prior on a motion mode is a number typed into a DecisionTreeFactor. A robot usually has more to go on than that: operator notes, map labels and log lines that say something about the ground it is driving over. This notebook turns such text into a unary DecisionTreeFactor on each step’s mode and lets the hybrid factor graph weigh it against the geometry.

The setup:

  • A wheeled robot drives 40 steps with wheel odometry and a noisy GPS fix every 4 steps.

  • Each odometry step has a binary mode mk∈{normal,slippery}m_k \in \{\text{normal}, \text{slippery}\}. On slippery ground the wheels spin, so the robot moves less than odometry reports.

  • Each step also comes with a one-line note, such as “Sprinklers ran on the lawn crossing at dawn.”

Between GPS fixes the geometry can tell that the robot fell short, but not on which steps. The notes can say which. We compare four sources for the per-step factor P(mk)P(m_k):

sourceP(mk=slippery)P(m_k = \text{slippery})
geometrya fixed prior of 0.25 for every step
keywords0.85 if the note matches a list of slippery words, else 0.2
language modelthe probability a language model gives when asked whether the note describes slippery ground
oracle0.9 or 0.1 from the true mode (an upper bound)

The language-model probabilities come from Jev, TypeSafe’s calibrated decision model, following Frank Dellaert’s use of it as a zero-shot source of factors for discrete Bayes nets. They are recorded below, so the notebook runs without an API key; set LIVE = True to query the model again.

Open In Colab

Notes

Five kinds of note. Two of them are hard for keywords on purpose: slippery ground described without any slippery word, and ordinary ground described with one (“slip ring”, “dry ice”). The last slippery kind carries no information at all, so no reader can find those steps from the text.

Routes

Slippery zones of 2 to 4 steps start with probability 0.12 at each step, so about 30% of the steps are slippery. On a slippery step the robot covers only 30 to 70% of the commanded 1 m.

step  1  normal    Grease trap inspection scheduled for next week.
step  2  slippery  Spilled cleaning fluid across the corridor outside the lab.
step  3  slippery  Spilled cleaning fluid across the corridor outside the lab.
step  4  normal    Concrete floor in warehouse zone 2.
step  5  normal    Rubber mat at the office entrance.
step  6  normal    Carpeted corridor B, quiet.
step  7  slippery  Battery at 64 percent, on schedule.
step  8  slippery  Continuing to waypoint 7.
step  9  slippery  Door to room 214 is closed.
step 10  slippery  Passing the break room.
step 11  slippery  Heavy dew on the grass shortcut this morning.
step 12  slippery  Sprinklers ran on the lawn crossing at dawn.

Evidence

Language models answer confidently, often with probabilities of exactly 0 or 1. A factor value of 0 makes a mode impossible, so the geometry could never overrule it. We therefore clip the probabilities to [ϵ,1−ϵ][\epsilon, 1-\epsilon] with a floor ϵ\epsilon that is revisited at the end.

Each odometry step is a HybridNonlinearFactor with a tight and a loose component, as in HybridInference. Each component carries its noise model’s negLogConstant(), the negative log of the Gaussian’s normalization constant. Without it the loose component would explain any motion at no extra cost. The evidence is a DecisionTreeFactor on the same mode, and the GPS fixes are position priors.

DCSAM alternates between the continuous and the discrete estimate, so it finds a local optimum, and its first discrete step is taken at the initial poses. We therefore run it from two starts: the poses that the evidence’s most likely modes give, and the poses with every step loose, which lets the GPS show where the robot fell short. We keep the solution with the lower graph error, i.e. the higher posterior.

Results over 40 routes

source           mode accuracy  position RMSE [m]
geometry                 0.824              0.305
keywords                 0.765              0.399
language model           0.937              0.295
oracle                   0.999              0.162

mode accuracy by note         geometry        keywords  language model          oracle
slip_explicit                    0.689           0.985           1.000           1.000
slip_implicit                    0.643           0.298           0.994           0.994
slip_silent                      0.692           0.144           0.058           1.000
norm_plain                       0.880           0.975           0.999           1.000
norm_trap                        0.903           0.564           0.997           1.000

Geometry alone finds about two thirds of the slippery steps of every kind from the shortfall between GPS fixes, but often blames the wrong steps within an interval. Keywords help on plainly worded notes and fail on the other two kinds by construction. The language model reads the implicit notes and ignores the traps, so it gets nearly every step with an informative note right. On the silent notes it says “normal” with confidence and the solver follows it, where geometry alone finds most of those slips. That is why its position error is only a little below that of geometry, while the oracle shows how much better the trajectory gets when every mode is right.

Loading...

One route up close

The trajectories show where the error comes from. Dead reckoning trusts every odometry step, so it overshoots each slippery stretch. The graph pulls the trajectory back toward the GPS fixes, and the mode evidence decides which steps absorb the correction.

Loading...

The mode probabilities involved are of two kinds. The evidence is the unary factor P(mk)P(m_k) that each source puts on a step. The posterior combines it with the geometry: given the estimated poses, the mode of step kk is coupled only to its own odometry factor and evidence, so discretePosterior on a graph with just those two factors gives P(mk∣xk−1,xk)P(m_k \mid x_{k-1}, x_k).

Loading...

How hard to floor the language model

A higher floor keeps the text evidence from overruling the geometry when the note is uninformative. Here it helps little. At a floor of 0.4, in about half of the routes where silent slips are missed, marking them slippery would lower the graph error, so the misses come partly from DCSAM settling in a local optimum and not only from the evidence.

 floor  mode accuracy  silent-slip accuracy  position RMSE [m]
  0.05          0.937                 0.058              0.295
  0.10          0.937                 0.058              0.295
  0.20          0.937                 0.058              0.295
  0.30          0.937                 0.106              0.290
  0.40          0.934                 0.125              0.284

Remarks

  • The notes here are synthetic. What carries over is the pattern: a text source turned into a floored unary factor per discrete mode, fused with geometry by the hybrid graph.

  • The wording of the request matters on borderline notes. With a shorter task description (“judge the ground traction from the note attached to it”), “Grease trap inspection scheduled for next week” came back 0.58 slippery instead of 0.10. Repeating an identical request changed probabilities by at most 0.02.

  • Ask the language model to compare described options (“normal” or “slippery” for this note). Numbers it would have to estimate, such as noise levels or how often slipping happens, belong in the model or should be learned from data.

  • DCSAM is a local method, and the start matters as much as the evidence. Started only from the all-loose poses, the language model reaches a mode accuracy of 0.86 instead of 0.94. Trying more than one start and comparing graph errors is cheap.