Magnetorquer-Only Control

Three magnetorquers can steer a spacecraft without reaction wheels, but each instantaneous control torque must be perpendicular to the local magnetic field: \(\boldsymbol{\tau}=\boldsymbol{m}\times\boldsymbol{B}\). As the spacecraft orbits, the field direction changes and the missing torque direction becomes available at other times. The MTQ_Lovera controller uses this changing field to reduce pointing error.

The headless simulation below runs for 18,000 seconds, about three orbits, before the Godot view opens. For this undisturbed example, the boresight error falls from 90° to about 5°. Magnetic control can need many orbits to settle, especially when disturbance torques are present.

Boresight error decreases over a three-orbit Lovera magnetic-control simulation. A 1U CubeSat slowly aligns its boresight using magnetorquers over three orbits.

The GIF compresses the long run. Yellow marks the 1U CubeSat’s body boresight and green marks the fixed inertial target direction. The camera is fixed in an inertial frame.

magnetorquer_lovera_godot.py
"""Point a 1U CubeSat with magnetorquers alone over several orbits."""

import matplotlib.pyplot as plt
import numpy as np

import ADCS
from ADCS.helpers.animations import animate_orbit_godot
from ADCS.helpers.animations.godot.overlays import Arrow, TargetLine

magnetorquers = [ADCS.MTQ(axis=axis, max_torque=0.005)
                for axis in np.eye(3)]
magnetometers = [ADCS.MTM(axis=axis) for axis in np.eye(3)]
satellite = ADCS.Satellite(
    mass=4.0, J_0=np.diag([0.0333, 0.0333, 0.00667]),
    actuators=magnetorquers, sensors=magnetometers,
)
orbit = ADCS.Orbital_State(
    ephem=ADCS.Ephemeris(), J2000=0.22,
    R=np.array([5000.0, 0.0, 5000.0]), V=np.array([0.0, 7.5, 0.0]),
)
initial_state = ADCS.State(
    w=np.zeros(3),
    q=np.array([np.cos(np.pi / 4), 0.0, np.sin(np.pi / 4), 0.0]),
)
controller = ADCS.controller.MTQ_Lovera(
    est_sat=satellite, p_gain=5e-7, d_gain=1e-3, eps=1.0,
)
goal = ADCS.goals.ECI_Goal(eci_vector=np.array([0.0, 0.0, 1.0]))
results = ADCS.simulate(
    x=initial_state, satellite=satellite, os0=orbit,
    controller=controller, goal=goal, dt=5.0, tf=18000.0,
)
ADCS.plot(results, ADCS.plots.TargetPlot(modes=["real_target"],
                                    title="Boresight error"),
          layout=(1, 1), figsize=(8, 4))

animate_orbit_godot(
    results=results, graphics_quality="high",
    overlays=[
        Arrow("@boresight:default", label="Body boresight", color="#facc15",
              scale="fixed_px", px=120, width_px=5),
        TargetLine(color="#22c55e", length_px=150, width_px=5),
    ],
    camera_distance_m=12.0, camera_yaw_deg=0.0, camera_pitch_deg=45.0,
)

The three MTQ actuators are the only actuators on this satellite. The controller’s gains and dipole limit are chosen for this inertia and orbit; other hardware and disturbance models may need different values. The package also offers MTQ_Wisniewski for magnetorquer-only sliding-mode control. When reaction wheels are available, MTQ_w_RW_QP combines wheel and magnetic commands through bounded quadratic-programming allocation.