Robotics · UWB · ROS 2 · Python
Follow me: steering a ground robot with three UWB ranges
How I used ultra-wideband ranging to make a payload robot follow one person: three anchors on the vehicle, a tag on the person, and steering rules built on range differences instead of full positioning.
By Dhruv Suthar
On an R&D project for an unmanned ground vehicle that carries load alongside a person on foot, the core feature was simple to state: follow this person, and only this person. I built it twice. The first version used a camera. The second used ultra-wideband (UWB) ranging, and that is the one this article is about.
Why a camera was not enough
The camera version detected a person in the frame and turned the offset from the centre into commands: move left, move right, centred, no person. It worked when conditions were kind. Outdoors they often are not. Lighting changes, the person steps behind something, or someone else walks into the frame and the robot has to decide which person it is following.
UWB fixes the identity problem by design. The person carries a small tag, and the vehicle measures its distance to that tag by timing radio pulses. There is no question of which person: the robot follows the tag. It also does not care about lighting.
The layout: three anchors, one tag
Three UWB anchors are mounted on the vehicle: a left and a right anchor across the front, about 1.3 m apart, and a third towards the back. The tag measures its distance to each one, so every update gives three numbers: left, right and back.
The obvious next step is trilateration: solve for the tag’s x and y and steer towards that point. I chose not to. With a short baseline on the vehicle and noisy ranges, the solved position jumps around, and a robot that chases a jumping target drives badly. What the robot actually needs is three answers: is the person in front or behind, are they to the left or the right, and are they too far away? Each of those can be read straight from the ranges.
- Left versus right: if the right anchor is closer than the left, the person is to the right.
- Front versus back: if the back anchor is closer than both front anchors, the person is behind or beside the vehicle.
- Distance: the average of the two front ranges is a good estimate of how far ahead the person is.
Getting the ranges into ROS 2
This part took the most trial and error. In the first setup the range readings reached the vehicle’s PLC, and a ROS 2 node polled them over OPC UA a few times a second, parsed each anchor’s distance, and published them as JSON on a topic. Later I tried reading the tag directly over Bluetooth, and feeding distances through the backend over a WebSocket. The control logic never changed between these, because each source published the same left, right and back message. Keeping that boundary fixed is what made it possible to swap the plumbing without retuning the robot.
# Illustrative: whatever the source, publish the same shape
def publish_ranges(self, left, right, back):
msg = String()
msg.data = json.dumps({
"left_anchor": left,
"right_anchor": right,
"back_anchor": back,
"follow_distance": self.follow_distance,
})
self.publisher.publish(msg)Calibrate the gap when following starts
How far behind someone should the robot stay? Rather than hard-coding a number, the node records the average of the left and right ranges at the moment follow mode is switched on and uses that as the gap to keep. The person sets the distance by where they are standing when they start. When follow mode is switched off, the calibration is cleared, so the next session starts fresh.
# Illustrative: the gap is captured, not configured
if not follow_enabled:
self.follow_distance = None
elif self.follow_distance is None and left > 0 and right > 0:
self.follow_distance = (left + right) / 2The steering rules
The vehicle is skid-steered: it turns by driving its left and right sides at different speeds, or in opposite directions to spin on the spot. The follow logic is a short list of rules, checked in order on every cycle.
# Illustrative version of the decision order
MAX_RANGE = 12.0 # metres; beyond this, trust nothing
DEADBAND = 0.25 # metres of left/right difference to ignore
def follow_step(left, right, back, gap):
avg = (left + right) / 2
# 1. Missing or implausible readings: stop
if 0 in (left, right) or max(left, right, back) > MAX_RANGE:
return stop()
# 2. Person behind or beside the vehicle: turn on the spot towards them
if back < left or back < right:
return spin(towards="right" if right < left else "left")
# 3. Person ahead and further than the gap: drive and steer
if avg > gap:
speed = scale(avg, gap, gap + 7.0, slow, fast)
diff = right - left
if abs(diff) < DEADBAND:
return drive(speed, speed)
turn = scale(abs(diff), 0.3, 1.0, small, large)
if diff < 0: # right anchor closer: person is to the right
return drive(left_side=speed + turn, right_side=speed - turn)
return drive(left_side=speed - turn, right_side=speed + turn)
# 4. Close enough: hold position
return stop()A few details carry most of the weight. Speed scales with how far past the gap the person is, so the robot creeps when they are just ahead and catches up when they pull away. Steering is a speed difference between the two sides, also scaled, so a small offset gives a gentle curve and a large one a firm turn. The deadband matters more than it looks: two noisy ranges subtracted from each other are noisier than either one, and without it the robot weaves.
The baseline sets how fine that steering can be. With the front anchors 1.3 m apart, a 0.25 m range difference corresponds to the person being roughly 11 degrees off centre. That angle does not shrink with distance, so it is a fair trade: the robot ignores small offsets at any range and corrects anything larger.
Following is the lowest priority
The follow logic is never the only thing deciding how the vehicle moves. It sits underneath everything else.
- The operator wins. Follow commands only apply while the joystick is in its neutral range; touching it hands control back immediately.
- Follow mode is an explicit switch, from the vehicle’s own controls or the remote-control app, never a default.
- LiDAR watches a zone in front of the vehicle. If something is inside it, the speed limit is scaled down by distance to the nearest point, and an object in the stop zone sends the drives to a safe value at once.
- Every motor command passes through a ramp that limits how much it can change per cycle, with separate acceleration and deceleration times, so a sudden jump in the ranges cannot become a sudden jump in the wheels.
What I would do next
The rules above came out of a lot of trial and error, and some limits are clear. The person’s own body can block the tag from an anchor, which inflates one range and makes the robot think they have moved sideways. A short median filter per anchor and a timeout that stops the robot when readings go stale would both help. A wider front baseline would sharpen the steering, and UWB modules that measure angle of arrival as well as range would answer the left-or-right question directly. And the camera does not have to go: UWB is good at knowing which person to follow, a camera is good at seeing exactly where they are, and fusing the two is the natural next version.
- Steer on range differences; you may not need a full position fix.
- Let the person set the following gap when they switch following on.
- Use a deadband sized to the noise of the difference, not of a single range.
- Keep one message shape between the ranging source and the controller.
- Make following the lowest priority: operator, obstacles and ramping sit above it.
