# =============================================================================
# Default PID tuning — 30 m planing motor yacht
# =============================================================================
#
# WARNING — Conservative bench/start values only.
# These gains come from classical marine control literature (Fossen 2011,
# Perez 2005) scaled to a 30 m planing motor yacht class. They are intended
# only for bench testing and the very first sea trial — they MUST be replaced
# with the integrator's affinated values during commissioning.
#
# The "real" tuning libraries are integrator IP and are NOT shipped here.
#
# Units:
#   - kp/ki/kd: dimensionless (controller internal units)
#   - frequencies: Hz
#   - rate / deadband: degrees, degrees/second
#
# Cascaded loops (brief section 6):
#   - inner: rudder-position controller, 50 Hz
#   - outer: heading controller, 10 Hz
#
# Gain scheduling: outer-loop gains interpolated over SOG (knots).
# Outside the scheduled range the closest endpoint is held.
# =============================================================================

schema_version: "0.1.0"

inner_loop_base:
  kp: 2.5
  ki: 0.15
  kd: 0.30
inner_loop_freq_hz: 50.0

outer_loop_base:
  kp: 0.90
  ki: 0.02
  kd: 1.20
outer_loop_freq_hz: 10.0

# Three-point schedule covering manoeuvring (5 kn), cruise (15 kn), top (28 kn).
# At low speed: more kp, less kd (rudder bites more, less inertia anticipation).
# At high speed: less kp, more kd (gentler corrections, anticipate overshoot).
gain_schedule:
  - speed_knots: 5.0
    gains: { kp: 1.20, ki: 0.03, kd: 0.80 }
  - speed_knots: 15.0
    gains: { kp: 0.90, ki: 0.02, kd: 1.20 }
  - speed_knots: 28.0
    gains: { kp: 0.55, ki: 0.01, kd: 1.80 }

rot_feedforward_gain: 1.50

setpoint_deadband_deg: 0.5
setpoint_rate_limit_dps: 4.0
anti_windup_limit: 8.0

adaptive_enabled: false
adaptive_max_deviation_pct: 50.0
