Skip to content

Instantly share code, notes, and snippets.

@klowrey
Last active November 28, 2018 22:40
Show Gist options
  • Save klowrey/ced25f2cb73e222665264877f06f696f to your computer and use it in GitHub Desktop.
Save klowrey/ced25f2cb73e222665264877f06f696f to your computer and use it in GitHub Desktop.
mujoco.jl rollouts
using MuJoCo
function dorollout(f, T)
pm = mj_loadXML(f)
pd = mj_makeData(pm)
m = mj.mapmodel(pm)
datas = [ mj.mapdata(pm, mj_makeData(pm)) for t=1:Threads.nthreads() ]
@time begin
Threads.@threads for k=1:Threads.nthreads()
for t=1:T
mj_step(m, datas[k])
end
end
end
for t=1:Threads.nthreads()
println(datas[t].d)
mj_deleteData(datas[t])
end
mj_deleteModel(m)
end
f = "models/humanoid.xml"
dorollout(f, 1000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment