Add initial SmartFlight planner integration
Purpose
Create the initial integration module for a weather aware planner from Shearwater.ai's web planner into MAVProxy. Shearwater provides top quality path planning software, and recently exposed it over a REST API. They are looking for feedback from ArduPilot partners/users, so I thought it would be nice to write them a MAVProxy module so that you can use their planner from a GCS. Their planner is in beta - this is not
Assumptions
- You can request an API key from Shearwater or have a license (TBD)
- Your GCS has internet connectivity when you make the plan (or you plan before flying)
- You only are using this in SITL so far- we ignore some params so it might not obey your vehicle's kinematic constraints, so don't fly this yet
Details
Related to https://github.com/ArduPilot/MAVProxy/pull/1533 with a bit of overlap
Usage
Request a bearer token from sheawater, and put it in a .env file next to smart_flight_planner.py.
SMARTFLIGHT_BEARER_TOKEN=eyJhbG......
I recommend the mavinit.scr settings:
module load smartflight
smartflight show boundary
smartflight show start
smartflight show goal
Run SITL (assuming your already built plane before, for rapid iteration)
./Tools/autotest/sim_vehicle.py --debug -v plane --console --map --custom-location="21.306831, -157.945131, 5, 90" --no-configure --no-rebuild --mavcesium
Disable grid, disable follow on the map, then zoom out to see the whole island.
It comes preloaded with a sample area, and a start and goal loiter location. Let's start by using those.
In the console, click "SmartFlight -> Compute Plan" to call the planner. Once the console says that it computed the plan, use the map to right click -> SmartFlight -> Show -> Show Plans
Three different plans show up that are optimized according to different criteria.
You can now set takeoff mode, arm.
TAKEOFF
arm throttle
Wait to get in the loiter, then on the MAVProxy console, click "SmartFlight -> Execute -> Energy Optimized Plan.
You'll see the green plan populate with waypoint numbers, the vehicle switch to AUTO and start flying the green path.
This automatically loads the route into the current mission and engages AUTO (assuming the vehicle is armed).
At any point, hit RTL, and change some of the parameters.
- Adjust the start and end with map right click -> SmartFlight -> Set -> Set Start or Set Goal. You will see the green loiter circle move.
- Adjust the boundary with map right click -> SmartFlight -> Draw boundary
- Adjust the altitude limits for the planner in CLI with
smartflight set <tab>.
When ready, recompute the plan and show it again. If you try to compute the same plan multiple times, it will instead reuse the locally cached one. Planner computation can take ~45 seconds for paths across Oahu.
The CLI fully exposes all the UI functions. With MAVCesium, you get a good idea of how this allows you to fly close to terrain, and obey AGL constraints from regulations without crashing into terrain.
Future improvements
- Implement start and terminal loiters
- Implement hide functionality for features
- Automate more of the usage by automatically drawing plans when they are computed
- Using the vehicle params instead of loading defaults from the JSON file
- Redraw planner features if map module is reloaded
- Re-add console menu if the console module is reloaded
- Chain multiple planner routes together for longer missions with intermediate behavior
@Ryanf55 any reason not to merge now?
@Ryanf55 any reason not to merge now?
Please merge at your convenience. I just squashed.