A robot arm must carry a part from a tray to a bin.
A mobile base must cross a room with people and furniture in it. There are two ways to obtain a controller. One is to write it from a model: the equations of motion, the actuator limits and a cost to minimize, which is the classical route of control theory. The other is to learn it from examples, either a human teleoperating the machine or a planner running in simulation, and then to move the result to the real hardware. Learning avoids modelling every contact and every sensor, and it can absorb behaviour that nobody knows how to write down. It also introduces four difficulties, and this article is organized around them.
The first is distribution shift. The learner is trained on states that the expert visited, but it is evaluated on states that its own, slightly different, actions lead to. Small errors move it to places the data do not cover, where it makes larger errors. The second is multimodality. A task can have several equally good solutions (pass the obstacle on the left or on the right), and a policy trained to predict the average action will choose neither. The third is the gap between simulation and reality: data are cheap in simulation, but the simulator is wrong in ways that matter. The fourth is safety. Some constraints (do not cross this line, do not exceed this speed near a person) must hold even when the learned policy is wrong, and an exploring learner is not allowed to find out the hard way.
The plan: the companion book example derives the model-based baselines, LQR and model-predictive control (MPC). the companion book example analyzes imitation learning, with behaviour cloning’s quadratic compounding error and DAgger’s linear bound. the companion book example describes diffusion policies, which model whole chunks of future actions as a conditional distribution. the companion book example bounds the cost of moving from simulator to reality, and the companion book example derives a safety filter from control barrier functions. Sections 8.8 to 8.10 implement and evaluate everything, the companion book example collects the failure modes, and the companion book example says what a controls engineer must review before anything of this kind goes near a real machine.
Two points of scope first. The environments are a planar point mass and a planar two-link arm written in NumPy, because the outline’s standard simulators and benchmark data cannot be downloaded offline. The “expert” is a hand-written controller with privileged knowledge of the task, standing in for a human or a planner. The networks are small multilayer perceptrons with manual backpropagation (the library of the companion book), trained in seconds on one CPU core. There is no vision, no contact and no real actuator. The mathematics and the failure patterns carry over; the absolute numbers do not.
Safety and scope. this article is educational and is not professional advice. Nothing here is safe for real hardware, or for use near people, without independent safety engineering. A safety filter that is proven for a model is not a guarantee for a machine; the companion book example proves what a filter does under stated assumptions, and the companion book example shows what happens when those assumptions are false. the companion book example lists what a controls and safety engineer has to review.
Continue with the book
Explore the full treatment, worked examples, and exercises in Applied AI for Generation and Control.
Companion article for Applied AI for Generation and Control, published by Choral Software. Article text and original examples © 2026 Choral Software. All rights reserved.
