Python Vehicle Simulator
Home Recognitions Patents Appointments

The Python Vehicle Simulator is a supplementary Python implementation of the Matlab and GNU Octave scripts in the VESSELS catalogue of the MSS toolbox. The library also contains guidance, navigation, and control (GNC) blocks for time-domain simulation. The software can be downloaded from:

GitHub Repository: https://github.com/cybergalactic/PythonVehicleSimulator

Hydrodynamic modelling and the GNC algorithms are described in:

T. I. Fossen (2021). Handbook of Marine Craft Hydrodynamics and Motion Control, 2nd Edition, John Wiley & Sons, Chichester, UK.

The different vehicles are defined as Python "objects" with "methods" for feedback control. For instance, the Remus 100 AUV is specified by choosing option #9 from the commad line interface shown below.

The picture shows the Remus 100 Autonomous Underwater Vehicle (AUV) of the NTNU AUR-lab. The length of the vehicle is 1.9 m, the cylinder diameter is 19 cm and the mass of the vehicle is 31.9 kg. The maximum speed of 2.5 m/s is obtained when the propeller runs at 1525 RPM in zero currents.

The animated GIF file "3D_animation.gif".
The Python code for the constrcutor and main simulation loop are shown below (see main.py and remus100.py for more details). The constructor, vehicle = remus100('depthHeadingAutopilot',30,50,1525,0.5,170), defines the Remus 100 AUV with a heading and depth autopilot. The setpoints (constructor arguments) are 50 degrees in yaw and 30 m depth. The propeller revolution is chosen as 1525 rpm. The AUV is exposed for an ocean current of speed 0.5 m/s and direction 170 deg. The vehicle's state plots below confirm that the autopilots achieve their control objectives.
The main simulation loop is used to generate time series. The results are plotted as three figures numbered 1-3 using the functions plotVehicleStates(simTime, simData, 1), plotControls(simTime, simData, vehicle, 2) and plot3D(simData, numDataPoints, FPS, filename, 3). In addition, a 3D animated GIF file is generated. The GIF file can be opended manually in a web browser by right-clicking the file or automatically by adding webbrowser.get(browser).open_new_tab('file://' + os.path.abspath(filename)) to the main loop.
Copyright © Thor I. Fossen
Last updated: 16 June 2024