Skip to content

Commit

Permalink
Generated Images and updated some slides.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lorenzo Paiola committed Nov 3, 2024
1 parent 896adaa commit 093dc47
Show file tree
Hide file tree
Showing 9 changed files with 6,198 additions and 76 deletions.
Binary file added report_slides/typst/images/MSD.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1,490 changes: 1,490 additions & 0 deletions report_slides/typst/images/basket_100iters_0.2dT.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1,522 changes: 1,522 additions & 0 deletions report_slides/typst/images/basket_100iters_0.5dT.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1,493 changes: 1,493 additions & 0 deletions report_slides/typst/images/basket_8iters_0.2dT.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1,519 changes: 1,519 additions & 0 deletions report_slides/typst/images/basket_8iters_0.5dT.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
57 changes: 57 additions & 0 deletions report_slides/typst/images/freethrow_wind.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified report_slides/typst/main.pdf
Binary file not shown.
51 changes: 43 additions & 8 deletions report_slides/typst/main.typ
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
box-task-title: none
)

#show figure.caption: set text(size: 15pt)
#show figure.caption: set text(size: 14pt)

#slide[
= Overview
Expand All @@ -33,7 +33,7 @@
]

#slide[
= What is Iterative Learning Control ?
= Iterative Learning Control in a nutshell

Iterative Learning Control @bristowSurveyIterativeLearning2006 (ILC) generally concerns the control of a repeated task. It does so by:

Expand All @@ -58,12 +58,6 @@

]

#slide[
= Contributions of the paper
- Treatment of the case in which *\#inputs<\#outputs*
-
]

#slide[
== System Set up
#task[
Expand Down Expand Up @@ -100,8 +94,19 @@
= Simulations
#side-by-side()[
== Carts

#image("images/MSD.png")

Mass-spring-damper system actuated just on the last cart

][
== Basketball in the wind

#side-by-side()[
#image("images/freethrow_wind.svg")
][
Basket hoops in
]
]

]
Expand Down Expand Up @@ -136,6 +141,36 @@
]
]

#slide()[
=== Basketball - *$d tilde(T) = 0.2s$*
#side-by-side()[
#figure(
image("images/basket_8iters_0.2dT.svg", fit: "contain"),
caption: "8 Iterations",
)
][
#figure(
image("images/basket_100iters_0.2dT.svg", fit: "contain"),
caption: "100 Iterations",
)
]
]

#slide()[
=== Basketball - *$d tilde(T)$* = 0.5s
#side-by-side()[
#figure(
image("images/basket_8iters_0.5dT.svg", fit: "contain"),
caption: "8 Iterations",
)
][
#figure(
image("images/basket_100iters_0.5dT.svg", fit: "contain"),
caption: "100 Iterations",
)
]
]


#slide[
#set text(size: 0.7em)
Expand Down
142 changes: 74 additions & 68 deletions scripts/basketball.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ for i in 1:Niter
# Set up and solve ODE
p = (A, B, C, αrray[:, :, i], T, dT, utotconstr, dist)
prob = ODEProblem(LinearDynamicsDisturbed!, u0, tspan, p)
sol = solve(prob, ROCK2(), abstol=1e-9)
sol = solve(prob, ROCK2(), abstol=1e-9)
# Heun, ROCK2, Ralston all work-> if you put a standard solver like Tsit5 it gives incorrect results. I think this is due to the stiffness of the input and the adaptive timestep of some solvers miss the step function.
solarray[i] = sol

# Extract and store results
Expand All @@ -54,7 +55,7 @@ for i in 1:Niter
# Update α for next iteration
if i < Niter
yⁱ[:, :, i] = xⁱ[:, :, i]
αrray[:, :, i+1] = αrray[:, :, i] + reshape(L * (ywant[:] - yⁱ[:, :, i][:]), No, o)
αrray[:, :, i+1] = αrray[:, :, i] + reshape(L * (ywant[:] - yⁱ[:, :, i][:]), No, o)
end
end

Expand All @@ -66,72 +67,77 @@ v_vals = [solarray[end](t)[N+1:2N] for t in t_vals] # Velocity data
u_vals = hcat([utotconstr(A, B, C, αrray[:, :, end], t, T,dT) for t in t_vals]...)

# Creating the figure
f = Figure(resolution=(1200, 1000))

plotcolors = ColorSchemes.matter

# 1. Position plot
ax1 = Axis(f[1, 1],
title="Positions",
xlabel="Time",
ylabel=L"q_{i}",
ylabelrotation=0, # Rotates y-label 90 degrees
ylabelsize=18,
xticks=t_vals[1]:0.5:t_vals[end]
)
for i in 1:N
lines!(ax1, t_vals, getindex.(x_vals, i), label=L"q_{%$i}") # Positions
scatter!(ax1, T, ywant[i, :], color=:black, marker=:x, markersize=8, label=L"$\overline{y}$") # Desired positions
end
axislegend(ax1, unique=true, orientation=:horizontal, position = :lt)

# 2. Velocity plot
ax2 = Axis(f[2, 1],
title="Velocities",
xlabel="Time",
ylabel=L"\dot{q}_{i}",
ylabelrotation=0, # Rotates y-label 90 degrees
ylabelsize=18,
xticks=t_vals[1]:0.5:t_vals[end]
)
for i in 1:N
lines!(ax2, t_vals, getindex.(v_vals, i), label=L"\dot{q}_{%$i}") # Velocities
end
axislegend(ax2, unique=true, orientation=:horizontal, position = :lt)
#
base_vals = zeros(o, l, No, length(t_vals))
# 3. Base functions plot using pi_paper
ax3 = Axis(f[3, 1],
title="Base Functions",
xlabel="Time",
ylabel=L"$\pi_{i}$",
ylabelrotation=0, # Rotates y-label 90 degrees
ylabelsize=18,
xticks=t_vals[1]:0.5:t_vals[end]
)
for i in 1:o
base_vals[i, :, :, :] .= reshape(hcat([pi_constr(A, B, C, t, T, dT, i) for t in t_vals]...),(l,No,length(t_vals)))
for k in 1:l
for j in 1:No# Using pi_paper to compute the base functions
#color_index = ((i - 1) * 2N + j) / (o * 2N)
lines!(ax3, t_vals, base_vals[i, k, j, :])#, color=plotcolors[color_index])
f = Figure(resolution=(1200, 1000))

plotcolors = ColorSchemes.matter

# 1. Position plot
ax1 = Axis(f[1, 1],
title="Positions",
xlabel="Time",
ylabel=L"q_{i}",
ylabelrotation=0, # Rotates y-label 90 degrees
ylabelsize=18,
xticks=t_vals[1]:0.5:t_vals[end]
)
for i in 1:N
lines!(ax1, t_vals, getindex.(x_vals, i), label=L"q_{%$i}") # Positions
scatter!(ax1, T, ywant[i, :], color=:black, marker=:x, markersize=8, label=L"$\overline{y}$") # Desired positions
end
axislegend(ax1, unique=true, orientation=:horizontal, position = :lt)

# 2. Velocity plot
ax2 = Axis(f[2, 1],
title="Velocities",
xlabel="Time",
ylabel=L"\dot{q}_{i}",
ylabelrotation=0, # Rotates y-label 90 degrees
ylabelsize=18,
xticks=t_vals[1]:0.5:t_vals[end]
)
for i in 1:N
lines!(ax2, t_vals, getindex.(v_vals, i), label=L"\dot{q}_{%$i}") # Velocities
end
axislegend(ax2, unique=true, orientation=:horizontal, position = :lt)
#
base_vals = zeros(o, l, No, length(t_vals))
# 3. Base functions plot using pi_paper
ax3 = Axis(f[3, 1],
title="Base Functions",
xlabel="Time",
ylabel=L"$\pi_{i}$",
ylabelrotation=0, # Rotates y-label 90 degrees
ylabelsize=18,
xticks=t_vals[1]:0.5:t_vals[end]
)
for i in 1:o
base_vals[i, :, :, :] .= reshape(hcat([pi_constr(A, B, C, t, T, dT, i) for t in t_vals]...),(l,No,length(t_vals)))
for k in 1:l
for j in 1:No# Using pi_paper to compute the base functions
color_index = ((i-1)*l*No + (k-1)*No + j) / (o*l*No)
lines!(ax3, t_vals, base_vals[i, k, j, :], color=plotcolors[color_index])
end
end
end
end
#
# 4. Control Action plot (input uₙ)
ax4 = Axis(f[4, 1],
title="Control Action",
xlabel="Time",
ylabel=L"$u(t)$",
ylabelrotation=0, # Rotates y-label 90 degrees
ylabelsize=18,
xticks=t_vals[1]:0.5:t_vals[end]
)
for i in 1:l
lines!(ax4, t_vals, u_vals[i, :],label=L"u_{%$i}")
end
axislegend(ax4, unique=true, orientation=:horizontal, position = :lt)
#
# 4. Control Action plot (input uₙ)
ax4 = Axis(f[4, 1],
title="Control Action",
xlabel="Time",
ylabel=L"$u(t)$",
ylabelrotation=0, # Rotates y-label 90 degrees
ylabelsize=18,
xticks=t_vals[1]:0.5:t_vals[end]
)
for i in 1:l
lines!(ax4, t_vals, u_vals[i, :],label=L"u_{%$i}")
end
axislegend(ax4, unique=true, orientation=:horizontal, position = :lt)

# Display the figure
display(f)

# Display the figure
display(f)
## Save figure
imgpath = "./report_slides/typst/images/"
figname = "basket_$(Niter)iters_$(dT)dT.svg"
save(imgpath * figname, f)

0 comments on commit 093dc47

Please sign in to comment.