pathfinder-for-autonomous-navigation / psim

Six DOF flight simulator and related GNC implementations.
MIT License
4 stars 6 forks source link

Add CXX Attitude Controller #158

Closed kylekrol closed 4 years ago

kylekrol commented 4 years ago

CXX Attitude Controller

Fixes #82.

Summary of changes

Ptest Effects

NA.

Testing

This will be deferred to a future PR. I am going to opening an issue and working on replacing our current MATLAB controller with this CXX implementation and getting a HOOTL case with attitude control hopefully running soon.

Constants

MATLAB constants weren't touched.

As for the CXX constants, we will need to come up with some location to document the constants and make it very clear to flight software what changing some of the externs' values will do - i.e. right now to configure the pointing controller flight software would, in theory, change the controller's gains and the satellite's moment of inertia matrix once we dock we may make edits to gains, moment intertia measurements, etc from the ground whether this be in the middle of the mission due to off nominal behavior or once we have docked and want to enable ADCS again.

Documentation Evidence

See inline documentation for the time being.

kylekrol commented 4 years ago

Looks good to me

I'll let Nathan take a look as well but go ahead and make that issue in flight software.

kylekrol commented 4 years ago

@nhz2 @stewartaslan @tanishqaggarwal

So just a quick summary of the changes I've made to the interface and why.

For the sake of FSW, the original extern constant scheme still seems to make sense because those values will only ever change as the result of an explicit radio uplink/command from the ground - not autonomously. As such, it makes sense to leave them as "constants" and wrap them in state fields.

From the MATLAB perspective, we need to be able to pass all of the constants into the MEX function. Otherwise, setting the controller gain, for example, in MATLAB wouldn't change our C++ controller and that's an issue. We need full control for our mex functions.

To hopefully accommodate both to everyone's satisfaction, I've created two separate interfaces in which the code compilers either an extern mex_control_pointing function when the macro MEX is defined, or an extern control_pointing function. The former takes all required constants as an input (controller gains and moment of inertia) and the latter will be used by FSW and pulls from the GNC "constants".

I decided to create two interfaces as opposed to defaulted function arguments to ensure that FSW uses the function as intended and doesn't deviate from the defined interface.

In passing, I've also added in something constants to convert from radians to degrees and vice versa.

kylekrol commented 4 years ago

Tracking that in this issue: https://github.com/pathfinder-for-autonomous-navigation/FlightSoftware/issues/287