Autopilot algorithms
Nodes:nav
sim
 Module:shiva
 Parameters:Autopilot
The module provides control loops for navigation and stabilization.
Configuration parameters

Autopilot
Control parameters

mode
Operation modeoption
[off,local,primary,secondary,failsafe,auxillary]
The priority of data, published by the module. All priorities, except
local
are broadcasting data in network. 
Roll
Roll [deg] to Ailerons [%]

tc
Time constantreal
[s]
0.1
Smaller values make it faster to respond, larger values make it slower to respond. The error is divided by this time constant to get the rate setpoint.

Kp
Proportional gainreal
2

Ki
Integral gainreal
2.5

Kd
Differential gainreal

Kff
Feed forward gainreal

Lp
Rate limitreal
[deg/s]
40

Li
Integral limitbyte
[%]
10

Lo
Output limitbyte
[%]
100

rdiff
Rate limit diffreal

ifactor
Integral large error factorword
[deg/s]

trim
Regulator output trimming factors.

low
Low speed trimreal
[%]

high
High speed trimreal
[%]

flaps
Flaps trimreal
[%]

gain
Regulator output gains.

low
Low speed gainreal

high
High speed gainreal

flaps
Flaps gainreal

stab
Stability gainreal
This value is the gain multiplier for ailerons control when estimated stability is 1 (unstable). I.e. when parameter set to
0.2
 the ailerons output will be multiplied by0.2
when in stall condition, thus lowering the output value. For reverse ailerons  set parameter to negative, i.e. when set to0.5
, the ailerons gain will be0.5
in stall condition, making it reversed, and zero at about0.5
of estimated stability. See chart for details. 
cmd
Setpoint

max
Setpoint limitreal
[deg]
45

slew
Setpoint slew rate limitword
[deg/s]
40

diff
Setpoint limit diffreal

offset
Setpoint offsetreal
[deg]

Pitch
Pitch [deg] to Elevator [%]

tc
Time constantreal
[s]
0.5
Smaller values make it faster to respond, larger values make it slower to respond. The error is divided by this time constant to get the rate setpoint.

Kp
Proportional gainreal
6

Ki
Integral gainreal
3.5

Kd
Differential gainreal

Kff
Feed forward gainreal

Lp
Rate limitreal
[deg/s]
40

Li
Integral limitbyte
[%]
25

Lo
Output limitbyte
[%]
100

rdiff
Rate limit diffreal

ifactor
Integral large error factorword
[deg/s]

trim
Regulator output trimming factors.

low
Low speed trimreal
[%]

high
High speed trimreal
[%]

flaps
Flaps trimreal
[%]

stab
Stall condition trimbyte
[%]
The estimated stability value will be multiplied by this factor and subtracted from elevator control [%]. This will make elevator down when in stall condition.

gain
Regulator output gains.

low
Low speed gainreal

high
High speed gainreal

flaps
Flaps gainreal

cmd
Setpoint

max
Setpoint limitreal
[deg]
20

slew
Setpoint slew rate limitword
[deg/s]
10

diff
Setpoint limit diffreal

offset
Setpoint offsetreal
[deg]

Yaw
Yaw [deg] to Rudder [%]

tc
Time constantreal
[s]
2.5
Smaller values make it faster to respond, larger values make it slower to respond. The error is divided by this time constant to get the rate setpoint.

Kp
Proportional gainreal
6

Ki
Integral gainreal
1.1

Kd
Differential gainreal

Kff
Feed forward gainreal

Lp
Rate limitreal
[deg/s]
40

Li
Integral limitbyte
[%]
5

Lo
Output limitbyte
[%]
100

rdiff
Rate limit diffreal

ifactor
Integral large error factorword
[deg/s]

trim
Regulator output trimming factors.

low
Low speed trimreal
[%]

high
High speed trimreal
[%]

flaps
Flaps trimreal
[%]

gain
Regulator output gains.

low
Low speed gainreal

high
High speed gainreal

flaps
Flaps gainreal

slew
Yaw setpoint slew rate limitword
[deg/s]

slip
Slip error to yaw rate proportional gainreal
2

Bearing
Waypoint to Roll [deg]. L1 controller for trajectory navigation.

dist
L1 periodreal
[m]
25

damp
Damping factorreal
0.9

radius
Waypoint switch radiusword
[m]
50
The waypoint is passed when the distance is lower than this value.

trig
Waypoint heading rate switch triggerword
[deg/s]
10
Another way to detect waypoint passed condition, i.e. when the rate of heading to the waypoint is higher than this value  the waypoint is considered as passed.

topt
Turn direction optimizationoption
[optimized,shortest]
Enabling this option will optimize turn directions to avoid large bank angle changes. I.e. for Uturns this makes aircraft to continue existing turn maneuver when applicable.

Airspeed
Kinetic Energy to Pitch (TECS). This controller regulates rate of energy by changing the commanded pitch angle.

tc
Time constantreal
[s]
6
Smaller values make it faster to respond, larger values make it slower to respond. The error is divided by this time constant to get the rate setpoint.

Kp
Energy rate error gainreal
0.5
The energy rate error is multiplied by this factor to provide pitch angle.

Ki
Integrator gainreal
1.1
Trimming for the pitch angle to maintain commanded rate of energy.

weight
Speed vs altitude tecs weighting factorreal
1
This parameter adjusts the amount of weighting that the pitch control applies to speed vs height errors. Setting it to 0 will cause the pitch control to control height and ignore speed errors. This will normally improve height accuracy but give larger airspeed errors. Setting it to 1 will cause the pitch control loop to control speed and ignore height errors. This will normally reduce airspeed errors, but give larger height errors. The value of 0.5 allows the pitch control to simultaneously control height and speed.

slew
Speed setpoint slew ratereal
[m/s^2]
1
Commanded airspeed rate of change limit.

Altitude
Potential Energy to Throttle (TECS). This controller regulates rate of energy by changing the engine throttle.

tc
Time constantreal
[s]
10
Smaller values make it faster to respond, larger values make it slower to respond. The error is divided by this time constant to get the rate setpoint.

Kp
Energy rate error gainreal
0.3
The energy rate error is multiplied by this factor to provide throttle.

Ki
Integrator gainreal
0.1
Trimming gain for the throttle to maintain commanded rate of energy.

roll
Roll to energy rate feedforwardreal
Increasing this gain increases the amount of throttle that will be used to compensate for the additional drag created by turning.

slew
Vertical speed setpoint slew ratereal
[m/s^2]
1
Commanded vertical speed rate of change limit.

Engine
Governor

Kp
Proportional gainreal
2.5

Kd
Differential gainreal
3.1

Kff
Feed forward factorreal
0.5

lpf
Rpm lp filterreal
0.1

rpm
Engine RPM

cruise
Cruise rpmdword
[rpm]
This is the RPM setting for cruise speed.

max
Maximum rpmdword
[rpm]
This is the engine maximum allowed RPM.

min
Minimum rpmdword
[rpm]
This is the engine idle RPM.

slew
Commanded rpm max slew ratereal
[rpm/s]
500
Maximum slew rate for the commanded RPM

thr
Throttle setpoint

max
Max throttlebyte
[%]
100
This is the maximum throttle that can be used by the regulator. For overpowered aircraft, this should be reduced to a value that provides sufficient thrust to climb at the maximum pitch angle.

min
Min throttlebyte
[%]
This is the minimum throttle that can be used by the controller. For electric aircraft this will normally be set to zero, but can be set to a small nonzero value if a folding prop is fitted to prevent the prop from folding and unfolding repeatedly inflight or to provide some aerodynamic drag from a turning prop to improve the descent rate. For aircraft with internal combustion engine this parameter should be set for desired idle rpm.

slew
Throttle max slew ratebyte
[%/s]
Maximum slew rate for the commanded throttle

Taxi
Taxiways navigation

Steering
Yaw [deg] to Steering [%]

tc
Time constantreal
[s]
2.5
Smaller values make it faster to respond, larger values make it slower to respond. The error is divided by this time constant to get the rate setpoint.

Kp
Proportional gainreal
5

Ki
Integral gainreal
0.1

Kff
Feed forward gainreal
0

Lp
Rate limitreal
[deg/s]
1000

Li
Integral limitbyte
[%]
5

gain
Steering high speed gainreal
0.1

Track
Crosstrack [m] to Yaw [deg]

dist
L1 periodreal
[m]
6

damp
Damping factorreal
1.7

trig
Taxiway switch radiusword
[m]
15

Brakes
Speed to Brakes [%]

Kp
Proportional gainreal
10

Kd
Differential gainreal

Flaps
Auto flaps control

max
Vso flapsbyte
[%]

min
Vsi flapsbyte
[%]

takeoff
Takeoff flapsbyte
[%]

approach
Approach flapsbyte
[%]

final
Final approach flapsbyte
[%]

ld
Flaps ld gainreal
Flaps level will affect proportionally the LD ratio when this parameter is set. The corrected LD ratio is used by landing procedure only to estimate landing patterns. F.ex. when set to
0.6
 full flaps will make LD ratio (used by landing procedure) to be 0.6 of estimated LD, but 50% flaps will make LD to be 0.8 of estimated value. 
Takeoff
Takeoff procedure

mode
Takeoff modeoption
[runway,launcher,helipad]

check
Checks to perform before takeoff

hdg
Heading errorbyte
[deg]
Will cancel takeoff if heading error is more than this value

xtrack
Crosstrack errorbyte
[m]
Will cancel takeoff if crosstrack error is more than this value

run
Takeoff Run phase parameters

speed
Max speedbyte
[m/s]

pitch
Run phase pitch anglebyte
[deg]

tslew
Throttle rate limitbyte
[%/s]

climb
Takeoff Climbing phase parameters

pitch
Liftoff phase pitch anglebyte
[deg]

altitude
Liftoff phase altitudebyte
[m]

thr
Climbing throttlebyte
[%]

launcher
Launcher parameters

acc
Launcher trigger accelerationbyte
[m/s^2]

tdelay
Launcher throttle delayreal
[s]

cdelay
Launcher controls delayreal
[s]

Landing
Landing procedure

mode
Landing modeoption
[runway,parachute,helipad]

agl
Agl correction altitudeword
[m]

app
Approach phase parameters

Kp
Delta [m] to speed [m/s] gainreal
0.1

thr
Approach throttlebyte
[%]
5

cap
Energy capacity factorreal

flare
Flare phase parameters

alt
Flare phase altitudebyte
[m]
20

pitch
Flare max pitch angle limitbyte
[deg]

sink
Flare sink ratereal
[m/s]
0.5

touch
Touchdown phase parameters

alt
Touchdown phase altitudebyte
[m]
3

pitch
Touchdown max pitch angle limitbyte
[deg]
6

speed
Speed to trigger run phasebyte
[m/s]

acc
Acceleration to trigger run phasebyte
[m/s^2]

brakes
Brakes slew rate limitbyte
[%/s]

thr
Throttle blockingoption
[cut,override,ignore]