# Module 6.1: Modular Pipelines vs. End-to-End Learning

- Course: [Course 6: Modern Robot Learning & Embodied AI](https://roboticsconcepts.dev/courses/modern-robot-learning-embodied-ai.md)
- HTML Page: https://roboticsconcepts.dev/courses/modern-robot-learning-embodied-ai/modular-pipelines-vs-end-to-end-learning/
- Key Concepts: Sense–Plan–Act vs. end-to-end policies, Hybrid hierarchical control stacks, Where classical guarantees still win

When you watch a video of a robot folding laundry or hopping over rubble, it's tempting to assume one giant neural network is running the whole show from camera pixels straight down to motor currents. In practice, real robot hardware almost never works like that — it looks much more like a team where learned models and classical controllers each handle what they do best.

## The classic Sense–Plan–Act pipeline (and where it breaks)

For decades, robotics teams split the problem into neat boxes: a perception module detects objects and estimates poses, a planner searches for a collision-free path through space, and a low-level controller tracks that path at hundreds of hertz. That modular split is wonderful when everything is rigid and known — you can inspect every stage, prove stability bounds, and swap out a camera without retraining your arm controller.

The trouble starts when objects get squishy, shiny, or cluttered. Try writing a geometric pose estimator for a crumpled t-shirt or a pile of cables. Even a tiny mistake in perception cascades downstream: the planner trusts a bad object pose, builds a pristine trajectory into empty air, and the controller dutifully misses the grasp by three centimeters.

## End-to-end learning vs. hybrid stacks

End-to-end learning flips the script by training a policy that maps sensor observations directly to actions. Because gradients flow from task success all the way back to perception, the network learns to focus only on the visual cues that actually matter for moving — say, the rim of a mug rather than its exact 3D CAD mesh.

Still, going 100% end-to-end down to raw motor torques throws away decades of reliable engineering. You don't want a neural network re-discovering joint limits or fighting gravity compensation from scratch on expensive hardware. That's why modern deployments settle on hybrid hierarchical stacks:

- Top layer (1–15 Hz): a learned policy or Vision-Language model reads images and instructions, deciding what to do next or outputting short trajectory chunks.
- Middle layer (20–100 Hz): inverse kinematics (Course 1) or operational-space control translates Cartesian commands into safe, singularity-aware joint targets.
- Bottom layer (500–1000 Hz): classical PD loops, torque limits, and collision guards keep motors smooth and stop the arm before it bends a wrist into the table.

## Hands-On Lab

Module 6.1 sets up the architectural map before we dive into code. As you read the scenario below, compare how a Sense–Plan–Act stack, a pure end-to-end policy, and a hybrid hierarchy respond when lighting changes or a motor hits a joint limit.

## Where classical guarantees still earn their keep

Think about driving a car with modern driver assistance. You want smart perception to spot a cyclist in dusk lighting, but you also want an ordinary, deterministic anti-lock braking loop running underneath so the wheels don't lock up on wet asphalt. Nobody wants the ABS pump to hallucinate.

In robot arms and legged machines, classical kinematics, state estimation filters, and low-level impedance controllers act like that safety floor. They make the learning problem vastly easier because the policy only has to steer a well-behaved, damped machine rather than wrestling raw electrical currents.

## Hybrid policy-to-controller decomposition

```text
u_motor = PD_1kHz( q_ref = IK( x_eef + Δx_policy(obs_20Hz) ), q, q̇ )
```

The learned policy predicts compact, high-level corrections at 10–50 Hz, while deterministic kinematics and high-rate PD loops enforce smoothness and safety.

## Check Your Intuition

**Question:** Your lab builds a bin-picking robot using a learned vision policy. Why do most teams still keep a classical IK solver and 1 kHz joint PD loop underneath the policy instead of outputting raw motor voltages directly from the neural network?

- [ ] Neural networks cannot output floating-point numbers fast enough for voltages
- [✓] Classical kinematics and high-rate PD loops handle joint limits, gravity compensation, and smooth tracking, making the policy easier to train and safer on hardware
- [ ] Raw motor voltages are only used on mobile robots, never on robot arms

**Explanation:** Separating high-level visual decision making from low-level safety, kinematics, and high-frequency damping shrinks the learning search space and protects the hardware.

## Where You'll See This in Modern Robotics

In the companion notebook for 6.1, you'll simulate a tabletop reach with perception noise and compare how cascading errors hurt a rigid modular pipeline while a closed-loop hybrid controller recovers gracefully.

## Companion Python Notebook: 01 · Modular Pipelines vs. Hybrid Hierarchical Policies

Compare a classical sense-plan-act controller against a learned policy outputting targets into a fast 500 Hz PD/safety filter.

- Open in molab (WASM): https://molab.marimo.io/github/alchemicduncan/robotics-concepts-dev/blob/main/notebooks/course-6/01_modular_vs_end_to_end_learning.py/wasm
- Open in Google Colab: https://colab.research.google.com/github/alchemicduncan/robotics-concepts-dev/blob/main/notebooks/colab/course-6/01_modular_vs_end_to_end_learning.ipynb
- Download .py: https://roboticsconcepts.dev/downloads/notebooks/course-6/01_modular_vs_end_to_end_learning.py
- Download .ipynb: https://roboticsconcepts.dev/downloads/notebooks/colab/course-6/01_modular_vs_end_to_end_learning.ipynb
- Run locally: `uvx marimo edit --sandbox notebooks/course-6/01_modular_vs_end_to_end_learning.py`
