Skip to content

Commit

Permalink
Updated domain randomization to work in parallel mode now.
Browse files Browse the repository at this point in the history
- now a separate domain randomization handler is used.
  • Loading branch information
robfiras committed Oct 5, 2023
1 parent 638132a commit 6380d8c
Show file tree
Hide file tree
Showing 16 changed files with 364 additions and 2,690 deletions.
321 changes: 14 additions & 307 deletions examples/domain_randomization/atlas.yaml
Original file line number Diff line number Diff line change
@@ -1,327 +1,34 @@
Joints:
# set either a sigma for sampling from a normal distirbution or set a delta-range for uniform sampling.
back_bkz:
damping:
sigma: 0.0
uniform_range: null
stiffness:
sigma: 0.0
uniform_range: null
armature:
sigma: 0.0
uniform_range: null
frictionloss:
sigma: 0.0
uniform_range: null
back_bkx:
damping:
sigma: 0.0
uniform_range: null
stiffness:
sigma: 0.0
uniform_range: null
armature:
sigma: 0.0
uniform_range: null
frictionloss:
sigma: 0.0
uniform_range: null
back_bky:
damping:
sigma: 0.0
uniform_range: null
stiffness:
sigma: 0.0
uniform_range: null
armature:
sigma: 0.0
uniform_range: null
frictionloss:
sigma: 0.0
uniform_range: null
l_arm_shz:
damping:
sigma: 0.0
uniform_range: null
stiffness:
sigma: 0.0
uniform_range: null
armature:
sigma: 0.0
uniform_range: null
frictionloss:
sigma: 0.0
uniform_range: null
l_arm_shx:
damping:
sigma: 0.0
uniform_range: null
stiffness:
sigma: 0.0
uniform_range: null
armature:
sigma: 0.0
uniform_range: null
frictionloss:
sigma: 0.0
uniform_range: null
l_arm_ely:
damping:
sigma: 0.0
uniform_range: null
stiffness:
sigma: 0.0
uniform_range: null
armature:
sigma: 0.0
uniform_range: null
frictionloss:
sigma: 0.0
uniform_range: null
l_arm_elx:
damping:
sigma: 0.0
uniform_range: null
stiffness:
sigma: 0.0
uniform_range: null
armature:
sigma: 0.0
uniform_range: null
frictionloss:
sigma: 0.0
uniform_range: null
l_arm_wry:
damping:
sigma: 0.0
uniform_range: null
stiffness:
sigma: 0.0
uniform_range: null
armature:
sigma: 0.0
uniform_range: null
frictionloss:
sigma: 0.0
uniform_range: null
l_arm_wrx:
damping:
sigma: 0.0
uniform_range: null
stiffness:
sigma: 0.0
uniform_range: null
armature:
sigma: 0.0
uniform_range: null
frictionloss:
sigma: 0.0
uniform_range: null
r_arm_shz:
damping:
sigma: 0.0
uniform_range: null
stiffness:
sigma: 0.0
uniform_range: null
armature:
sigma: 0.0
uniform_range: null
frictionloss:
sigma: 0.0
uniform_range: null
r_arm_shx:
damping:
sigma: 0.0
uniform_range: null
stiffness:
sigma: 0.0
uniform_range: null
armature:
sigma: 0.0
uniform_range: null
frictionloss:
sigma: 0.0
uniform_range: null
r_arm_ely:
damping:
sigma: 0.0
uniform_range: null
stiffness:
sigma: 0.0
uniform_range: null
armature:
sigma: 0.0
uniform_range: null
frictionloss:
sigma: 0.0
uniform_range: null
r_arm_elx:
damping:
sigma: 0.0
uniform_range: null
stiffness:
sigma: 0.0
uniform_range: null
armature:
sigma: 0.0
uniform_range: null
frictionloss:
sigma: 0.0
uniform_range: null
r_arm_wry:
damping:
sigma: 0.0
uniform_range: null
stiffness:
sigma: 0.0
uniform_range: null
armature:
sigma: 0.0
uniform_range: null
frictionloss:
sigma: 0.0
uniform_range: null
r_arm_wrx:
damping:
sigma: 0.0
uniform_range: null
stiffness:
sigma: 0.0
uniform_range: null
armature:
sigma: 0.0
uniform_range: null
frictionloss:
sigma: 0.0
uniform_range: null
hip_flexion_r:
damping:
sigma: 0.0
uniform_range: null
stiffness:
sigma: 0.0
uniform_range: null
armature:
sigma: 0.0
uniform_range: null
frictionloss:
sigma: 0.0
uniform_range: null
hip_adduction_r:
damping:
sigma: 0.0
uniform_range: null
stiffness:
sigma: 0.0
uniform_range: null
armature:
sigma: 0.0
uniform_range: null
frictionloss:
sigma: 0.0
uniform_range: null
hip_rotation_r:
damping:
sigma: 0.0
uniform_range: null
stiffness:
sigma: 0.0
uniform_range: null
armature:
sigma: 0.0
uniform_range: null
frictionloss:
sigma: 0.0
uniform_range: null
knee_angle_r:
damping:
sigma: 0.0
uniform_range: null
stiffness:
sigma: 0.0
uniform_range: null
armature:
sigma: 0.0
uniform_range: null
frictionloss:
sigma: 0.0
uniform_range: null
ankle_angle_r:
# here a default randomizaiton can be set for all joints.
Default:
# these joints will not be included during domain randomization.
exclude: ["pelvis_tx", "pelvis_ty", "pelvis_tz", "pelvis_tilt", "pelvis_list", "pelvis_rotation"]
Joints:
damping:
sigma: 0.0
uniform_range: null
stiffness:
sigma: 0.0
uniform_range: null
armature:
sigma: 0.0
uniform_range: null
frictionloss:
sigma: 0.0
uniform_range: null
hip_flexion_l:
damping:
sigma: 0.0
uniform_range: null
stiffness:
sigma: 0.0
uniform_range: null
armature:
sigma: 0.0
uniform_range: null
frictionloss:
sigma: 0.0
uniform_range: null
hip_adduction_l:
damping:
sigma: 0.0
uniform_range: null
stiffness:
sigma: 0.0
uniform_range: null
armature:
sigma: 0.0
uniform_range: null
frictionloss:
sigma: 0.0
uniform_range: null
hip_rotation_l:
damping:
sigma: 0.0
uniform_range: null
stiffness:
sigma: 0.0
uniform_range: null
armature:
sigma: 0.0
uniform_range: null
frictionloss:
sigma: 0.0
uniform_range: null
knee_angle_l:

# here joint specific configurations can be made
Joints:
# set either a sigma for sampling from a normal distirbution or set a delta-range for uniform sampling.
back_bkz:
damping:
sigma: 0.0
uniform_range: null
uniform_range: [4.0, 6.0]
stiffness:
sigma: 0.0
uniform_range: null
armature:
sigma: 0.0
uniform_range: null
frictionloss:
sigma: 0.0
uniform_range: null
ankle_angle_l:
back_bkx:
damping:
sigma: 0.0
uniform_range: null
uniform_range: [4.0, 6.0]
stiffness:
sigma: 0.0
uniform_range: null
armature:
sigma: 0.0
uniform_range: null
frictionloss:
sigma: 0.0
uniform_range: null

22 changes: 22 additions & 0 deletions examples/domain_randomization/example_humanoid_muscle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import numpy as np
from loco_mujoco import LocoEnv


env = LocoEnv.make("HumanoidMuscle", disable_arms=False, use_box_feet=False, domain_randomization_config="./humanoid.yaml")

action_dim = env.info.action_space.shape[0]

env.reset()
env.render()
absorbing = False
i = 0

while True:
if i == 1000 or absorbing:
env.reset()
i = 0
action = np.random.randn(action_dim)
nstate, _, absorbing, _ = env.step(action)

env.render()
i += 1
8 changes: 6 additions & 2 deletions examples/domain_randomization/example_humanoid_torque.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
import numpy as np
from loco_mujoco import LocoEnv

import time

env = LocoEnv.make("HumanoidTorque", domain_randomization_config="./humanoid.yaml")

action_dim = env.info.action_space.shape[0]

np.random.seed(0)
env.reset()
env.render()
absorbing = False
i = 0

while True:
start_time = time.time()
for j in range(100):
if i == 1000 or absorbing:
env.reset()
i = 0
print(j)
action = np.random.randn(action_dim)
nstate, _, absorbing, _ = env.step(action)

env.render()
i += 1
print("Time needed: ", time.time() - start_time)
Loading

0 comments on commit 6380d8c

Please sign in to comment.