pathfinder-for-autonomous-navigation / psim

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

Create MEX Functions for the Attitude Estimator #188

Closed kylekrol closed 3 years ago

kylekrol commented 4 years ago

Basically what's described by the title. We need to be able to run the cxx estimator code both in the full MATLAB sim as well as within @stewartaslan's breakout attitude simulation to verify it's correct.

To learn a little about MEX, a good place to look would be the mex files we have in psim already (MATLAB/environmental_models/helper_functions/*.cpp) and the MATLAB mex documentation online.

We'll probably need three functions similar to these:

function [state] = adcs_estimator_reset_mex(q, gyro_bias, cov)
function [state] = adcs_estimator_triad_reset_mex(t, r_ecef, b_body, s_body)
function [state, q_est, qyro_bias_est, cov_est] = adcs_estimator_update_mex(state,
    t, r_ecef, b_body, s_body, w_body)

where state is a MATLAB struct that contains information that must persist across calls to the filter. Most notably, this is the attitude estimate quaternion, gyro bias estimate, and state covariance estimate.

The first function, adcs_estimator_reset_mex, doesn't need to incorporate any cxx code.

The second, adcs_estimator_triad_reset_mex, should call the following function once it's implemented:

void attitude_estimator_reset(AttitudeEstimatorState &state,
    double t, lin::Vector3d const &r_ecef, lin::Vector3f const &b_body,
    lin::Vector3f const &s_body);

Lastly, adcs_estimator_update_mex will need to populate a gnc::AttitudeEstimatorState and gnc::AttitudeEstimatorData struct to then call:

void attitude_estimator_update(AttitudeEstimatorState &state,
    AttitudeEstimatorData const &data, AttitudeEstimate &estimate);