Skip to content

Commit faffc7c

Browse files
committed
adding mujoco elliptic cone
1 parent e6ab08f commit faffc7c

File tree

4 files changed

+77
-21
lines changed

4 files changed

+77
-21
lines changed
540 KB
Loading
299 KB
Binary file not shown.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# ## Ghost
2+
set_camera!(vis, cam_pos=[-1,1,0], zoom=1)
3+
4+
z_sim = get_maximal_state(storage)
5+
timesteps = [5, 10, 15]# .+ 150
6+
7+
for t in timesteps
8+
name = Symbol("robot_$t")
9+
build_robot(mech, vis=vis, name=name, color= magenta_light)
10+
z = z_sim[t]
11+
set_robot(vis, mech, z, name=name)
12+
end
13+
14+
z_sim[220][1] -= 0.1
15+
z_sim[220][13 + 1] -= 0.05
16+
set_robot(vis, mech, z_sim[220])
17+
18+
z_sim[104][1] -= 0.025
19+
z_sim[104][13 + 1] -= 0.05
20+
set_robot(vis, mech, z_sim[104])

examples/simulation/cone_compare.jl

Lines changed: 57 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ line_mat_lc = LineBasicMaterial(color=color_lc, linewidth=10.0)
6060
points_lc = Vector{Point{3,Float64}}()
6161
for (i, xt) in enumerate(storage_lc.x[1])
6262
k = xt
63-
push!(points_lc, Point(k[1], k[2] + 0.04, k[3]))
63+
push!(points_lc, Point(k...))
6464
end
6565
setobject!(vis[:path_lc], MeshCat.Line(points_lc, line_mat_lc))
6666

@@ -86,15 +86,12 @@ storage_nc = simulate!(mech_nc, 4.0,
8686
opts=opts)
8787

8888
# ## Visualize
89-
for (i, x) in enumerate(storage_nc.x[1])
90-
storage_nc.x[1][i] += [0.0; 0.0; 0.1]
91-
end
92-
9389
line_mat_nc = LineBasicMaterial(color=color_nc, linewidth=25.0)
9490
points_nc = Vector{Point{3,Float64}}()
9591
for (i, xt) in enumerate(storage_nc.x[1])
9692
k = xt
97-
push!(points_nc, Point(k[1], k[2] - 0.04, k[3] + 0.0))
93+
@show k[3]
94+
push!(points_nc, Point(k...))
9895
end
9996
setobject!(vis[:path_nc], MeshCat.Line(points_nc, line_mat_nc))
10097

@@ -103,39 +100,78 @@ vis, anim = visualize(mech_nc, storage_nc,
103100
name=:nc,
104101
animation=anim)
105102

106-
# ## MuJoCo cone
107-
color_mj = magenta;
103+
# ## MuJoCo pyramidal cone
104+
color_mjlc = magenta;
105+
106+
mech_mjlc = get_mechanism(:box,
107+
timestep=timestep,
108+
gravity=gravity,
109+
friction_coefficient=friction_coefficient,
110+
contact_type=:linear,
111+
mode=:box, color=color_mjlc);
112+
113+
# ## Load
114+
initialize!(mech_mjlc, :box,
115+
x=x0,
116+
q=one(UnitQuaternion),
117+
v=v0,
118+
ω=ω0)
119+
file = jldopen(joinpath(@__DIR__, "../mujoco_benchmark/results/cone_compare_pyramidal.jld2"))
120+
storage_mjlc = generate_storage(mech_mjlc, [get_maximal_state(mech_mjlc), file["ztraj"]...])
121+
122+
# ## Visualize
123+
vis, anim = visualize(mech_mjlc, storage_mjlc,
124+
vis=vis,
125+
name=:mjlc,
126+
animation=anim)
127+
128+
line_mat_mjlc = LineBasicMaterial(color=color_mjlc, linewidth=25.0)
129+
points_mjlc = Vector{Point{3,Float64}}()
130+
for (i, xt) in enumerate(storage_mjlc.x[1])
131+
k = xt
132+
push!(points_mjlc, Point(k[1], k[2], k[3]))
133+
end
134+
setobject!(vis[:path_mjlc], MeshCat.Line(points_mjlc, line_mat_mjlc))
135+
136+
137+
# ## MuJoCo elliptic cone
138+
color_mjnc = RGBA(0,0,0);
108139

109-
mech_mj = get_mechanism(:box,
140+
mech_mjnc = get_mechanism(:box,
110141
timestep=timestep,
111142
gravity=gravity,
112143
friction_coefficient=friction_coefficient,
113144
contact_type=:linear,
114-
mode=:box, color=color_mj);
145+
mode=:box, color=color_mjnc);
115146

116147
# ## Load
117-
initialize!(mech_mj, :box,
148+
initialize!(mech_mjnc, :box,
118149
x=x0,
119150
q=one(UnitQuaternion),
120151
v=v0,
121152
ω=ω0)
122-
file = jldopen(joinpath(@__DIR__, "../MuJoCo_benchmark/results/cone_compare.jld2"))
123-
storage_mj = generate_storage(mech_mj, [get_maximal_state(mech_mj), file["ztraj"]...])
153+
file = jldopen(joinpath(@__DIR__, "../mujoco_benchmark/results/cone_compare_elliptic.jld2"))
154+
storage_mjnc = generate_storage(mech_mjnc, [get_maximal_state(mech_mjnc), file["ztraj"]...])
124155

125156
# ## Visualize
126-
vis, anim = visualize(mech_mj, storage_mj,
157+
vis, anim = visualize(mech_mjnc, storage_mjnc,
127158
vis=vis,
128-
name=:mj,
159+
name=:mjnc,
129160
animation=anim)
130161

131-
line_mat_mj = LineBasicMaterial(color=color_mj, linewidth=25.0)
132-
points_mj = Vector{Point{3,Float64}}()
133-
for (i, xt) in enumerate(storage_mj.x[1])
162+
line_mat_mjnc = LineBasicMaterial(color=color_mjnc, linewidth=25.0)
163+
points_mjnc = Vector{Point{3,Float64}}()
164+
for (i, xt) in enumerate(storage_mjnc.x[1])
134165
k = xt
135-
push!(points_mj, Point(k[1], k[2], k[3]))
166+
push!(points_mjnc, Point(k[1], k[2], k[3]))
136167
end
137-
setobject!(vis[:path_mj], MeshCat.Line(points_mj, line_mat_mj))
168+
setobject!(vis[:path_mjnc], MeshCat.Line(points_mjnc, line_mat_mjnc))
138169

139170
settransform!(vis[:lc], MeshCat.Translation(0,+0.04,0))
171+
settransform!(vis[:path_lc], MeshCat.Translation(0,+0.04,0))
140172
settransform!(vis[:nc], MeshCat.Translation(0,-0.04,0))
141-
settransform!(vis[:mj], MeshCat.Translation(0,+0.00,0))
173+
settransform!(vis[:path_nc], MeshCat.Translation(0,-0.04,0))
174+
settransform!(vis[:mjlc], MeshCat.Translation(0,+0.00,0))
175+
# settransform!(vis[:mjnc], MeshCat.Translation(0,-0.08,-0.02))
176+
settransform!(vis[:mjnc], MeshCat.Translation(0,-0.08,0))
177+
settransform!(vis[:path_mjnc], MeshCat.Translation(0,-0.08,0))

0 commit comments

Comments
 (0)