Skip to content

Robot fish/tailfin simulation using Simulink's Simscape multibody library. Inspired by the MIT RoboTuna.

Notifications You must be signed in to change notification settings

ocean1xin/Simscape-Robot-Fish

 
 

Repository files navigation

Simscape Robot Fish

Robot fish/tailfin simulation using Simulink's Simscape multibody library. Inspired by the MIT RoboTuna. See SimscapeRobotFishMath.pdf for math explanation.

Requirements

  1. MATLAB (r2019A)
  2. Simulink
  3. Simscape
  4. Simscape Multibody

Running Simulations

  1. Open the source folder in MATLAB
  2. Run params.m to populate Matlab workspace
  3. (OPTIONAL) Edit waveform parameters (A,c1,c2,k,w) in lighthillCurve.m
  4. Open Model.slx
  5. In "Simulation->Model Configuration Parameters" choose the "daessc (DAE solver for simscape)" solver with variable-step
  6. Run Model.slx

Simscape Renderings:

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.

Params: wave number = 1/2, frequency = 4 rad/s, c1 = 0.84, c2 = 5.49 (Normalized to body length)

Params: wave number = 3/4, frequency = 10 rad/s, c1 = 0.84, c2 = 5.49 (Normalized to body length)

Simulink Model Structure

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.

Top-Level Structure

PD Torque Feedback Controller

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].

8 Body Links and Tailfin

Each Body Link + Joint

Output Data

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:

Params: wave number = 3/4, frequency = 3 rad/s, c1 = 1.65, c2 = 18 (Normalized to body length)

Controller Torque

Reference Angles

Reference Angular Velocity

rootFindingAnimation.py

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.

About

Robot fish/tailfin simulation using Simulink's Simscape multibody library. Inspired by the MIT RoboTuna.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • MATLAB 60.1%
  • Python 39.9%