Introduction

Imagine teaching a robot to write the letter “A”. You grab its robotic arm, guide it through the strokes, and then expect it to repeat the motion on its own. This process, known as Learning from Demonstrations (LfD), is a holy grail in robotics. It bypasses the need for tedious code and allows anyone to program a robot simply by showing it what to do.

But here is the catch: the real world is messy. If you bump the robot while it’s writing, or if a drone faces a sudden gust of wind, standard imitation learning methods often fail. The robot might struggle to recover its path or fail to stop exactly where it’s supposed to. It knows the path, but it doesn’t necessarily understand the flow of motion required to stabilize itself and converge to a stop.

In a fascinating new paper titled “KoopMotion: Learning Almost Divergence-Free Koopman Flow Fields for Motion Planning,” researchers from the University of Pennsylvania’s GRASP Laboratory propose a robust solution. They treat robot motion not just as a line to follow, but as a fluid-like dynamical system.

By combining Koopman Operator Theory (a mathematical framework that turns complex non-linear problems into linear ones) with novel constraints on flow divergence, they have created a method that ensures robots can recover from disturbances and land exactly on their target—even when trained on very little data.

In this post, we will deconstruct KoopMotion, exploring how it turns sparse demonstrations into smooth, stable “flow fields” that guide robots like water flowing into a drain.


Background: The Challenge of Imitation

To understand why KoopMotion is significant, we first need to look at how robots usually learn dynamics.

When a robot watches a demonstration, it receives a sequence of states (positions) over time. The goal is to learn a function that predicts the next state given the current state.

\[ \mathbf { x } _ { k + 1 } = f ( \mathbf { x } _ { k } ) \]

Basic Dynamics Equation

Here, \(f\) is usually highly non-linear. Traditionally, roboticists use Gaussian Mixture Models (GMMs) or Neural ODEs to approximate \(f\). While these work well for mimicking the shape of a motion, they struggle with stability. There is often no mathematical guarantee that the robot will actually stop at the goal or return to the path if pushed away.

Enter the Koopman Operator

This is where the authors pivot to a concept from physics and control theory: Koopman Operator Theory.

Standard dynamics look at how states (\(x\)) evolve. Koopman theory flips the script. It looks at how observable functions (measurements) of the state evolve. The central insight is profound: Any non-linear dynamical system can be represented as an infinite-dimensional linear system.

If we can find the right “lens” (or lifting functions) to view the data through, the complex, curvy motion of a robot arm becomes simple linear algebra. This makes analyzing stability—knowing for sure if the robot will crash or converge—much easier.


The KoopMotion Methodology

The core of the KoopMotion paper is a pipeline that takes human demonstrations and converts them into a stable “flow field.” Let’s break down the architecture.

Overview of KoopMotion workflow showing demonstrations, the KoopMotion module with lifting and inverse reconstruction, and deployment on a real robot.

As shown in Figure 1, the process involves three stages:

  1. Demonstration: Capturing raw trajectory data (like handwriting).
  2. KoopMotion Module: Learning the dynamics in a “lifted” space.
  3. Deployment: Generating velocity commands for a real robot.

1. Lifting to a Higher Dimension

To linearize the dynamics, the system maps the robot’s state \(\mathbf{x}\) into a higher-dimensional space using a function \(\Psi\). In this new space, the evolution of time is governed by a linear matrix, the Koopman Operator \(\mathcal{K}\).

Koopman Operator Equation

Finding the right lifting function \(\Psi\) is usually the hard part. The authors avoid “guessing” these functions by using Fourier Features. They transform the state using cosines with learnable weights and biases.

Fourier Feature Lifting Function

Think of this as expanding the robot’s 2D position into a massive dictionary of 1,024 different wave patterns. By combining these waves, the model can describe incredibly complex shapes using simple linear math.

2. Shaping the Flow: The Novel Loss Functions

If the researchers stopped there, they would have a standard Koopman model. But a standard model mimics the data it sees; it doesn’t necessarily know what to do in the empty space around the demonstration.

To fix this, KoopMotion introduces two critical constraints (loss functions) during training to mold the vector field.

Constraint A: The “Almost” Divergence-Free Condition

The researchers want the robot’s path to act like a stable tube. They borrow a concept from fluid dynamics called divergence. If the divergence of a field is positive, the flow expands; if negative, it contracts.

To keep the robot on track without erratic behavior, they encourage the divergence of the learnt vector field \(\hat{\mathbf{F}}\) to be close to zero (divergence-free) along the trajectory.

Divergence Equation

The associated loss function penalizes any non-zero divergence in the region of the demonstration:

Divergence Loss Function

This encourages the flow to be “neutral”—it doesn’t push the robot away from the path, creating a smooth corridor of motion.

Constraint B: The Goal Convergence (The “Sink”)

A common issue in LfD is that the robot reaches the end of the motion and then drifts away. The authors enforce a hard constraint: the goal position must be a fixed point.

In the lifted space, applying the Koopman Operator to the goal state should return the goal state exactly. Nothing should change.

Goal Fixed Point Condition

Goal Loss Function

This acts like a mathematical anchor, ensuring that once the robot reaches the finish line, the velocity commands drop to zero.

3. The Total Optimization

The system learns by minimizing a combination of three objectives:

  1. Koopman Loss: Does the linear model accurately predict the next step?
  2. Flow Divergence Loss: Is the flow smooth and contained?
  3. Goal Loss: Does it stop at the end?

Total Loss Function Optimization

Where \(\mathcal{L}_{Koopman}\) is the standard prediction error:

Koopman Prediction Loss


Experiments and Results

The researchers validated KoopMotion on the LASA handwriting dataset, a standard benchmark where robots must learn to write cursive letters.

Visualizing the Flow Fields

The results are visually striking. In the figure below, the red lines are the training data (human demonstrations). The black lines are the trajectories generated by KoopMotion starting from the same points.

What is most important, however, are the gray streamlines. These represent the “imagined” motion plans for every other point in space.

Qualitative performance of KoopMotion on LASA dataset showing flow fields.

Notice how the gray lines smoothly funnel toward the goal, even from areas far away from the red training data. The robot isn’t just memorizing a line; it is learning a global map of “where to go.”

Stability Analysis

Because KoopMotion uses linear operators, we can check its stability by looking at the eigenvalues. For a discrete-time system to be stable, all eigenvalues must have a magnitude less than 1 (meaning the energy of the system dissipates as it converges to the goal).

Eigenvalue equation

The authors visualized the eigenfunctions—the underlying structures or “modes” of the dynamics.

Eigenfunctions of KoopMotion models showing partitions of dynamics.

The colors in Figure 6 essentially show how the Koopman operator partitions the space. Different colors represent regions with distinct dynamical behaviors. The spectral analysis confirmed that all learnt models were asymptotically stable.

Quantitative Success

How does it compare to other methods? The authors compared KoopMotion against standard baselines like Dynamic Movement Primitives (DMP) and other stable learning algorithms (CLF-DM, CDSP).

They used two metrics:

  1. DTWD (Dynamic Time Warping Distance): Measures shape similarity.
  2. SEA (Swept Error Area): Measures spatiotemporal accuracy (does it be in the right place at the right time?).

Comparison table and graphs for DTWD and SEA metrics.

As shown in Figure 4, KoopMotion (blue bars) is comparable on shape similarity but significantly outperforms baselines on SEA (lower is better). This means KoopMotion captures the timing and velocity profile of the human demonstration much better than competitors.

Sample Efficiency

One of the most impressive claims is sample efficiency. Robots are slow, and gathering data is expensive. KoopMotion was trained on a temporally sub-sampled dataset, using only 3% of the original training data.

Sparsity of the dataset visualization.

Despite seeing such a sparse representation (Figure 8b), the model filled in the gaps perfectly.

Real-World Verification: The Water Tank

Simulations are fine, but does it work in the real world? The authors deployed KoopMotion on a miniature autonomous surface vehicle (mASV) in a water tank. This is a challenging environment because the water exerts forces (currents, drag) that act as constant disturbances.

Experimental verification with autonomous surface vehicles.

In Figure 5, you can see the robot’s path (dots in the middle row).

  • Top Row: The learnt flow field.
  • Middle Row: The actual robot executing the path.
  • Bottom Row: The eigenvalue plot confirming stability (all red dots inside the circle).

The robot successfully tracked the “Leaf” shape, the “Z” shape, and even a multi-modal path where it had to choose a trajectory based on its starting point. This proves the “Sim2Real” transfer capability of the flow fields.


Why Divergence Matters (Ablation Study)

To prove that their specific loss functions were necessary, the authors performed an ablation study. What happens if you turn off the “Divergence-Free” loss?

Comparison of flow fields with divergence loss set to zero.

Figure 11 shows the result. Without the divergence constraint, the flow fields (gray lines) still exist, but they are less “attracting.” They don’t pull the robot toward the trajectory as aggressively. The divergence loss essentially tightens the flow, ensuring that if the robot strays, the vector field pushes it back into the lane immediately.

However, the authors note a trade-off: extremely high divergence penalties can cause all trajectories to collapse onto a single path too early, potentially losing some of the stylistic variations in the human demonstration.


Conclusion

KoopMotion represents a step forward in making robotic motion planning more robust and mathematically grounded. By moving away from “black box” neural networks and utilizing Koopman Operator Theory, the authors achieved three major things:

  1. Guaranteed Stability: Through spectral analysis (eigenvalues), we can verify the robot will converge.
  2. Robustness: The “flow field” approach allows the robot to recover from disturbances seamlessly.
  3. Efficiency: It learns complex behaviors from very sparse data.

For students and researchers in robotics, this paper highlights the power of combining classical physics-based intuition (divergence, flow) with modern data-driven learning. It transforms the robot from a machine that merely copies a line into an agent that understands the dynamics of the motion itself.

As robots move out of factories and into unstructured environments—like navigating crowded sidewalks or performing surgery—this kind of “fluid” adaptability will be essential.