Skip to content

Winch model in Matlab: examples, tests and documentation - #88

Merged
ufechner7 merged 10 commits into
mainfrom
matlab-machine
Oct 29, 2026
Merged

ufechner7 merged 10 commits into
mainfrom
matlab-machine

Conversation

@ufechner7

Copy link
Copy Markdown
Member

Summary

The winch model can now run in Matlab inside the Julia simulation, driven by SystemStateControl for the full power cycle, as planned in PlanMatlab.md.

  • examples/matlab/async_machine_step.m: the AsyncMachine of WinchModels.jl in Matlab. It updates the brake and the rate limited set speed and returns the acceleration with its analytic partial derivatives. It is called by the MatlabMachine (Add the MatlabMachine, a winch model implemented in Matlab aenarete/WinchModels.jl#32) once per time step.
  • examples/autopilot_matlab.jl, in the example menu: runs autopilot.jl with the Matlab winch for the selected project. From another environment (e.g. the menu) it starts a new Julia process in examples/matlab without system image. autopilot.jl uses WINCH_MODEL, if defined, as winch model.
  • examples/matlab/: own environment with MATLAB.jl (it cannot be installed without Matlab), plus
    • test_async_machine_step.jl: Matlab vs. Julia model, 20740 of 20740 checks passed
    • compare_full_cycle.jl: full power cycles with both winch models, for any project
    • bench_engine.jl: cost of different ways of calling Matlab from Julia
  • Docs: new page "Winch Model in Matlab"; the examples page links to it.

Results (Matlab R2021a, Linux)

project energy, Julia energy, Matlab difference
hydra10_951 654.2 Wh 654.3 Wh 0.014 %
hydra20_426 752.3 Wh 752.4 Wh 0.018 %
hydra20_600 1759.4 Wh 1760.2 Wh 0.044 %
hydra20_920 1555.1 Wh 1557.8 Wh 0.177 %

About 1.5 ms per time step (2.2 ms p99) with the Matlab winch, real-time capable up to a time-lapse factor of about 18. autopilot_matlab.jl with the 3D viewer missed the deadline in 0.14 % of the time steps.

Depends on

The Matlab examples need these versions; until they are released, develop them in examples/matlab. Nothing outside examples/matlab and autopilot_matlab.jl uses them, so the normal examples, tests and docs work with the released versions.

🤖 Generated with Claude Code

ufechner7 and others added 9 commits October 29, 2026 19:42
examples/matlab/async_machine_step.m implements the AsyncMachine of WinchModels.jl in
Matlab, used by the MatlabMachine (winch_model: "MatlabMachine"). It updates the brake
and the rate limited set speed and returns the acceleration and its partial derivatives.
test_async_machine_step.jl compares it with the Julia AsyncMachine and measures the time
per call; the folder has its own environment with MATLAB.jl.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bench_engine.jl measures the time of one call of Matlab from Julia for different ways of
calling it (step 0 of PlanMatlab.md), including the unchecked eval_string used by the
MatlabMachine.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…b winch model

compare_full_cycle.jl flies the power cycles of autopilot.jl, without viewer and
turbulence, with the AsyncMachine and with the MatlabMachine, and compares energy,
tether force, reel-out speed and time per step. The environment gets KiteControllers
(from this repository), KiteModels and Printf; the machine-specific path of WinchModels
is removed from its [sources].

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…winch model

autopilot_matlab.jl runs autopilot.jl in the environment examples/matlab, with the
MatlabMachine instead of the winch model of the selected project; from another
environment, e.g. the menu, it starts a new Julia process without system image.
autopilot.jl uses WINCH_MODEL, if defined, as winch model. The environment
examples/matlab gets the packages autopilot.jl needs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The projects are passed as arguments, or as the global PROJECTS when the script is
included; system.yaml is the default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Requirements, setup, usage, how the Matlab winch model is called, accuracy, speed, how
to write an own Matlab winch model and limitations. The examples page links to it
from a new section for autopilot_matlab.jl.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…time step

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ufechner7
ufechner7 merged commit adacc09 into main Oct 29, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant