Skip to content

Commit

Permalink
Add test_parking.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
ufechner7 committed Jul 8, 2024
1 parent d2687f1 commit 206dd4d
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions test/test_parking.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using Pkg
if ! ("KiteModels" keys(Pkg.project().dependencies))
using TestEnv; TestEnv.activate()
end

using KiteViewers, KiteModels, KitePodModels, Rotations, Timers

# change this to KPS3 or KPS4
const Model = KPS4
set_data_path()

if ! @isdefined kcu; const kcu = KCU(se()); end
if ! @isdefined kps4; const kps4 = Model(kcu); end

# the following values can be changed to match your interest
dt = 0.05
TIME = 30
TIME_LAPSE_RATIO = 1
STEPS = Int64(round(TIME/dt))
STATISTIC = false
SHOW_KITE = false
# end of user parameter section #

viewer::Viewer3D = Viewer3D(SHOW_KITE)

function update_system2(kps)
sys_state = SysState(kps)
KiteViewers.update_system(viewer, sys_state; scale = 0.08, kite_scale=3)
end

function simulate(integrator, steps)
start = integrator.p.iter
start_time_ns = time_ns()
for i in 1:steps
set_depower_steering(kps4.kcu, 0.25, 0.0)
# KitePodModels.on_timer(kcu, dt)
KiteModels.next_step!(kps4, integrator, dt=dt)
reltime = i*dt
if mod(i, TIME_LAPSE_RATIO) == 0 || i == steps
update_system2(kps4)
wait_until(start_time_ns+dt, always_sleep=true)
start_time_ns = time_ns()
end
end
(integrator.p.iter - start) / steps
end

integrator = KiteModels.init_sim!(kps4, stiffness_factor=0.5, prn=STATISTIC)

av_steps = simulate(integrator, STEPS)
nothing

0 comments on commit 206dd4d

Please sign in to comment.