Skip to content

ry444nn/6dof

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI has been used to improve formatting, no writing has been done with it

6DOF Physics Simulation With Python

An airplane has 6 degrees of freedom (3 rotational, 3 transitional) Transitional meaning planes we move is traditionally known as x, y, z Rotational transitions as the name suggests are rotating through the axis roll, pitch, yaw respectively. alt text Two coordinate systems will be established as well:

  1. Inertial frame: fixed system that doesn't translate or rotate (x = north, y = east, z = down)
  2. Body Fixed frame: it rotates and translates with the aircraft and is located at the center of mass (x = positive out of cockpit nose, y = positive out of right hand, z = positive looking down)

Euler angles are described a system of three angles (rotational roll, pitch, yaw) that describe the orientation of the body relative to the transitional planes.

alt text

In space, attitude means the rotation of the aircraft in 3D space (attitude hold in an jet like the viggen holds the heading). And we have three euler angles:

  • Bank (φ)
  • Altitude (θ)
  • Azimuth (ψ)

*note that i'm not using roll, yaw, pitch since that is incorrect as banking is a transition while rolling is a specific location in space.

To describe any flying object we follow:

  1. Azimuth (0 ... 360)
  2. Altitude (-90 ... 90)
  3. Bank (-180 .. 180)

In that specific term, note that we've set limits since 2*pi equals it self (a plane that has a bank of 540 degrees is the same as 180). In simple terms euler angles is the relation between our inertial frame and our body fixed frame by describing azimuth, altitude, bank. Yet, consider if an object is at an angle on the x axis then we could describe it in two ways:

  1. Altitude 90
  2. Azimuth 180 -> Altitude 90 -> Bank 180

As the plane moves through space (rotating, pitching, turning) the body fixed frame changes - yet the inertial frame is constant. We need to find out how the body frame rotates in relation to the inertial frame and that rotation is the attitude.

Direction cosines are described as the angles between two inertial systems and they are arranged into a matrix. Quaternions are a different system to represent the same rotations (4 numbers). I will not discuss this further as i cannot understand it myself due to lack of knowledge.

We can use three different rotation matrices to convert a inertial frame to a body frame. Yet, you should keep note that the wind has its own coordinate system which we will take into account later.

Its important to note that the cos of 90 degrees will be 0, meaning in our transitional matrix we cannot get the value for theta 90. This rarely happens though, in addition its important to note that computing cos and sin for computers actually takes a fair bit of time which can add up and this should be considered when making the simulation.

A better method is using Quaternions which represent a rotation between two coordinate frames using 4 numbers. One of most important things is not having the gimbal lock problem (when two body frames have their axes on one-another, imagine a cube in a gimbal system if the cube is pitched up by 90 degrees the axes for the outer yaw right and inner roll ring have been pointing in the same direction meaning we lost a direction of freedom). The key to is that you can rotate any object in space with a very specific axis to any other rotation, so instead of doing three rotations do a single rotation around a weird axis. Basically find that axis, find how much you have to rotate and you get your four numbers.


Radians

A radian is the relation between arc length and radius, and a single radian is defined the angle where the arc is equal to the radius. To my understanding radians are put to simplify mathematical equations (In differential perhaps, yet i haven't learned it yet)

p (roll rate), q (pitch rate), r (yaw rate) are angular velocities so when q = 1 rad it means the plane is pitching up 57.2 degrees per second. Remember theta (pitch) and phi (roll) are in use radians.


Stability Axis

The stability axis: it is fixed to the body yet the x axis is aligned to the velocity vector (a velocity vector is where the airplane should be pointing at, this term is easily seen in helicopters. When you roll left in the Apache your velocity vector goes left, yet your plane might not fully reach that point.) Same goes for the other axis.

We describe gravity in the earth’s fixed frame since it's always pointing down.

A vector is described in a 3D space for an aircraft with three axes: x, y, z. The gravity in relation to earth’s frame would be:

$$ \vec{g} = \begin{bmatrix} 0 \\ 0 \\ g \end{bmatrix} $$

For the stability axis we have:

$$ \vec{F}_{Aero} = \begin{bmatrix} -D \\ F_{Ay} \\ -L \end{bmatrix}_{\text{Stability}} $$


Formulas

Transitional Equations

In airplanes to find the acceleration we have to account for the plane rotating and moving at the same time so we use: (a good example would be how if you are rotating in a circle and you throw a ball it's curving to your eye, but to a 3rd person it goes straight)

$$ \dot{\vec{v}} = \frac{1}{m}\vec{F}_{A,T} + \vec{g} - (\vec{\omega} \times \vec{v}) $$

Symbols

  • $\dot{\vec{v}}$: Acceleration in relation to the center of mass (rotational body)
  • $\frac{1}{m}\vec{F}_{A,T}$: The applied + thrust forces (engine thrust, air resistance, lift) divided by the mass
  • $\vec{g}$: Effective gravity (9.81 m/s²)
  • $\vec{\omega} \times \vec{v}$: Coriolis acceleration term (velocity vector of the plane in rads)

Newton’s Second Law

$$ \dot{\vec{v}} = \vec{F} = \vec{F}_{A,T} + m \vec{g} $$

Doesn't really apply since the earth is rotating, thus because the coordinate system is accelerating itself you really get two acceleration terms.

  1. Centrifugal acceleration: About 0.03 m/s² and it's absorbed by effective gravity.
  2. Coriolis acceleration: More complicated...

There are two factors of this formula, I have used the factor of one for simplicity, but here follows factor 2:

$$ \dot{-2 \vec{\omega} \times \vec{v}} $$

In simple terms, this is exactly what calculates that rotation I mentioned. Omega is how fast and which way earth is moving. And v is how fast it's moving compared to the ground. So the cross product is perpendicular to the spin and motion. This sideway push is called Coriolis effect. It's the same reason why bullets drift to the right in the north, why hurricanes spin the way they do.


Scalar Equations

A reference coordinate system will be established here:

  1. x points to the nose (forward)
  2. y points to the right wing
  3. z points to the belly (down)

And we have their respective velocities:

Body-axis velocity (how the plane moves in relation to itself)

In m/s

  1. u speed along x. plane cruising at 300km/h
  2. v speed along y (slipstream, dcs >:). plane sliding rightwards (this refers to the difference between the angle of plane going forward in reality which is slightly turned since we have air resistance to its actual front)
  3. w speed along z (heave) climbing and descending

Furthermore we have angular rates, once more in respective to the coordinate system:

Body-axis angular rates (how the plane moves in relation to its own axes)

In rad/s

  1. p roll rate (bank left, bank left). aileron roll
  2. q pitch rate (nose up). gentle pull-up
  3. r yaw rate. coordinated turn

euler angles (relative to earth)

These are in degrees or rad

  1. φ (phi) = roll angle (bank angle) how much the wings are tilted left/right
  2. θ (theta) = pitch angle (nose up/down from horizontal)
  3. ψ (psi) = heading/yaw angle (which way the nose points in the horizontal plane)

Example: (F16 is moving 600km/h banking 45 degrees to the right)

u = 600km/h
v = 0
w = 0
p = 0 # (steady bank)
q = 0 # (no pitch)
r = -4 # yawing at a steady rate
φ = 45 deg


Forward (x-u)

$$ \dot{u} = \frac{F_x}{m} - g \sin \theta - (q w - r v) $$

  1. F is the thrust acceleration
  2. -g sin θ when the plane is pitching, it has some gravity that pulls it back
  3. -(q w - r v) rotational correction just like coriolis

Sideways (y-v)

$$ \dot{v} = \frac{F_y}{m} + g \cos \theta \sin \phi - (r u - p w) $$

  1. F is the sideways acceleration
  2. g cos θ sin φ gravity is again pulling when you are banking left or right
  3. once more rotational correction

Vertical (z-w)

$$ \dot{w} = \frac{F_z}{m} + g \cos \theta \cos \phi - (p v - q u) $$

  1. F is the downward acceleration
  2. g cos θ cos φ a positive acceleration downwards when the airplane is pointing down
  3. rotational correctness

Basically if the plane never rotated we could've just ignored the rotational correctness.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors