-
Notifications
You must be signed in to change notification settings - Fork 6
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
Magnetometer & Sun Vector Attitude Filter Implementation #194
Conversation
b7cc7e7
to
d949b97
Compare
!lin::all(lin::isfinite(data.w_body)) || | ||
!lin::isfinite(data.t)) { | ||
// Set the state and estimate to be invalid | ||
state = AttitudeEstimatorState(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can the filter just propagate without sensor readings? Or does the state need to be reset.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can't just propagate without sensor readings, at least that's how it's coded now. In terms of our use case however, there won't be a cc where we don't have at least magnetometer and gyroscope data. If for some reason we don't have that information, we have bigger problems than our attitude filter too lol
|
||
// Calculate this steps measurement | ||
UkfVector5 z_new { | ||
lin::atan(data.s_body(1) / data.s_body(0)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be NAN if s_body(0)==0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a little concerning... However, in cxx a finite float over zero results in plus or minus infinity (IEEE floats at least) and according to the documentation the std::atan
function (which is what lin::atan
essentially calls) returns pi/2
and -pi/2
for inf
and -inf
respectively. In theory we should be alright.
This code will get replaced when the new sun vector variance handling scheme is incorporated (issue for that coming soon).
Links:
https://en.cppreference.com/w/cpp/numeric/math/atan
https://stackoverflow.com/questions/4745311/c-division-by-0
Co-Authored-By: nhz2 <[email protected]>
Co-Authored-By: nhz2 <[email protected]>
Co-Authored-By: nhz2 <[email protected]>
Co-Authored-By: nhz2 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple of comments
Co-authored-by: nhz2 <[email protected]>
Magnetometer & Sun Vector Attitude Filter Implementation
Fixes #190.
Summary of changes
q_eci_perifocal
constant to fix the sun vector model; appropriate unit tests were fixed as well.On the surface, the attitude filter seems to work. It's difficult to write good test cases using just PIO because numerical precision, at least so far, has been as issue. For example, the Frobenius norm of the update state covariance matrix is only accurate to two significant digits. Also, we currently only have a single testcase.
There are multiple tickets open to track the work on the attitude filter going forward: #187, #188, #189, #191, #193, and #197. This work includes:
Ptest Effects
NA
Testing
See the added unit test cases and tickets listed above for further testing improvements to come.
Constants
gnc::constant::ukf_sigma_v
src/gnc_attitude_estimator.cpp
gnc::constant::ukf_sigma_u
sr/gnc_attitude_estimator.cpp
gnc::constant::ukf_sigma_b
src/gnc_attitude_estimator.cpp
gnc::constant::ukf_sigma_s
src/gnc_attitude_estimator.cpp
dt_thresh
(local scope)src/gnc_attitude_estimator.cpp
q_factor
(local scope)src/gnc_attitude_estimator.cpp
var_q
(local scope)src/gnc_attitude_estimator.cpp
var_g
(local scope)src/gnc_attitude_estimator.cpp
init_state
(local scope)src/gnc_attitude_estimator.cpp
Documentation Evidence
See inline documentation and the paper mentioned in the file documentation in
include/gnc/attitude_estimator.hpp
.