Skip to content

Commit dadfeb4

Browse files
committed
First working example
1 parent 911a342 commit dadfeb4

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

mwes/mwe_02.jl

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ if ! ("ControlPlots" ∈ keys(Pkg.project().dependencies))
77
using TestEnv; TestEnv.activate()
88
using Test
99
end
10-
using WinchControllers, KiteUtils, ControlPlots
10+
using WinchControllers, WinchModels, KiteUtils, ControlPlots
1111

1212
if isfile("data/system_tuned.yaml")
1313
set = load_settings("system_tuned.yaml")
@@ -63,4 +63,19 @@ v_act = find_equilibrium_speed(winch, v_set, force)
6363
x0 = [v_act] # State at operating point
6464
u0 = [v_set, force] # Input at operating point
6565

66+
function finite_jacobian(f, x; ϵ=sqrt(eps(eltype(x))))
67+
n = length(x)
68+
m = length(f(x))
69+
J = zeros(m, n)
70+
for i in 1:n
71+
Δx = zeros(n)
72+
Δx[i] = ϵ
73+
J[:, i] = (f(x + Δx) - f(x - Δx)) ./ (2ϵ)
74+
end
75+
J
76+
end
77+
78+
A = finite_jacobian(x -> motor_dynamics(x, u0), x0)
79+
B = finite_jacobian(u -> motor_dynamics(x0, u), u0)
80+
6681

0 commit comments

Comments
 (0)