<<< etheli.com Home Page

Cleanflight / Betaflight Patch:
Add horizon_tilt_effect command


My MiniFTC

Update (1/2017):  This modification has been merged into the Cleanflight code and is part of the released firmware v1.14.2.  See here for documentation on the commands.

See here for the Betaflight version.

This Cleanflight modification adds two new CLI commands, 'horizon_tilt_effect' and 'horizon_tilt_mode', which control the effect the current inclination has on self-leveling in the Horizon flight mode.  With the existing horizon mode, the strength of the self-leveling is solely dependent on the stick position.  This is problematic when trying to do maneuvers like large loops and fast-forward flight.  Adding a factor that takes into account the current inclination of the craft provides a big improvement for these maneuvers and improves the "feel" of horizon mode.  (The current inclination is the number of degrees of pitch or roll that the vehicle is away from level, whichever is greater).

These commands affect Horizon mode for the LUX and REWRITE controllers.  The math is all integer based, so no (slower) floating-point operations are involved when using the REWRITE controller.

This mod also addresses an issue with the "Transition (Horizon)" ('d_level') parameter -- as of Cleanflight v1.13.0 the 'sensitivity_horizon' (LUX) and 'd_level' (REWRITE) CLI parameters were merged so that both use the 'd_level' parameter.  The problem is that the ranges behave differently -- in LUX, increasing the value results in more self leveling and zero results in no self leveling; in REWRITE, increasing the value results in less self leveling.  With this mod, increasing the value results in more self leveling and zero results in no self leveling.  The default has been changed to 75, which should give relatively unchanged default behavior for this parameter on both PID controllers.

The original idea for this came from ctzsnooze (see CleanFlight issue #695); I've expanded on it and turned it into a configurable option.  One characteristic of horizon mode I made a point of retaining is that, when the vehicle is flat and the sticks are near center, the self-leveling effect is not diminished by larger 'horizon_tilt_effect' settings.  Like in the existing horizon mode, the strength of the self-leveling can be effectively managed using the "Strength (Horizon)" ('i_level') parameter.  Also, the "Transition (Horizon)" ('d_level') parameter operates the same as before.

Setting 'horizon_tilt_effect' to 0 will run the old horizon-mode behavior.  For other values, see below:

horizon_tilt_effect 0|175|75: Controls the effect the current inclination (tilt) has on self-leveling in the Horizon flight mode. Larger values result in less self-leveling (more "acro") as the tilt of the vehicle increases. The default value of 75 provides good performance when doing large loops and fast-forward flight. With a value of 0 the strength of the self-leveling would be solely dependent on the stick position.

horizon_tilt_mode SAFE|EXPERT: Sets the preformance mode for 'horizon_tilt_effect'

SAFE = leveling always active when sticks centered:
This is the "safer" range because the self-leveling is always active when the sticks are centered. So, when the vehicle is upside down (180 degrees) and the sticks are then centered, the vehicle will immediately be self-leveled to upright and flat. (Note that after this kind of very-fast 180-degree self-leveling, the heading of the vehicle can be unpredictable.)

EXPERT = leveling can be totally off when inverted:
In this range, the inclination (tilt) of the vehicle can fully "override" the self-leveling. In this mode, when the 'horizon_tilt_effect' parameter is set to around 75, and the vehicle is upside down (180 degrees) and the sticks are then centered, the vehicle is not self-leveled. This can be desirable for performing more-acrobatic maneuvers and potentially for 3D-mode flying.

The 'horizon_tilt_effect' and 'horizon_tilt_mode' values are separate for each profile, and are implemented for both the LUX and REWRITE PID controllers.

This modification is posted as a GitHub pull request here:  Add horizon_tilt_effect command #2364

Below is a file of the modified firmware that may be used for testing.  It is based on the released Cleanflight v1.13.0.

Firmware file for Naze32:  cleanflight_NAZE_v1.13.0rel_addHorTiltEffVbatHyst_20160821.hex

This firmware also adds the 'vbat_hysteresis' parameter, as described here.  (If you'd like firmware files for other boards posted, let me know.)

Note:  These firmware files should be considered a beta-test releases and are to be used at your own risk.  After loading this firmware the controller's configuration may be reset to factory-default values, so the configuration should be backed up before and restored after the firmware update.

Complete source code is here and here.

If you have questions/comments or find this patch useful, please let me know.




Betaflight version

A
Betaflight version of the 'horizon_tilt_effect' modification is posted as a GitHub pull request here:  Add horizon_tilt_effect command (2) #2570.  See here for documentation on the commands.

Below are firmware files for Betaflight v3.0.1 that have been modified to support the 'horizon_tilt_effect' and 'horizon_tilt_mode' commands.

Betaflight v3.0.1 Naze:  betaflight_NAZE_v3.0.1rel_addHorizonTiltEffect_20161204.hex
Betaflight v3.0.1 BeeBrain:  betaflight_BEEBRAIN_v3.0.1rel_addHorizonTiltEffect_20161204.hex
Betaflight v3.0.1 SPRacingF3:  betaflight_SPRACINGF3_v3.0.1rel_addHorizonTiltEffect_20161204.hex
Betaflight v3.0.1 SPRacingF3EVO:  betaflight_SPRACINGF3EVO_v3.0.1rel_addHorizonTiltEffect_20161204.hex

Below are firmware files for Betaflight v3.1.6 that have been modified to support the 'horizon_tilt_effect' and 'horizon_tilt_mode' commands, and also have a bug fix for the angle/accelerometer-trim direction (see here for details).

Betaflight v3.1.6 Naze:  betaflight_NAZE_v3.1.6rel_horTiltEff_angSignFix_20170304_1.hex
Betaflight v3.1.6 BeeBrain:  betaflight_BEEBRAIN_v3.1.6rel_horTiltEff_angSignFix_20170304_1.hex
Betaflight v3.1.6 SPRacingF3:  betaflight_SPRACINGF3_v3.1.6rel_horTiltEff_angSignFix_20170304_1.hex
Betaflight v3.1.6 SPRacingF3EVO:  betaflight_SPRACINGF3EVO_v3.1.6rel_horTiltEff_angSignFix_20170304_1.hex
Betaflight v3.1.6 SPRacingF3NEO:  betaflight_SPRACINGF3NEO_v3.1.6rel_horTiltEff_angSignFix_20170304_1.hex

Other builds for Betaflight may be found here.

(If you'd like firmware files for other boards posted, let me know.)

Source code for the Betaflight 3.0.1 version is here (.zip) and here on GitHub.
Source code for the Betaflight 3.1.6 version is here (.zip) and her on GitHub.

Note:  These firmware files should be considered a beta-test releases and are to be used at your own risk.  After loading this firmware the controller's configuration may be reset to factory-default values, so the configuration should be backed up before and restored after the firmware update.



Click here to contact me

Back to etheli.com home page



ET Heli