Invalid DateTime · 3 min read
What Production Robotics Taught Me About Writing Planners
Before starting my Ph.D., I spent two years writing autonomy software that flew on real vehicles rather than in simulation. A few habits from that time changed how I write planning code now, even for research prototypes that will never see a real robot.
Treat “no plan” as a first-class output
Research code has a bad habit of assuming the planner always returns something. Production code can’t make that assumption — sensors drop out, optimization problems go infeasible, and the system needs a defined behavior for exactly that moment, not a crash three layers up the call stack.
struct PlanResult {
bool valid;
Trajectory trajectory; // only meaningful if valid == true
std::string reason; // populated when !valid
};
PlanResult plan(const State& state, const Obstacles& obstacles) {
if (!state.is_recent()) {
return {false, {}, "stale state estimate"};
}
auto solution = solve_trajectory_optimization(state, obstacles);
if (!solution.converged) {
return {false, {}, "optimizer did not converge"};
}
return {true, solution.trajectory, ""};
}
Writing the failure path first, before the happy path, tends to produce a cleaner interface than bolting error handling on afterward.
Log the decision, not just the state
It’s easy to log vehicle state at high rate and assume that’s enough to debug a bad maneuver after the fact. It usually isn’t — you can reconstruct what the vehicle did, but not why the planner chose it. Logging the inputs to a planning decision (which candidate trajectories were considered, which constraints were active) turns a “why did it do that” investigation from an afternoon into a few minutes.
Simulate the sensor, not just the dynamics
A vehicle dynamics simulator that feeds a planner ground-truth state will hide entire classes of bugs that only show up under real estimator noise and latency. Adding even a crude sensor model — delay, dropout, a plausible noise covariance — during development surfaces planner brittleness far earlier than field testing does.
None of this is exotic engineering advice, but it’s the kind of thing that’s easy to skip when a prototype “just needs to work once” for a paper deadline, and expensive to retrofit once the code has to run on something that can’t be restarted mid-flight.