Spacecraft Control Framework 1.0
Spacecraft Control Library
sc_landing_control.h
1//
2// sc_landing_control.h
3// SCControl
4//
5// Created by Michael Paluszek on 08/14/2017
6//
7// Implements landing control
8// Landing controller.
9//
10// Determines the thrust vector and throttle for landing on a planet.
11// Uses a bang-bang for vertical control during terminal ascent.
12// Horizontal control is velocity damping.
13//
14// This function generates throttle and thrust vector
15// orientation. Thrust vector orientation is achieved by reorienting
16// the vehicle or the engine nozzle. The reorientation controller needs
17// to be fast enough so that the engine is pointing along the desired
18// vector. You can set the throttle to zero until you reach the desired
19// orientation.
20//
21// The control has four modes:
22//
23// Mode 1 - Drive the vertical velocity to zero and hover
24// Mode 2 - Drive all velocities to zero
25// Mode 3 - Bang-Bang vertical control
26// Mode 4 - Engine balances gravity
27//
28// vMaxFrac is the fraction of the maximum velocity allowed during Mode 3.
29// The maximum velocity is for free-fall.
30//
31// This is used as the terminal control for an optimal landing
32// guidance algorithm.
33//
34// When you reach mode 4 it is up to you to set the throttle to zero.
35//
36// The terminal errors will depend on the time step of your controller.
37//
38//
39
40#ifndef __SC_LANDING_CONTROL__
41#define __SC_LANDING_CONTROL__
42
43#include <stdio.h>
44#ifdef AS_OS_WINDOWS
45#include "matrixlib.h"
46#else
47#include <MatrixLib/MatrixLib.h>
48#endif
49
50
52
53 private:
54 bool initialized;
55 double accel; // Maximum acceleration (km/s^2)
56 double gain_velocity; // Velocity gain
57 double g; // Gravitational acceleration at the surface in (km/s^2)
58 int mode; // Mode setting 1-4
59 double v_threshold; // Rate to switch modes
60 double h_touchdown; // Landing gear height
61 double v_max_frac; // Maximum velocity during mode 3
62
63 ml_matrix u_thrust; // Thrust unit vector
64 double throttle; // Throttle setting
65
66 double h_3;
67 double a_mag;
68
69 ml_matrix accel_demand;
70
71 public:
73 landing_control(void);
77 void initialize( const double accel, const double gain_rate, const double g, const double v_threshold, const double h_landing, const double v_max_frac );
79 void update( const ml_matrix& v, const double h, const ml_matrix& u_v );
81 bool is_initialized( void ) { return initialized;};
83 double get_throttle( void ) { return throttle;};
85 int get_mode( void ) { return mode;};
87 ml_matrix get_thrust_unit_vector( void ){ return u_thrust; };
89 void set_defaults( void );
91 void set_acceleration( double a ){accel = a;};
93 ml_matrix get_acceleration( void ){return accel_demand;};
94
95};
96
97
98#endif
Definition: sc_landing_control.h:51
void initialize(const double accel, const double gain_rate, const double g, const double v_threshold, const double h_landing, const double v_max_frac)
Initialize.
Definition: sc_landing_control.cc:38
int get_mode(void)
Get mode.
Definition: sc_landing_control.h:85
bool is_initialized(void)
Tell if it is initialzed.
Definition: sc_landing_control.h:81
~landing_control()
Destructor.
Definition: sc_landing_control.cc:20
ml_matrix get_thrust_unit_vector(void)
Get unit vector.
Definition: sc_landing_control.h:87
void set_acceleration(double a)
Set defaults.
Definition: sc_landing_control.h:91
void set_defaults(void)
Set defaults.
Definition: sc_landing_control.cc:24
double get_throttle(void)
Get throttle.
Definition: sc_landing_control.h:83
ml_matrix get_acceleration(void)
Set defaults.
Definition: sc_landing_control.h:93
void update(const ml_matrix &v, const double h, const ml_matrix &u_v)
Update.
Definition: sc_landing_control.cc:50
landing_control(void)
Constructor.
Definition: sc_landing_control.cc:14