Vehicle Dynamics Simulation using SimPy
A Quick Introduction to SimPy for ODE Simulations
Below, the basic concepts of SimPy - and how they apply to the problem of simulating Ordinary Differential Equations -will be overviewed.
Execute the following steps:
You can now optionally the basic verification steps that SimPy's offers:
2. Characterizing a system using Ordinary Differential Equations
A dynamic system, say a mass-spring system, can be characterized by the relation between its state variables and its inputs. This relation is expressed in the form of differential equations (and in that case "Ordinary Differential Equations"). To derive the ODE representation, we rely on laws of physics with the level of accuracy and fidelity we consider appropriate for the specific task at hand.
The specifc system (shown in Figure 1) can be captured by the following secord order Ordinary Differential Equation (ODE):
Figure 1: Sprin-mass system.
Simulating such a system with the help of SimPy is particularly simple as shown in the code section below.
The aforementioned system is particularly simple as it is expressed using linear ODEs. A slightly more difficult case arises, when one has to deal with nonlinear systems. Take for example the case of the Lorenz Attractor, a well known nonlinear system actively used to illustrate concepts of the chaos theory. Its state equations are:
The parameters σ,ρ,β are dominating the response of the system and if ones sets them as:
Then the system exhibits chaotic behavior as shown in the simulation case study below.
Simulation of a Quadrotor Aerial Robot
The classes/methods below implement the simulation of the vehicle dynamics of a quadrotor aerial robot. The system is considered to be captured using rigid body modeling and the four thrust vectors attached to it, while its self-response is only characterized by its mass and the cross-inertia terms. Within that framework, scipy is employed for the forward integration purposes of the state update, while direct calculations and linear algebra are employed for the moment/forces calculations as well as the coordinate system transformations.