Skip to content

Commit ab86d79

Browse files
committed
Deal with inconsistent use of :box vs :block
1 parent 08d799c commit ab86d79

File tree

12 files changed

+46
-46
lines changed

12 files changed

+46
-46
lines changed

examples/simulation/cone_compare.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ opts = SolverOptions(rtol=1.0e-6, btol=1.0e-6)
3232

3333
# ## Linear cone
3434
color_lc = orange;
35-
mech_lc = get_mechanism(:box,
35+
mech_lc = get_mechanism(:block,
3636
timestep=timestep,
3737
gravity=gravity,
3838
friction_coefficient=friction_coefficient,
@@ -41,7 +41,7 @@ mech_lc = get_mechanism(:box,
4141
color=color_lc);
4242

4343
# ## Simulate
44-
initialize!(mech_lc, :box,
44+
initialize!(mech_lc, :block,
4545
x=x0,
4646
q=one(Quaternion),
4747
v=v0,
@@ -59,7 +59,7 @@ via, anim = visualize(mech_lc, storage_lc,
5959

6060
# ## Nonlinear cone
6161
color_nc = cyan;
62-
mech_nc = get_mechanism(:box,
62+
mech_nc = get_mechanism(:block,
6363
timestep=timestep,
6464
gravity=gravity,
6565
friction_coefficient=friction_coefficient,
@@ -68,7 +68,7 @@ mech_nc = get_mechanism(:box,
6868
color=color_nc);
6969

7070
# ## Simulate
71-
initialize!(mech_nc, :box,
71+
initialize!(mech_nc, :block,
7272
x=x0,
7373
q=one(Quaternion),
7474
v=v0,
@@ -91,15 +91,15 @@ vis, anim = visualize(mech_nc, storage_nc,
9191
# ## MuJoCo pyramidal cone
9292
color_mjlc = magenta;
9393

94-
mech_mjlc = get_mechanism(:box,
94+
mech_mjlc = get_mechanism(:block,
9595
timestep=timestep,
9696
gravity=gravity,
9797
friction_coefficient=friction_coefficient,
9898
contact_type=:linear,
9999
mode=:box, color=color_mjlc);
100100

101101
# ## Load
102-
initialize!(mech_mjlc, :box,
102+
initialize!(mech_mjlc, :block,
103103
x=x0,
104104
q=one(Quaternion),
105105
v=v0,
@@ -125,15 +125,15 @@ setobject!(vis[:path_mjlc], MeshCat.Line(points_mjlc, line_mat_mjlc))
125125
# ## MuJoCo elliptic cone
126126
color_mjnc = RGBA(0,0,0);
127127

128-
mech_mjnc = get_mechanism(:box,
128+
mech_mjnc = get_mechanism(:block,
129129
timestep=timestep,
130130
gravity=gravity,
131131
friction_coefficient=friction_coefficient,
132132
contact_type=:linear,
133133
mode=:box, color=color_mjnc);
134134

135135
# ## Load
136-
initialize!(mech_mjnc, :box,
136+
initialize!(mech_mjnc, :block,
137137
x=x0,
138138
q=one(Quaternion),
139139
v=v0,

examples/system_identification/data/data.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ function generate_hardware_dataset(;N::Int=10,
6464
timestep= 1/148 * S
6565
gscaled = -9.81*20
6666

67-
mechanism = get_mechanism(:box, timestep=timestep, gravity=gravityscaled);
67+
mechanism = get_mechanism(:block, timestep=timestep, gravity=gravityscaled);
6868
trajs = []
6969
pairs = []
7070
for i = 1:N

examples/system_identification/hardware_examples/visualization.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ function d2data(d)
7272
]
7373
return data
7474
end
75-
mech = get_mechanism(:box, timestep=timestep/S, gravity=gravityscaled, friction_coefficient=Dsol[end][1], radius=0.00, side=2.0, mode=:box);
75+
mech = get_mechanism(:block, timestep=timestep/S, gravity=gravityscaled, friction_coefficient=Dsol[end][1], radius=0.00, side=2.0, mode=:box);
7676
set_simulator_data!(mech, d2data(Dsol[end]))
7777
id = 7#4,6,7,8
7878
traj_truth = trajs1[id]
@@ -81,7 +81,7 @@ v15 = traj_truth.v[1][1]
8181
q2 = traj_truth.q[1][1]
8282
ϕ15 = traj_truth.ω[1][1]
8383

84-
initialize!(mech, :box, x=x2, v=v15, q=q2, ω=ϕ15)
84+
initialize!(mech, :block, x=x2, v=v15, q=q2, ω=ϕ15)
8585
traj_sim = simulate!(mech, 0.80, record=true,
8686
opts=SolverOptions(btol=1e-6, rtol=1e-6, verbose=false))
8787

examples/system_identification/learning.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ open(vis)
2222
S = 7
2323
timestep= 1/148 * S
2424
gscaled = -9.81*20
25-
mech = get_mechanism(:box,
25+
mech = get_mechanism(:block,
2626
timestep=timestep,
2727
gravity=gravityscaled,
2828
friction_coefficient=0.2,
@@ -31,7 +31,7 @@ mech = get_mechanism(:box,
3131
mode=:box);
3232

3333
# ## Simualate
34-
initialize!(mech, :box,
34+
initialize!(mech, :block,
3535
x=[0.0, -1.0, 1.0],
3636
v=[0.0, 2.0, 1.0],
3737
ω=[2.0, 5.0, 10.0])
@@ -61,18 +61,18 @@ data0 = params0[:data]
6161
################################################################################
6262
## Optimization Objective: Evaluation & Gradient
6363
################################################################################
64-
clean_loss(:box, pairs0, data0,
64+
clean_loss(:block, pairs0, data0,
6565
n_sample=250,
6666
opts=SolverOptions(btol=3e-4, rtol=3e-4),
6767
timestep=timestep,
6868
gravity=gravityscaled)
6969

70-
[clean_loss(:box, pairs0, data0 + [i;zeros(55)],
70+
[clean_loss(:block, pairs0, data0 + [i;zeros(55)],
7171
opts=SolverOptions(btol=3e-4, rtol=3e-4),
7272
timestep=timestep,
7373
gravity=gravityscaled)
7474
for i in Vector(-0.10:0.01:0.1)]
75-
[clean_loss(:box, pairs0, data0 + [0;i;zeros(54)],
75+
[clean_loss(:block, pairs0, data0 + [0;i;zeros(54)],
7676
opts=SolverOptions(btol=3e-4, rtol=3e-4),
7777
timestep=timestep,
7878
gravity=gravityscaled)
@@ -108,7 +108,7 @@ lower = [0.00, 0.05]
108108
upper = [0.80, 1.50]
109109

110110
function f0(d; rot=0)
111-
return clean_loss(:box, pairs0, d2data(d),
111+
return clean_loss(:block, pairs0, d2data(d),
112112
n_sample=200,
113113
timestep=timestep,
114114
gravity=gravityscaled,
@@ -118,7 +118,7 @@ end
118118

119119
function fgH0(d;
120120
rot=0)
121-
f, g, H = clean_loss(:box, pairs0, d2data(d),
121+
f, g, H = clean_loss(:block, pairs0, d2data(d),
122122
n_sample=200,
123123
timestep=timestep,
124124
gravity=gravityscaled,
@@ -151,7 +151,7 @@ dsol #[0.171, 0.933]
151151
using Plots; pyplot()
152152
x=range(0.00,stop=0.80,length=10)
153153
y=range(0.10,stop=1.50,length=10)
154-
f(x,y) = log(10, clean_loss(:box, pairs0, d2data([x,y]), n_sample=50, timestep=timestep, gravity=gravityscaled,
154+
f(x,y) = log(10, clean_loss(:block, pairs0, d2data([x,y]), n_sample=50, timestep=timestep, gravity=gravityscaled,
155155
opts=SolverOptions(btol=3e-4, rtol=3e-4))[1])
156156
plot(x,y,f,st=:surface,camera=(25,75))
157157

@@ -212,11 +212,11 @@ upper = [0.80,
212212
-0.05, -0.05, +1.50]
213213

214214
function f0(d; rot=0, n_sample=50)
215-
return clean_loss(:box, pairs0, d2data(d), n_sample=n_sample, timestep=timestep, gravity=gravityscaled, rot=rot, opts=SolverOptions(btol=3e-4, rtol=3e-4))[1]
215+
return clean_loss(:block, pairs0, d2data(d), n_sample=n_sample, timestep=timestep, gravity=gravityscaled, rot=rot, opts=SolverOptions(btol=3e-4, rtol=3e-4))[1]
216216
end
217217

218218
function fgH0(d; rot=0, n_sample=50)
219-
f, g, H = clean_loss(:box, pairs0, d2data(d), n_sample=n_sample, timestep=timestep, gravity=gravityscaled, rot=rot, opts=SolverOptions(btol=3e-4, rtol=3e-4))
219+
f, g, H = clean_loss(:block, pairs0, d2data(d), n_sample=n_sample, timestep=timestep, gravity=gravityscaled, rot=rot, opts=SolverOptions(btol=3e-4, rtol=3e-4))
220220
return f, ∇d2data' * g, ∇d2data' * H * ∇d2data
221221
end
222222
dsol, Dsol = quasi_newton_solve(f0, fgH0, d0, iter=50, gtol=1e-8, ftol=1e-6,

examples/system_identification/synthetic_examples/box.jl

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ open(vis)
1111
# Include new files
1212
include( "../utils.jl")
1313

14-
mech = get_mechanism(:box, timestep=0.05, g=-9.81, friction_coefficient=0.2, radius=0.00, side=0.50, mode=:box);
15-
initialize!(mech, :box, x=[0,-1,1.], v=[0,2,1.], ω=[2,5,10.])
14+
mech = get_mechanism(:block, timestep=0.05, g=-9.81, friction_coefficient=0.2, radius=0.00, side=0.50, mode=:box);
15+
initialize!(mech, :block, x=[0,-1,1.], v=[0,2,1.], ω=[2,5,10.])
1616
storage = simulate!(mech, 5.0, record=true,
1717
opts=SolverOptions(btol=1e-6, rtol=1e-6, verbose=false))
1818
visualize(mech, storage, vis=vis, show_contact=false)
@@ -25,7 +25,7 @@ init_kwargs = Dict(:xlims => [[0,0,0.2], [1,1,0.4]],
2525
:vlims => [-2ones(3), [2,2,-1.]],
2626
:ωlims => [-6ones(3), 6ones(3)])
2727
mech_kwargs = Dict(:friction_coefficient => 0.1, :radius => 0.0, :side => 0.5)
28-
generate_dataset(:box, H=0.40, N=35,
28+
generate_dataset(:block, H=0.40, N=35,
2929
opts=SolverOptions(btol=3e-4, rtol=3e-4),
3030
init_kwargs=init_kwargs,
3131
mech_kwargs=mech_kwargs,
@@ -36,20 +36,20 @@ generate_dataset(:box, H=0.40, N=35,
3636
################################################################################
3737
# Load Dataset
3838
################################################################################
39-
params0, trajs0, pairs0 = open_dataset(:box; N = 35, mech_kwargs...)
39+
params0, trajs0, pairs0 = open_dataset(:block; N = 35, mech_kwargs...)
4040

4141
data0 = params0[:data]
4242

4343
################################################################################
4444
# Optimization Objective: Evaluation & Gradient
4545
################################################################################
46-
# @benchmark clean_loss(:box, pairs0, data0, opts=SolverOptions(btol=3e-4, rtol=3e-4))
47-
# @profiler clean_loss(:box, pairs0, data0, opts=SolverOptions(btol=3e-4, rtol=3e-4))
48-
clean_loss(:box, pairs0, data0, opts=SolverOptions(btol=3e-4, rtol=3e-4))
46+
# @benchmark clean_loss(:block, pairs0, data0, opts=SolverOptions(btol=3e-4, rtol=3e-4))
47+
# @profiler clean_loss(:block, pairs0, data0, opts=SolverOptions(btol=3e-4, rtol=3e-4))
48+
clean_loss(:block, pairs0, data0, opts=SolverOptions(btol=3e-4, rtol=3e-4))
4949

50-
[clean_loss(:box, pairs0, data0 + [i;zeros(55)], opts=SolverOptions(btol=3e-4, rtol=3e-4))
50+
[clean_loss(:block, pairs0, data0 + [i;zeros(55)], opts=SolverOptions(btol=3e-4, rtol=3e-4))
5151
for i in Vector(-0.10:0.01:0.1)]
52-
[clean_loss(:box, pairs0, data0 + [0;i;zeros(54)], opts=SolverOptions(btol=3e-4, rtol=3e-4))
52+
[clean_loss(:block, pairs0, data0 + [0;i;zeros(54)], opts=SolverOptions(btol=3e-4, rtol=3e-4))
5353
for i in Vector(-0.10:0.01:0.1)]
5454

5555
plot(hcat([p[1][1:3] for p in pairs0]...)')
@@ -109,11 +109,11 @@ upper = [0.80,
109109
-0.05, -0.05, +1.00]
110110

111111
function f0(d; rot=0)
112-
return clean_loss(:box, pairs0, d2data(d), n_sample=35, rot=rot, opts=SolverOptions(btol=3e-4, rtol=3e-4))[1]
112+
return clean_loss(:block, pairs0, d2data(d), n_sample=35, rot=rot, opts=SolverOptions(btol=3e-4, rtol=3e-4))[1]
113113
end
114114

115115
function fgH0(d; rot=0)
116-
f, g, H = clean_loss(:box, pairs0, d2data(d), n_sample=35, rot=rot, opts=SolverOptions(btol=3e-4, rtol=3e-4))
116+
f, g, H = clean_loss(:block, pairs0, d2data(d), n_sample=35, rot=rot, opts=SolverOptions(btol=3e-4, rtol=3e-4))
117117
return f, ∇d2data' * g, ∇d2data' * H * ∇d2data
118118
end
119119
dsol = quasi_newton_solve(f0, fgH0, d0, iter=50, gtol=1e-8, ftol=1e-6,
@@ -178,11 +178,11 @@ upper = [
178178
0.80, -0.05, -0.05, +1.00]
179179

180180
function f0(d; rot=0)
181-
return clean_loss(:box, pairs0, d2data(d), n_sample=35, rot=rot, opts=SolverOptions(btol=3e-4, rtol=3e-4))[1]
181+
return clean_loss(:block, pairs0, d2data(d), n_sample=35, rot=rot, opts=SolverOptions(btol=3e-4, rtol=3e-4))[1]
182182
end
183183

184184
function fgH0(d; rot=0)
185-
f, g, H = clean_loss(:box, pairs0, d2data(d), n_sample=35, rot=rot, opts=SolverOptions(btol=3e-4, rtol=3e-4))
185+
f, g, H = clean_loss(:block, pairs0, d2data(d), n_sample=35, rot=rot, opts=SolverOptions(btol=3e-4, rtol=3e-4))
186186
return f, ∇d2data' * g, ∇d2data' * H * ∇d2data
187187
end
188188

test/behaviors.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ end
1818

1919
@testset "Box toss" begin
2020
for timestep in [0.10, 0.05, 0.01, 0.005]
21-
mech = get_mechanism(:box,
21+
mech = get_mechanism(:block,
2222
timestep=timestep,
2323
gravity=-9.81,
2424
friction_coefficient = 0.1)
2525

26-
initialize!(mech, :box,
26+
initialize!(mech, :block,
2727
x=[0.0, 0.0, 0.5],
2828
v=[1.0, 1.5, 1.0],
2929
ω=[5.0, 4.0, 2.0] .* timestep)

test/data.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ end
141141
for (spring, damper) in [(0.0, 0.0), (2.0, 0.3)]
142142
test_data_system(:sphere,
143143
contact=false)
144-
test_data_system(:box,
144+
test_data_system(:block,
145145
contact=false)
146146
test_data_system(:box2D,
147147
contact=false)
@@ -212,7 +212,7 @@ end
212212
for (spring, damper) in [(0.0, 0.0), (2.0, 0.3)]
213213
test_data_system(:sphere,
214214
contact=true)
215-
test_data_system(:box,
215+
test_data_system(:block,
216216
contact=true)
217217
test_data_system(:box2D,
218218
contact=true)

test/energy.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,14 @@ end
9898
@testset "Dice" begin
9999
gravity0 = -10.0
100100

101-
mech = get_mechanism(:box,
101+
mech = get_mechanism(:block,
102102
timestep=timestep0,
103103
gravity=gravity0,
104104
contact=false)
105105

106106
v0 = [1,2,3.0]
107107
ω0 = [1,1,1.0]
108-
initialize!(mech, :box,
108+
initialize!(mech, :block,
109109
v=v0,
110110
ω=ω0)
111111

test/jacobian.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ end
8181
test_solmat(:atlas, tsim=tsim, ctrl=(m,k)->control!(m,k,u=0.1), ϵ=1.0e-7)
8282
test_solmat(:atlas, tsim=tsim, ctrl=(m,k)->control!(m,k,u=0.1), ϵ=1.0e-7, spring=1e3, damper=5e2)
8383
test_solmat(:quadruped, tsim=tsim, ctrl=(m,k)->control!(m,k,u=0.1), ϵ=1.0e-7, spring=1.0, damper=0.2)
84-
test_solmat(:box, tsim=tsim, ctrl=(m,k)->control!(m,k,u=0.1), ϵ=1.0e-7)
84+
test_solmat(:block, tsim=tsim, ctrl=(m,k)->control!(m,k,u=0.1), ϵ=1.0e-7)
8585
test_solmat(:snake, tsim=tsim, ctrl=(m,k)->control!(m,k,u=0.1), ϵ=1.0e-7, spring=1.0, damper=0.2)
8686
test_solmat(:slider, tsim=tsim, ctrl=(m,k)->control!(m,k,u=0.1), ϵ=1.0e-7, spring=1.0, damper=0.2)
8787
test_solmat(:pendulum, tsim=tsim, ctrl=(m,k)->control!(m,k,u=0.1), ϵ=1.0e-7, spring=1.0, damper=0.2)
@@ -101,7 +101,7 @@ end
101101
test_solmat(:atlas, tsim=tsim, ctrl=(m,k)->control!(m,k,u=0.1), ϵ=1.0e-7)
102102
test_solmat(:atlas, tsim=tsim, ctrl=(m,k)->control!(m,k,u=0.1), ϵ=1.0e-7, spring=1e3, damper=5e2)
103103
test_solmat(:quadruped, tsim=tsim, ctrl=(m,k)->control!(m,k,u=0.1), ϵ=1.0e-7, spring=1.0, damper=0.2)
104-
test_solmat(:box, tsim=tsim, ctrl=(m,k)->control!(m,k,u=0.1), ϵ=1.0e-7)
104+
test_solmat(:block, tsim=tsim, ctrl=(m,k)->control!(m,k,u=0.1), ϵ=1.0e-7)
105105
test_solmat(:snake, tsim=tsim, ctrl=(m,k)->control!(m,k,u=0.1), ϵ=1.0e-7, spring=1.0, damper=0.2)
106106
test_solmat(:slider, tsim=tsim, ctrl=(m,k)->control!(m,k,u=0.1), ϵ=1.0e-7, spring=1.0, damper=0.2)
107107
test_solmat(:pendulum, tsim=tsim, ctrl=(m,k)->control!(m,k,u=0.1), ϵ=1.0e-7, spring=1.0, damper=0.2)

test/mechanisms.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
mechanisms = [
22
:ant,
33
:atlas,
4-
:box,
4+
:block,
55
:box2D,
66
:cartpole,
77
:dzhanibekov,

0 commit comments

Comments
 (0)