-
Notifications
You must be signed in to change notification settings - Fork 13.6k
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
ekf2: cleanup output predictor init #20960
base: main
Are you sure you want to change the base?
Conversation
dagar
commented
Jan 18, 2023
- output predictor align also init _output_vert_new
- output predictor reset handle all fields
- output predictor resetQuaternion() normalize
- output predictor calculateOutputStates() paranoid timestamp check
- output predictor correctOutputStates() paranoid timestamp checks and explicitly pop delayed sample at correct time
6bbfef5
to
b4a313d
Compare
b4a313d
to
284073f
Compare
e9003b7
to
a5efedd
Compare
a5efedd
to
c32a89e
Compare
- output predictor align also init _output_vert_new - output predictor reset handle all fields - output predictor resetQuaternion() normalize - output predictor calculateOutputStates() paranoid timestamp check - output predictor correctOutputStates() paranoid timestamp checks and explicitly pop delayed sample at correct time
c32a89e
to
b172705
Compare
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.
I think we could move on with that PR, could you rebase please?
edb8750
to
0290a61
Compare
// calculate the quaternion rotation delta from the EKF to output observer states at the EKF fusion time horizon | ||
const Quatf q_delta((quat_state * output_delayed.quat_nominal.inversed()).normalized()); | ||
const Dcmf rot_change{q_delta}; | ||
|
||
// add the reset amount to the output observer buffered data | ||
for (uint8_t i = 0; i < _output_buffer.get_length(); i++) { | ||
|
||
_output_buffer[i].quat_nominal = (q_delta * _output_buffer[i].quat_nominal).normalized(); | ||
|
||
// apply change to velocity | ||
_output_buffer[i].vel = rot_change * _output_buffer[i].vel; | ||
_output_buffer[i].vel_alternative = rot_change * _output_buffer[i].vel_alternative; | ||
} | ||
|
||
// apply the change in attitude quaternion to our newest quaternion estimate | ||
_output_new.quat_nominal = (q_delta * _output_new.quat_nominal).normalized(); | ||
|
||
// calculate a gain that provides tight tracking of the estimator attitude states and | ||
// adjust for changes in time delay to maintain consistent damping ratio of ~0.7 | ||
const uint64_t time_latest_us = _time_last_update_states_us; | ||
const float time_delay = fmaxf((time_latest_us - time_delayed_us) * 1e-6f, _dt_update_states_avg); | ||
const float att_gain = 0.5f * _dt_update_states_avg / time_delay; | ||
|
||
// calculate a corrrection to the delta angle | ||
// that will cause the INS to track the EKF quaternions | ||
_delta_angle_corr = delta_ang_error * att_gain; | ||
_output_tracking_error(0) = delta_ang_error.norm(); | ||
// apply change to velocity | ||
_output_new.vel = rot_change * _output_new.vel; | ||
_output_new.vel_alternative = rot_change * _output_new.vel_alternative; | ||
|
||
/* | ||
* Loop through the output filter state history and apply the corrections to the velocity and position states. | ||
* This method is too expensive to use for the attitude states due to the quaternion operations required | ||
* but because it eliminates the time delay in the 'correction loop' it allows higher tracking gains | ||
* to be used and reduces tracking error relative to EKF states. | ||
*/ | ||
propagateVelocityUpdateToPosition(); |
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.
Isn't this exactly the same as in resetQuaternion?
|
||
// apply change to velocity | ||
_output_buffer[i].vel = rot_change * _output_buffer[i].vel; | ||
_output_buffer[i].vel_alternative = rot_change * _output_buffer[i].vel_alternative; |
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.
I see what you're trying to do here, but why correcting the velocities here if they are anyway re-corrected just after?
const float vert_vel_err = (vel_state(2) - output_vert_delayed.vert_vel); | ||
const float vert_vel_integ_err = (pos_state(2) - output_vert_delayed.vert_vel_integ); | ||
// calculate the velocity and position deltas between the output and EKF at the EKF fusion time horizon | ||
output_delayed.vel = q_delta.rotateVectorInverse(output_delayed.vel); |
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.
Shouldn't we use rotateVector(...
or rot_change * ...
here?
Also, it seems that this is only needed because the velocity is corrected during the quaternion correction above.