-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This reverts commit 6f36279.
- Loading branch information
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using Test #src | ||
using StaticArrays, Plots | ||
|
||
# At this point, we import the useful Dionysos sub-modules. | ||
using Dionysos | ||
const DI = Dionysos | ||
const UT = DI.Utils | ||
const DO = DI.Domain | ||
const ST = DI.System | ||
const SY = DI.Symbolic | ||
const OP = DI.Optim | ||
const AB = OP.Abstraction | ||
|
||
include( | ||
joinpath( | ||
dirname(dirname(pathof(Dionysos))), | ||
"problems/double_pendulum", | ||
"safety_stable_equilibrium.jl", | ||
), | ||
) | ||
|
||
# and we can instantiate the DC system with the provided system | ||
concrete_problem = DoublePendulum.problem(; approx_mode = "growth") | ||
concrete_system = concrete_problem.system | ||
|
||
x0 = SVector(0.0, 0.0, 0.0, 0.0) | ||
hx = SVector(0.1, 0.1, 0.1, 0.1) | ||
state_grid = DO.GridFree(x0, hx) | ||
|
||
u0 = SVector(0.0); | ||
h = SVector(0.3); | ||
input_grid = DO.GridFree(u0, h); | ||
|
||
using JuMP | ||
optimizer = MOI.instantiate(AB.UniformGridAbstraction.Optimizer) | ||
MOI.set(optimizer, MOI.RawOptimizerAttribute("concrete_problem"), concrete_problem) | ||
MOI.set(optimizer, MOI.RawOptimizerAttribute("state_grid"), state_grid) | ||
MOI.set(optimizer, MOI.RawOptimizerAttribute("input_grid"), input_grid) | ||
MOI.optimize!(optimizer) | ||
|
||
abstract_controller = MOI.get(optimizer, MOI.RawOptimizerAttribute("abstract_controller")) | ||
concrete_controller = MOI.get(optimizer, MOI.RawOptimizerAttribute("concrete_controller")) | ||
|
||
# ### Trajectory display | ||
# We choose the number of steps `nsteps` for the sampled system, i.e. the total elapsed time: `nstep`*`tstep` | ||
# as well as the true initial state `x0` which is contained in the initial state-space defined previously. | ||
nstep = 100 | ||
x0 = SVector(0.15, 0.0, 0.0, 0.0) # SVector(0.15,0.0) # | ||
control_trajectory = | ||
ST.get_closed_loop_trajectory(concrete_system.f, concrete_controller, x0, nstep) | ||
|
||
fig = plot(; aspect_ratio = :equal); | ||
plot!(concrete_system.X); | ||
plot!(control_trajectory; markersize = 1, arrows = false) |