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

Support MAV_CMD_EXTERNAL_WIND_ESTIMATE #27847

Merged

Conversation

python36
Copy link
Contributor

When flying without a GPS receiver, drift correction does not work properly because the autopilot does not have information about the wind speed and direction.
I can get wind information using online services (e.g. windy.com) and with this command set a custom wind speed and direction, which will greatly improve drift correction.

This is very important when flying without GPS.

libraries/AP_AHRS/AP_AHRS.h Outdated Show resolved Hide resolved
libraries/AP_AHRS/AP_AHRS_DCM.cpp Outdated Show resolved Hide resolved
@python36
Copy link
Contributor Author

@peterbarker I make a new commit taking into account your proposals.

Copy link
Contributor

@peterbarker peterbarker left a comment

Choose a reason for hiding this comment

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

Should we have a timeout on the use of this wind estimate?

In your testing, how long does the use of this estimate last during a flight?

An autotest for this would be nice.

libraries/AP_AHRS/AP_AHRS.h Outdated Show resolved Hide resolved
libraries/AP_AHRS/AP_AHRS.h Outdated Show resolved Hide resolved
libraries/AP_AHRS/AP_AHRS_DCM.cpp Outdated Show resolved Hide resolved
libraries/GCS_MAVLink/GCS_Common.cpp Outdated Show resolved Hide resolved
libraries/AP_AHRS/AP_AHRS_DCM.cpp Outdated Show resolved Hide resolved
@LupusTheCanine
Copy link

Should we have a timeout on the use of this wind estimate?

IMHO it is likely that the estimate will be closer to truth than 0 wind velocity unless the wind is rapidly changing which will mess with dead reckoning no mater what you do.

@peterbarker
Copy link
Contributor

Playing with MAVProxy command: long EXTERNAL_WIND_ESTIMATE 10 0 30

AHRS_EKF_TYPE of 0 (DCM)

On ground With AIRSPEED_USE of zero:
image

On ground With AIRSPEED_USE of one:
image

In-flight when loitering with a 5m/s wind from 180 (with airspeed)
image

In-flight when loitering with a 5/m/s wind from 180, without airspeed:
image

Copy link
Contributor

@peterbarker peterbarker left a comment

Choose a reason for hiding this comment

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

Solid autotest.

Needs to be broken into several commits, one-per-subsystem with appropriate commit commits.

See https://ardupilot.org/dev/docs/git-interactive-rebase.html and Tools/gittools/git-subsystems-split

@@ -6052,6 +6052,44 @@ def ForceArm(self):
)
self.disarm_vehicle()

def _MAV_CMD_EXTERNAL_WIND_ESTIMATE(self, command):
self.reboot_sitl()
Copy link
Contributor

Choose a reason for hiding this comment

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

Why this reboot?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without rebooting it crashes with the problem:

2024-09-02T10:59:42.8273703Z AT-1454.7: mavproxy_start was called 3 times
2024-09-02T10:59:42.8274525Z AT-1454.7: Supplied terrain data to autopilot in 1176 messages
2024-09-02T10:59:42.8275279Z Had to force-reset SITL 1 times
2024-09-02T10:59:42.8276256Z AT-1454.7: Writing test result in jUnit format to autotest_result_ArduPlane_test.Plane_junit.xml
2024-09-02T10:59:42.8277039Z 
2024-09-02T10:59:42.8277325Z >>>> FAILED STEP: test.Plane at Mon Sep  2 10:59:42 2024
2024-09-02T10:59:42.8277981Z Failure Summary:
2024-09-02T10:59:42.8278383Z   test.Plane:
2024-09-02T10:59:42.8278959Z     TakeoffAuto3 (Test the behaviour of an AUTO takeoff, pt3.
2024-09-02T10:59:42.8279511Z 
2024-09-02T10:59:42.8279661Z         Conditions:
2024-09-02T10:59:42.8280127Z         - ARSPD_USE=1
2024-09-02T10:59:42.8280609Z         - TKOFF_OPTIONS[0]=1
2024-09-02T10:59:42.8281646Z         ) (Wrong value) (see /tmp/buildlogs/ArduPlane-TakeoffAuto3.txt) (duration 1.3573386669158936 s)
2024-09-02T10:59:42.8284539Z     MAV_CMD_EXTERNAL_WIND_ESTIMATE (test MAV_CMD_EXTERNAL_WIND_ESTIMATE as a mavlink command) (Failed to set wind speed or/and direction: speed != 1 or direction != 45) (see /tmp/buildlogs/ArduPlane-MAV_CMD_EXTERNAL_WIND_ESTIMATE.txt) (duration 0.09662985801696777 s)
2024-09-02T10:59:42.8286841Z FAILED 1 tests: ['test.Plane']
2024-09-02T10:59:42.9402933Z ##[error]Process completed with exit code 1.```

Tools/autotest/arduplane.py Outdated Show resolved Hide resolved
@python36 python36 force-pushed the MAV_CMD_EXTERNAL_WIND_ESTIMATE branch 2 times, most recently from 8a94408 to 1ee8439 Compare September 2, 2024 14:32
@tridge
Copy link
Contributor

tridge commented Sep 2, 2024

@priseborough I notice in your branch here: https://github.com/priseborough/ardupilot/commits/pr-ekfWindStateUpdate-rebase04/ that you seem to be doing the same thing, but with EKF3 instead of DCM
how close is that to being ready? Should we merge the DCM only PR first and then layer yours on top?

@tridge
Copy link
Contributor

tridge commented Sep 2, 2024

@tridge do you want to try Pauls branch in SITL, with DCM fallback disabled?

@peterbarker
Copy link
Contributor

@python36 what sorts of boards are you running this on? We're wondering how to guard the feature compilation-wise, whether to say >1024MB instead of DCM (need to change the latter when EKF3 supports it).

@priseborough
Copy link
Contributor

@priseborough I notice in your branch here: https://github.com/priseborough/ardupilot/commits/pr-ekfWindStateUpdate-rebase04/ that you seem to be doing the same thing, but with EKF3 instead of DCM how close is that to being ready? Should we merge the DCM only PR first and then layer yours on top?

@tridge My branch is very close. I'm in the process of finalising autotests. I vote we merge this first and I'll rebase and deal with the AHRS library conflicts.

@priseborough
Copy link
Contributor

FYI the https://github.com/priseborough/ardupilot/commits/pr-ekfWindStateUpdate-rebase04/ branch bundles a few dead reckoning inprovements:

Enables a VTOL to fly using dead reckoning when GPS is unavailable provided the origin is set before flight.
Keeps the last known local position after dropping out of dead reckoning when going from forward flight to VTOL modes.
Uses MAV_CMD_EXTERNAL_POSITION_ESTIMATE messages to update the wind estimate.
Uses MAV_CMD_EXTERNAL_WIND_ESTIMATE messages to update EKF3 wind estimates also using the accuracy fields to set the wind state covariances. Vehicle velocity is also updated to be consistent with the wind and airspeed.

@python36 python36 force-pushed the MAV_CMD_EXTERNAL_WIND_ESTIMATE branch from 1ee8439 to d2651b0 Compare September 3, 2024 06:34
@python36
Copy link
Contributor Author

python36 commented Sep 3, 2024

@python36 what sorts of boards are you running this on? We're wondering how to guard the feature compilation-wise, whether to say >1024MB instead of DCM (need to change the latter when EKF3 supports it).

I am using fmuv3 board so I have 2MB of flash on board. I created a new commit.

@python36 python36 force-pushed the MAV_CMD_EXTERNAL_WIND_ESTIMATE branch from d2651b0 to 17c42fa Compare September 3, 2024 10:39
@python36 python36 force-pushed the MAV_CMD_EXTERNAL_WIND_ESTIMATE branch from 17c42fa to 2fdbed3 Compare September 3, 2024 16:12
@peterbarker peterbarker merged commit d802b0e into ArduPilot:master Sep 4, 2024
93 checks passed
@peterbarker
Copy link
Contributor

Merged, thanks!

@python36
Copy link
Contributor Author

python36 commented Sep 4, 2024

Merged, thanks!

🎉🎉🎉 Thanks all.
@peterbarker Thank you very much

@rmackay9
Copy link
Contributor

rmackay9 commented Nov 6, 2024

This is a very interesting feature but one question I have about the implementation is why was MAV_CMD_EXTERNAL_WIND_ESTIMATE used? It's really not a command so it probably should have been provided using a new mavlink message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants