-
Notifications
You must be signed in to change notification settings - Fork 19.3k
Scripting: SoarNav applet, intelligent autonomous soaring #30766
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
Conversation
b4cb86c
to
6306c75
Compare
Sample log of a flight on SITL and Realflight using the latest version of SoarNav 0.9.57. |
2ba201d
to
a8ea5e6
Compare
5d69a37
to
e8a3b62
Compare
SoarNav is an advanced Lua script for intelligent, autonomous soaring that enhances ArduPilot's capabilities. It uses a suite of strategic features to maximize flight time within a defined area. The script employs a hybrid exploration strategy, dynamically balancing the search for new grid cells with guided re-visiting of the least explored areas based on recent thermal success. This is coupled with an intelligent thermal memory that saves thermal core locations. A sophisticated clustering algorithm then identifies promising hot zones using a weighted score based on nearby thermals' strength, age, and proximity. Real-time thermal analysis is performed using adaptive sampling for a responsive strength calculation. The script is architected for robust performance with a modular state machine and parameter caching. Safety is enhanced with dynamic anti-stuck logic, tactical rerouting, and thermal street detection capabilities.
Sorry, this PR is too messy. I'll open another one from a separate branch of my fork, as it should be. |
ArduPilot's SOAR mode equips gliders with the essential capability to autonomously thermal. When lift is encountered, it can efficiently center the thermal to gain altitude, extending flight time.
However, its effectiveness is bound by significant limitations. The system operates reactively and lacks a proactive exploration strategy to search a designated area for lift. Furthermore, it possesses no spatial memory; once a thermal dissipates or is lost, its location is forgotten, preventing the aircraft from revisiting historically productive zones.
When used in AUTO mode, SOAR simply follows a predefined waypoint track, enabling thermalling only if lift is found by chance along that rigid path. It performs no intelligent analysis or strategic deviation to actively hunt for thermals.
SoarNav was developed to overcome these boundaries, introducing the strategic exploration and intelligence that the core system lacks.
SoarNav is an advanced Lua script designed for automated thermal hunting. It utilizes a dual, intelligent strategy that goes beyond simple navigation.
Key Features:
Systematic Exploration (Virtual Grid): The script divides the flight area into a virtual grid, which is systematically explored to find new lift sources. The flight area is highly flexible, supporting both a circular radius and multiple polygon files selected via parameter. The grid logic is highly optimized with pre-calculated cell centers and distance-based updates to ensure high performance and low CPU load.
Advanced Thermal Analysis (Strength & Quality): The script remembers not just the location of a thermal, but also its quality. It analyzes the climb rate to save its average and peak strength and assesses its consistency (steady vs. variable lift).
Intelligent Thermal Memory (Core, Clustering & Focus Mode): The script now saves the thermal core (the location of the strongest lift) for superior accuracy. A clustering algorithm identifies "hot zones" with a high density of thermals. When a cluster is detected, the script can engage a Focus Mode, temporarily concentrating its search in that highly promising area. To ensure reliability, a "Lost Thermal-Awareness" failsafe prevents the script from chasing thermals that have dissipated.
Energy-Aware Logic: The script's strategy adapts to the aircraft's energy state. When low on altitude, it prioritizes safety by navigating to the strongest known thermal to regain height. With ample altitude, it makes a probabilistic choice between exploring a new grid cell or navigating towards a known thermal, balancing exploration with exploitation.
Thermal Streeting (Pattern Recognition): Instead of treating thermals as isolated events, the script attempts to identify "thermal streets"—lines of lift aligned with the wind. If a pattern is detected, it will proactively navigate along the projected street axis to find the next thermal in the chain.
Dynamic Drift Prediction: When targeting a known hotspot, the script uses the current wind vector and the hotspot's age to predict its new, drifted position, increasing the chances of a successful intercept.
Advanced Tactical Navigation (Anti-Stuck & Reroute): The script features two distinct tactical maneuvers. First, a robust anti-stuck logic detects if the aircraft is making poor progress (e.g., due to headwinds) and initiates an upwind repositioning maneuver. Second, a tactical reroute can be triggered mid-flight, initiating an intelligent 90-degree course change to break out of sink and explore a different airmass.
Intuitive Pilot Interaction: The pilot can intervene at any time. Moving the pitch or yaw sticks instantly pauses navigation. A rapid roll gesture toggles a persistent manual override, while a rapid pitch gesture re-centers the circular search area to the aircraft's current location.
This contribution aims to provide a powerful and robust autonomous soaring experience for the ArduPilot glider community.