Skip to content

Rudder angle indicator is mirrored: default invertRudder: true plus a hardcoded second negation invert a spec-compliant steering.rudderAngle #1147

Description

@fakehec

Summary

The autopilot widget's rudder angle indicator is displayed on the wrong side for a Signal K–compliant steering.rudderAngle source: rudder-to-starboard shows as port and vice-versa. Control is unaffected — the +1/+10 buttons move the physical rudder to the correct side. This is purely the indicator.

Tested on KIP 4.8.5, with a Raymarine rudder reference feeding steering.rudderAngle over PGN 127245 → n2k-signalk.

Signal K convention

Per the spec, steering.rudderAngle is "Current rudder angle, +ve is rudder to Starboard" (radians). So a positive value must render on the starboard side.

Root cause: two sign inversions in series

The value is negated twice on the way to the SVG:

  1. Widget optionwidget-autopilot.component.ts:771:

    this.rudder.set(this.runtime.options()?.autopilot?.invertRudder ? -newValue.data.value : newValue.data.value);

    and the shipped default is invertRudder: true (widget-autopilot.component.ts:272).

  2. SVG componentsvg-autopilot.component.ts:149 negates again:

    this.updateRudderAngle(-rudderAngle);

updateRudderAngle() then maps angle > 0 → port bar, angle ≤ 0 → starboard bar (svg-autopilot.component.ts:219-276).

Tracing a starboard rudder (SK +):

invertRudder after widget (:771) after SVG negation (:149) bar filled result
true (default) + port ❌ mirrored
false + starboard ✅ correct

So the SVG's hardcoded -rudderAngle already provides the one inversion the bar mapping needs; the invertRudder option then adds a second, and because its default is true, a spec-compliant rudder renders mirrored out of the box. The option's "off" state (false) is the one that's actually correct.

Impact

Any install whose steering.rudderAngle follows the SK sign convention shows the rudder indicator reversed until the user finds and toggles "Invert Rudder Angle Indicator" in the widget options. (Toggling it does fix it — that's the workaround.)

Suggested fix

Two options, in increasing tidiness:

  1. Minimal: change the default to invertRudder: false (widget-autopilot.component.ts:272) so a spec-compliant source is correct out of the box; the option still lets anyone with a reversed sender flip it.
  2. Cleaner: drop the hardcoded negation at svg-autopilot.component.ts:149 (pass rudderAngle through) and swap the bar mapping so angle > 0 → starboard, ≤ 0 → port. Then invertRudder becomes a single, pure user override, default false, with the spec as the baseline — one inversion point instead of two.

Trade-off worth calling out: either change flips the indicator for existing users who currently sit on the default true and have (unknowingly) come to rely on it, so it may deserve a release note. Happy to open a PR for whichever direction you prefer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions