Euler Equations

MiRaTa CubeSat rotating above Earth in the Godot viewer.

For a rigid spacecraft without reaction wheels, Euler’s rotational equation is

\[\mathbf{J}^{\mathcal{B}}\dot{\boldsymbol{\omega}}^{\mathcal{B}} + \boldsymbol{\omega}^{\mathcal{B}} \times (\mathbf{J}^{\mathcal{B}}\boldsymbol{\omega}^{\mathcal{B}}) = \boldsymbol{\tau}^{\mathcal{B}}.\]

All vectors are expressed in the spacecraft body frame \(\mathcal{B}\). \(\mathbf{J}^{\mathcal{B}}\) is the inertia matrix, \(\boldsymbol{\omega}^{\mathcal{B}}\) is the angular velocity, and \(\boldsymbol{\tau}^{\mathcal{B}}\) is the total applied torque. The implementation, including the reaction-wheel case and quaternion kinematics, is documented in ADCS.satellite_hardware.satellite.satellite.Satellite.dynamics_core().

The example approximates a uniform 4 kg, 10 × 10 × 30 cm 3U spacecraft, with principal inertias of \(0.0333\), \(0.0333\), and \(0.00667\) kg·m². It starts with a five-degree-per-second spin about a largest principal axis. Both runnable scripts use this same setup.

euler_equations.py
import numpy as np
import ADCS

satellite = ADCS.Satellite(
    mass=4.0,
    J_0=np.diag([0.0333, 0.0333, 0.00667]),
)
initial_state = ADCS.State(
    w=np.deg2rad([5.0, 0.0, 0.0]),
    q=np.array([1.0, 0.0, 0.0, 0.0]),
)
orbit = ADCS.Orbital_State(
    ephem=ADCS.Ephemeris(),
    J2000=0.22,
    R=np.array([7000.0, 0.0, 0.0]),
    V=np.array([0.0, 7.5, 0.0]),
)
results = ADCS.simulate(
    x=initial_state, satellite=satellite, os0=orbit,
    dt=1.0, tf=30.0,
)

Choose a visualization:

Attitude plot

import matplotlib.pyplot as plt

ADCS.plot(results, ADCS.plots.AttitudePlot(), layout=(1, 1))
plt.show()

Godot animation

from ADCS.helpers.animations import animate_orbit_godot

animate_orbit_godot(
    results=results,
    overlays=[],
    graphics_quality="high",
)

Initial quaternion

Changing \(q\) changes the starting orientation.

q=np.array([1.0, 0.0, 0.0, 0.0])
MiRaTa with the identity initial quaternion
q=np.array([2**-0.5, 0.0, 2**-0.5, 0.0])
MiRaTa rotated 90 degrees about its body y axis

Principal-axis spin

For this inertia matrix, \(x\) and \(y\) share the largest principal moment; \(z\) is the smallest. The quaternion is unchanged in these runs.

w=np.deg2rad([5.0, 0.0, 0.0])
MiRaTa spinning about its largest principal axis
w=np.deg2rad([0.0, 0.0, 5.0])
MiRaTa spinning about its smallest principal axis

Tips and tricks

The first simulation run gives access to the saved attitude states:

run = results.first()
attitude = run.state_hist[0].q