From 1a5c459060def252cbfc6b72e8e7f135768ae647 Mon Sep 17 00:00:00 2001 From: Uwe Fechner Date: Sat, 23 Mar 2024 15:27:12 +0100 Subject: [PATCH] fix play() function --- examples/autopilot.jl | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/examples/autopilot.jl b/examples/autopilot.jl index d1c20b32..a76bc3f2 100644 --- a/examples/autopilot.jl +++ b/examples/autopilot.jl @@ -16,6 +16,16 @@ fpps::FPPSettings = FPPSettings() ssc::SystemStateControl = SystemStateControl(wcs, fcs, fpps) dt::Float64 = wcs.dt +function init_globals() + global kcu, kps4, wcs, fcs, fpps, ssc + kcu = KCU(se()) + kps4 = KPS4(kcu) + wcs = WCSettings(); update(wcs); wcs.dt = 1/se().sample_freq + fcs = FPCSettings(); fcs.dt = wcs.dt + fpps = FPPSettings() + ssc = SystemStateControl(wcs, fcs, fpps) +end + # the following values can be changed to match your interest MAX_TIME::Float64 = 460 TIME_LAPSE_RATIO = 4 @@ -115,12 +125,10 @@ function simulate(integrator, stopped=true) end function play(stopped=false) - global steps, kcu, ssc, kps4, wcs + global steps, kcu, kps4, wcs, fcs, fpps, ssc while isopen(viewer.fig.scene) - kcu = KCU(se()) - wcs = WCSettings(); update(wcs); wcs.dt = 1/se().sample_freq - ssc = SystemStateControl(wcs, fcs, fpps) - kps4 = KPS4(kcu) + init_globals() + on_parking(ssc) integrator = KiteModels.init_sim!(kps4, stiffness_factor=0.04) toc() steps = simulate(integrator, stopped)