Skip to content

Measure heading and course right-handed, positive to the right as seen from the ground station - #362

Draft
1-Bort-1 wants to merge 2 commits into
agent/353-move-to-kiteutils-0-14-and-document-calcfrom
agent/361-follow-kiteutils-right-handed-heading-an
Draft

1-Bort-1 wants to merge 2 commits into
agent/353-move-to-kiteutils-0-14-and-document-calcfrom
agent/361-follow-kiteutils-right-handed-heading-an

Conversation

@1-Bort-1

@1-Bort-1 1-Bort-1 commented Nov 14, 2026 •

Copy link
Copy Markdown
Member

Depends-On: OpenSourceAWE/KiteUtils.jl release after v0.14.2

KiteUtils' next release changes the heading and course convention (OpenSourceAWE/KiteUtils.jl#194). Both angles become zero with the nose, or the velocity, pointing to zenith and positive to the right as seen from the ground station. They also no longer depend on the wind direction. Today they are positive to the left. This branch moves KiteModels to that convention everywhere it produces or reads a heading, while the kite models fly exactly as before.

A user sees the sign of every heading, course and heading rate flip: the getters, the system state, and every log written from now on. The initial headings and heading_rates in settings.yaml are read in the new convention. A file written for the old one turns the kite the other way until the sign is flipped. Positive steering still turns the kite the same way, to the left as seen from the ground station, which is now a negative heading rate. The changelog says this under BREAKING.

calc_heading(kps4; upwind_dir_=upwind_dir(kps4), neg_azimuth=false)   # before
calc_heading(kps4)                                                     # after: no wind direction
calc_course(kps4, false)   →   calc_course(kps4)

Decisions I made:

  • The heading's wind-direction keyword and the "negate the azimuth" option are removed from the heading and course getters, not kept as no-ops. With no wind direction in the angle they mean nothing, and nothing in this repository passes them.
  • The steering keeps its physical direction, so positive steering now gives a negative heading rate. Flipping the steering instead would change how every existing controller and recorded flight steers the kite. The issue asked for the models to fly as before.
  • The one-point model's gravity correction of the turn rate keeps the published equation (Fechner et al. 2015, Eq. 30). The minus sign sits where the paper's heading has the opposite sign, and the model's stored heading is now the new one.
  • The parking controller in the 3D examples is rewritten in the new convention (navigation set point and steering inversion), not fed negated angles. KiteControllers carries its own copy and has its own task (Follow KiteUtils' right-handed heading and course in the controllers:... KiteControllers.jl#89).

Fixed along the way:

  • That controller's steering self-test had been failing since Calc heading_rate and body_rate #281. The controller then started taking the measured heading rate, but the test kept passing zero while expecting the rate of its 1° heading step. It now passes that rate.
  • The orientation tests' short helper passed the wind direction as the wind speed. It now uses the full helper with wind from the west.
  • The four-point model had an unused "azimuth" field named psi, which is now deleted.
  • The heading example had a duplicated test case and an unused helper, both deleted. Its pitched case, which had been marked broken against a guessed value, now asserts the 40.89° the orientation test computes for the same kite.
  • The parking example's steering gain is now negative in its logs and plots, which the changelog says.

Before writing anything new I searched the repository and KiteUtils for an existing heading wrap, the convention's getters and every caller of the heading keywords; the zero-heading checks reuse KiteUtils' angle wrap instead of a new helper, and nothing else needed a new function.

For the reviewer: this is stacked on #354 (move to KiteUtils 0.14), which merges first. It holds until KiteUtils releases the change in OpenSourceAWE/KiteUtils.jl#195, which is open and green. KitePodModels, WinchModels and KiteViewers also need releases that allow KiteUtils 0.14, which #354 waits on too. Left before merge: once that release is out, this branch moves the KiteUtils bound to it, re-resolves both default manifests and reruns the affected tests. The code and tests are ready for review now.

Verification

All runs used the KiteUtils #194 branch, with KitePodModels, WinchModels and KiteViewers from their branches that allow 0.14. Every other package was pinned to the tracked manifest.

  • Reproduced first: test/test-heading-steering.jl on the unchanged code gives MethodError: no method matching calc_heading(::SVector{4, Float64}, ::Float64, ::Float64; upwind_dir::Float64, respos::Bool) (51 passed, 15 errored).
  • Green after: test-orientation (88), test-heading-steering (67), test-initial-rates (43), test-kps3 (166), examples/test_heading.jl (7, none broken), test-kps4, test-update-sys-state and test-azimuth all pass. Sign-dependent reference values were mirrored from the old ones, not loosened: every orientation case reads 360° minus its old value, and a nose to zenith reads 0 at every wind direction tested.
  • Same flight, before (base of this branch on KiteUtils 0.13.3) and after, 200 steps with steering and initial headings:
    • Four-point model with steering: bit-identical.
    • One-point model: within 2.4e-10 m over the first 12 steps, then it drifts in its looping flight. The old code drifts as far from itself when its heading is nudged by 1e-11 rad (3.4e-10 m over 12 steps, 29 m over 200, against 53 m here). The heading formula changed in its last digits.
  • Closed-loop parking (four-point model, steering disturbance at 20 s, 40 s): azimuth within 0.006° and elevation within 0.0006° of before, heading mirrored. The parking controller self-test passes 7 of 7. The figure could not be attached: the upload fails with HTTP 400, tracked in 1-Bart-1/Agents#1025.
  • examples/steering_test_1p.jl: turn-rate law factor 19.2857 → 19.2855 °/m, delay 0.12 s both. steering_test_4p.jl: c1 = 0.1489 and c2 = 4.795, delay 0.26 s, before and after.
  • Docs build clean · REUSE lint clean
  • Local full suite: PASS (6 min, exit 0) on this head, with the KiteUtils Install run_julia and create_sys_image with install_examples() #195 branch installed.
  • GitHub CI: expected to fail until the KiteUtils release, because CI installs KiteUtils 0.13, whose heading has the old sign.
  • Risk: a user's settings file with a non-zero initial heading or heading rate silently starts the kite turned the other way.

Opened by 1-Bort-1, an AI agent working for @1-Bart-1.
Closes #361 · task KiteModels.jl-361
Refs OpenSourceAWE/KiteUtils.jl#194

BREAKING: the heading and the course are zero towards zenith and
positive to the right as seen from the ground station, with no wind
direction in them, as calc_heading and calc_course of KiteUtils after
v0.14.2 define them. calc_heading(s) and calc_course(s) pass
azimuth_east and drop the keywords upwind_dir_ and neg_azimuth, which
no longer mean anything.

The models fly as before: the gravity correction of the KPS3 steering
(Eq. 30 of Fechner et al. 2015) carries the sign of the paper's heading,
and the settings heading and heading_rate of KPS4 are solved against
calc_heading, so they now mean the new convention. A positive steering
input still turns the kite to the left as seen from the ground station,
which is now a negative heading rate.

Tests, the heading and steering examples and the parking controller
example are re-derived for the new sign; the parking controller's
calc_steering self-test passes the heading rate it expects again.
The unused psi field of KPS4 is removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@1-Bort-1 1-Bort-1 added the agent:running Agent task state label Nov 14, 2026
@1-Bort-1 1-Bort-1 added agent:ci Agent task state agent:review Agent task state and removed agent:running Agent task state agent:ci Agent task state labels Nov 14, 2026

@1-Bort-1 1-Bort-1 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent review (advisory)

Verdict: APPROVE WITH COMMENTS · 2 inline, 0 off the diff

Good

  • calc_heading(s) / calc_course(s) (src/KiteModels.jl:485-499) now pass calc_azimuth_east with no wind keyword, matching the KiteUtils#194 signature in the issue. upwind_dir_ and neg_azimuth are removed, not kept as no-ops, and the BREAKING changelog entry names both.
  • KPS3 gravity correction (src/KPS3.jl:341): negating c2_cor while the stored psi changes sign leaves the physics unchanged, as the issue requires. test-kps3.jl:89 flips psi to -0.2 and keeps the reference forces, which shows this.
  • Orientation reference values were mirrored to 360° minus the old values (319.1→40.9, 229.1→130.9, 234.7→125.3). Tolerances were not loosened, and the wind-rotation cases still read 0, which is the issue's "nose to zenith reads 0 at every wind direction" check.
  • The heading-steering tests give the sign a physical meaning. Heading +90° now asserts a negative azimuth: flying right as seen from the ground station is south for an anticlockwise azimuth. Steering +20% now asserts a heading below -20° with respos=false, which fits steering turning the kite the same physical way as before.
  • Parking controller navigate: sin(phi - phi_set) mirrors the bearing to right-positive. phi and phi_set stay in the same wind frame, so parking_wind_dir.jl still gets a consistent chi_set.
  • test-orientation.jl:43 delegates the 4-argument helper to the 5-argument one. This removes a duplicate and fixes the old bug where deg2rad(-90) was passed as the wind speed.
  • set_initial_heading! and heading_slope! solve against calc_heading(s), so set.heading and set.heading_rate take the new convention with no code change. The settings docstring (src/KiteModels.jl:992) states that convention.

Not good

  • examples/test_heading.jl:96 — This @test_broken was given a guessed new reference of 45°. test-orientation.jl:156 computes 40.89° for the identical orientation and position and passes, so the issue's "re-derive, not loosen" is not met here: the case stays permanently broken against a value known to be wrong instead of becoming a passing @test at 40.8933946491309.
  • test/test-orientation.jl:99 — Each zero-heading case now accepts 0 or 360, copied inline in five places (also lines 209, 244 and 256). The single heading > 359 wrap that existed before was multiplied rather than kept as one helper. §7 says the same setup repeated across tests becomes one helper.
  • isapprox(heading, 0, …) || isapprox(heading, 360, …) is repeated five times in test-orientation.jl and once in examples/test_heading.jl. One wrapped-angle helper, or respos=false in obtain_results, would state the property once, and a || inside @test hides the evaluated value when the test fails.
  • test-heading-steering.jl:41: the testset is renamed to "heading 90°" only, but line 51 also asserts the -90° mirror. The name no longer covers everything the test protects.
  • test-kps3.jl:467 still says "the heading is calculated with the new wind". The test is still valid because the KPS3 kite frame comes from the apparent wind, but in a PR that removes the wind from the heading the comment now reads as the old convention.
  • examples_3d/parking_controller.jl:188: ndi_gain is now negative (-2.08), and auto_parking_4p.jl logs and plots it as NDI_GAIN. The changelog does not mention this sign change visible in the example plots.
  • The card lists the cleanup items (deleted psi field, duplicate test case, unused helper, self-test fix) but does not say what was searched for before writing, as §2 asks.

claude, rubric CLEAN_CODE.md. A different lab from the implementer
on purpose: a reviewer sharing its blind spots would not flag its mistakes.

Comment thread examples/test_heading.jl Resolved
Comment thread test/test-orientation.jl Resolved
@1-Bort-1 1-Bort-1 added agent:queued Agent task state agent:running Agent task state and removed agent:review Agent task state agent:queued Agent task state labels Nov 14, 2026
The pitch-and-azimuth case of the heading example now asserts the
40.89° that the orientation test computes for the same kite, instead of
a broken guess. Zero headings are compared with wrap2pi rather than an
inline 0-or-360 check. Test name and comment follow the new convention;
the changelog says the parking example's NDI gain is now negative.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@1-Bort-1 1-Bort-1 added agent:ci Agent task state and removed agent:running Agent task state labels Nov 14, 2026
@1-Bort-1

Copy link
Copy Markdown
Member Author

Local full suite: PASS (6 min, Julia 1.13.3, one cell of the matrix)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent:review Agent task state blocking Open work waits on this

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant