Skip to content

Commit

Permalink
plot_timing working
Browse files Browse the repository at this point in the history
  • Loading branch information
Uwe Fechner committed Mar 26, 2024
1 parent 2c1be72 commit 46051b8
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 23 deletions.
12 changes: 9 additions & 3 deletions Manifest-1.10.toml.default
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

julia_version = "1.10.2"
manifest_format = "2.0"
project_hash = "ce061d05be54a6c4dcdb40f6e3c2375618cb215c"
project_hash = "ae980e6d5022026c2642b2bd9f31715e245db809"

[[deps.ADTypes]]
git-tree-sha1 = "016833eb52ba2d6bea9fcb50ca295980e728ee24"
Expand Down Expand Up @@ -951,6 +951,12 @@ git-tree-sha1 = "fee018a29b60733876eb557804b5b109dd3dd8a7"
uuid = "5ab0869b-81aa-558d-bb23-cbf5423bbe9b"
version = "0.6.8"

[[deps.KiteControllers]]
deps = ["ControlPlots", "KiteUtils", "NLsolve", "Observables", "Parameters", "Printf", "StaticArrayInterface", "StaticArrays", "StructTypes", "Timers", "WinchModels", "YAML"]
path = "/home/ufechner/repos/KiteControllers.jl"
uuid = "b19fd437-5b3a-4cca-b199-c3ded0f20ded"
version = "0.2.0"

[[deps.KiteModels]]
deps = ["AtmosphericModels", "Dierckx", "DiffEqBase", "DocStringExtensions", "KitePodModels", "KiteUtils", "LinearAlgebra", "NLsolve", "Parameters", "PrecompileTools", "Reexport", "Rotations", "StaticArrays", "Sundials", "WinchModels"]
git-tree-sha1 = "600932d54f038b7e86d3f456c8b43805d927cdf9"
Expand All @@ -965,9 +971,9 @@ version = "0.3.1"

[[deps.KiteUtils]]
deps = ["Arrow", "CSV", "DocStringExtensions", "LinearAlgebra", "Parameters", "PrecompileTools", "RecursiveArrayTools", "Rotations", "StaticArrays", "StructArrays", "StructTypes", "YAML"]
git-tree-sha1 = "ebd24ee12ce31339d27b2a58fedafbb45d6a8e6d"
git-tree-sha1 = "97d43dfe9dda3f705efd81f6fce3314903678b78"
uuid = "90980105-b163-44e5-ba9f-8b1c83bb0533"
version = "0.6.0"
version = "0.6.2"

[[deps.KiteViewers]]
deps = ["FileIO", "GLMakie", "GeometryBasics", "Joysticks", "KiteUtils", "LinearAlgebra", "Parameters", "Pkg", "PrecompileTools", "Printf", "Reexport", "Rotations", "StaticArrays", "Timers"]
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ YAML = "ddb6d928-2868-570f-bddf-ab3f9cf99eb6"

[compat]
KiteModels = "0.5.4"
KiteUtils = "0.6"
KiteUtils = "0.6.2"
NLsolve = "4.5"
Observables = "0.3, 0.4, 0.5"
Parameters = "0.12"
Expand Down
43 changes: 24 additions & 19 deletions examples/autopilot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function simulate(integrator, stopped=true)
if i <= length(T)
T[i] = dt * i
if i > 10/dt
DELTA_T[i] = t_sim * 1000
sys_state.t_sim = t_sim * 1000
STEERING[i] = sys_state.steering
DEPOWER_[i] = sys_state.depower
LAST_I=i
Expand Down Expand Up @@ -220,31 +220,34 @@ function save_log_()
KiteViewers.set_status(viewer, "Saved log as:")
KiteViewers.plot_file[] = replace(filename, homedir() => "~")
end
end
end# println("Mean time per timestep: $(mean(sl.t_sim)) ms")
# println("Maximum time per timestep: $(maximum(sl.t_sim)) ms")
# index = Int64(round(12/dt))
# println("Maximum for t>12s : $(maximum(sl.t_sim[index:end])) ms")

end

include("logging.jl")

# function plot_timing()
# if maximum(DELTA_T) > 0
# res=plotx(T[1:LAST_I], DELTA_T[1:LAST_I], 100*STEERING[1:LAST_I], 100*DEPOWER_[1:LAST_I],
# ylabels=["t_sim [ms]", "steering [%]", "depower [%]"],
# fig="simulation_timing")
# println("Mean time per timestep: $(mean(DELTA_T)) ms")
# println("Maximum time per timestep: $(maximum(DELTA_T)) ms")
# index = Int64(round(12/dt))
# println("Maximum for t>12s : $(maximum(DELTA_T[index:end])) ms")
# KiteViewers.plot_file[]="data/last_plot.jld2"
# save(KiteViewers.plot_file[], res)
# end
# nothing
# end
function plot_timing()
log=load_log(PARTICLES, KiteViewers.plot_file[])
sl = log.syslog
display(ControlPlots.plotx(sl.time, sl.t_sim, 100*sl.steering, 100*sl.depower;
ylabels=["t_sim [ms]", "steering [%]","depower [%]"]))
println("Mean time per timestep: $(mean(sl.t_sim)) ms")
println("Maximum time per timestep: $(maximum(sl.t_sim)) ms")
index = Int64(round(12/dt))
println("Maximum for t>12s : $(maximum(sl.t_sim[index:end])) ms")
plt.pause(0.01)
plt.show(block=false)
nothing
end

function plot_main()
log=load_log(PARTICLES, KiteViewers.plot_file[])
sl = log.syslog
println(length(log.syslog.time))
display(ControlPlots.plotx(log.syslog.time, log.z, rad2deg.(sl.elevation), sl.azimuth, sl.l_tether, sl.force, sl.v_reelout;
display(plotx(log.syslog.time, log.z, rad2deg.(sl.elevation), sl.azimuth, sl.l_tether, sl.force, sl.v_reelout;
ylabels=["height [m]", "elevation [°]", "azimuth [°]", "length [m]", "force [N]", "v_ro [m/s]"]))
plt.pause(0.01)
plt.show(block=false)
Expand All @@ -257,7 +260,7 @@ on(viewer.btn_OK.clicks) do c
if viewer.menu.i_selected[] == 1
plot_main()
elseif viewer.menu.i_selected[] == 2
show_plot()
plot_timing()
elseif viewer.menu.i_selected[] == 3
load_log_()
elseif viewer.menu.i_selected[] == 4
Expand All @@ -271,7 +274,9 @@ on(viewer.menu.i_selected) do c
elseif c ==3
load_log_()
elseif c == 2
show_plot()
plot_timing()
elseif c == 1
plot_main()
end
end

Expand Down

0 comments on commit 46051b8

Please sign in to comment.