animation.mp4
Almost all dynamical systems can be written in the form of
The state vector is all the necessary information to describe the state of the system. For this simulation, the state vector includes position in the inertial frame, velocity in the body frame, quaternion from inertial to body, and angular rate expressed in the body frame.
where:
-
$p_I = [x, y, z]^T$ is the position vector in the inertial frame. -
$v_B = [u, v, w]^T$ is the velocity vector in the body frame. -
$q_{IB} = [q_0, q_1, q_2, q_3]^T$ is the quaternion representing the orientation from the inertial frame to the body frame. -
$\omega = [\omega_x, \omega_y, \omega_z]^T$ is the angular velocity vector in the body frame.
The dynamics for starship (and any rigid body) are defined below
where:
-
$F_b$ is the sum of external forces in the body frame. -
$M_b$ is the sum of external moments (torques) in the body frame. -
$g = [0, 0, -9.81]^T$ is the gravitational acceleration vector in the inertial frame. -
is the direction cosine matrix that transforms vectors from the inertial frame to the body frame (it is the transpose of
).
-
$\mathbf{I}_b$ is the moment of inertia tensor in the body frame. Note that if the moment of inertia is dependent on the mass and CG location. -
$\boldsymbol{\Omega}(w)$ is the skew-symmetric matrix representation of the angular velocity$\omega$ .
If some of the math is a bit overwhelming then don't worry. All you need to know is that the state vector holds the data on position, velocity, orientation, and angular rate and all the fancy equations tell us how those states change given some external forces and moments.
But where do those forces come from? In a vacuum, dynamics are simple, but Starship is flying through an atmosphere. Instead of blasting you with Greek letters, here is an intuitive way to think about the aerodynamics.
Every aerodynamic component such as a wing or a fuselage has aerodynamic properties such as lift, coefficient or drag coefficient. These properties when combined with speed and density can give a force and a moment. The total forces and moments acting on the Starship are found by summing the contributions of each individual component, including the secondary moments generated by forces acting away from the center of mass.
In order to control the system we must linearize the dynamics around an operating point and apply linear control, however how are we supposed to do that when Starship is falling at terminal velocity? The trick is that we don't linearize around the full 13 dimensional state vector. Rather we linearize around a reduced order model that only captures that thing we want to control, in this case pitch. So the state vector for pitch is as shown below. Where
where:
-
$u$ is the x velocity in the body frame -
$w$ is the z velocity in the body frame -
$q$ is pitch rate -
$\theta$ is pitch
If we can find a point in state space where
In the formula
Once a trim point is found the dynamics can be linearized around that point by calculating the Jacobian of the dynamics with respect to the state and control. The Jacobian can be calculated symbolically or using finite difference.
From the linearization, an LTI system can be derived as follows.
From this we can use linear control techniques such as a Linear Quadratic Regulator (LQR). This control techniques works by minimizing the cost of a quadratic performance index subject to linear dynamics. The cost formulation is shown below where
The control law that this formulation produces is in the form of a linear feedback law in the form