Spacecraft Control Framework 1.0
Spacecraft Control Library
sc_pid3axis.h
Go to the documentation of this file.
1//-----------------------------------------------------------------------------------------
2// A PID Based 3 axis controller for spacecraft
3//-----------------------------------------------------------------------------------------
4// Copyright (c) 2009 Princeton Satellite Systems. All rights reserved.
5//-----------------------------------------------------------------------------------------
6
11#ifndef __PID3AXIS__
12#define __PID3AXIS__
13
14#ifdef AS_OS_WINDOWS
15 #include "matrixlib.h"
16#else
17 #include <MatrixLib/MatrixLib.h>
18#endif
19
20
33{
34
35 private:
37 ml_matrix gain_a_pitch;
39 ml_matrix gain_b_pitch;
41 ml_matrix gain_c_pitch;
43 ml_matrix gain_d_pitch;
45 ml_matrix gain_a_roll;
47 ml_matrix gain_b_roll;
49 ml_matrix gain_c_roll;
51 ml_matrix gain_d_roll;
53 ml_matrix gain_a_yaw;
55 ml_matrix gain_b_yaw;
57 ml_matrix gain_c_yaw;
59 ml_matrix gain_d_yaw;
61 ml_matrix gain_l;
63 ml_matrix accel_sat;
65 ml_matrix x_roll;
67 ml_matrix x_yaw;
69 ml_matrix x_pitch;
70 ml_matrix axis_command;
72 ml_matrix inertia;
74 double angle_command;
76 int rotate_command;
78 int align_command;
80 int initialized;
82 int pitch_initialized;
84 int roll_initialized;
86 int yaw_initialized;
88 ml_matrix body_vector_command;
90 ml_matrix eci_vector_command;
92 ml_matrix q_target_last;
94 double max_angle;
95
96 public:
98 ml_matrix q_desired_state;
99
101 PID3Axis( void );
103 void Initialize( ml_matrix a, ml_matrix b, ml_matrix c, ml_matrix d, double angle, ml_matrix inr );
105 void InitializePitch( ml_matrix a, ml_matrix b, ml_matrix c, ml_matrix d, double angle, ml_matrix inr );
107 void InitializeRoll( ml_matrix a, ml_matrix b, ml_matrix c, ml_matrix d, double angle, ml_matrix inr );
109 void InitializeYaw( ml_matrix a, ml_matrix b, ml_matrix c, ml_matrix d, double angle, ml_matrix inr );
111 void AddWindupCompensation( ml_matrix l, ml_matrix saturation );
113 ml_matrix Update( ml_matrix q_eci_to_body );
115 void Reset( void );
117 void SetRotateCommand( ml_matrix axis, double angle );
119 void SetAlignCommand( ml_matrix body_vector, ml_matrix eci_vector );
121 void SetAlignAndRotateCommand( ml_matrix body_vector, ml_matrix eci_vector, double angle );
123 void SetInertia( ml_matrix inertia ){this->inertia = inertia;};
125 void SetDesQuat( ml_matrix qdes );
127 ml_matrix GetDesQuat( void );
129 bool GetStatus( void );
131 ml_matrix GetInertia( void );
133 void SetMaximumDeltaAngle( double delta ){max_angle = delta;};
134
135};
136
137
138#endif
Definition: sc_pid3axis.h:33
void Reset(void)
Reset the pid.
Definition: sc_pid3axis.cc:150
ml_matrix Update(ml_matrix q_eci_to_body)
Update the output.
Definition: sc_pid3axis.cc:271
void Initialize(ml_matrix a, ml_matrix b, ml_matrix c, ml_matrix d, double angle, ml_matrix inr)
Initialize all state matrices.
Definition: sc_pid3axis.cc:43
bool GetStatus(void)
Get the PID status.
Definition: sc_pid3axis.cc:124
void SetRotateCommand(ml_matrix axis, double angle)
Set the rotate command.
Definition: sc_pid3axis.cc:165
ml_matrix GetInertia(void)
Get the inertia.
Definition: sc_pid3axis.cc:259
ml_matrix q_desired_state
Target quaternion.
Definition: sc_pid3axis.h:98
void SetAlignCommand(ml_matrix body_vector, ml_matrix eci_vector)
Set the align command.
Definition: sc_pid3axis.cc:184
void AddWindupCompensation(ml_matrix l, ml_matrix saturation)
Add windup compensation.
Definition: sc_pid3axis.cc:136
void InitializeYaw(ml_matrix a, ml_matrix b, ml_matrix c, ml_matrix d, double angle, ml_matrix inr)
Initialize yaw matrices.
Definition: sc_pid3axis.cc:103
void SetDesQuat(ml_matrix qdes)
Set the desired quaternion.
Definition: sc_pid3axis.cc:242
ml_matrix GetDesQuat(void)
Set the desired quaternion to the default.
Definition: sc_pid3axis.cc:251
void SetMaximumDeltaAngle(double delta)
Set the maximum delta per step.
Definition: sc_pid3axis.h:133
void SetAlignAndRotateCommand(ml_matrix body_vector, ml_matrix eci_vector, double angle)
Set the align and rotate command.
Definition: sc_pid3axis.cc:210
void InitializePitch(ml_matrix a, ml_matrix b, ml_matrix c, ml_matrix d, double angle, ml_matrix inr)
Initialize pitch matrices.
Definition: sc_pid3axis.cc:69
void SetInertia(ml_matrix inertia)
Set the inertia.
Definition: sc_pid3axis.h:123
void InitializeRoll(ml_matrix a, ml_matrix b, ml_matrix c, ml_matrix d, double angle, ml_matrix inr)
Initialize roll matrices.
Definition: sc_pid3axis.cc:86
PID3Axis(void)
Constructor.
Definition: sc_pid3axis.cc:17