@@ -8,16 +8,15 @@ using Dojo
8
8
# ## Visualizer
9
9
vis= Visualizer ()
10
10
open (vis)
11
- set_camera! (vis,
12
- cam_pos= [- 0.01 , 0.0 , 90.0 ],
11
+ set_camera! (vis,
12
+ cam_pos= [- 0.01 , 0.0 , 90.0 ],
13
13
zoom= 30 )
14
- set_floor! (vis,
15
- x= 20.0 ,
16
- y= 20.0 ,
14
+ set_floor! (vis,
15
+ x= 20.0 ,
16
+ y= 20.0 ,
17
17
color= RGBA (1.0 , 1.0 , 1.0 , 1.0 ))
18
- set_light! (vis,
19
- ambient= 0.65 ,
20
- fill= 0.60 ,
18
+ set_light! (vis,
19
+ ambient= 0.65 ,
21
20
direction= " Positive" )
22
21
23
22
# ###############################################################################
@@ -33,28 +32,28 @@ opts = SolverOptions(rtol=1.0e-6, btol=1.0e-6)
33
32
34
33
# ## Linear cone
35
34
color_lc = orange;
36
- mech_lc = get_mechanism (:box ,
37
- timestep= timestep,
38
- gravity= gravity,
35
+ mech_lc = get_mechanism (:box ,
36
+ timestep= timestep,
37
+ gravity= gravity,
39
38
friction_coefficient= friction_coefficient,
40
- contact_type= :linear ,
41
- mode= :box ,
39
+ contact_type= :linear ,
40
+ mode= :box ,
42
41
color= color_lc);
43
42
44
43
# ## Simulate
45
- initialize! (mech_lc, :box ,
46
- x= x0,
47
- q= one (UnitQuaternion),
48
- v= v0,
44
+ initialize! (mech_lc, :box ,
45
+ x= x0,
46
+ q= one (UnitQuaternion),
47
+ v= v0,
49
48
ω= ω0)
50
49
51
- storage_lc = simulate! (mech_lc, 4.0 ,
52
- record= true ,
50
+ storage_lc = simulate! (mech_lc, 4.0 ,
51
+ record= true ,
53
52
opts= opts)
54
53
55
54
# ## Visualize
56
- via, anim = visualize (mech_lc, storage_lc,
57
- vis= vis,
55
+ via, anim = visualize (mech_lc, storage_lc,
56
+ vis= vis,
58
57
name= :lc )
59
58
60
59
line_mat_lc = LineBasicMaterial (color= color_lc, linewidth= 10.0 )
@@ -67,28 +66,28 @@ setobject!(vis[:path_lc], MeshCat.Line(points_lc, line_mat_lc))
67
66
68
67
# ## Nonlinear cone
69
68
color_nc = cyan;
70
- mech_nc = get_mechanism (:box ,
71
- timestep= timestep,
72
- gravity= gravity,
69
+ mech_nc = get_mechanism (:box ,
70
+ timestep= timestep,
71
+ gravity= gravity,
73
72
friction_coefficient= friction_coefficient,
74
- contact_type= :nonlinear ,
75
- mode= :box ,
73
+ contact_type= :nonlinear ,
74
+ mode= :box ,
76
75
color= color_nc);
77
76
78
77
# ## Simulate
79
- initialize! (mech_nc, :box ,
80
- x= x0,
81
- q= one (UnitQuaternion),
82
- v= v0,
78
+ initialize! (mech_nc, :box ,
79
+ x= x0,
80
+ q= one (UnitQuaternion),
81
+ v= v0,
83
82
ω= ω0)
84
83
85
- storage_nc = simulate! (mech_nc, 4.0 ,
86
- record= true ,
84
+ storage_nc = simulate! (mech_nc, 4.0 ,
85
+ record= true ,
87
86
opts= opts)
88
87
89
88
# ## Visualize
90
89
for (i, x) in enumerate (storage_nc. x[1 ])
91
- storage_nc. x[1 ][i] += [0.0 ; 0.0 ; 0.1 ]
90
+ storage_nc. x[1 ][i] += [0.0 ; 0.0 ; 0.1 ]
92
91
end
93
92
94
93
line_mat_nc = LineBasicMaterial (color= color_nc, linewidth= 25.0 )
@@ -99,34 +98,34 @@ for (i, xt) in enumerate(storage_nc.x[1])
99
98
end
100
99
setobject! (vis[:path_nc ], MeshCat. Line (points_nc, line_mat_nc))
101
100
102
- vis, anim = visualize (mech_nc, storage_nc,
103
- vis= vis,
104
- name= :nc ,
101
+ vis, anim = visualize (mech_nc, storage_nc,
102
+ vis= vis,
103
+ name= :nc ,
105
104
animation= anim)
106
105
107
106
# ## MuJoCo cone
108
107
color_mj = magenta;
109
108
110
- mech_mj = get_mechanism (:box ,
111
- timestep= timestep,
112
- gravity= gravity,
109
+ mech_mj = get_mechanism (:box ,
110
+ timestep= timestep,
111
+ gravity= gravity,
113
112
friction_coefficient= friction_coefficient,
114
- contact_type= :linear ,
113
+ contact_type= :linear ,
115
114
mode= :box , color= color_mj);
116
115
117
116
# ## Load
118
- initialize! (mech_mj, :box ,
119
- x= x0,
120
- q= one (UnitQuaternion),
121
- v= v0,
117
+ initialize! (mech_mj, :box ,
118
+ x= x0,
119
+ q= one (UnitQuaternion),
120
+ v= v0,
122
121
ω= ω0)
123
122
file = jldopen (joinpath (@__DIR__ , " ../MuJoCo_benchmark/results/cone_compare.jld2" ))
124
123
storage_mj = generate_storage (mech_mj, [get_maximal_state (mech_mj), file[" ztraj" ]. .. ])
125
124
126
125
# ## Visualize
127
- vis, anim = visualize (mech_mj, storage_mj,
128
- vis= vis,
129
- name= :mj ,
126
+ vis, anim = visualize (mech_mj, storage_mj,
127
+ vis= vis,
128
+ name= :mj ,
130
129
animation= anim)
131
130
132
131
line_mat_mj = LineBasicMaterial (color= color_mj, linewidth= 25.0 )
0 commit comments