Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor GaussMarkov sensor noise handling #881

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

Natsoulas
Copy link
Contributor

Description

Followed user feedback about inconsistencies in how various sensors handle the GaussMarkov noise model. This PR addresses all the issues pointed out in issue #867 and updates relevant documentation. Necessary private class attributes are made accessible outside of the class via getter and setter methods introduced in this PR. Additionally, I edited sensor modules to initialize the GM noise models in their constructors rather than in their Reset() methods (this was only some sensors).

Verification

Each change/refactor was verified via passing unit tests and running scenarioGaussMarkovRandomWalk.py to ensure the refactor did not change any functionality of the code.

Documentation

Changed imuSensor name for walkBounds to errorBounds, and documented latex doc for the IMU Sensor called imuSensor/_Documentation/BasiliskCorruptions.tex

Future work

See if community desires any additional refactoring or clarification of Gauss Markov sensor noise modeling through additional documentation

@Natsoulas Natsoulas added documentation Improvements or additions to documentation enhancement New feature or request labels Dec 21, 2024
@Natsoulas Natsoulas self-assigned this Dec 21, 2024
@Natsoulas Natsoulas requested a review from a team as a code owner December 21, 2024 19:52
@Natsoulas Natsoulas linked an issue Dec 21, 2024 that may be closed by this pull request
@Natsoulas Natsoulas force-pushed the refactor-sensor-noise-handling branch 8 times, most recently from 34b0b7e to a7c5408 Compare December 23, 2024 01:43
@sdunlap-afit
Copy link

@Natsoulas Looking through the code, it seems ImuSensor::Reset() is still setting the two AMatrix variables to I. If you remove these from Reset(), you may also want to remove this comment in scenarioGaussMarkovRandomWalk.py to avoid confusion: # Set IMU2's A Matrix to zero AFTER initialization.

@Natsoulas
Copy link
Contributor Author

Thanks @sdunlap-afit for looking over my changes. I'll incorporate that change this afternoon.

@Natsoulas Natsoulas force-pushed the refactor-sensor-noise-handling branch from a7c5408 to fc98f12 Compare December 23, 2024 23:02
@Natsoulas Natsoulas force-pushed the refactor-sensor-noise-handling branch from fc98f12 to e04558d Compare December 23, 2024 23:04
@Natsoulas
Copy link
Contributor Author

@sdunlap-afit I just removed the lines setting A as the identity in Reset(), and edited the comment in the scenario. Let me know if you have any more suggestions. I appreciate your help!

@sdunlap-afit
Copy link

@Natsoulas On my last pass, I was primarily looking for references to AMatrix and missed a couple calls to setPropMatrix() in CoarseSunSensor::Reset().
Also, Magnetometer only calls setPropMatrix() in the constructor and doesn't have a getter/setter, so random walk can't be disabled.
Other than that, everything looks good to me. Thanks again for all your work on this!

Copy link
Contributor

@schaubh schaubh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great progress, some additional feedback to address.

@@ -73,19 +81,19 @@ class ImuSensor: public SysModel {
bool NominalReady; //!< -- Flag indicating that system is in run
Eigen::Matrix3d PMatrixAccel; //!< [-] Cholesky-decomposition or matrix square root of the covariance matrix to apply errors with
Eigen::Matrix3d AMatrixAccel; //!< [-] AMatrix that we use for error propagation
Eigen::Vector3d walkBoundsAccel;//!< [-] "3-sigma" errors to permit for states
Eigen::Vector3d walkBoundsAccel; //!< [-] Total error bounds for accelerometer states. @warning Will be renamed to errorBoundsAccel in December 2025
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mm, this gives the user 1 year to know a change is coming, but not a true depreciation. Can we create the new errorBoundsAccel variable now as a privat variable, create the suitable setter and getter, document, but leave the public walkBoundsAccel. To see if the user sets it, could we default it to -1, and if anything else when we set errorBoundsAccel to this value? This way old code doesn't break, but users have 1 year to upgrade to the new setter and getter?

void setAMatrixGyro(const Eigen::MatrixXd& propMatrix);
Eigen::MatrixXd getAMatrixAccel() const;
Eigen::MatrixXd getAMatrixGyro() const;
void setWalkBoundsAccel(const Eigen::Vector3d& bounds);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update to the new setter and getter names?

Eigen::Vector3d ImuSensor::getWalkBoundsGyro() const
{
return this->walkBoundsGyro;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update the imuSensor.rst file to discuss how to properly set the noise values. You can note that the use of directly setting walkBoundsAccel is now deprecated.

@@ -54,6 +54,11 @@

Both IMUs use the same process noise level (P Matrix) to ensure comparable noise magnitudes.

Note that any sensors using the ``GaussMarkov`` noise model should be configured with
user-defined configuration parameters such as ``walkBounds`` and ``AMatrix``. Otherwise,
the default values will be used and they may not be appropriate for the sensor the user
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By default we should have have no noise or random walk? Please ensure that signal is not modified unless the users sets these values.

@@ -47,9 +47,12 @@ class StarTracker: public SysModel {
void applySensorErrors();
void computeTrueOutput();
void computeQuaternion(double *sigma, STSensorMsgPayload *sensorValue);


void setAMatrix(const Eigen::MatrixXd& propMatrix);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should have a getAMatrix()?

public:

uint64_t sensorTimeTag; //!< [ns] Current time tag for sensor out
ReadFunctor<SCStatesMsgPayload> scStateInMsg; //!< [-] sc input state message
Message<STSensorMsgPayload> sensorOutMsg; //!< [-] sensor output state message
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to update starTracker.rst as well to discuss how to set the noise values.

nMatrix.setZero();
nMatrix(0,0) = this->senNoiseStd(0);
nMatrix(1,1) = this->senNoiseStd(1);
nMatrix(2,2) = this->senNoiseStd(2);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update module RST file on how to set noise values.

@@ -99,6 +99,9 @@ class CoarseSunSensor: public SysModel {
int CSSGroupID=-1; //!< [-] (optional) CSS group id identifier, -1 means it is not set and default is used
BSKLogger bskLogger; //!< -- BSK Logging

void setAMatrix(const Eigen::Matrix<double, -1, 1, 0, -1, 1>& propMatrix);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make the getAMatrix()?

@@ -120,7 +124,7 @@ class CSSConstellation: public SysModel {
void Reset(uint64_t CurrentClock); //!< Method for reseting the module
void UpdateState(uint64_t CurrentSimNanos); //!< @brief [-] Main update method for CSS constellation
void appendCSS(CoarseSunSensor *newSensor); //!< @brief [-] Method for adding sensor to list

public:
Message<CSSArraySensorMsgPayload> constellationOutMsg; //!< [-] CSS constellation output message
std::vector<CoarseSunSensor *> sensorList; //!< [-] List of coarse sun sensors in constellation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update module RST file on how to set noise values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
Status: 👀 In review
Development

Successfully merging this pull request may close these issues.

Inconsistent sensor noise handling
3 participants