Skip to content

Commit 6719d4a

Browse files
authored
Merge pull request #112 from control-toolbox/quickfix
Quickfix
2 parents 37c6ba0 + 353dda7 commit 6719d4a

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

examples/goddard.jl

+8-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
using OptimalControl
66
using Plots
7-
unicodeplots()
7+
#unicodeplots()
8+
ENV["GKSwstype"]="nul" # no plot display on stdout
89

910
# Parameters
1011
const Cd = 310
@@ -51,8 +52,10 @@ f(x, u) = F0(x) + u[1]*F1(x)
5152
constraint!(ocp, :dynamics, f)
5253

5354
# Solve
54-
sol = solve(ocp)
55+
N = 30
56+
sol = solve(ocp, grid_size=N)
5557
plot(sol)
58+
savefig("sol-direct.pdf")
5659

5760
## Indirect solve
5861

@@ -101,7 +104,7 @@ function shoot!(s, p0, t1, t2, t3, tf) # B+ S C B0 structure
101104
end
102105

103106
# Initialisation from direct solution
104-
t = sol.T; t = (t[1:end-1] + t[2:end]) / 2
107+
t = sol.T; N = length(t)-1; t = (t[1:end-1] + t[2:end]) / 2
105108
x = [ sol.X[i, 1:3] for i 1:N+1 ]; x = (x[1:end-1] + x[2:end]) / 2
106109
u = [ sol.U[i, 1 ] for i 1:N+1 ]; u = (u[1:end-1] + u[2:end]) / 2
107110
p = [ sol.P[i, 1:3] for i 1:N ]
@@ -143,4 +146,5 @@ m_plot = plot(sol, idxs=(0, 3), xlabel="t", label="m")
143146
pr_plot = plot(sol, idxs=(0, 4), xlabel="t", label="p_r")
144147
pv_plot = plot(sol, idxs=(0, 5), xlabel="t", label="p_v")
145148
pm_plot = plot(sol, idxs=(0, 6), xlabel="t", label="p_m")
146-
plot(r_plot, pr_plot, v_plot, pv_plot, m_plot, pv_plot, layout=(3, 2))
149+
plot(r_plot, pr_plot, v_plot, pv_plot, m_plot, pm_plot, layout=(3, 2))
150+
savefig("sol-indirect.pdf")

0 commit comments

Comments
 (0)