|
4 | 4 |
|
5 | 5 | # ## Setup
|
6 | 6 |
|
7 |
| -using LinearAlgebra |
8 |
| -using StaticArrays |
| 7 | +using ContactImplicitMPC |
| 8 | +using LinearAlgebra |
9 | 9 | using Random
|
10 | 10 |
|
11 | 11 | # ## Simulation
|
@@ -62,8 +62,8 @@ function run_policy(s::Simulation; H_sim::Int = 4000, verbose = verbose,
|
62 | 62 |
|
63 | 63 | q1_ref = copy(ref_traj.q[2]) + offset
|
64 | 64 | 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)) |
67 | 67 | @assert norm((q1_sim - q0_sim) / h_sim - (q1_ref - q0_ref) / h) < 1.0e-8
|
68 | 68 |
|
69 | 69 | sim = simulator(s, q0_sim, q1_sim, h_sim, H_sim,
|
|
82 | 82 | # ## Collect runs
|
83 | 83 | function collect_runs(s::Simulation; n::Int = 1, H_sim::Int = 4000, verbose::Bool = false)
|
84 | 84 | trajs = []
|
85 |
| - Random.seed!(100) |
| 85 | + ContactImplicitMPC.Random.seed!(100) |
86 | 86 | offset_max = [+0.50, 0.30, +0.30, +0.00]
|
87 | 87 | offset_min = [-0.50, 0.00, -0.30, -0.30]
|
88 | 88 | offset_Δ = offset_max .- offset_min
|
89 | 89 | for i = 1:n
|
90 | 90 | 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) |
92 | 92 | traj = run_policy(s, H_sim = H_sim, offset = offset, verbose = verbose)
|
93 | 93 | push!(trajs, traj)
|
94 | 94 | end
|
|
0 commit comments