One physical model
Fluid and robot equations are derived from one constrained action, so coupling is part of the dynamics rather than a post-processing force.
1 Carnegie Mellon University · 2 Massachusetts Institute of Technology
† Equal contribution
Robotic swimming is a genuinely strongly coupled problem: the robot reshapes the surrounding flow, and the resulting pressure and viscous forces immediately change the robot's motion. Treating those two systems as separate simulators connected by an external force can miss the vortex interactions that make fish-like locomotion efficient and agile.
Fluid and robot equations are derived from one constrained action, so coupling is part of the dynamics rather than a post-processing force.
An integral-form immersed boundary constraint remains well-conditioned around adjacent links and overlapping boundary nodes.
Implicit differentiation captures how design or gait parameters alter both robot motion and the surrounding fluid state.
Matching the swimming efficiency and agility of fish has remained an elusive goal in underwater robotics. Such locomotion relies on complex vortex interactions between the robot's body and the surrounding fluid, governed by coupled ordinary and partial differential equations — significantly more difficult than the multi-body dynamics of classical rigid robotic systems.
We present a differentiable framework for simulating strongly coupled fluid-robot multiphysics as a unified optimization problem. The coupled manipulator and incompressible Navier–Stokes equations are derived together from a single Lagrangian using the principle of least action. We employ discrete variational mechanics to derive a stable, well-conditioned, and physically accurate scheme for jointly simulating articulated bodies and the surrounding fluid, and leverage the implicit function theorem to compute derivatives through the fully coupled dynamics.
Using this simulator and its gradients, we realize undulating swimming gaits and optimize a highly dynamic C-start escape maneuver for a bioinspired eel robot. We validate both gaits on physical hardware, demonstrating successful sim-to-real transfer.
Existing multiphysics simulators time-integrate the fluid and robot equations separately, then couple them through an explicit force term. We instead pose the entire problem as a single least-action optimization: the unified Lagrangian is discretized directly, and the coupling forces emerge as Lagrange multipliers of a no-slip constraint.
For a system with configuration $q(t)\in\R^n$, velocity $v(t)\in\R^m$, kinetic energy $T(v)$, and potential energy $U(q)$, the principle of least action poses the dynamics as a continuous-time optimization problem:
Introducing a Lagrange multiplier $\lambda$ for the kinematic constraint and writing $L(q,v) = T(v) - U(q)$, the action becomes $\;S(q,v)=\int_{t_0}^{t_f} L(q,v) + \lambda^\top(\dot q - v)\, dt.$ Stationarity yields the Euler–Lagrange equation
which in robotics is more familiar as the manipulator equation $\;M(q)\ddot q + C(q,\dot q)\dot q + G(q) = 0.$ The least-action principle generalizes to dissipative systems via Lagrange–D'Alembert, to non-trivial kinematics $v=f(q,\dot q)$, and to additional constraints $c(q,v)=0$:
For a rigid multibody robot interacting with an incompressible Newtonian fluid (e.g., water), we define fluid and robot Lagrangians as
where $\rho$ is fluid density, $\mu$ its dynamic viscosity, $\Omega$ the fluid domain with boundary $\partial\Omega$, $\Gamma$ the robot geometry with boundary $\partial\Gamma$, and $M^r$ the robot mass matrix. Damping enters via the viscous term $F(t)=\int_\Omega \mu\,\Delta v^f\, dV$. The full multiphysics is then a single constrained optimization over fluid and robot states:
Constraints $c_1\!-\!c_4$ are the standard kinematic and conservation conditions; $c_5$ encodes joint constraints; $c_6$ is the no-slip condition at the fluid-robot interface and is the only coupling between the two physics.
Forming the action $S = \int (L^f + L^r + F^\top q^f + \sum_{i=1}^6 \lambda_i c_i)\, dt$ and taking variations w.r.t. $(q^f,v^f)$ and $(q^r,v^r)$ recovers the coupled incompressible Navier–Stokes and manipulator equations:
The purple terms in (7) and (9) share the same dual variable $\lambda_6$. The pressure $p \equiv \dot\lambda_2$ is itself the multiplier that enforces $\nabla\!\cdot v^f=0$ — a fact Lagrange noted in his Mécanique analytique. Boundary conditions and the no-slip interface inherit the same constraint-with-dual-variable structure that Allmaras (2005) used for compressible aerodynamics.
Discretizing the action in time is delicate. A midpoint quadrature gives a discrete Lagrangian $L_d(q_k,q_{k+1}) = h\,L\!\left(\tfrac{q_k+q_{k+1}}{2},\,\tfrac{q_{k+1}-q_k}{h}\right)$ in which the velocity $\bv_k$ lives between the configurations $q_k$ and $q_{k+1}$. For pure rigid-body simulation this half-step delay is harmless. For our problem it is not: the fluid is represented as a velocity field $\bv^f$ while the robot pose lives in $q^r$, and the no-slip constraint must couple them at a consistent time.
Marsden & West (2001) resolve this via the discrete Legendre transform, which is awkward in the presence of constraints. We instead define every constraint at the time step at which its variable naturally lives ($q_k$ for the robot, $\bv_k$ for the fluid), and rewrite the discrete Euler–Lagrange relation directly via the chain rule:
Substituting these back into the discrete Euler–Lagrange equation produces, after some algebra, two coupled update rules — one for the robot, one for the fluid — that are simultaneously solved each time step. With $\bv^r_{k+1}$ and $\bv^f_{k+1}$ as unknowns:
Together with the discrete constraints $G^\top \bv^f_{k+1}=0$ (incompressibility), $B\bv^f_{k+1}=v_{bc}$ (boundary), $\bar E\,\bv^f_{k+1} = {}^b\bv^r(\bv^r_{k+1})$ (no-slip), and $c_5(q^r_{k+1})=0$ (joints), the system forms a sparse nonlinear root-finding problem solved by Newton's method. The resulting scheme is a 2nd-order implicit leap-frog integrator, and derivatives through it are obtained from the implicit function theorem.
The fluid domain is discretized with a second-order finite-volume scheme yielding the following discrete counterparts of the continuous operators that appear in the Navier–Stokes equations:
$\;\int_\Omega \rho v^f\, dV \mapsto M^f v^f,\quad \int_\Omega \nabla p\, dV \mapsto Gp,\quad \int_\Omega (v^f\!\cdot\!\nabla)v^f\, dV \mapsto N(v^f),\quad \int_\Omega \Delta v^f\, dV \mapsto Lv^f.$
$M^f$ is the lumped fluid mass matrix, $G$ the discrete gradient, $N(\cdot)$ the (nonlinear) convection operator, and $L$ the discrete Laplacian. $B$ extracts cells on $\partial\Omega$.
The classical immersed-boundary method enforces no-slip pointwise: $\;\int_\Omega v^f\,\delta(q^f-{}^bq^r)\, d\Omega = {}^bv^r,\;$ discretized as $\;E v^f - {}^bv^r = 0,\;$ with a convolution matrix $E$ built from a smoothed delta. This satisfies no-slip only at a finite set of boundary nodes — allowing fluid penetration when nodes are sparse, and producing redundant, ill-conditioned constraints when nodes from neighboring bodies overlap. Both pathologies are common in articulated robots.
We instead integrate the constraint along the whole boundary $\Gamma$:
Discretizing with piecewise-linear interpolation along the boundary and integrating the smoothed delta along each segment yields a new convolution matrix $\bar E$:
Unlike the pointwise form, $\bar E$ stays well-conditioned when boundary nodes overlap, and the constraint is satisfied between nodes rather than only at them. Differentiating through (15) inside (12)–(13) gives the multibody-friendly coupling we use throughout the paper.
Differentiability turns the simulator into an optimization tool rather than only a rollout engine. Let $x_k=[q^r,\bar v^r,\bar v^f]_k$ collect the full robot and fluid state, let $\beta$ denote gait or design parameters, and let $f(x_{k+1},x_k;\beta)=0$ denote the implicit coupled update. We solve
Applying the implicit function theorem to the entire nonlinear multiphysics solve gives $\partial x_{k+1}/\partial x_k$ and $\partial x_k/\partial\beta$. Backpropagating those sensitivities through time yields $\nabla_\beta J$, including how every parameter changes both the articulated body and the surrounding flow. We use these gradients with box-constrained L-BFGS to optimize the C-start maneuver below.
A robot-only derivative would ignore how a parameter changes vortex formation and hydrodynamic loading. Here the sensitivity passes through the same strongly coupled equations used for simulation.
We evaluate the simulator in a 122 × 122 cm cavity of initially still water with walled boundary conditions. The eel is represented in maximal coordinates by six 9.8 cm rigid links connected by five revolute joints. Our finite-volume fluid uses 1 cm cells; the Genesis SPH baseline uses equivalently sized particles so both methods are compared at consistent spatial fidelity.
We drive each joint with a phase-shifted sinusoid to produce a traveling wave at 1 Hz with body wavelength $\lambda = L_B$. Across joint amplitudes from 10° to 40° (20 trials each), our method consistently tracks hardware while the SPH baseline drifts — the gap widens with amplitude.
We use the simulator's gradients to optimize a fish-inspired C-start escape maneuver. The robot first curls into a C-shape during a bending phase (0–1 s), then rapidly straightens and launches a traveling wave during the propulsion phase (1–3 s). The terminal objective penalizes error between the final center-of-mass configuration $q_N^{\mathrm{com}}$ and a goal configuration $q_{\mathrm{goal}}$ representing a 90° turn:
We optimize the five bend angles $\bar\theta_{1:5}$, traveling-wave phase $\phi$, and wavelength $\lambda$, while fixing joint amplitude to 25° to avoid the pool wall. Box-constrained L-BFGS uses $10^\circ\!\leq\!\bar\theta_{1:5}\!\leq\!36^\circ$, $-\pi/2\!\leq\!\phi\!\leq\!0$, and $0.5L_B\!\leq\!\lambda\!\leq\!L_B$. Starting from $\bar\theta_{1:5}^{\mathrm{ig}}=10^\circ$, $\phi^{\mathrm{ig}}=-\pi/3$, and $\lambda^{\mathrm{ig}}=0.6L_B$, optimization converges to $[17^\circ,18^\circ,20^\circ,24^\circ,36^\circ]$, $\phi^*=-1.16$, and $\lambda^*=0.57L_B$. The optimized gait executes the desired turn open-loop on hardware; the SPH baseline realizes neither the turn nor the propulsion.
a.Initial guess (before optimization)
b.After gradient-based optimization — 90° turn from rest
A 3-second C-start rollout contains 300 steps at 100 Hz. On an M3 Ultra Mac Studio CPU, our implicit unified solve completes the rollout in approximately 261 s. The matched Genesis SPH rollout takes 2727 s on the same CPU and 300 s on an NVIDIA RTX 3070 Ti GPU.
The eel robot has 6 rigid links (9.8 cm each) connected by revolute joints driven by Dynamixel XC330-M288-T servos. It is fully untethered, with an onboard 900 mAh battery and a Robotis OpenRB-150 microcontroller in the head link. Buoyant 3D-printed shells house the electronics; thin rigid fins underneath maintain a thin-plate hydrodynamic profile. Head-link pose is tracked by an overhead camera via AprilTags in a 122 × 122 cm pool, recreating the simulated walled cavity.
| No. | Part Description | Material | Quantity | Price (USD) |
|---|---|---|---|---|
| 1 | 3D-printing filament | PET-CF (3D printed) | 1 | $44.99 |
| 2 | 1-mm-thick plate | Fiberglass | 1 | $9.99 |
| 3 | 7.4V 900mAh LiPo battery | Lithium Polymer | 1 | $9.90 |
| 4 | PCB board | FR-4 PCB | 1 | $3.00 |
| 5 | 25.4-cm-long JST wires | Wires | 3 | $1.41 |
| 5 | EHR-3 connector | Plastic | 2 | $0.20 |
| 5 | DC-to-DC Converters (OKR-T/6-W12-C) | Electronics | 1 | $9.24 |
| 6 | OpenRB-150 MicroController | Electronics | 1 | $28.64 |
| 7 | XC330/XL330-M288-T Servos | NA | 1 | $103.39 / $27.49 |
| 8 | Fasteners (screws, helicoils, pins, etc.) | Stainless Steel | Multiple | $15.40 |
| Total | $226.16 (Head) / $150.26 (Body) | |||
All design files can be found here.
The experiments demonstrate substantially better sim-to-real fidelity than the particle-based baseline, but the model is not yet a complete description of the physical platform. The optimized C-start consistently undershoots the hardware travel distance, likely because the current model omits free-surface dynamics, servo compliance, detailed fin geometry, and uncertainty in mass properties and viscosity.
Implicit integration is expensive, particularly in 3D. Future solvers must exploit sparsity and structure to scale to larger domains and longer-horizon optimization.
The Eulerian grid is well suited to dynamic swimming and physical constraints, but is less convenient for visual rendering than particle-based fluid representations.
Promising extensions include implicit large-eddy simulation, design optimization, and other strongly coupled systems such as rigid-soft robots with contact.
@inproceedings{lee2026realizing,
title = {Realizing Robotic Swimming with Unified Fluid-Robot Multiphysics},
author = {Lee, Jeong Hun and Hu, Junzhe and Kwok, Sofia
and Majidi, Carmel and Manchester, Zachary},
booktitle = {Robotics: Science and Systems (RSS)},
year = {2026},
note = {Equal contribution: J. H. Lee and J. Hu}
}
The authors thank the members of the Robotic Exploration Lab and the Soft Machines Lab at Carnegie Mellon University for valuable discussions and feedback.
This work was supported by the National Science Foundation Graduate Research Fellowship under Grant No. DGE2140739.