Safety Subsystem for a Warehouse Robot Near People
System DesignModel answerLast updated
Design a real-time perception and decision pipeline that keeps a mobile warehouse robot from hitting workers, covering fusion, a 50 ms latency budget, stop-versus-slow logic, and sensor failures.
Collision-Safety Subsystem for an Autonomous Warehouse Robot
Your team is building the safety and collision-avoidance layer for a mobile robot that moves goods around a busy warehouse. Human workers and other robots share the floor with it, and both move unpredictably.
Hardware available
- A 360-degree LiDAR (long range, fine angular resolution)
- A set of ultrasonic proximity sensors (short range, coarse resolution)
- Wheel encoders
Operating assumptions
- Top speed is 2 m/s.
- A map of the warehouse is stored on the robot in advance.
- A ROS2-style publish/subscribe middleware passes messages between software nodes.
What the subsystem must do
- Detect people in or near the robot's path, work out how far the robot needs to stop, and trigger either an emergency stop or a path/speed adjustment when a collision is likely.
- Keep the delay from sensor reading to motor command under 50 ms.
- Stay dependable despite noisy sensors and people who are temporarily hidden from view (for example behind shelving).
Walk through your design, covering:
- Fusion: how you combine LiDAR and ultrasonic data to decide that an object is a person.
- Data flow: the path from raw sensor input to the motor-controller interface, including a latency budget.
- Decision logic: when the robot should merely slow down and when it should perform an emergency stop, based on its speed and the distance to the obstacle.
- Failure handling: what happens when the LiDAR reports a contaminated window or goes silent.
Explain the trade-offs you make and use rough numbers where they help.
Hints
Hint 1
Start from physics: compute the stopping distance at 2 m/s from reaction time, braking deceleration and a margin, and note how far the robot travels during your 50 ms latency.
Hint 2
Consider splitting the system into a simple, independent safety layer that can cut motor power and a richer perception/planning layer whose goal is to avoid ever triggering the first one.
Hint 3
Do not make safety depend on correctly identifying humans: treat anything unknown as a person and use classification only to relax behavior. For failures, think watchdogs, heartbeats, and a default of stopping when a safety-critical input is lost.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
1. Pin down the numbers
- Speed: up to 2 m/s. Assume safe braking of about 1.5 m/s², since harder braking can tip or shift loads.
- Latency: 50 ms at 2 m/s means 0.1 m traveled before any command takes effect.
- Stopping distance:
d_stop = v·t_react + v²/(2a) + margin. At 2 m/s that is roughly 0.1 + 1.33 + 0.2 ≈ 1.65 m. At 0.5 m/s it is about 0.3 m. - Sensors: LiDAR at 20-40 Hz with ~20 m range; ultrasonics at ~0.1-2 m with a wide cone; encoders for true velocity.
- Environment: people walking at ~1.5 m/s, other robots, and occlusion from racks.
Guiding principle: safety must not rely on correctly classifying a human. Classification may only relax behavior (e.g., pass a pallet more closely). Anything unknown is treated as a person.
2. Two independent channels
- Safety channel (hard real-time). Runs on a safety-rated MCU or RTOS (think ISO 13849 and ISO 3691-4 for driverless vehicles). It consumes raw LiDAR protective fields, ultrasonic ranges and encoder speed. No ML, no dynamic allocation, and it can cut motor power itself.
- Intelligent channel (ROS2 on the main computer). Clustering, tracking, human scoring, prediction and local re-planning. Its goal is smooth slowing and detouring so that the safety channel almost never fires.
A planner bug can then never disable the emergency stop.
3. Data flow and latency budget
LiDAR / Ultrasonic / Encoders
-> Drivers (timestamp, ego-motion compensation)
-> Preprocess (crop, downsample, subtract static map)
-> Clustering
-> Fusion + tracking (Kalman filter per object)
-> Short-horizon prediction
-> Decision (envelope check, time-to-collision)
-> Velocity command -> motor controller (CAN)
Safety MCU watches raw sensors and heartbeats in parallel and can override.
| Stage | Budget |
|---|---|
| Sensor acquisition (40 Hz scan or sector streaming) | ~25 ms |
| Preprocess + map subtraction | ~5 ms |
| Clustering, fusion, tracking | ~8 ms |
| Prediction + decision | ~3 ms |
| Publish + CAN + motor driver | ~4 ms |
| Total | ~45 ms |
The scan period dominates, so run the LiDAR at a high rate or process angular sectors as packets arrive. Use real-time QoS, pinned cores, a real-time kernel and zero-copy intra-process transport.
4. Sensor fusion
LiDAR is the primary detector. Subtract the known map (walls, racks) so only dynamic returns remain, then cluster them. Score each cluster for human-likeness: a leg-pair pattern (two small arcs, roughly 10-20 cm wide, 20-50 cm apart), an overall footprint of about 0.3-0.8 m, and non-rigid motion consistent with walking.
Ultrasonics confirm and fill gaps. They cover what LiDAR misses: objects above or below the scan plane, glass or shrink-wrap, and very short range. Fuse at the track level:
- An ultrasonic echo that matches a LiDAR track raises its confidence.
- An echo with no LiDAR match creates an "unknown close obstacle," handled conservatively.
Tracking. A Kalman filter per object with state [x, y, vx, vy], data association by Hungarian or gated nearest-neighbor matching, and an M-of-N rule before confirming a track (rejects dust and single-point spikes). Predict about 500 ms ahead with growing covariance; the uncertainty ellipse becomes the obstacle footprint.
Occlusion. Keep occluded tracks alive ("coast") for about 1 s rather than deleting them. Use the map to mark blind corners and aisle exits as possible emergence zones and pre-slow there (e.g., ~0.8 m/s) so that the stopping distance is shorter than the visible sightline.
5. Decision logic
Build a safety envelope around the robot, stretched along its velocity and widened when turning. Always size it from encoder-measured speed, not commanded speed.
- Protective zone: length
d_stop(v). - Warning zone:
d_stop(v) + v·0.5 s + human_reach(a person can step ~0.75 m in 0.5 s).
| Condition | Action |
|---|---|
| Any return, even unclassified, in the protective zone, or TTC < stopping time | E-stop (max controlled deceleration, then remove drive power) |
| Object in warning zone, or TTC < ~1.5 s | Slow so the object falls outside the new protective zone; try a local re-plan |
| Confirmed human within ~3 m, not on a collision course | Cap speed (~1 m/s), keep ≥ 0.5 m lateral clearance |
| Ultrasonic-only detection under ~0.5 m | E-stop (little information, so be conservative) |
| Clear | Nominal speed |
Add hysteresis, for example requiring the zone to stay clear for ~500 ms before resuming, to avoid stop-go oscillation.
6. Failure modes
- Dirty lens: detect via LiDAR self-diagnostics or a sudden drop in valid returns per sector. Enter degraded mode: limit speed to what ultrasonics alone can protect (~1 m reliable range implies ~0.3 m/s, with
d_stopnear 0.15 m), treat the affected sector as blocked, notify fleet management and send the robot for maintenance. - LiDAR silent: every critical node emits heartbeats, watched by a watchdog on the safety MCU, independent of the main computer. No valid scan within ~2 periods (≤ ~60 ms) triggers a controlled stop. If the main computer's heartbeat stops, the MCU brakes the robot directly.
- Encoder disagreement: if odometry diverges from LiDAR scan matching (wheel slip), assume the worst-case velocity and slow.
- Default: loss of any safety-critical input leads to a stop. Never keep driving on an assumption that nothing changed.
7. Trade-offs and common mistakes
- Making the safety path depend on an ML classifier or on ROS scheduling.
- Ignoring the latency distance and sizing zones from commanded rather than measured speed.
- Deleting occluded tracks instantly, or having no hysteresis.
- Being too conservative: constant E-stops destroy throughput, which is why the intelligent channel exists to slow early and re-plan.
- Forgetting the fault case: a silent sensor must be treated as a hazard, not as "no obstacle."