Repository navigation
Build a KiteGeometry SystemDefinition from KPS3 and KPS4 and carry it in the log #327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
1-Bort-1
wants to merge
6
commits into
frame-unification
Choose a base branch
from
agent/322-one-kite-system-definition-across-the-ki
base: frame-unification
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
db9afa5
Build a KiteGeometry SystemDefinition from KPS3 and KPS4
1-Bort-1 a7a87e6
Carry the system definition in the torque-control reel-out log
1-Bort-1 39a72c0
Document system_definition and topology_metadata
1-Bort-1 f100446
Address review: massless bridle segments, internal assembly helper, u…
1-Bort-1 afc7d10
merge: latest frame-unification
1-Bort-1 688934c
merge: latest frame-unification
1-Bort-1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| <!-- | ||
| SPDX-FileCopyrightText: 2026 Bart van de Lint | ||
| SPDX-License-Identifier: MIT | ||
| --> | ||
| ### Added | ||
| - `system_definition(s)` builds a KiteGeometry `SystemDefinition` of a KPS3 or KPS4 model: its points, the springs it integrates as segments, the tether and the winch. | ||
| - `topology_metadata(s)` carries that definition in a log: `save_log(logger, name; metadata)` writes it under the key `topology`. | ||
| - KiteGeometry is re-exported. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| # SPDX-FileCopyrightText: 2026 Bart van de Lint | ||
| # SPDX-License-Identifier: MIT | ||
|
|
||
| """ | ||
| system_definition(s::KPS4) | ||
|
|
||
| The `SystemDefinition` of the four-point model: its points where they are now, and as | ||
| segments the tether and bridle springs it integrates, at full stiffness. The bridle | ||
| segments are massless. Call it after `init!` for the initial pose. | ||
| """ | ||
| function system_definition(s::KPS4) | ||
| tether_segments = s.set.segments | ||
| extra_masses = zeros(length(s.pos)) | ||
| extra_masses[tether_segments + 1] = s.set.kcu_mass | ||
| extra_masses[(tether_segments + 2):end] .= s.masses[(tether_segments + 2):end] | ||
| bridle_segments = length(s.springs) - tether_segments | ||
| diameters = [fill(s.set.d_tether, tether_segments); fill(s.set.d_line, bridle_segments)] | ||
| densities = [fill(s.set.rho_tether, tether_segments); zeros(bridle_segments)] | ||
| segments = [Segment(; name=string(i), points=(Int(spring.p1), Int(spring.p2)), | ||
| l0=spring.length, diameter=diameters[i] / 1000, | ||
| density=densities[i], | ||
| unit_stiffness=spring.axial_stiffness * spring.length) | ||
| for (i, spring) in enumerate(s.springs)] | ||
| return assemble_system_definition(s, segments, extra_masses) | ||
| end | ||
|
|
||
| """ | ||
| system_definition(s::KPS3) | ||
|
|
||
| The `SystemDefinition` of the one-point model: its points where they are now, the tether | ||
| segments between them at full stiffness, and the kite and KCU mass on the last point. Call | ||
| it after `init!` for the initial pose. | ||
| """ | ||
| function system_definition(s::KPS3) | ||
| extra_masses = zeros(length(s.pos)) | ||
| extra_masses[end] = s.set.mass + s.set.kcu_mass | ||
| segments = [Segment(; name=string(i), points=(i, i + 1), l0=s.segment_length, | ||
| diameter=s.set.d_tether / 1000, density=s.set.rho_tether, | ||
| unit_stiffness=s.axial_stiffness * s.segment_length) | ||
| for i in 1:s.set.segments] | ||
| return assemble_system_definition(s, segments, extra_masses) | ||
| end | ||
|
|
||
| """ | ||
| assemble_system_definition(s::AbstractKiteModel, segments, extra_masses) | ||
|
|
||
| The `SystemDefinition` of `s` with its `segments`, the first `s.set.segments` of which are | ||
| the tether from the winch at point 1 to point `s.set.segments + 1`. | ||
| """ | ||
| function assemble_system_definition(s::AbstractKiteModel, segments, extra_masses) | ||
| n_points = length(s.pos) | ||
| tether_segments = s.set.segments | ||
| metadata = Metadata(string(nameof(typeof(s))), "", "", "1.0.0", "structure_schema.yml", | ||
|
1-Bort-1 marked this conversation as resolved.
|
||
| n_points, "") | ||
| points = [Point(; name=string(i), type=i == 1 ? STATIC : DYNAMIC, pos_ENU=s.pos[i], | ||
| extra_mass=extra_masses[i]) | ||
| for i in 1:n_points] | ||
| tether = Tether(; name="tether", start_point=1, end_point=tether_segments + 1, | ||
| segments=collect(1:tether_segments)) | ||
| winch = Winch(; name="winch", tethers=[1], winch_point=1, gear_ratio=s.set.gear_ratio, | ||
| drum_radius=s.set.drum_radius) | ||
| return SystemDefinition(; metadata, points, segments, tethers=[tether], winches=[winch]) | ||
| end | ||
|
|
||
| """ | ||
| topology_metadata(s::AbstractKiteModel) | ||
|
|
||
| The table metadata that carries the structure document of `system_definition(s)` in a | ||
| log, under the key `topology`: pass it as `save_log(logger, name; metadata)`. | ||
| """ | ||
| function topology_metadata(s::AbstractKiteModel) | ||
| return Dict("topology" => YAML.write(structure_document(system_definition(s)))) | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| # SPDX-FileCopyrightText: 2026 Bart van de Lint | ||
| # SPDX-License-Identifier: MIT | ||
|
|
||
| using Pkg | ||
| if dirname(Pkg.project().path) != @__DIR__ | ||
| Pkg.activate(@__DIR__) | ||
| end | ||
| using KiteModels, KiteUtils, Test, YAML | ||
| using KiteModels: init! | ||
|
|
||
| set_data_path(joinpath(dirname(dirname(pathof(KiteModels)::String)), "data")) | ||
|
|
||
| "The pair of point indices each segment of `definition` joins." | ||
| segment_points(definition) = [segment.points for segment in definition.segments] | ||
|
|
||
| @testset "KPS4 definition holds the points and springs the model integrates" begin | ||
| kps4 = KPS4(load_settings("system.yaml")) | ||
| init!(kps4; delta=0.001, prn=false) | ||
| definition = system_definition(kps4) | ||
| segments = kps4.set.segments | ||
| @test definition.metadata.n_points == length(kps4.pos) == segments + 5 | ||
| @test segment_points(definition) == [(spring.p1, spring.p2) for spring in kps4.springs] | ||
| @test [point.pos_ENU for point in definition.points] == kps4.pos | ||
| @test [segment.l0 for segment in definition.segments] == | ||
| [spring.length for spring in kps4.springs] | ||
| @test only(definition.tethers).segments == 1:segments | ||
| @test only(definition.tethers).end_point == segments + 1 | ||
| @test only(definition.winches).winch_point == 1 | ||
| @test [segment.unit_stiffness for segment in definition.segments] ≈ | ||
| [spring.axial_stiffness * spring.length for spring in kps4.springs] | ||
| @test sum(point.extra_mass for point in definition.points) ≈ | ||
| kps4.set.mass + kps4.set.kcu_mass | ||
| @test all(segment.density == 0 for segment in definition.segments[(segments + 1):end]) | ||
| end | ||
|
|
||
| @testset "KPS3 definition is one tether from the winch to the kite" begin | ||
| kps3 = KPS3(load_settings("system.yaml")) | ||
| init!(kps3; delta=0.001) | ||
| definition = system_definition(kps3) | ||
| segments = kps3.set.segments | ||
| @test definition.metadata.n_points == length(kps3.pos) == segments + 1 | ||
| @test segment_points(definition) == [(i, i + 1) for i in 1:segments] | ||
| @test only(definition.tethers).segments == 1:segments | ||
| @test definition.points[end].extra_mass ≈ kps3.set.mass + kps3.set.kcu_mass | ||
| end | ||
|
|
||
| @testset "a saved log carries the KPS4 definition under topology" begin | ||
| kps4 = KPS4(load_settings("system.yaml")) | ||
| init!(kps4; delta=0.001, prn=false) | ||
| logger = Logger(length(kps4.pos), 1) | ||
| log!(logger, SysState(kps4)) | ||
| path = mktempdir() | ||
| save_log(logger, "topology"; path, metadata=topology_metadata(kps4)) | ||
| document = YAML.load(load_log("topology"; path).metadata["topology"]) | ||
| @test structure_document(SystemDefinition(document)) == | ||
| structure_document(system_definition(kps4)) | ||
| end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.