Although mentioned somewhere, the
AutoCruise GPS mode is not discussed too much. In fact, I was unaware of its implementation in LibrePilot. Some time ago I decided to do some code reading and make an attempt to add a new flight mode to Librepilot to
perform a level flight in specified direction while keeping altitude. Finding the already existing code for AutoCruise was a really pleasant surprise
I believe the AutoCruise mode is intended mostly for FixedWing vehicle type and not for VTOLs / multirotors.
I've made some tests that confirmed the existing code functions quite well and reliable. It just needs a minimal setup to be used.
First of all, the other GPS flight modes like
ReturnToBase and
PositionHold, should be already properly setup and working fine.
AutoCruise cannot be set in the
Configuration / Input / FlightMode Switch Positions. Not available in the dropdown list there. Use
System tab instead:
Settings / FlightModeSettings / FlightModePosition and set it there for the desired switch position.
There is one more parameter to be changed:
Settings / FlightModeSettings / PositionHoldOffset / Horizontal. Default value of 30 is way too low. I can suggest a value of
300 which may not be the optimal but gives quite satisfactory results. I'll try to explaing in short:
The way the AutoCruise works is flying in GoToEndPoint (not FollowVector!) mode to a point that is projected some distance away from current airplane position at the same height as of airplane position. The initial direction (heading) is the one captured at the moment of AutoCruise mode engagement.
The target position is being continuously updated with airplane position changes, keeping height and heading, also taking in mind pilot's manual control commands (if any) on pitch and yaw. This allows some precise minimal changes in the heading and height the plane follows autonomously.
The forementioned
PositionHoldOffset / Horizontal (meters) is used to setup how far away from current position is the target endpoing projected. Default value of 30 (that is fine for VTOL configuration and the way used in VTOL flight code) is not fine for FixedWing mode. For a fast flying vehicle (airplane) this is too nearby and the airplane likely overshoots its target. This causes ugly wanderings as the plane attempts to start turning back to target. See first video:
Video 1 (AutoCruise with default PositionHoldOffset / Horizontal = 30) - unstableThe suggested value of 300 seems to work fine for MiniTalon (60km/h cruise speed) and Wing Z-84 (45-50km/h cruise speed).
You may also wish to increase the default value for
Settings / FlightModeSettings / PositionHoldOffset / Vertical. It is used to control AutoCruise sensitivity for manual pilot commands (pitch stick) for altitude changes.
When in FixedWing mode, changing
PositionHoldOffset / Horizontal & Vertical has no side effects on other flight modes. At least I did not found references when browsing flight code. If I'm wrong, devs or some more experienced will step in to correct me, I believe.
Video 2 (AutoCruise with PositionHoldOffset / Horizontal = 300) - OK