google-deepmind / google-deepmind/rgb_stacking

Domain Randomization Help

Open
#5 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
132
Forks
13
PR merge metrics
No merged PRs in 30d

Description

Hi I am trying to implement domain randomization.

1) Between scene_initialization and domain initialization where will be the best place to initialize the physics, mass as mentioined in the paper.

2) How does one really initialize the friction, Can you please examine my code.

3) How does one implement action delay, are the rewards and observations delayed too

@dataclasses.dataclass
class DomainRandomizer:
def __init__(self, basket, props, robot):

self.props = props
self.basket = basket
self.arm = robot.arm
self.gripper = robot.gripper

self.gripper_friction = Uniform([0.3, 0.1, 0.05], [0.6, 0.1, 0.005])

friction, mass, low, hi = np.array([1, 0.005, 0.0001], float), 0.201, 0.9, 1.1
self.object_rand = dict(friction=Uniform(friction * low, friction * hi),
mass=Uniform(mass * low, mass * hi))

friction = np.array([0.1, 0.1, 0.0001], float)
self.arm_rand = dict(friction=Uniform(friction * low, friction * hi),
damping=Uniform(0.1 * low, 0.1 * hi),
armature=Uniform(low, hi),
friction_loss=Uniform(0.3 * low, 0.3 * hi))

friction = np.array([1, 0.005, 0.0001], float)
self.hand_rand = dict(friction=Uniform(friction * low, friction * hi),
driver_damping=Uniform(0.2 * low, 0.2 * hi),
armature=Uniform(0.1 * low, 0.1 * hi),
spring_link_damping=Uniform(0.00125 * low, 0.00125 * hi))

friction = np.array([1.0, 0.001, 0.001], float)
self.basket_friction = Uniform(friction * low, friction * hi)

gear_ratio = np.array([1, 0, 0, 0, 0, 0], float)
self.actuator_gear = Uniform(gear_ratio * low, gear_ratio * hi)

def __call__(self, random_state: np.random.RandomState) -> bool:
for p in self.props:
collision_geom = p.mjcf_model.find_all('geom')[1]
collision_geom.friction = self.object_rand['friction'].sample()

basket_geoms = self.basket.mjcf_model.find_all('geom')
for b in basket_geoms:
b.friction = self.basket_friction.sample()

hand_driver = self.gripper.mjcf_model.find('default', 'driver')
hand_spring_link = self.gripper.mjcf_model.find('default', 'spring_link')
hand = self.gripper.mjcf_model.find('default', 'reinforced_fingertip')

hand.geom.friction = self.hand_rand['friction'].sample()
hand_driver.joint.armature = self.hand_rand['armature'].sample()
hand_driver.joint.damping = self.hand_rand['driver_damping'].sample()
hand_spring_link.joint.damping = self.hand_rand['spring_link_damping'].sample()

for joint in self.arm.joints:
joint.armature = self.arm_rand['armature'].sample()
joint.damping = self.arm_rand['damping'].sample()
joint.frictionloss = self.arm_rand['friction_loss'].sample()

for actuator in self.arm.actuators:
actuator.gear = self.actuator_gear.sample()

geoms = self.arm.mjcf_model.find_all('geom')
for g in geoms:
g.friction = self.arm_rand['friction'].sample()

return True

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.