-
Notifications
You must be signed in to change notification settings - Fork 17.3k
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
Allow setting of EKF3 wind state from MAV_CMD_EXTERNAL_WIND_ESTIMATE #28279
Open
peterbarker
wants to merge
7
commits into
ArduPilot:master
Choose a base branch
from
peterbarker:pr/ekf3-set-wind
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+250
−13
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
93982cd
AP_DAL: Handle external wind state set
priseborough 20d9827
Replay: Handle external wind state set
priseborough 00981e4
AP_NavEKF3: Allow wind state to be set externally
priseborough c15a7e2
AP_AHRS: pass external wind estimates through to EKF3
peterbarker fa55838
GCS_MAVLink: pass external airspeed speed accuracy and direction accu…
peterbarker ab201ee
autotest: Add external wind set to replay message list
priseborough c4a97c6
autotest: do replay logging for external wind estimate
peterbarker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -760,3 +760,60 @@ void NavEKF3_core::FuseDragForces() | |
* MISC FUNCTIONS * | ||
********************************************************/ | ||
|
||
#if EK3_FEATURE_SETWIND | ||
bool NavEKF3_core::setWind(float speed, float speed_accuracy, float direction, float direction_accuracy) | ||
{ | ||
// reset the corresponding covariances | ||
zeroRows(P,22,23); | ||
zeroCols(P,22,23); | ||
|
||
// set the wind state variances | ||
if (is_positive(speed_accuracy)) { | ||
if (is_positive(direction_accuracy)) { | ||
const ftype spdVar = sq(speed_accuracy); | ||
const ftype dirnVar = sq(radians(direction_accuracy)); | ||
|
||
const ftype PS0 = cosf(radians(direction)); | ||
const ftype PS1 = sq(PS0); | ||
const ftype PS2 = sinf(radians(direction)); | ||
const ftype PS3 = sq(PS2); | ||
const ftype PS4 = dirnVar*sq(speed); | ||
const ftype PS5 = PS0*PS2*(-PS4 + spdVar); | ||
|
||
P[22][22] = PS1*spdVar + PS3*PS4; | ||
P[23][22] = PS5; | ||
P[22][23] = PS5; | ||
P[23][23] = PS1*PS4 + PS3*spdVar; | ||
} else { | ||
P[22][22] = P[23][23] = sq(speed_accuracy); | ||
} | ||
} else { | ||
P[22][22] = P[23][23] = sq(WIND_SPD_UNCERTAINTY); | ||
} | ||
|
||
// reset the NE wind velocity states to the measurement | ||
Vector2F wind_vel_prev = stateStruct.wind_vel; | ||
stateStruct.wind_vel.x = -speed * cosF(radians(direction)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. need to check sign convention for ekf3 wind state vs external wind state |
||
stateStruct.wind_vel.y = -speed * sinF(radians(direction)); | ||
|
||
// update the vehicle velocity states to be consistent with the new wind estimate if dead reckoning | ||
if ((imuSampleTime_ms - lastGpsPosPassTime_ms) > frontend->deadReckonDeclare_ms) { | ||
velResetNE = stateStruct.wind_vel - wind_vel_prev; | ||
stateStruct.velocity.xy() += velResetNE; | ||
|
||
// update the output buffer | ||
for (uint8_t i=0; i<imu_buffer_length; i++) { | ||
storedOutput[i].velocity.xy() = stateStruct.velocity.xy(); | ||
} | ||
outputDataNew.velocity.xy() = stateStruct.velocity.xy(); | ||
outputDataDelayed.velocity.xy() = stateStruct.velocity.xy(); | ||
|
||
// store the time of the reset | ||
lastVelReset_ms = imuSampleTime_ms; | ||
lastExtWindVelSet_ms = imuSampleTime_ms; | ||
} | ||
|
||
return true; | ||
|
||
} | ||
#endif // EK3_FEATURE_SETWIND |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
what does is_positive() do for a NaN?