Spacecraft Control Framework 1.0
Spacecraft Control Library
Public Member Functions | Public Attributes | List of all members
PID3Axis Class Reference

#include <sc_pid3axis.h>

Public Member Functions

 PID3Axis (void)
 Constructor.
 
void Initialize (ml_matrix a, ml_matrix b, ml_matrix c, ml_matrix d, double angle, ml_matrix inr)
 Initialize all state matrices. More...
 
void InitializePitch (ml_matrix a, ml_matrix b, ml_matrix c, ml_matrix d, double angle, ml_matrix inr)
 Initialize pitch matrices.
 
void InitializeRoll (ml_matrix a, ml_matrix b, ml_matrix c, ml_matrix d, double angle, ml_matrix inr)
 Initialize roll matrices.
 
void InitializeYaw (ml_matrix a, ml_matrix b, ml_matrix c, ml_matrix d, double angle, ml_matrix inr)
 Initialize yaw matrices.
 
void AddWindupCompensation (ml_matrix l, ml_matrix saturation)
 Add windup compensation.
 
ml_matrix Update (ml_matrix q_eci_to_body)
 Update the output. More...
 
void Reset (void)
 Reset the pid.
 
void SetRotateCommand (ml_matrix axis, double angle)
 Set the rotate command. More...
 
void SetAlignCommand (ml_matrix body_vector, ml_matrix eci_vector)
 Set the align command. More...
 
void SetAlignAndRotateCommand (ml_matrix body_vector, ml_matrix eci_vector, double angle)
 Set the align and rotate command. More...
 
void SetInertia (ml_matrix inertia)
 Set the inertia.
 
void SetDesQuat (ml_matrix qdes)
 Set the desired quaternion. More...
 
ml_matrix GetDesQuat (void)
 Set the desired quaternion to the default. More...
 
bool GetStatus (void)
 Get the PID status. More...
 
ml_matrix GetInertia (void)
 Get the inertia. More...
 
void SetMaximumDeltaAngle (double delta)
 Set the maximum delta per step.
 

Public Attributes

ml_matrix q_desired_state
 Target quaternion.
 

Detailed Description

A PID Based 3 axis controller for spacecraft.

Includes a limit on the max angle command allowed per update step.
Uses the input inertia to compute a torque demand. Acceleration is computed

for each axis independently. Supports several input formats including a desired quaternion, a rotation about an axis, and an align command. The PID is implemented as a state space controller of the form.

Member Function Documentation

◆ Initialize()

void PID3Axis::Initialize ( ml_matrix  a,
ml_matrix  b,
ml_matrix  c,
ml_matrix  d,
double  angle,
ml_matrix  inr 
)

Initialize all state matrices.

Initialize the class with the discrete controller gains (state space format).

Parameters
aGain matrix A
bGain matrix B
cGain matrix C
dGain matrix D
angleMaximum angle constraint (rad)
inrVehicle inertia matrix (3x3)

References Reset().

◆ Update()

ml_matrix PID3Axis::Update ( ml_matrix  q_ECI_body)

Update the output.

Update the controller.

Parameters
q_ECI_bodyCurrent vehicle orientation (4x1)
Returns
Torque demand (3x1)

References au_to_q(), q_desired_state, q_to_angle(), q_to_vec(), sc_warn(), u_to_q(), and unwrap().

◆ SetRotateCommand()

void PID3Axis::SetRotateCommand ( ml_matrix  axis,
double  angle 
)

Set the rotate command.

Set a rotation command using an axis and angle.

Parameters
axisAxis in the body frame to rotate around (3x1)
angleAngle in rad to rotate

◆ SetAlignCommand()

void PID3Axis::SetAlignCommand ( ml_matrix  body_vector,
ml_matrix  eci_vector 
)

Set the align command.

Set an alignment command using a body vector and an inertial vector.

Parameters
body_vectorAxis in the body frame to align (3x1)
eci_vectorInertial vector to align with (3x1)

◆ SetAlignAndRotateCommand()

void PID3Axis::SetAlignAndRotateCommand ( ml_matrix  body_vector,
ml_matrix  eci_vector,
double  angle 
)

Set the align and rotate command.

Set an alignment command and rotate using a body vector, an inertial vector and an angle about the inertial vector.

Parameters
body_vectorAxis in the body frame to align (3x1)
eci_vectorInertial vector to align with (3x1)
angleAngle about inertial vector

References au_to_q(), q_desired_state, and u_to_q().

◆ SetDesQuat()

void PID3Axis::SetDesQuat ( ml_matrix  qdes)

Set the desired quaternion.

Set a target quaternion.

Parameters
qdesThe new desired quaternion (4x1)

References q_desired_state.

◆ GetDesQuat()

ml_matrix PID3Axis::GetDesQuat ( void  )

Set the desired quaternion to the default.

Get the target quaternion.

Returns
The current target quaternion (4x1)

References q_desired_state.

◆ GetStatus()

bool PID3Axis::GetStatus ( void  )

Get the PID status.

Get the status of the controller.

Returns
True if PID is initialized, false otherwise

◆ GetInertia()

ml_matrix PID3Axis::GetInertia ( void  )

Get the inertia.

Get the inertia matrix.

Returns
The current inertia matrix (3x3)