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.0

Ki
Integral gainreal
2.5

Kd
Differential gainreal

Kff
Feed forward gainreal

Lp
Rate limitreal
[deg/s]
40.0

Li
Integral limitreal
[%]
10.0

Lo
Output limitreal
[%]
100.0

rdiff
Rate limit diffreal

ifactor
Integral large error factorreal
[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 limitreal
[deg/s]
40

diff
Setpoint limit diffreal

offset
Setpoint offsetreal
[deg]

Pitch
Pitch [deg] to Elevator [%]

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.5

Ki
Integral gainreal
3.5

Kd
Differential gainreal

Kff
Feed forward gainreal

Lp
Rate limitreal
[deg/s]
40.0

Li
Integral limitreal
[%]
25.0

Lo
Output limitreal
[%]
100.0

rdiff
Rate limit diffreal

ifactor
Integral large error factorreal
[deg/s]

trim
Regulator output trimming factors.

low
Low speed trimreal
[%]

high
High speed trimreal
[%]

flaps
Flaps trimreal
[%]

stab
Stall condition multiplierreal
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 limitreal
[deg/s]
20

diff
Setpoint limit diffreal

offset
Setpoint offsetreal
[deg]

Yaw
Yaw [deg] to Rudder [%]

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.5

Ki
Integral gainreal
3.5

Kd
Differential gainreal

Kff
Feed forward gainreal

Lp
Rate limitreal
[deg/s]
120.0

Li
Integral limitreal
[%]
10.0

Lo
Output limitreal
[%]
100.0

rdiff
Rate limit diffreal

ifactor
Integral large error factorreal
[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 limitreal
[deg/s]
80

slip
Slip error to yaw rate proportional gainreal
1.5

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

dist
L1 periodreal
[m]
20.0

damp
Damping factorreal
0.75

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 to be 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]
4
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.01
The energy rate error is multiplied by this factor to provide pitch angle.

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

weight
Speed vs altitude tecs weighting factorreal
1.0
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.0
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]
7
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.01
The energy rate error is multiplied by this factor to provide throttle.

Ki
Integrator gainreal
0.2
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]
2
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 throttlereal
[%]
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 throttlereal
[%]
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 ratereal
[%/s]
Maximum slew rate for the commanded throttle

Taxi
Taxiways navigation

Steering
Yaw [deg] to Steering [%]

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.5

Ki
Integral gainreal
0.1

Kff
Feed forward gainreal
0.5

Lp
Rate limitreal
[deg/s]
30.0

Li
Integral limitreal
[%]
10.0

gain
Steering high speed gainreal
0.1

Track
Crosstrack [m] to Yaw [deg]

dist
L1 periodreal
[m]
5.0

damp
Damping factorreal
0.5

trig
Taxiway switch radiusword
[m]
5

Brakes
Speed to Brakes [%]

Kp
Proportional gainreal

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

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 limitreal
[%/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.01

thr
Approach throttlebyte
[%]
10

cap
Energy capacity factorreal

flare
Flare phase parameters

alt
Flare phase altitudebyte
[m]
15

pitch
Flare max pitch angle limitbyte
[deg]

sink
Flare sink ratereal
[m/s]

touch
Touchdown phase parameters

alt
Touchdown phase altitudebyte
[m]
4

pitch
Touchdown max pitch angle limitbyte
[deg]
8

speed
Speed to trigger run phasebyte
[m/s]
15

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

brakes
Brakes slew rate limitbyte
[%/s]

thr
Throttle blockingoption
[cut,override,ignore]