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
29 changes: 27 additions & 2 deletions src/simulation/sensors/magnetometer/magnetometer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,23 @@ Magnetometer::Magnetometer()
this->senBias.fill(0.0); // Tesla
this->senNoiseStd.fill(-1.0); // Tesla
this->walkBounds.fill(0.0);
this->noiseModel = GaussMarkov(this->numStates);

// Initialize noise model
this->noiseModel = GaussMarkov(this->numStates, this->RNGSeed);

// Initialize noise matrices with defaults
Eigen::MatrixXd nMatrix;
nMatrix.resize(3,3);
nMatrix.setZero();
this->noiseModel.setNoiseMatrix(nMatrix);

Eigen::MatrixXd pMatrix;
pMatrix.setIdentity(3,3);
this->noiseModel.setPropMatrix(pMatrix);

this->noiseModel.setUpperBounds(this->walkBounds);

// Initialize other parameters
this->scaleFactor = 1.0;
this->maxOutput = 1e200; // Tesla
this->minOutput = -1e200; // Tesla
Expand Down Expand Up @@ -67,10 +83,19 @@ void Magnetometer::Reset(uint64_t CurrentSimNanos)
bskLogger.bskLog(BSK_ERROR, "Spacecraft state message name (stateInMsg) is empty.");
}

// Update noise model parameters
this->noiseModel.setUpperBounds(this->walkBounds);
auto nMatrix = (this->senNoiseStd).asDiagonal();

Eigen::MatrixXd nMatrix;
nMatrix.resize(3,3);
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.

this->noiseModel.setNoiseMatrix(nMatrix);
this->noiseModel.setRNGSeed(this->RNGSeed);

// Set saturation bounds
Eigen::MatrixXd satBounds;
satBounds.resize(this->numStates, 2);
satBounds(0, 0) = this->minOutput;
Expand Down