Skip to content

Commit f9c8e96

Browse files
committed
example deps
1 parent 9a4b4a9 commit f9c8e96

24 files changed

+107
-109
lines changed

examples/flamingo/flat.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
# ## Setup
66

7-
using LinearAlgebra
8-
using StaticArrays
7+
using ContactImplicitMPC
8+
using LinearAlgebra
99

1010
# ## Simulation
1111
s = get_simulation("flamingo", "flat_2D_lc", "flat")
@@ -52,8 +52,8 @@ p = ci_mpc_policy(ref_traj, s, obj,
5252
mpc_opts = CIMPCOptions());
5353

5454
# ## Initial conditions
55-
q1_sim = SVector{model.dim.q}(copy(ref_traj.q[2]))
56-
q0_sim = SVector{model.dim.q}(copy(q1_sim - (copy(ref_traj.q[2]) - copy(ref_traj.q[1])) / N_sample));
55+
q1_sim = ContactImplicitMPC.SVector{model.dim.q}(copy(ref_traj.q[2]))
56+
q0_sim = ContactImplicitMPC.SVector{model.dim.q}(copy(q1_sim - (copy(ref_traj.q[2]) - copy(ref_traj.q[1])) / N_sample));
5757

5858
# ## Simulator
5959
sim = simulator(s, q0_sim, q1_sim, h_sim, H_sim,

examples/flamingo/piecewise.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
# ## Setup
66

7-
using LinearAlgebra
8-
using StaticArrays
7+
using ContactImplicitMPC
8+
using LinearAlgebra
99

1010
# ## Simulation
1111
s_sim = get_simulation("flamingo", "piecewise1_2D_lc", "piecewise", approx = true)
@@ -49,8 +49,8 @@ p = ci_mpc_policy(ref_traj, s, obj,
4949
);
5050

5151
# ## Initial conditions
52-
q1_sim = SVector{model.dim.q}(copy(ref_traj.q[2]))
53-
q0_sim = SVector{model.dim.q}(copy(q1_sim - (copy(ref_traj.q[2]) - copy(ref_traj.q[1])) / N_sample));
52+
q1_sim = ContactImplicitMPC.SVector{model.dim.q}(copy(ref_traj.q[2]))
53+
q0_sim = ContactImplicitMPC.SVector{model.dim.q}(copy(q1_sim - (copy(ref_traj.q[2]) - copy(ref_traj.q[1])) / N_sample));
5454

5555
# ## Simulator
5656
sim = simulator(s_sim, q0_sim, q1_sim, h_sim, H_sim,

examples/flamingo/sine.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
# ## Setup
66

7-
using LinearAlgebra
8-
using StaticArrays
7+
using ContactImplicitMPC
8+
using LinearAlgebra
99

1010
# ## Simulation
1111
s_sim = get_simulation("flamingo", "sine3_2D_lc", "sinusoidal");
@@ -57,8 +57,8 @@ p = ci_mpc_policy(ref_traj, s, obj,
5757
);
5858

5959
# ## Initial conditions
60-
q1_sim = SVector{model.dim.q}(copy(ref_traj.q[2]))
61-
q0_sim = SVector{model.dim.q}(copy(q1_sim - (copy(ref_traj.q[2]) - copy(ref_traj.q[1])) / N_sample));
60+
q1_sim = ContactImplicitMPC.SVector{model.dim.q}(copy(ref_traj.q[2]))
61+
q0_sim = ContactImplicitMPC.SVector{model.dim.q}(copy(q1_sim - (copy(ref_traj.q[2]) - copy(ref_traj.q[1])) / N_sample));
6262

6363
# ## Simulator
6464
sim = simulator(s_sim, q0_sim, q1_sim, h_sim, H_sim,

examples/flamingo/slope.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
# ## Setup
66

7-
using LinearAlgebra
8-
using StaticArrays
7+
using ContactImplicitMPC
8+
using LinearAlgebra
99

1010
# ## Simulation
1111
s_sim = get_simulation("flamingo", "slope_smooth_2D_lc", "slope");
@@ -57,8 +57,8 @@ p = ci_mpc_policy(ref_traj, s, obj,
5757
);
5858

5959
# ## Initial conditions
60-
q1_sim = SVector{model.dim.q}(copy(ref_traj.q[2]))
61-
q0_sim = SVector{model.dim.q}(copy(q1_sim - (copy(ref_traj.q[2]) - copy(ref_traj.q[1])) / N_sample));
60+
q1_sim = ContactImplicitMPC.SVector{model.dim.q}(copy(ref_traj.q[2]))
61+
q0_sim = ContactImplicitMPC.SVector{model.dim.q}(copy(q1_sim - (copy(ref_traj.q[2]) - copy(ref_traj.q[1])) / N_sample));
6262

6363
# ## Simulator
6464
sim = simulator(s_sim, q0_sim, q1_sim, h_sim, H_sim,

examples/generate_notebooks.jl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@ using Literate
22

33
function preprocess(str)
44
str = replace(str, "# PREAMBLE" => "")
5-
str = replace(str, "# PKG_SETUP" =>
6-
"""
7-
using Pkg, ContactImplicitMPC
8-
Pkg.activate(joinpath(dirname(pathof(ContactImplicitMPC)), ".."))
9-
""")
5+
str = replace(str, "# PKG_SETUP" => "")
106
return str
117
end
128

examples/hopper/3D_flat.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
# ## Setup
66

7-
using LinearAlgebra
8-
using StaticArrays
7+
using ContactImplicitMPC
8+
using LinearAlgebra
99

1010
# ## Simulation
1111
s_sim = get_simulation("hopper_3D", "flat_3D_lc", "flat");
@@ -81,8 +81,8 @@ p = ci_mpc_policy(ref_traj, s, obj,
8181
);
8282

8383
# ## Initial conditions
84-
q1_sim = SVector{model.dim.q}(copy(ref_traj.q[2]))
85-
q0_sim = SVector{model.dim.q}(copy(q1_sim - (copy(ref_traj.q[2]) - copy(ref_traj.q[1])) / N_sample));
84+
q1_sim = ContactImplicitMPC.SVector{model.dim.q}(copy(ref_traj.q[2]))
85+
q0_sim = ContactImplicitMPC.SVector{model.dim.q}(copy(q1_sim - (copy(ref_traj.q[2]) - copy(ref_traj.q[1])) / N_sample));
8686

8787
# ## Simulator
8888
sim = simulator(s_sim, q0_sim, q1_sim, h_sim, H_sim,

examples/hopper/3D_sine.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
# ## Setup
66

7-
using LinearAlgebra
8-
using StaticArrays
7+
using ContactImplicitMPC
8+
using LinearAlgebra
99

1010
# ## Simulation
1111
s_sim = get_simulation("hopper_3D", "sine2_3D_lc", "sinusoidal");
@@ -81,8 +81,8 @@ p = ci_mpc_policy(ref_traj, s, obj,
8181
);
8282

8383
# ## Initial conditions
84-
q1_sim = SVector{model.dim.q}(copy(ref_traj.q[2]))
85-
q0_sim = SVector{model.dim.q}(copy(q1_sim - (copy(ref_traj.q[2]) - copy(ref_traj.q[1])) / N_sample));
84+
q1_sim = ContactImplicitMPC.SVector{model.dim.q}(copy(ref_traj.q[2]))
85+
q0_sim = ContactImplicitMPC.SVector{model.dim.q}(copy(q1_sim - (copy(ref_traj.q[2]) - copy(ref_traj.q[1])) / N_sample));
8686

8787
# ## Simulator
8888
sim = simulator(s_sim, q0_sim, q1_sim, h_sim, H_sim,

examples/hopper/flat.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
# ## Setup
66

7+
using ContactImplicitMPC
78
using LinearAlgebra
8-
using StaticArrays
99

1010
# ## Simulation
1111
s = get_simulation("hopper_2D", "flat_2D_lc", "flat")
@@ -51,8 +51,8 @@ p = ci_mpc_policy(ref_traj, s, obj,
5151
mpc_opts = CIMPCOptions());
5252

5353
# ## Initial conditions
54-
q1_sim = SVector{model.dim.q}(copy(ref_traj.q[2]))
55-
q0_sim = SVector{model.dim.q}(copy(q1_sim - (copy(ref_traj.q[2]) - copy(ref_traj.q[1])) / N_sample));
54+
q1_sim = ContactImplicitMPC.SVector{model.dim.q}(copy(ref_traj.q[2]))
55+
q0_sim = ContactImplicitMPC.SVector{model.dim.q}(copy(q1_sim - (copy(ref_traj.q[2]) - copy(ref_traj.q[1])) / N_sample));
5656

5757
# ## Simulator
5858
sim = simulator(s, q0_sim, q1_sim, h_sim, H_sim,

examples/hopper/monte_carlo.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
# ## Setup
66

7-
using LinearAlgebra
8-
using StaticArrays
7+
using ContactImplicitMPC
8+
using LinearAlgebra
99
using Random
1010

1111
# ## Simulation
@@ -62,8 +62,8 @@ function run_policy(s::Simulation; H_sim::Int = 4000, verbose = verbose,
6262

6363
q1_ref = copy(ref_traj.q[2]) + offset
6464
q0_ref = copy(ref_traj.q[1]) + offset
65-
q1_sim = SVector{model.dim.q}(q1_ref)
66-
q0_sim = SVector{model.dim.q}(copy(q1_sim - (q1_ref - q0_ref) / N_sample))
65+
q1_sim = ContactImplicitMPC.SVector{model.dim.q}(q1_ref)
66+
q0_sim = ContactImplicitMPC.SVector{model.dim.q}(copy(q1_sim - (q1_ref - q0_ref) / N_sample))
6767
@assert norm((q1_sim - q0_sim) / h_sim - (q1_ref - q0_ref) / h) < 1.0e-8
6868

6969
sim = simulator(s, q0_sim, q1_sim, h_sim, H_sim,
@@ -82,13 +82,13 @@ end
8282
# ## Collect runs
8383
function collect_runs(s::Simulation; n::Int = 1, H_sim::Int = 4000, verbose::Bool = false)
8484
trajs = []
85-
Random.seed!(100)
85+
ContactImplicitMPC.Random.seed!(100)
8686
offset_max = [+0.50, 0.30, +0.30, +0.00]
8787
offset_min = [-0.50, 0.00, -0.30, -0.30]
8888
offset_Δ = offset_max .- offset_min
8989
for i = 1:n
9090
verbose && println("sample = $i/$n")
91-
offset = offset_min .+ offset_Δ .* rand(s.model.dim.q)
91+
offset = offset_min .+ offset_Δ .* ContactImplicitMPC.rand(s.model.dim.q)
9292
traj = run_policy(s, H_sim = H_sim, offset = offset, verbose = verbose)
9393
push!(trajs, traj)
9494
end

examples/hopper/parkour.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
# ## Setup
66

7-
using LinearAlgebra
8-
using StaticArrays
7+
using ContactImplicitMPC
8+
using LinearAlgebra
99

1010
# Define a special stride where x and z are updated.
1111
function get_stride(model, traj)
@@ -55,8 +55,8 @@ p = ci_mpc_policy(ref_traj, s, obj,
5555
mpc_opts = mpc_opts);
5656

5757
# ## Initial conditions (stairs)
58-
q1_sim = SVector{model.dim.q}(copy(ref_traj.q[2]))
59-
q0_sim = SVector{model.dim.q}(copy(q1_sim - (copy(ref_traj.q[2]) - copy(ref_traj.q[1])) / N_sample));
58+
q1_sim = ContactImplicitMPC.SVector{model.dim.q}(copy(ref_traj.q[2]))
59+
q0_sim = ContactImplicitMPC.SVector{model.dim.q}(copy(q1_sim - (copy(ref_traj.q[2]) - copy(ref_traj.q[1])) / N_sample));
6060

6161
# ## Simulator (stairs)
6262
sim_stair = ContactImplicitMPC.simulator(s_sim, q0_sim, q1_sim, h_sim, H_sim,
@@ -110,8 +110,8 @@ p = ci_mpc_policy(ref_traj, s, obj,
110110
);
111111

112112
# ## Set initial configurations to simulation result
113-
q0_sim = deepcopy(SVector{model.dim.q}(sim_stair.traj.q[end-1]))
114-
q1_sim = deepcopy(SVector{model.dim.q}(sim_stair.traj.q[end]))
113+
q0_sim = deepcopy(ContactImplicitMPC.SVector{model.dim.q}(sim_stair.traj.q[end-1]))
114+
q1_sim = deepcopy(ContactImplicitMPC.SVector{model.dim.q}(sim_stair.traj.q[end]))
115115

116116
# ## Simulator (flip)
117117
sim_flip = ContactImplicitMPC.simulator(s_sim, q0_sim, q1_sim, h_sim, H_sim,

0 commit comments

Comments
 (0)