July 17, 2026
Fish-like swimming has inspired the design of several dozens if not hundreds of bioinspired robots in the last few decades. But the control and motion planning of such robots has been challenging due to the poorly modeled fluid-structure interaction and the nonlinear underactuated dynamics of such robots. While reinforcement learning has allowed significant advances in the context of ground and aerial robots, the lack of a suitable simulation environment with appropriate computational speed and accuracy have prevented similar progress for fish-like robots. We address this two-fold problem by developing a simulation platform that approximates the motion of our fish-like robot with computational efficiency. Then the motion control and path tracking by the robot is performed using PID control where the (variable) gains are learned using back propagation through time and training on a curriculum. The policy learned in the simulation is then applied on the physical platform, demonstrating an excellent match.
The locomotion of fish has several characteristics like speed, efficiency, agility and stealth that engineers have sought to emulate and this motivation has inspired the design of a variety of fish-like robots, such as [1]–[4] to name a few. Fish achieve high speed, efficiency and agility by exploiting the interaction of their body with the vortex wake and the added mass effect, [5], [6]. This fluid-structure interaction can be difficult to model or simulate in a fast and computationally efficient manner. So while dozens or hundreds of fish-inspired robots have been designed, the control and motion planning of such robots has remained a challenge.
Reinforcement learning and data driven methods offer a means to address this challenge and advances in their application to fish-like robots have begun to be made, see for example [7]–[11]. Deep reinforcement learning (DRL) combined with central pattern generators and a purely data driven surrogate model have been used to learn to track a path by a fish like robot in [7]. DRL along with a simple model of three link swimmer simulated in Mujoco were used to control the motion of a soft fish like robot with dielectric elastomer actuator in [8]. In [11] the hydrodynamic model of a robotic fish with pectoral fins was learned using bidirectional long short-time memory networks and its gaits were controlled using central pattern generators. In [9] a Koopman operator was constructed using data from a physical model that was then used to control its motion. The motion control in these papers is limited to tracking a reference heading angle and thereby a path. The speed of swimming is usually very small, less than a fraction of a body length per second, a regime where the complexity of hydrodynamic effects are reduced. Furthermore the robot does not simultaneously track a speed.
In this paper, we describe a deep reinforcement learning framework for controlling the speed and heading angle of a fish like robot. Since models and efficient simulation platforms are absent for generating training data, we first develop a model and simulation environment for a planar carangiform type of fish-like robot, based on the models developed in [10], [12]–[14]. The parameters in these models are estimated using experimental data. The physical platform is a highly efficient and agile swimming robot whose primary means of propulsion is an internal rotor [15]–[18]. The robot has two actuators, one for propulsion and one primarily for steering; this motivates the use of separate PID controllers for tracking a reference angle and one for tracking a speed. Reference angle tracking is used in conjunction with a line-of-sight planner to track a path. The gains for these PID controllers however have to change with the curvature along the path and the reference speed [19]. Recent work has shown that differentiable physics simulators enable efficient gradient-based learning of control policies by allowing gradients to propagate through system dynamics [20]–[22]. Since we develop a differentiable simulator of the Chaplygin sleigh dynamics, gradients can be propagated directly through the system model during training. The control policy (for these gains) is therefore learned using backpropagation through time on a curriculum of tracking tasks. The policy learned in simulation is then applied on the physical platform and is demonstrated by the robot tracking various curved paths at changing reference speeds. See the attached supplementary file for a video and source codes are available at this Github repository (agilefish-diff-rl).
We developed a fish-like robot with a simple and modular architecture inspired by previously reported internally actuated rotor-driven systems [12], [17]. Multiple variations of such inertial-propulsion platforms have been proposed in the literature [16], [23], demonstrating the viability of oscillatory internal mass actuation for aquatic locomotion. Inspired by these platforms, we developed a modular and simplified variant designed specifically as a control-oriented experimental testbed.
The robot consists of a rigid extruded shell shaped as a hydrofoil, referred to as the head, as shown in Fig. 1 (a). The head is \(150\) mm long with an extruded height of \(75\) mm, and the tail is \(100\) mm long. The total length of the robot is \(250\) mm (1 body length), and the total weight is \(535\) g. This sealed shell houses the propulsion module and onboard electronics, see Fig. 1 (b). Propulsion is generated by an internally mounted balanced rotor that produces periodic inertial excitation, which interacts with the surrounding fluid to generate net forward thrust through internal momentum exchange rather than external propeller action. The rotor is driven by a brushless motor (370 Kv Vertiq 4006 module), enabling precise control of oscillation amplitude and frequency. Forward velocity is regulated by commanding a sinusoidal rotor velocity, \(\dot{\phi} = A \omega sin(\omega t)\), where \(A\) and \(\omega = 2\pi \cdot f\). Onboard computation performs estimation and control, with an IMU (BNO085) providing inertial measurements for state estimation. A Raspberry Pi Zero 2W serves as the computer on board. Heading control is achieved through a servo-actuated tail rudder. The robot achieves a minimum turning radius of 0.3 body lengths (BL) and a maximum swimming speed of 2 BL/s.
We construct a mathematical model of planar swimming for the robot described in section 2. The purpose of the model is not detailed fluid reconstruction, but to capture the essential propulsion mechanism, steady-state limit-cycle behavior, and tail-induced rudder mechanism for steering. Propulsion in the robot is generated by an internal rotor mounted within the head, see Fig. 1b and 2.
The robot’s configuration is described by the planar pose of the head \(( x_h, y_h, \theta_h ) \in SE(2)\) and the absolute orientation of each tail segment \(\theta_i \in S^1\). Hence, the generalized coordinates for the system are \(\mathbf{q}= \begin{bmatrix} x_h, y_h, \theta_h, \theta_n, \cdots , \theta_2, \theta_1 \end{bmatrix}\). Here, the rudder angle \(\alpha(t)\) is actuated by a lightweight servo and is treated as a prescribed input rather than a generalized coordinate.
The kinetic energy of the robot is \(T = \frac{1}{2}\dot{\mathbf{q}}^T M(\mathbf{q},\alpha)\dot{q} + I_r \dot{\phi}^2\) where, \(I_r\) is the rotor moment of inertia and the mass matrix \(M(\mathbf{q})\) includes both the mass and the hydrodynamic added mass of each tail segment, [5]. Tail flexibility is modeled using torsional springs between consecutive links which gives the potential energy as \(V = \frac{1}{2} k_j \Big( \sum_{j=1}^{n-1} (\theta_j-\theta_{j+1})^2 \Big) = \frac{1}{2} \mathbb{K}\mathbf{q}^{\intercal} \tilde{A} \mathbf{q}\) Then, the Lagrangian \(\mathcal{L} = T-V\) is given by, \[\mathcal{L} = \frac{1}{2} \dot{\mathbf{q}}^{\intercal} \mathcal{M}(\mathbf{q},\alpha) \dot{\mathbf{q}} - \frac{1}{2} \mathbb{K} \mathbf{q}^{\intercal} \tilde{A} \mathbf{q}\]
Hydrodynamic viscous drag on the head and tail links is modeled using a Rayleigh dissipation function defined in the body frame of each rigid element. The viscous drag is modeled using the body-fixed frame velocities of each bodies \(v_{b,i}\) and diagonal damping matrices \(C_h\) for the head and \(C_l\) for all the links. Then the Rayleigh dissipation function is defined as, \[\mathcal{R} = \frac{1}{2}v_{b,h}^T C_h v_{b,h} + \frac{1}{2} \sum_{i =1}^n v_{b,i}^T C_h v_{b,i}\] Propulsion in oscillatory swimmers is dominated by the net momentum exchange generated by the oscillating rotor–tail system. Explicitly resolving the associated vortex shedding and wake evolution would require a fully coupled fluid–structure simulation, which is computationally expensive and complex for control-oriented modeling. Instead, we adopt a reduced-order mechanical representation that captures the dominant propulsion mechanism through added-mass effects and a nonholonomic constraint that enforces zero lateral velocity at an effective contact point \(p\) located at the tail end. At this point, lateral slip is assumed to be suppressed, leading to the Chaplygin-type Pfaffian constraint \[\label{eq:non-holonomic} \mathcal{A}(\mathbf{q},\alpha)\dot{\mathbf{q}} = 0\tag{1}\] In the inviscid flow approximation, such nonholonomic constraints have been shown to model the Kutta-Joukowski vortex shedding condition [12], [13] and have inspired underwater robot design and control, see [15], [17]. With the Lagrangian \(\mathcal{L}\), the generalized damping forces \(Q_d = -\frac{\partial \mathcal{R}}{\partial \dot{\mathbf{q}}}\), and the nonholonomic constraint at point \(p\) defined in 1 the equations of motion are obtained by combining the Euler–Lagrange equations with the constraint using a Lagrange multiplier. This yields
\[\begin{align} \label{eq:Euler95Lag} \frac{\mathrm{d}}{\mathrm{d}t}\Big(\frac{\partial \mathcal{L}}{\partial \dot{q}_i }\Big)-\frac{\partial \mathcal{L}}{\partial q_i} + \frac{\partial{\mathcal{R}}}{\partial{\dot{\mathbf{q}}}} = \mathcal{A}^T(\mathbf{q},\alpha)\dot{\mathbf{q}} \lambda,\\ s.t.~~~ \mathcal{A}(\mathbf{q},\alpha)\dot{\mathbf{q}} = 0 \end{align}\tag{2}\]
The resulting constrained equations of motion are written as, \[\label{eq:model} \begin{bmatrix} M(\mathbf{q},\alpha) & B(\dot{\mathbf{q}},\mathbf{q},\alpha) \\ \mathcal{A}(\mathbf{q},\alpha) & 0 \end{bmatrix} \begin{bmatrix} \ddot{\mathbf{q}} \\ \dot{\mathbf{q}} \end{bmatrix} = \begin{bmatrix} \mathbb{K} \tilde{A} \mathbf{q}+ Q_d(\dot{\mathbf{q}},\mathbf{q},\alpha) + \mathcal{A}(\mathbf{q},\alpha) \lambda \\ 0 \end{bmatrix}\tag{3}\] This formulation captures the primary hydrodynamic forces while maintaining a compact structure suitable for analysis, fast simulation and learning-based control.
To assess the fidelity of the reduced-order model, we compare its predictions against experimental data collected from the physical robot. The damping and torsional stiffness parameters were identified from \(12\) experimental trials, each of \(20\) seconds duration.
Figure 3 compares simulation and experimental results for a representative actuation case (amplitude \(A = 9\) rad and frequency \(\omega = 2 \pi \cdot 2\)). The forward velocity (let \(v_{bh,x} := v_{bx}\) for ease of notation) response shows strong agreement in both transient behavior and steady-state magnitude. The nonlinear model reproduces the stable limit-cycle dynamics induced by oscillatory actuation, and the resulting steady propulsion accurately matches the experimentally observed planar \(X-Y\) trajectory. Experimental validation in Figure. 3 (d) shows that with the presence of a stable limit-cycle, the steady-state forward velocity scales approximately linearly with a scalar throttle variable. Over the operating range of \(0.1–0.3\) m/s, velocity exhibits an approximately linear relationship with both the amplitude of acceleration (\(A\omega^2\)) and the square of it, that is \((A\omega^2)^2\), with the latter providing a slightly better empirical fit. We therefore define the throttle input as, \[s := A^2\omega^4 \label{eq:throttle95map}\tag{4}\] This limit-cycle structure suggests regulating motion by shaping oscillatory behavior rather than directly commanding forces. Thus, the robot’s long-term speed is governed by the limit-cycle behavior and can be regulated by adjusting the actuation parameters, also shown in [14].
The control objective consists of simultaneous forward velocity tracking and geometric path tracking through heading regulation. Propulsion depends on oscillation amplitude (\(A\)) and frequency (\(f\)), while steering is achieved through rudder deflection (\(\alpha\)), leading to coupled actuation channels. Manual PID tuning in this setting is nontrivial because speed and heading dynamics interact through the underlying limit-cycle behavior, requiring significant heuristic adjustment to achieve stable and responsive performance. We therefore adopt a structured dual-loop PID controller: one loop regulates heading via \(\alpha\) using heading error (\(e_{\theta}\)), \[\label{eq:PID} \hat{\alpha} = K_{p,a} e_{\theta} + K_{i,a} \int e_{\theta} \mathrm{d}t + K_{d,a} \frac{\mathrm{d}e_{\theta}}{\mathrm{d}t}\tag{5}\] and the other regulates forward speed via the throttle variable \(s\), which is informed by limit cycles. \[\label{zpchwisy} s = K_{p,s} e_v + K_{i,s} \int e_v \mathrm{d}t + K_{d,s} \frac{\mathrm{d}e_v}{\mathrm{d}t}\tag{6}\] Here, \(e_v\) is the error in velocity. Instead of selecting gains heuristically, the PID gain vector is treated as a set of decision variables to be optimized.
The continuous time solutions to 3 are time-discretised and represented as \[x_{k+1} = f(x_k, u_k),\] where \(x_k \in \mathcal{X}\) denotes the system state and \(u_k \in \mathcal{U}\) the control input at time \(t_k\). Observations are given by \(o_k = g(x_k)\). Instead of directly outputting control actions, a neural network parameterized by \(\theta\) produces time-varying controller gains \(K_k = \pi_\theta(o_k)\), where \(K_k\) collects the steering and throttle gains at time step \(k\). These gains parameterize the structured controller, which generates the control input \(u_k = \mathcal{P}(x_k, K_k)\), where \(\mathcal{P}\) denotes the PID control law given in Eq. 5 with gains \(K_k\) .
The resulting closed-loop system is \[x_{k+1} = f\big(x_k, \mathcal{P}(x_k, \pi_\theta(g(x_k)))\big),\] making the entire trajectory implicitly dependent on \(\theta\).
We formulate controller learning as the finite-horizon optimal control problem. \[\min_{\theta} J(\theta),\] where,\(J(\theta) = \sum_{k=0}^{N-1} \ell(x_k, u_k).\)
The stage cost is defined as \[\begin{align} \ell_k =\; & w_1 e_{\theta,k}^2 + w_2 e_{v,k}^2 + w_3 e_{cte,k}^2 \\ & +\; w_4 \Delta u_k^2 + \lambda_{K} \|K_k\|^2 + \lambda_{\Delta K} \|\Delta K_k\|^2 . \end{align}\] where, \(e_{\theta,k}\) denotes the heading (steering) error, \(e_{v,k}\) the body-frame forward velocity tracking error, and \(e_{cte,k}\) is the cross-track error relative to the reference path. The term \(\Delta v_k = v_k - v_{k-1}\) denotes the change in body-frame forward velocity, for smooth changes in velocity. The gain vector at time step \(k\) is given by \(K_k\), where \(\|K_k\|^2\) penalizes large gain magnitudes and \(\|\Delta K_k\|^2 = \|K_k - K_{k-1}\|^2\) penalizes rapid temporal variations in the gains.
The PID gains are generated by a neural policy \(K_k = \pi_\theta(o_k),\) which parameterizes the closed-loop controller. We minimize the finite-horizon objective \[J(\theta) = \sum_{k=0}^{N-1} \ell(x_k,u_k),\] subject to the closed-loop dynamics \(x_{k+1} = f(x_k,u_k), \quad u_k = \mathcal{P}(x_k,K_k).\) Applying the chain rule over the unrolled trajectory yields \[\nabla_\theta J = \sum_{k=0}^{N-1} \left( \frac{\partial \ell_k}{\partial x_k} \frac{\partial x_k}{\partial \theta} + \frac{\partial \ell_k}{\partial u_k} \frac{\partial u_k}{\partial \theta} \right),\] where state variations are recursively induced by the system dynamics. The gradient flow through the closed loop can be summarized as \[\theta \;\rightarrow\; K_k \;\rightarrow\; u_k \;\rightarrow\; x_{k+1} \;\rightarrow\; \ell_k .\]
Gradients are computed by unrolling the closed-loop system for \(N\) steps and applying backpropagation through time (BPTT) [20], allowing differentiation through the PID update, throttle mapping, and physical dynamics. The parameters are updated using gradient descent: \[\theta \leftarrow \theta - \alpha \nabla_\theta J.\]
We next summarize the policy architecture and optimization settings used to train the controller through the differentiable closed-loop simulation. At each time step \(k\), the policy receives an input vector \(z_k \in \mathbb{R}^{6}\) composed of normalized tracking signals and including the normalized head angle and velocity. \[z_k = \big[ \theta_{h,k}^{\mathrm{norm}},\; v_{bx,k}^{\mathrm{norm}},\; v_{\mathrm{des}}^{\mathrm{norm}},\; e_{\theta,k}^{\mathrm{norm}},\; e_{v,k}^{\mathrm{norm}},\; e_{cte,k}^{\mathrm{norm}} \big]^\top ,\] where \(\theta_{h,k}^{\mathrm{norm}}=\theta_{h,k}/(\pi/2)\), \(v_{bx,k}^{\mathrm{norm}}=v_{bx,k}/v_{\max}\), \(v_{\mathrm{des}}^{\mathrm{norm}}=v_{\mathrm{des}}/v_{\max}\), \(e_{\theta,k}^{\mathrm{norm}}=e_{\theta,k}/(\pi/2)\), \(e_{v,k}^{\mathrm{norm}}=e_{v,k}/v_{\max}\), and \(e_{cte,k}^{\mathrm{norm}}=e_{cte,k}/L_d\). The policy outputs a vector \(a_k \in \mathbb{R}^{6}\), which is mapped to bounded PID gains using an elementwise \(\tanh\) squashing followed by affine scaling: \[K_k = \mathrm{scale}(\tanh(a_k)),\] where \(K_k = [K_{p,a}, K_{i,a}, K_{d,a}, K_{p,s}, K_{i,s}, K_{d,s}]^\top\).
In particular, the steering gains are constrained to \(K_{p,a},K_{i,a},K_{d,a}\in[0,1]\), and the speed gains are constrained to \(K_{p,s}\in[0,2.5]\), \(K_{i,s}\in[0,0.1]\), and \(K_{d,s}\in[0,0.1]\). Given the gain vector \(K_k\), two PID updates are applied in closed loop. The steering PID uses the heading error \(e_{\theta,k}\) to produce a steering command \(\alpha_k\), followed by a rate limiter to enforce actuator slew limits. In parallel, the speed PID uses the velocity error \(e_{v,k}\) to produce a throttle signal \(s_k \in [0,1]\). The throttle signal \(s_k\) is transformed into motor amplitude and frequency parameters \((A_k,\omega_k)\) via a deterministic mapping as in 4 . These parameters define the rotor phase and angular acceleration according to \[\begin{align} \varphi_{k+1} &= \mathrm{mod}\!\left(\varphi_k + \omega_k \Delta t,\; 2\pi\right), \\ \ddot{\phi}_k &= -A_k\,\omega_k^{2}\,\sin(\varphi_{k+1}), \end{align}\] yielding the control inputs \((\alpha_k,\ddot{\phi}_k)\) applied to the sleigh dynamics.
Policy parameters are optimized using Adam with global-norm gradient clipping (1.0), using BPTT with an unroll length of \(N=15\) time steps per update, similar to [20]. Each policy update is computed over a batch of \(B=8\) independent environments. The policy is parameterized by a fully connected multilayer perceptron (MLP) with three hidden layers of sizes \(128\), \(128\), and \(64\), each followed by ReLU activations. Training was conducted on a multi-core CPU on Clemson’s Palmetto Cluster [24].
Training is performed entirely in simulation using procedurally generated reference trajectories. We employ a curriculum that varies both commanded speed and path curvature to progressively increase task difficulty, similar to prior work [25]–[27]. Within each batch, all environments track a common base reference trajectory, while the commanded speeds are set deterministically to span \(v_{bx}\in[0.1,0.3]\). This exposes the policy to diverse speed-tracking conditions while preserving a consistent path tracking objective across the batch.
In addition to speed variation, we adopt a curvature-based progression similar to [27]. Training begins with low-curvature trajectories and gradually increases path difficulty over time. The policy alternates between sinusoidal and circular reference paths every second episode. For sinusoidal trajectories, the amplitude (1.0 m and 1.5 m) and number of cycles (0.5, 1, and 2) are varied to increase curvature and lateral acceleration demands. For sinusoidal trajectories, a small random phase offset (uniformly sampled over \([0, 2\pi]\)) is also applied independently to each environment. This preserves curvature magnitude while preventing the policy from memorizing a fixed spatial pattern. For circular trajectories, the radius is reduced between 1.5 m and 1.0 m to impose tighter turning requirements. Progression to higher difficulty levels is performance-driven: the curriculum advances only when the mean cross-track error over a sliding window of recent episodes falls below predefined thresholds (0.03 m and 0.01 m). This ensures that increased curvature is introduced only after the policy demonstrates adequate tracking performance at the current level. Together, these variations in speed and curvature encourage the policy to first develop stable speed and heading regulation on smoother, slower trajectories before adapting to tighter turns, higher lateral accelerations, and more demanding cross-track tracking conditions.
To assess the effectiveness of the proposed learning framework, we evaluate the closed-loop tracking performance of our trained policy in simulation across varying curvature levels and commanded speeds \(v_{bx} \in [0.1,\,0.3]\). Fig. 5 shows the BPTT training curve averaged over nine random seeds. The mean loss decreases rapidly during the initial training phase, indicating that the policy quickly learns regulation of heading and speed. The periodic variations in the loss correspond to the alternating curriculum between sinusoidal and circular trajectories. Despite these transitions, the overall loss trend decreases and stabilizes. The narrow standard deviation band across seeds suggests consistent convergence behavior.
As shown in Figs. 6 and 8, the controller achieves a mean cross-track error of approximately \(0.01\,\mathrm{m}\) across both sinusoidal and circular trajectories while maintaining negligible heading error. Comparable tracking accuracy is obtained across additional evaluated trajectories, including straight-line and square-wave paths, which are omitted for brevity.
A small but persistent velocity tracking error of approximately \(0.05\,\mathrm{m/s}\) is observed in the circular trajectory (Fig. 8) when tracking the higher reference speed of \(0.3\,\mathrm{m/s}\), whereas for the sinusoidal trajectory, a lower reference speed of \(0.12\,\mathrm{m/s}\) was tracked with a mean velocity error below 0.01 m/s. Although the commanded velocity is constant along each reference path, maintaining a strictly constant speed is not necessarily dynamically feasible for a swimming robot subject to curvature-induced hydrodynamic constraints. In particular, tighter turns require greater turning effort, which can reduce the achievable forward velocity. The residual speed error, therefore, reflects an inherent trade-off between strict velocity tracking and accurate path following.
Figure 7 illustrates the gains generated by the trained policy during tracking of a sinusoidal trajectory. The steering and speed gains vary smoothly over time, exhibiting approximately sinusoidal profiles that reflect curvature-dependent gain modulation. As the swimmer enters higher-curvature segments, the proportional and integral gains increase, while the derivative gain exhibits a slight decrease. The reduction in derivative gain near curvature peaks indicates that the policy moderates damping when larger heading rates are naturally required by the path geometry, thereby preventing excessive resistance to the curvature-induced turning motion.
The speed proportional gain exhibits a slight decrease near curvature peaks. Because turning motion and forward propulsion are dynamically coupled in undulatory swimming systems, temporarily relaxing speed regulation during high-curvature segments reduces interference with geometric path tracking. Although the gains vary systematically with curvature, their deviations from the nominal mean values remain small. These modest adjustments suggest that relatively minor geometry-dependent variations in the gains are sufficient to achieve accurate tracking along the sinusoidal path.
Similarly, during circular trajectory tracking in Fig 9, the gains converge toward nearly steady values consistent with the constant curvature of the path. A small jump is observed around \(7.5\) seconds, which corresponds to angle wrapping in the heading error as the swimmer progresses along the circle. This discontinuity is due to the heading transitioning across the \(\pm \pi\) boundary rather than a change in curvature. Following this transition, the gains quickly resettle to values appropriate for the constant turning condition.
Overall, the simulation results demonstrate that the learned policy achieves accurate path tracking while performing structured, curvature-dependent gain modulation. The consistent behavior across sinusoidal and circular trajectories indicates that the policy adapts directly to path geometry rather than exhibiting arbitrary time-varying tuning.
A series of experiments were conducted to evaluate the real-world performance of the trained policy across different reference trajectories. The objective is to assess closed-loop tracking accuracy on the physical robotic fish and examine whether the behavior observed in simulation translates to practical operation. The policy is deployed directly onboard on the robot, and performance is quantified using root-mean-square (RMS) cross-track, heading, and speed errors.
Experiments were conducted in a \(14\,\text{ft} \times 7\,\text{ft}\) indoor pool equipped with an overhead vision system for global position feedback. Colored markers mounted on the robot body were detected using HSV-based segmentation and contour extraction. Pixel coordinates were corrected for lens distortion and converted to metric world-frame positions. To reduce measurement noise, low-pass filtering was applied, and vision measurements were fused with onboard IMU data using a Kalman filter to obtain consistent estimates of position, velocity, and orientation for closed-loop control.
Control was executed onboard a Raspberry Pi Zero 2W within a ROS-based architecture. Path tracking was implemented using a line-of-sight planner that selects a lookahead point on the reference trajectory at a fixed radius of \(0.4\,\text{m}\) from the robot. A PID controller generated the control inputs for heading and forward speed, with gains produced online by the learned actor policy. This onboard deployment enabled evaluation of tracking performance and curvature-dependent gain adaptation under real hydrodynamic conditions.
The trained policy was evaluated on four reference trajectories forming the letters “I”, “R”, “O”, and “S” at command speeds \(v_{bx} \in \{0.10,\,0.15,\,0.20,\,0.25\}\,\text{m/s}\). These trajectories span varying curvature profiles, ranging from near-straight motion (“I”) to segments with tighter turns (“S”).
Across all trajectories and command speeds, stable closed-loop tracking was achieved with bounded cross-track and heading errors. Figure 4 shows representative path overlays for different velocities. The swimmer successfully follows the geometric shape of each trajectory. Tracking accuracy exhibits a systematic dependence on command speed. Larger cross-track deviations are observed at lower velocities, while tracking improves as forward speed increases. This trend is consistent across the “I”, “R”, “O”, and “S” trajectories. Quantitative RMS cross-track, heading, and speed errors for all trajectories and speeds are summarized in Table 1.
The increased cross-track error at lower speeds can be attributed to the coupled training objective and the velocity-dependent steering authority of the fish robot. The policy is optimized to regulate both path tracking error and forward speed. Steering corrections reduce forward velocity, and at low command speeds aggressive heading adjustments can significantly disturb speed regulation. Consequently, the learned policy adopts a more conservative steering strategy to preserve velocity tracking, resulting in slightly increased lateral deviation.
Figure 11 illustrates longitudinal velocity tracking for each trajectory. A small transient overshoot is observed at the beginning of each trial across all commanded speeds. Although a derivative term is present in the speed controller, the initial control action induces a short acceleration phase before feedback regulation settles the motion. The overshoot remains bounded and quickly converges to the commanded value, indicating stable closed-loop behavior. Figure 12 shows the online evolution of PID gains during experimental tracking of the “R” and “S” trajectories at 0.2 m/s. Yaw gains vary across trajectories and over time, whereas velocity gains remain comparatively stable with minimal modulation.
Overall, the experimental results demonstrate that the learned policy generalizes effectively to the physical robot. The controller maintains stable path tracking while performing consistent, curvature-dependent gain modulation across multiple trajectories and commanded speeds.
| Cross-Track RMSE (m) | Speed RMSE (m/s) | |||||||
| Path | Velocity (m/s) | Velocity (m/s) | ||||||
| 0.10 | 0.15 | 0.20 | 0.25 | 0.10 | 0.15 | 0.20 | 0.25 | |
| I | 0.016 | 0.019 | 0.011 | 0.012 | 0.036 | 0.041 | 0.031 | 0.040 |
| R | 0.104 | 0.061 | 0.049 | 0.025 | 0.030 | 0.032 | 0.039 | 0.061 |
| O | 0.122 | 0.073 | 0.088 | 0.024 | 0.025 | 0.015 | 0.041 | 0.041 |
| S | 0.084 | 0.049 | 0.043 | 0.046 | 0.023 | 0.022 | 0.028 | 0.075 |
The paper presents results on the motion control and path tracking of a fish-inspired swimming robot using a reinforcement learning framework. A physics-based differentiable simulator with parameters identified from experimental data is used to enable gradient-based optimization of the control policy through backpropagation through time. The policy is structured as a gain-learning framework for PID controllers, thus maintaining an interpretable control structure. The policy learned in simulation is transferred to the experimental platform where accurate simultaneous speed and path tracking is achieved at different reference speeds. This sim-to-real transfer is enabled by the mutlistep process of modeling and curriculum learning. While the results are limited to planar swimming, future work will address three-dimensional motion control.
\(^{\dagger}\) All authors have contributed equally. * This work was supported by grant 2433150 from the National Science Foundation. \(^{1}\) The authors are with the
Department of Mechanical Engineering, Clemson University, USA. email: {ptallap}@clemson.edu↩︎