blog · robot navigation
Teaching a robot a path it has never driven
Drive a robot along twenty metres of a park path and it follows the next six hundred on its own. No training, no map: just an average, computed in the right space. Real network outputs from that park are below for you to play with.
Teach and repeat has a cost
Visual teach and repeat lets a robot follow a route after being driven along it once (the first post in this series explains why that works so reliably). But "once" means once per route. Every path the robot should ever take has to be driven by hand first; mapping a 0.08 km² urban park this way once took four days.
Yet many places where robots are useful repeat themselves. Rows in an orchard look alike. So do the corridors of a university building, the pavement along a river, or the sandy paths of a park. If the robot could learn what a path looks like instead of what this particular path looks like, it could follow paths it has never seen. That is the idea of visual teach and generalise (VTAG).
The first version of VTAG did this by fine-tuning a neural network to detect the chosen visual cue. It worked, but it needed thousands of training images and hours to days of training on a server for every new cue. In our paper in the Journal of Intelligent & Robotic Systems we replaced all of that with an average. It needs tens of images, no training at all, and it is ready the moment the operator stops driving.
The first VTAG
- Drive the pathRecord thousands of images.
- Train a networkFine-tune it on those images: hours to days.
- Load it on the robotTurn the recorded images into representations.
- NavigateMatch each live view against them.
VTAG with the average representation
- Drive the pathEach image becomes a representation, added to a running sum.
- Divide by TThe sum of T representations becomes their average.
- NavigateRight away, matching each live view against the average.
on the roboton a server
One network, one number
The robot uses a small convolutional network from our earlier work (the previous post explains it and lets you run it) (1.4 million parameters, about 15 ms per image on an NVIDIA Jetson). It was trained with contrastive learning for one job: given two pictures taken at the same place, possibly by day and by night or in summer and in winter, tell how far one is shifted horizontally against the other. It turns a 512 × 320 image into a grid of 6 × 64 cells, one per patch of the image, each holding 16 numbers that describe what is in that patch.
To compare two images, the robot slides one grid sideways over the other and, at every offset, multiplies the matching vectors and adds everything up. That gives a likelihood for every possible horizontal shift. The peak says where the scene sits compared with the stored image, and the robot steers proportionally to it. As in teach and repeat, steering towards that peak is all the control there is.
Why an average is the right answer
Suppose the operator drives a short stretch of path and the robot records T images. A live image matches this "path" well if it matches the training images well. Treating them as independent observations, the log-likelihood is the average of the log-likelihoods against each of them. The network was trained so that cross-correlating two representations gives exactly that log-likelihood, so
where Rl is the representation of the live image, Rtk those of the training images, and ⋆ the cross-correlation. The second equality is the whole trick: cross-correlation is linear, so the live image can be moved out of the sum. Comparing against all training images is the same as comparing against their average representation, a single 16 × 6 × 64 array of about 100 kB, which the robot can update with every new image while the operator is still driving.
This only works because the matching is linear. A cosine or Euclidean distance would not let the live image leave the sum. And note what the average does not mean: we are not estimating the "expected" feature. What is consistent across the training images (the edges of the path, where they always are) survives the averaging. What changes from image to image (a tree here, a bench there) averages out into something that matches nothing in particular.
the real network outputs · averaged and matched in your browser
Pick how many training images to average, then a view from further along the path.training images · the 20 m teach drive, 23 positions
front camera
rear camera
a live view the robot has never been taught
likelihood of every horizontal shift
A few things to try. With all 46 images averaged, the bold curve peaks where the path is, and the peak moves exactly as far as you turn the camera: that shift is the steering signal. The dashed line lies right on top of the bold one, which is equation (1) at work: the average of 46 comparisons and one comparison against the average are the same thing. Now switch off the rear camera and drop the slider to one position, so that the match rests on a single image, which also "remembers" its own trees and benches. For some views a second peak then takes over: the autumn view at 419 m lands about 100 px off. The coloured overlay shows which patches of the image support the winning shift, from blue (little) to red (most); you get it almost for free by stopping the sum in the cross-correlation one step early, before adding up over the image. Notice how much of it comes from the far part of the scene, around the tree line. We saw the same in the paper: distant features are more consistent from image to image, and each feature vector only sees a small patch, so wide nearby structures are hard for it to use.
None of these views was taught. The training images were taken in summer, under full leaves; the views come from two teach-and-repeat recordings of a route through the same park, one in late autumn and one in snow, made on other days. The average still finds the path in most of them, because the network was trained to ignore this kind of change in appearance.
the whole 600 m route · one dot per view
When the route was recorded, the robot drove along the middle of the path, so the right answer for every view is close to "straight ahead", a shift near zero; on bends the path ahead curves away, so small offsets are expected there. The chart shows the estimated shift in pixels for views along the whole route, computed now in your browser from the average you chose above. With all 46 images, 87 % of the autumn views and 84 % of the snow views land within ±32 px of straight ahead. The rear camera earns its place under snow: without it, the snow figure drops to 81 %, and to 73 % with a single front image.
When it works, and when it cannot
The derivation also says when to expect success. The training drive has to meet three conditions:
- the cue it shows (a path edge, a railing, a curb) continues along the path the robot should follow;
- the robot keeps it at the same place in the image while teaching, by driving at a constant offset from it; and
- everything else in the training images varies enough to average out.
For the third condition, the robot also records its rear camera, which doubles the variety at no cost; its images are flipped horizontally where needed, so that the cue keeps its place in the image. Where the first condition fails, for example where the path simply ends, no average can help. That is not a bug of the method but the limit of what any "follow this kind of path" approach can do.
In the field
We tested the method in five scenarios with a Boston Dynamics Spot and a Clearpath Jackal. Among them:
- Corridors. An average from one 15 m corridor of our faculty building kept Spot centred in two other corridors, with a mean deviation of 0.07 ± 0.04 m from the centre.
- A river bank. About 20 m taught along the railing of the Vltava embankment in Prague was enough for a 500 m walk there and back, among pedestrians and cyclists. Two representations, one flipped, told the robot which way it was facing.
- This park. An average built from a 20 m training drive, recorded with the front and rear cameras, guided the robot along a roughly 600 m loop in Stromovka, with four crossroads handled by a small topological map.
Compared with the original VTAG, the descriptor shrank from 16 MB to about 100 kB and building it went from hours or days to real time. The code and recorded experiments are on GitHub.
Read more
- Z. Rozsypálek, T. Rouček, J. Ulrich, T. Krajník: Rapid deployment of visual path following via average representation. Journal of Intelligent & Robotic Systems, 2025.
- Visual teach and generalise (VTAG): exploiting perceptual aliasing for scalable autonomous robotic navigation in horticultural environments. Computers and Electronics in Agriculture, 2023. The first version.
- Z. Rozsypálek et al.: Contrastive learning for image registration in visual teach and repeat navigation. Sensors, 2022. The network.
- Video of the experiments on YouTube.
About the demo: the representations were computed offline by the network the robot runs (model_tiny) and stored as 8-bit numbers. The training images are the map images of the paper's Stromovka experiment, front and rear camera; the rear images are used as stored in that map, the way the experiment's averaging script reads them (matched against the front-camera average, they line up better unflipped than flipped). The views along the route come from two separate teach-and-repeat recordings of a Stromovka route, late autumn and snow, front camera. Averaging, cross-correlation, contributions and the whole-route sweep run in your browser. The cross-correlation follows the paper's formula; the robot additionally allows a one-row vertical offset.