Robot fish/tailfin simulation using Simulink's Simscape multibody library. Inspired by the MIT RoboTuna. See SimscapeRobotFishMath.pdf for math explanation.
- MATLAB (r2019A)
- Simulink
- Simscape
- Simscape Multibody
- Open the source folder in MATLAB
- Run params.m to populate Matlab workspace
- (OPTIONAL) Edit waveform parameters (A,c1,c2,k,w) in lighthillCurve.m
- Open Model.slx
- In "Simulation->Model Configuration Parameters" choose the "daessc (DAE solver for simscape)" solver with variable-step
- Run Model.slx
This "robot fish" is modeled as a 8-joint manipulator tasked with tracking a time-dependent plane curve known as the Lighthill curve:
The Lighthill curve is supposed to model a fish's swimming waveform (or gait) in the XY-plane. Each fish's gait has its own unique amplitude profile, wavenumber, and angular frequency. These parameters are also a function of swimming speed, acceleration, etc.
At the top level inverseKinematics.m prepares a vector of reference angles from Y(x,t) which are passed to the PD controller block. The PD controller outputs a feedback torque as a function of the input angles and (low-pass filtered) angular velocities. The torque control input is passed to the system dynamics, rendered in Simscape, outputting the measured angles which feed back to PD controller block.
The simscape model is composed of 8 body link + 1 tail fin link. The 8 body links of constant length L = 6.25 cm are connected by the inner N = 7 revolute joints 1-7. There are also revolute joints '0' which connects the frontmost link to the world frame and 't' connects the 8th link to the tailfin. Joints 1-t each have torsional spring and dampers with constant coefficients k = 200 [g cm^2 / s^2] and b = 5 [g cm s^2].
Model.slx exports the reference angles, measured angles, and torques to .mat files in the Data folder which are then plotted by plotAll.m. Example plots are below for the current version with first 2/7 reference angles set to zero:
Creates GIF of N-joint polyline fitted to lighthill curve using the bisection method. This illustrates what inverseKinematics.m does. The reference angles used in the Matlab simulation are the angles between adjacent line segments.