munetauvsim.plotTimeSeries
Visualization functions for AUV simulation data.
Provides plotting functions for time-series analysis and 3D animated visualization of vehicle trajectories, states, controls, and ocean environment. Based on Fossen’s Python Vehicle Simulator plotting utilities.
Functions
- plotVehicleStates(simTime, simData, vehId, figNo)
Plot 6-DOF vehicle states (position, attitude, velocities) vs time.
- plotControls(simTime, simData, vehicle, figNo)
Plot vehicle control inputs (commanded and actual) vs time.
- plot3D(simData, sampleTime, numDataPoints, FPS, filename, vehicles, ocean, …)
Create 3D animated visualization and save as GIF.
Utility Functions
- R2D(value)
Convert radians to degrees.
- cm2inch(value)
Convert centimeters to inches for figure sizing.
Notes
Default plot parameters (figure size, DPI, legend size) are defined as module-level globals and can be modified before calling plot functions.
References
[1] Fossen, T.I. Python Vehicle Simulator. GitHub repository. https://github.com/cybergalactic/PythonVehicleSimulator
Functions
|
Convert radians to degrees. |
|
Convert centimeters to inches for matplotlib figure sizing. |
|
Create 3D animated visualization of vehicle trajectories and save as GIF. |
|
Plot vehicle control inputs (commanded and actual) versus time. |
|
Plot 6-DOF vehicle states (position, attitude, velocities) versus time. |
|
Compute the smallest signed angle to range [-pi, pi). |
Classes
|
AnchoredOffsetbox with Text. |
|
Abstract base class for objects that render into a FigureCanvas. |
|
|
|
|
|
Container and manager for ocean environmental components. |
|
A collection of 3D polygons. |
|
Abstract base class for structural hierarchy of vehicle classes. |
- munetauvsim.plotTimeSeries.cm2inch(value)[source]
Convert centimeters to inches for matplotlib figure sizing.
- munetauvsim.plotTimeSeries.plotVehicleStates(simTime, simData, vehId, figNo)[source]
Plot 6-DOF vehicle states (position, attitude, velocities) versus time.
Creates a multi-subplot figure showing comprehensive vehicle state evolution including position, attitude angles, velocities, and derived quantities like course angle and crab angle.
- Parameters:
simTime (ndarray, shape (N+1,)) – Time vector in seconds. Includes t=0 initial condition.
simData (ndarray, shape (N+1, 18)) – Simulation data for single vehicle: [eta(6), nu(6), u_control(3), u_actual(3)].
vehId (int) – Vehicle identification number for plot title.
figNo (int) – Figure number for plot window.
- Return type:
None
Notes
Creates 9 subplots:
Position (path) in North-East plane (x-y plane)
Depth (z) vs time
Roll (phi) and pitch (theta) angles vs time
Speed vs time
Course angle (chi) vs time
Pitch angle (theta) and flight path angle (alpha_c) vs time
Body-frame velocities (surge (u), sway (v), heave (w)) vs time
Angular rates (roll (p), pitch (q), yaw (r)) vs time
Yaw angle (psi) and crab angle (beta_c) vs time
All angles displayed in degrees.
Uses smallest signed angle (ssa) wrapping.
- munetauvsim.plotTimeSeries.plotControls(simTime, simData, vehicle, figNo)[source]
Plot vehicle control inputs (commanded and actual) versus time.
Creates subplots comparing commanded control inputs (u_control) with actual control responses (u_actual) after actuator dynamics and saturation.
- Parameters:
Notes
Number of subplots = vehicle.dimU (number of control inputs). For Remus100s: 3 subplots (rudder, stern plane, propeller).
Angles automatically converted to degrees based on control description strings.
Each subplot shows commanded (blue) vs actual (orange) control trajectory.
- munetauvsim.plotTimeSeries.plot3D(simData, sampleTime, numDataPoints, FPS, filename, vehicles, ocean, figNo=1, showClock=True, showData=True, showTraj=True, showPos=True, showCur=True, showFloor=True)[source]
Create 3D animated visualization of vehicle trajectories and save as GIF.
Generates animated 3D plot showing vehicle motion in East-North-Down frame with optional ocean environment features (current vectors, floor bathymetry, surface). Includes time clock and simulation data display.
- Parameters:
simData (ndarray, shape (n_vehicles, N+1, 18)) – Simulation data for all vehicles. (n_vehicles, N, [eta, nu, u_control, u_actual])
sampleTime (float) – Simulation time step in seconds.
numDataPoints (int) – Number of data points to use in plot. Divides simData into numDataPoints samples (downsampling).
FPS (int) – Frames per second for GIF animation.
filename (str) – Animated GIF file name.
vehicles (list of Vehicle) – Vehicle objects in order corresponding to simData.
ocean (Ocean) – Ocean environment object with floor and current data.
figNo (int, default=1) – Figure number for plot window.
showClock (bool, default=True) – Display simulation time clock overlay.
showData (bool, default=True) – Display simulation info panel (communication mode, depth range, current).
showTraj (bool, default=True) – Plot vehicle trajectory paths as lines.
showPos (bool, default=True) – Plot vehicle current positions as points.
showCur (bool, default=True) – Display animated ocean current vector field.
showFloor (bool, default=True) – Display ocean floor surface (if ocean.floor exists).
- Return type:
None
Notes
Performance Considerations:
Downsampling via numDataPoints reduces computation time
Ocean floor rendering is major performance bottleneck (~2500 grid points default)
Animation saving takes ~1-5 minutes depending on numDataPoints and features
Visual Elements:
Ocean surface: Transparent blue plane at z=0
Current vectors: Blue arrows at fixed grid, updated each frame
Floor: Terrain-colored surface with depth-based shading
Trajectories: Colored lines, one per vehicle
Positions: Moving points along trajectories
Waypoints: Triangle markers at target positions
Coordinate System:
END (East-North-Down)
Data Display Box Contents:
COM: Communication mode (Direct Access, FDMA, TDMA)
DEP: Depth range min-max in meters
CUR: Ocean current speed and direction
Animation Function:
Uses matplotlib.animation.FuncAnimation with custom frame generation.
Each frame updates positions, trajectories, current vectors, and display boxes.