Skip to content

Commit cf3e6f7

Browse files
committed
more documentation
1 parent 52fc96f commit cf3e6f7

32 files changed

+298
-160
lines changed

docs/make.jl

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,6 @@ push!(LOAD_PATH, "../src/")
22

33
using Documenter#, Dojo
44

5-
# # copy animations from src/examples/animations to docs/src/animations
6-
# path_doc_animations = joinpath(@__DIR__, "src/animations")
7-
# !isdir(path_doc_animations) && mkdir(path_doc_animations)
8-
# path_animations = joinpath(@__DIR__, "../examples/animations")
9-
# files = readdir(path_animations)
10-
# filter!(x -> endswith(x, ".gif"), files)
11-
# for file in files
12-
# cp(joinpath(path_animations, file), joinpath(path_doc_animations, file))
13-
# end
14-
155
makedocs(
166
modules = [Dojo],
177
format = Documenter.HTML(prettyurls = false),

environments/dynamics.jl

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,46 @@
1-
################################################################################
2-
# Step
3-
################################################################################
1+
"""
2+
dynamics(y, env, x, u, w)
3+
4+
evaluates an environment's dynamics (in-place)
5+
6+
y: state at next time step
7+
env: Environment
8+
x: state at current time step
9+
u: input
10+
w: system parameters
11+
"""
412
function dynamics(y, env::Environment, x, u, w)
513
step(env, x, u)[1]
614
y .= env.state
715
end
816

17+
"""
18+
dynamics_jacobian_state(dx, env, x, u, w)
19+
20+
evaluates an environment's dynamics Jacobian wrt state (in-place)
21+
22+
dx: state Jacobian at next time step
23+
env: Environment
24+
x: state at current time step
25+
u: input
26+
w: system parameters
27+
"""
928
function dynamics_jacobian_state(dx, env::Environment, x, u, w)
1029
step(env, x, u, diff=true)
1130
dx .= env.dynamics_jacobian_state
1231
end
1332

33+
"""
34+
dynamics_jacobian_input(du, env, x, u, w)
35+
36+
evaluates an environment's dynamics Jacobian wrt input (in-place)
37+
38+
du: input Jacobian at next time step
39+
env: Environment
40+
x: state at current time step
41+
u: input
42+
w: system parameters
43+
"""
1444
function dynamics_jacobian_input(du, env::Environment, x, u, w)
1545
# step(env, x, u, diff=true) # this is run in dynamics_jacobian_state
1646
du .= env.dynamics_jacobian_input

environments/environment.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ end
4949
5050
construct existing environment
5151
52-
model: String, name of of environment
52+
model: name of of environment
5353
kwargs: environment specific parameters
5454
"""
55-
function get_environment(model::String; kwargs...)
55+
function get_environment(model; kwargs...)
5656
return eval(Symbol(model))(; kwargs...)
5757
end
5858

environments/include.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,6 @@ include("hopper/methods/env.jl")
3535
include("pendulum/methods/env.jl")
3636
include("quadruped/methods/env.jl")
3737
include("raiberthopper/methods/env.jl")
38+
include("rexhopper/methods/env.jl")
3839
include("walker/methods/env.jl")
3940
include("box/methods/env.jl")

examples/animations/generate/ant.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ MeshCat.setanimation!(env.vis, anim)
1616
set_camera!(env.vis, cam_pos=[0,0,90], zoom=20)
1717

1818
# ## Ghost
19-
env = get_environment("ant", representation=:minimal, g=-9.81, timestep=0.05, damper=50.0, spring=25.0, friction_coefficient = 0.5,
19+
env = get_environment(:ant, representation=:minimal, g=-9.81, timestep=0.05, damper=50.0, spring=25.0, friction_coefficient = 0.5,
2020
contact=true, contact_body=true)
2121
open(env.vis)
2222
setvisible!(env.vis[:robot], false)
@@ -30,7 +30,7 @@ end
3030

3131

3232
# ## test random policy
33-
env = get_environment("ant", representation=:minimal, g=-9.81, timestep=0.05, damper=25.0, spring=10.0, friction_coefficient = 0.5,
33+
env = get_environment(:ant, representation=:minimal, g=-9.81, timestep=0.05, damper=25.0, spring=10.0, friction_coefficient = 0.5,
3434
contact=true, contact_body=true)
3535
# initialize!(env.mechanism, :ant)
3636
open(env.vis)

examples/animations/generate/halfcheetah.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ end
1414
MeshCat.setanimation!(env.vis, anim)
1515

1616
# ## Ghost
17-
env = get_environment("halfcheetah", timestep=0.05)
17+
env = get_environment(:halfcheetah, timestep=0.05)
1818
open(env.vis)
1919
setvisible!(env.vis[:robot], false)
2020
timesteps = [1, 50, 60, 70, 80, 90, 100, 108, T]
@@ -32,7 +32,7 @@ end
3232

3333

3434
## test random policy
35-
env = get_environment("halfcheetah", representation=:minimal, g=-9.81, timestep=0.05)
35+
env = get_environment(:halfcheetah, representation=:minimal, g=-9.81, timestep=0.05)
3636
initialize!(env.mechanism, :halfcheetah)
3737
open(env.vis)
3838
# storage = simulate!(env.mechanism, 1.0, record=true, verbose=false)

examples/reinforcement_learning/ant_ars.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ using LinearAlgebra
99
include(joinpath(@__DIR__, "algorithms/ars.jl")) # augmented random search
1010

1111
# ## Ant
12-
env = get_environment("ant",
12+
env = get_environment(:ant,
1313
representation=:minimal,
1414
gravity=-9.81,
1515
timestep=0.05,

examples/reinforcement_learning/dev/ags_halfcheetah.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ include("../ags.jl")
2323

2424

2525
opts_grad = SolverOptions(rtol = 1e-4, btol = 1e-3, undercut = 2.0)
26-
env = get_environment("halfcheetah", vis=vis, dt = 0.05, opts_grad = opts_grad)
26+
env = get_environment(halfcheetah", vis=vis, dt = 0.05, opts_grad = opts_grad)
2727
obs = reset(env)
2828
render(env)
2929
input_size = length(obs)

examples/reinforcement_learning/halfcheetah_ars.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ using LinearAlgebra
99
include(joinpath(@__DIR__, "algorithms/ars.jl")) # augmented random search
1010

1111
# ## Environment
12-
env = get_environment("halfcheetah",
12+
env = get_environment(:halfcheetah,
1313
timestep=0.05)
1414
obs = reset(env)
1515

examples/simulation/atlas_drop.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ storage = simulate!(mech, 5.0,
2626
opts=SolverOptions(rtol=1.0e-6, btol=1.0e-6, verbose=true))
2727

2828
# ## Visualize
29-
vis=visualizer()
29+
vis = Visualizer()
3030
render(vis)
3131
visualize(mech, storage,
3232
vis=vis, show_contact=true)

0 commit comments

Comments
 (0)