Skip to content

Commit

Permalink
Merge pull request #32 from aenarete/controlplots
Browse files Browse the repository at this point in the history
use Controlplots instead of Plots
  • Loading branch information
ufechner7 authored Aug 3, 2024
2 parents 9c2f1d5 + ade9b39 commit 354a328
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 108 deletions.
5 changes: 2 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,14 @@ Timers = "0.1.5"
julia = "1.10"

[extras]
ControlPlots = "23c2ee80-7a9e-4350-b264-8e670f12517c"
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
KiteModels = "b94af626-7959-4878-9336-2adc27959007"
KitePodModels = "9de5dc81-f971-414a-927b-652b2f41c539"
PackageCompiler = "9b87118b-4619-50d2-8e1e-99f35a4d4d9d"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
PyPlot = "d330b81b-6aea-500a-939a-2ce795aea3ee"
StructTypes = "856f2bd8-1eba-4b0a-8007-ebc267875bd4"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test", "KiteModels", "PyPlot", "KitePodModels", "PackageCompiler", "Plots"]
test = ["Test", "KiteModels", "KitePodModels", "PackageCompiler", "ControlPlots"]
7 changes: 4 additions & 3 deletions examples/depower.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@ integrator = KiteModels.init_sim!(kps4, stiffness_factor=0.5, prn=STATISTIC)

av_steps = simulate(integrator, STEPS, log=SAVE_PNG)
if PLOT_PERFORMANCE
using Plots
plot(range(0.5,TIME,step=0.5), time_vec, ylabel="CPU time [%]", xlabel="Simulation time [s]", legend=false)
savefig("performance.png")
using ControlPlots
p = plot(range(0.25,TIME,step=0.25), time_vec; ylabel="CPU time [%]", xlabel="Simulation time [s]")
display(p)
plt.savefig("performance.png")
end
# mean with :Dense integrator: 6.66% CPU time, 15 times realtime
# mean with :GMRES integrator: 1.96% CPU time, 51 times realtime
5 changes: 2 additions & 3 deletions examples/depower_bench_video.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,8 @@ integrator = KiteModels.init_sim!(kps4, stiffness_factor=0.5, prn=STATISTIC)

av_steps = simulate(integrator, STEPS, log=SAVE_PNG)
if PLOT_PERFORMANCE
using Plots
plot(range(0.5,TIME,step=0.5), time_vec, ylabel="CPU time [%]", xlabel="Simulation time [s]", legend=false)
savefig("performance.png")
using ControlPlots
plot(range(0.5,TIME,step=0.5), time_vec; ylabel="CPU time [%]", xlabel="Simulation time [s]")
end
# mean with :Dense integrator: 6.66% CPU time, 15 times realtime
# mean with :GMRES integrator: 1.96% CPU time, 51 times realtime
15 changes: 9 additions & 6 deletions examples/depower_simple.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,13 @@ function simulate(integrator, steps)
set_depower_steering(kps4.kcu, 0.35, 0.0)
end
t_sim = @elapsed KiteModels.next_step!(kps4, integrator; set_speed=0, dt=dt)
if i==1
t_sim = 0
end
t_gc = 0.0
# if t_sim < 0.08*dt
# t_gc = @elapsed GC.gc(false)
# end
if t_sim < 0.08*dt
t_gc = @elapsed GC.gc(false)
end
t_show = 0.0
if mod(i, TIME_LAPSE_RATIO) == 0 || i == steps
t_show = @elapsed update_system(viewer, SysState(kps4); scale = 0.08, kite_scale=3.0)
Expand Down Expand Up @@ -101,13 +104,13 @@ toc()
play()
stop(viewer)
if PLOT_PERFORMANCE
include("plot.jl")
using ControlPlots
if false
plotx(range(dt,TIME,step=dt), time_vec_gc, time_vec_sim, time_vec_sim.+time_vec_gc;
labels=["GC time","sim_time","total_time"],
ylabels=["GC time","sim_time","total_time"],
fig="depower_simple_timing")
else
plot1(range(3*TIME_LAPSE_RATIO*dt,TIME,step=dt*TIME_LAPSE_RATIO), time_vec_tot[3:end],
plot(range(3*TIME_LAPSE_RATIO*dt,TIME,step=dt*TIME_LAPSE_RATIO), time_vec_tot[3:end];
ylabel="time per frame [ms]")
end
end
7 changes: 4 additions & 3 deletions examples/joystick.jl
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ on(jsbuttons.btn2) do val; if val stop(viewer) end; end

play()
stop(viewer)
using Plots
plot(range(5*TIME_LAPSE_RATIO*dt,steps*dt,step=dt*TIME_LAPSE_RATIO), time_vec_tot[5:steps], xlabel="Simulation time [s]", ylabel="time per frame [ms]", label="time_tot")
plot!(range(5*TIME_LAPSE_RATIO*dt,steps*dt,step=dt*TIME_LAPSE_RATIO), time_vec_gc[5:steps], label="time_gc")
using ControlPlots
plot(range(5*TIME_LAPSE_RATIO*dt,steps*dt,step=dt*TIME_LAPSE_RATIO), [time_vec_tot[5:steps], time_vec_gc[5:steps]];
xlabel="Simulation time [s]", ylabel="time per frame [ms]", labels=["time total", "time_gc"])

62 changes: 0 additions & 62 deletions examples/plot.jl

This file was deleted.

8 changes: 4 additions & 4 deletions examples/reelout.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ integrator = KiteModels.init_sim!(kps4, stiffness_factor=0.5, prn=STATISTIC)

av_steps = simulate(integrator, STEPS, log=SAVE_PNG)
if PLOT_PERFORMANCE
using Plots
plt=plot(range(0.25,TIME,step=0.25), time_vec, ylabel="CPU time [%]", xlabel="Simulation time [s]", legend=false)
savefig("performance.png")
display(plt)
using ControlPlots
p = plot(range(0.25,TIME,step=0.25), time_vec; ylabel="CPU time [%]", xlabel="Simulation time [s]")
plt.savefig("performance.png")
display(p)
end
# mean with :Dense integrator: 6.66% CPU time, 15 times realtime
# mean with :GMRES integrator: 1.96% CPU time, 51 times realtime
Expand Down
4 changes: 2 additions & 2 deletions examples/steering_bench_video.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,6 @@ integrator = KiteModels.init_sim!(kps4, stiffness_factor=0.5, prn=STATISTIC)

av_steps = simulate(integrator, STEPS, log=SAVE_PNG)
if PLOT_PERFORMANCE
using Plots
plot(range(0.5,45,step=0.5), time_vec, ylabel="CPU time [%]", xlabel="Simulation time [s]", legend=false)
using ControlPlots
plot(range(0.1,TIME,step=0.1), time_vec; ylabel="CPU time [%]", xlabel="Simulation time [s]")
end
Binary file modified performance.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 0 additions & 17 deletions test/create_sys_image.jl

This file was deleted.

5 changes: 0 additions & 5 deletions test/update_packages.jl

This file was deleted.

0 comments on commit 354a328

Please sign in to comment.