Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ACDS — Attitude Control and Determination System

This repository contains the Attitude Control and Determination System (ACDS) for a CubeSat, developed as part of the PAE 2022 nanosatellite project. The ACDS is the subsystem that answers two questions for the spacecraft:

  • Determinationhow is the satellite oriented, and where is it? The attitude is estimated by comparing on-board sensor readings against physical reference models: the Earth's magnetic field (from the IGRF-13 model) and the satellite's orbital position (from the SGP4 propagator), expressed as a unit quaternion between the Earth-Centred-Inertial (ECI) frame and the body frame.
  • Controlhow do we reach and hold the desired orientation? Immediately after deployment the satellite tumbles, so a B-dot controller drives the magnetorquers to remove that spin (detumbling). Once stable, a three-axis quaternion PID controller slews the satellite to and holds a target attitude, with per-axis anti-windup on the actuator command.

The code here is the algorithmic core of the ACDS: the control laws, the attitude maths, and the reference models. It is written in portable C and can be built and run on a desktop for analysis and validation; the same routines run on the satellite's STM32/FreeRTOS on-board computer.

How it works

Stage Method Where
Geomagnetic reference field IGRF-13 spherical-harmonic model src/models/igrf13syn.c
Orbit position / velocity SGP4 propagation of a TLE src/models/sgp4.c
Attitude representation & maths Unit quaternions (compose, invert, axis-angle, matrix conversions) src/help_adcs.c
Detumbling B-dot control law: m = -k · dB/dt, torque = m × B src/adcs.c
Pointing Three-axis quaternion PID with anti-windup src/help_adcs.c (PID3Axis)

The detumbling law needs no attitude estimate — it only reacts to the rate of change of the measured magnetic field, which makes it robust in the initial tumbling phase. Once the body rate is low, the PID controller uses the quaternion attitude error to command a torque proportional to the pointing error while respecting the actuator saturation limit.

Repository layout

ACDS/
├── src/
│   ├── adcs.c / adcs.h            B-dot detumbling control law
│   ├── help_adcs.c / help_adcs.h  quaternion maths + 3-axis PID controller
│   ├── main.c                     desktop demonstration harness
│   └── models/
│       ├── igrf13syn.c / .h       IGRF-13 geomagnetic field model
│       └── sgp4.c / .h            SGP4 orbit propagator (Vallado/CelesTrak model)
├── Makefile
├── LICENSE
└── README.md

Build and run

The demonstration harness compiles as a single translation unit, so one command is enough:

make run

or, equivalently:

gcc src/main.c -lm -o adcs_demo && ./adcs_demo

This runs one update of the three-axis PID controller with a representative CubeSat configuration and prints the commanded torque per axis. It requires only a C compiler and the standard maths library — no hardware.

Runtime inputs

Some routines read external data that is not bundled here, because it is either large or mission-specific:

  • IGRF-13 (igrf13()) reads its time-interpolated Gauss coefficients from a gh.txt file in the working directory.
  • SGP4 (sgp4()) is initialised from a satellite's NORAD Two-Line Element (TLE) set.
  • detumbling_sim() replays recorded magnetometer and angular-rate traces (det_mag_field.txt, det_vel_ang.txt) to validate the B-dot law offline.

The commented examples at the bottom of src/main.c show how the IGRF-13 and SGP4 models are called.

Context

The ACDS is one subsystem of a larger CubeSat on-board computer built on an STM32L4 microcontroller running FreeRTOS. This repository isolates the attitude determination and control algorithms so they can be read, reused and validated independently of the flight firmware.

The IGRF-13 geomagnetic field and the SGP4 orbit propagator are standard, widely-used aerospace models; the implementations here follow those published references (SGP4 following the Vallado/CelesTrak algorithm).

Authors and license

Developed by Alex Melendez Ramos and Albert Fàbregas.

Released under the MIT License — see LICENSE.

About

Attitude Control and Determination System (ACDS) for a CubeSat: B-dot detumbling and 3-axis quaternion PID pointing, with IGRF-13 geomagnetic and SGP4 orbit models.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages