5
5
"""
6
6
struct Walker end
7
7
8
- function walker (; mode:: Symbol = :minimal , dt:: T = 0.05 , gravity= [0.0 ; 0.0 ; - 9.81 ],
9
- friction_coefficient:: T = 1.9 , spring= 0.0 , damper= 0.1 ,
10
- seed= 1 , contact:: Bool = true , info= nothing , vis:: Visualizer = Visualizer (), name:: Symbol = :robot ,
11
- opts_step= SolverOptions (), opts_grad= SolverOptions ()) where T
8
+ function walker (;
9
+ mode:: Symbol = :minimal ,
10
+ timestep= 0.05 ,
11
+ gravity= [0.0 ; 0.0 ; - 9.81 ],
12
+ friction_coefficient= 1.9 ,
13
+ spring= 0.0 ,
14
+ damper= 0.1 ,
15
+ seed= 1 ,
16
+ contact_feet= true ,
17
+ contact_body= true ,
18
+ info= nothing ,
19
+ vis= Visualizer (),
20
+ name= :robot ,
21
+ opts_step= SolverOptions (),
22
+ opts_grad= SolverOptions (),
23
+ T= Float64)
24
+
25
+ mechanism = get_walker (
26
+ timestep= timestep,
27
+ gravity= gravity,
28
+ friction_coefficient= friction_coefficient,
29
+ spring= spring,
30
+ damper= damper,
31
+ contact_feet= contact_feet,
32
+ contact_body= contact_body)
12
33
13
- mechanism = get_walker (timestep= dt, gravity= gravity, friction_coefficient= friction_coefficient, spring= spring, damper= damper, contact= contact)
14
34
initialize_walker! (mechanism)
15
35
16
36
if mode == :minimal
@@ -40,9 +60,11 @@ function walker(; mode::Symbol=:minimal, dt::T=0.05, gravity=[0.0; 0.0; -9.81],
40
60
u_prev = zeros (nu)
41
61
control_mask = [zeros (nu, 3 ) I (nu)]
42
62
motor_gear = [100 , 100 , 100 , 100 , 100 , 100. ]
43
- control_scaling = Diagonal (dt * motor_gear)
63
+ control_scaling = Diagonal (timestep * motor_gear)
44
64
45
- build_robot (mechanism, vis= vis, name= name)
65
+ build_robot (mechanism,
66
+ vis= vis,
67
+ name= name)
46
68
47
69
TYPES = [Walker, T, typeof (mechanism), typeof (aspace), typeof (ospace), typeof (info)]
48
70
env = Environment {TYPES...} (mechanism, mode, aspace, ospace,
@@ -61,7 +83,8 @@ function reset(env::Environment{Walker}; x=nothing, reset_noise_scale = 0.005)
61
83
env. state .= x
62
84
else
63
85
# initialize above the ground to make sure that with random initialization we do not violate the ground constraint.
64
- initialize! (env. mechanism, :walker , z = 0.25 )
86
+ initialize! (env. mechanism, :walker ,
87
+ z= 0.25 )
65
88
x0 = get_minimal_state (env. mechanism)
66
89
nx = minimal_dimension (env. mechanism)
67
90
@@ -80,7 +103,8 @@ function reset(env::Environment{Walker}; x=nothing, reset_noise_scale = 0.005)
80
103
return get_observation (env)
81
104
end
82
105
83
- function get_observation (env:: Environment{Walker} ; full_state:: Bool = false )
106
+ function get_observation (env:: Environment{Walker} ;
107
+ full_state= false )
84
108
full_state && (return env. state)
85
109
nx = minimal_dimension (env. mechanism)
86
110
if env. representation == :minimal
@@ -124,19 +148,3 @@ function is_done(::Environment{Walker}, x)
124
148
done = ! ((height > 0.8 ) && (height < 2.0 ) && (abs (ang) < 1.0 ))
125
149
return done
126
150
end
127
-
128
-
129
- #
130
- # env.state
131
- # i_torso = findfirst(body -> body.name == "torso", collect(env.mechanism.bodies))
132
- # z_torso = z[(i_torso-1)*13 .+ (1:13)]
133
- # x_velocity = z_torso[4]
134
- # z[3*13 + 4] = 324.0
135
- # z
136
- # set_maximal_state!(env.mechanism, z)
137
- #
138
- # initialize!(env.mechanism, :walker, x = 111.0, z = 1.0, θ=0.18)
139
- # x = get_minimal_state(env.mechanism)
140
- # z = get_maximal_state(env.mechanism)
141
- # is_done(env, x)
142
- #
0 commit comments