def realworld_swingup(time_limit=_DEFAULT_TIME_LIMIT, random=None, log_output=None, environment_kwargs=None, safety_spec=None, delay_spec=None, noise_spec=None, perturb_spec=None, dimensionality_spec=None, multiobj_spec=None, combined_challenge=None): """Returns the Cartpole Swing-Up task with specified real world attributes. Args: time_limit: Integer length of task random: random seed (unsure) log_output: String of path for pickle data logging, None disables logging environment_kwargs: additional kwargs for environment. safety_spec: dictionary that specifies the safety specifications. delay_spec: dictionary that specifies the delay specifications. noise_spec: dictionary that specifies the noise specifications. perturb_spec: dictionary that specifies the perturbations specifications. dimensionality_spec: dictionary that specifies extra observation features. multiobj_spec: dictionary that specifies complementary objectives. combined_challenge: string that can be 'easy', 'medium', or 'hard'. Specifying the combined challenge (can't be used with any other spec). """ physics = Physics.from_xml_string(*cartpole.get_model_and_assets()) safety_spec = safety_spec or {} delay_spec = delay_spec or {} noise_spec = noise_spec or {} perturb_spec = perturb_spec or {} dimensionality_spec = dimensionality_spec or {} multiobj_spec = multiobj_spec or {} # Check and update for combined challenge. (delay_spec, noise_spec, perturb_spec, dimensionality_spec) = (realworld_env.get_combined_challenge( combined_challenge, delay_spec, noise_spec, perturb_spec, dimensionality_spec)) # Updating perturbation parameters if combined_challenge. if combined_challenge == 'easy': perturb_spec.update({ 'param': 'pole_length', 'min': 0.9, 'max': 1.1, 'std': 0.02 }) elif combined_challenge == 'medium': perturb_spec.update({ 'param': 'pole_length', 'min': 0.7, 'max': 1.7, 'std': 0.1 }) elif combined_challenge == 'hard': perturb_spec.update({ 'param': 'pole_length', 'min': 0.5, 'max': 2.3, 'std': 0.15 }) if 'limits' not in safety_spec: if 'safety_coeff' in safety_spec: if safety_spec['safety_coeff'] < 0 or safety_spec[ 'safety_coeff'] > 1: raise ValueError( 'safety_coeff should be in [0,1], but got {}'.format( safety_spec['safety_coeff'])) safety_coeff = safety_spec['safety_coeff'] else: safety_coeff = 1 safety_spec['limits'] = { 'slider_pos_constraint': safety_coeff * np.array([-2, 2]), # m 'balance_velocity_constraint': np.array([(1 - safety_coeff) / 0.5 + 0.15, safety_coeff * 0.5]), # rad, rad/s 'slider_accel_constraint': safety_coeff * 130, # m/s^2 'action_roc_constraint': safety_coeff * 1.5, } task = RealWorldBalance(swing_up=True, sparse=False, random=random, safety_spec=safety_spec, delay_spec=delay_spec, noise_spec=noise_spec, perturb_spec=perturb_spec, dimensionality_spec=dimensionality_spec, multiobj_spec=multiobj_spec) environment_kwargs = environment_kwargs or {} if log_output: logger = loggers.PickleLogger(path=log_output) else: logger = None return wrappers.LoggingEnv(physics, task, logger=logger, time_limit=time_limit, **environment_kwargs)
def realworld_balance(time_limit=_DEFAULT_TIME_LIMIT, random=None, log_output=None, environment_kwargs=None, safety_spec=None, delay_spec=None, noise_spec=None, perturb_spec=None, dimensionality_spec=None, multiobj_spec=None, combined_challenge=None): """Returns the Cartpole Balance task with specified real world attributes. Args: time_limit: Integer length of task random: random seed (unsure) log_output: String of path for pickle data logging, None disables logging. environment_kwargs: additional kwargs for environment. safety_spec: dictionary that specifies the safety specifications. delay_spec: dictionary that specifies the delay specifications. noise_spec: dictionary that specifies the noise specifications. perturb_spec: dictionary that specifies the perturbations specifications. dimensionality_spec: dictionary that specifies extra observation features. multiobj_spec: dictionary that specifies complementary objectives. combined_challenge: string that can be 'easy', 'medium', or 'hard'. Specifying the combined challenge (can't be used with any other spec). """ physics = Physics.from_xml_string(*cartpole.get_model_and_assets()) safety_spec = safety_spec or {} delay_spec = delay_spec or {} noise_spec = noise_spec or {} perturb_spec = perturb_spec or {} dimensionality_spec = dimensionality_spec or {} multiobj_spec = multiobj_spec or {} # Check and update for combined challenge. (delay_spec, noise_spec, perturb_spec, dimensionality_spec) = (realworld_env.get_combined_challenge( combined_challenge, delay_spec, noise_spec, perturb_spec, dimensionality_spec)) # Updating perturbation parameters if combined_challenge. if combined_challenge == 'easy': perturb_spec.update({ 'param': 'pole_length', 'min': 0.9, 'max': 1.1, 'std': 0.02 }) elif combined_challenge == 'medium': perturb_spec.update({ 'param': 'pole_length', 'min': 0.7, 'max': 1.7, 'std': 0.1 }) elif combined_challenge == 'hard': perturb_spec.update({ 'param': 'pole_length', 'min': 0.5, 'max': 2.3, 'std': 0.15 }) task = RealWorldBalance(swing_up=False, sparse=False, random=random, safety_spec=safety_spec, delay_spec=delay_spec, noise_spec=noise_spec, perturb_spec=perturb_spec, dimensionality_spec=dimensionality_spec, multiobj_spec=multiobj_spec) environment_kwargs = environment_kwargs or {} if log_output: logger = loggers.PickleLogger(path=log_output) else: logger = None return wrappers.LoggingEnv(physics, task, logger=logger, time_limit=time_limit, **environment_kwargs)
def realworld_stand(time_limit=_DEFAULT_TIME_LIMIT, random=None, log_output=None, environment_kwargs=None, safety_spec=None, delay_spec=None, noise_spec=None, perturb_spec=None, dimensionality_spec=None, multiobj_spec=None, combined_challenge=None): """Returns the Stand task. Args: time_limit: Integer length of task random: random seed (unsure) log_output: String of path for pickle data logging, None disables logging environment_kwargs: additional kwargs for environment. safety_spec: dictionary that specifies the safety specifications. delay_spec: dictionary that specifies the delay specifications. noise_spec: dictionary that specifies the noise specifications. perturb_spec: dictionary that specifies the perturbations specifications. dimensionality_spec: dictionary that specifies extra observation features. multiobj_spec: dictionary that specifies complementary objectives. combined_challenge: string that can be 'easy', 'medium', or 'hard'. Specifying the combined challenge (can't be used with any other spec). """ physics = walker.Physics.from_xml_string(*walker.get_model_and_assets()) safety_spec = safety_spec or {} delay_spec = delay_spec or {} noise_spec = noise_spec or {} perturb_spec = perturb_spec or {} dimensionality_spec = dimensionality_spec or {} multiobj_spec = multiobj_spec or {} # Check and update for combined challenge. (delay_spec, noise_spec, perturb_spec, dimensionality_spec) = ( realworld_env.get_combined_challenge( combined_challenge, delay_spec, noise_spec, perturb_spec, dimensionality_spec, safety_spec, multiobj_spec)) # Updating perturbation parameters if combined_challenge. if combined_challenge == 'easy': perturb_spec.update( {'param': 'thigh_length', 'min': 0.225, 'max': 0.25, 'std': 0.002}) elif combined_challenge == 'medium': perturb_spec.update( {'param': 'thigh_length', 'min': 0.225, 'max': 0.4, 'std': 0.015}) elif combined_challenge == 'hard': perturb_spec.update( {'param': 'thigh_length', 'min': 0.225, 'max': 0.55, 'std': 0.04}) task = RealWorldPlanarWalker( move_speed=0, random=random, safety_spec=safety_spec, delay_spec=delay_spec, noise_spec=noise_spec, perturb_spec=perturb_spec, dimensionality_spec=dimensionality_spec, multiobj_spec=multiobj_spec) environment_kwargs = environment_kwargs or {} if log_output: logger = loggers.PickleLogger(path=log_output) else: logger = None return wrappers.LoggingEnv( physics, task, logger=logger, time_limit=time_limit, control_timestep=_CONTROL_TIMESTEP, **environment_kwargs)
def gen_task(use_peg, insert, fully_observable=True, time_limit=_TIME_LIMIT, random=None, log_output=None, environment_kwargs=None, safety_spec=None, delay_spec=None, noise_spec=None, perturb_spec=None, dimensionality_spec=None, multiobj_spec=None, combined_challenge=None): """Returns the Manipulator Bring task with specified real world attributes. Args: use_peg: A `bool`, whether to replace the ball prop with the peg prop. insert: A `bool`, whether to insert the prop in a receptacle. fully_observable: A `bool`, whether the observation should contain the position and velocity of the object being manipulated and the target location. time_limit: Integer length of task random: Optional, either a `numpy.random.RandomState` instance, an integer seed for creating a new `RandomState`, or None to select a seed automatically (default). log_output: String of path for pickle data logging, None disables logging environment_kwargs: additional kwargs for environment safety_spec: dictionary that specifies the safety specifications. delay_spec: dictionary that specifies the delay. noise_spec: dictionary that specifies the noise specifications. perturb_spec: dictionary that specifies the perturbations specifications. dimensionality_spec: dictionary that specifies extra observation features. multiobj_spec: dictionary that specifies complementary objectives. combined_challenge: string that can be 'easy', 'medium', or 'hard'. Specifying the combined challenge (can't be used with any other spec). """ physics = manipulator.Physics.from_xml_string( *manipulator.make_model(use_peg, insert)) safety_spec = safety_spec or {} delay_spec = delay_spec or {} noise_spec = noise_spec or {} perturb_spec = perturb_spec or {} dimensionality_spec = dimensionality_spec or {} multiobj_spec = multiobj_spec or {} # Check and update for combined challenge. (delay_spec, noise_spec, perturb_spec, dimensionality_spec) = (realworld_env.get_combined_challenge( combined_challenge, delay_spec, noise_spec, perturb_spec, dimensionality_spec, safety_spec, multiobj_spec)) task = RealWorldBring(use_peg=use_peg, insert=insert, fully_observable=fully_observable, safety_spec=safety_spec, delay_spec=delay_spec, noise_spec=noise_spec, perturb_spec=perturb_spec, dimensionality_spec=dimensionality_spec, multiobj_spec=multiobj_spec, random=random) environment_kwargs = environment_kwargs or {} if log_output: logger = loggers.PickleLogger(path=log_output) else: logger = None return wrappers.LoggingEnv(physics, task, logger=logger, control_timestep=_CONTROL_TIMESTEP, time_limit=time_limit, **environment_kwargs)
def realworld_run(time_limit=_DEFAULT_TIME_LIMIT, random=None, log_output=None, environment_kwargs=None, safety_spec=None, delay_spec=None, noise_spec=None, perturb_spec=None, dimensionality_spec=None, multiobj_spec=None, combined_challenge=None): """Returns the Run task. Args: time_limit: Integer length of task random: random seed (unsure) log_output: String of path for pickle data logging, None disables logging environment_kwargs: additional kwargs for environment. safety_spec: dictionary that specifies the safety specifications. delay_spec: dictionary that specifies the delay specifications. noise_spec: dictionary that specifies the noise specifications. perturb_spec: dictionary that specifies the perturbations specifications. dimensionality_spec: dictionary that specifies extra observation features. multiobj_spec: dictionary that specifies complementary objectives. combined_challenge: string that can be 'easy', 'medium', or 'hard'. Specifying the combined challenge (can't be used with any other spec). """ xml_string = quadruped.make_model(floor_size=_DEFAULT_TIME_LIMIT * _RUN_SPEED) physics = quadruped.Physics.from_xml_string(xml_string, common.ASSETS) safety_spec = safety_spec or {} delay_spec = delay_spec or {} noise_spec = noise_spec or {} perturb_spec = perturb_spec or {} dimensionality_spec = dimensionality_spec or {} multiobj_spec = multiobj_spec or {} # Check and update for combined challenge. (delay_spec, noise_spec, perturb_spec, dimensionality_spec) = (realworld_env.get_combined_challenge( combined_challenge, delay_spec, noise_spec, perturb_spec, dimensionality_spec)) # Updating perturbation parameters if combined_challenge. if combined_challenge == 'easy': perturb_spec.update({ 'param': 'shin_length', 'min': 0.25, 'max': 0.3, 'std': 0.005 }) elif combined_challenge == 'medium': perturb_spec.update({ 'param': 'shin_length', 'min': 0.25, 'max': 0.8, 'std': 0.05 }) elif combined_challenge == 'hard': perturb_spec.update({ 'param': 'shin_length', 'min': 0.25, 'max': 1.4, 'std': 0.1 }) if 'limits' not in safety_spec: if 'safety_coeff' in safety_spec: if safety_spec['safety_coeff'] < 0 or safety_spec[ 'safety_coeff'] > 1: raise ValueError( 'safety_coeff should be in [0,1], but got {}'.format( safety_spec['safety_coeff'])) safety_coeff = safety_spec['safety_coeff'] else: safety_coeff = 1 safety_spec['limits'] = { 'joint_pos_constraint': safety_coeff * 60 * np.pi / 180, # rad 'joint_velocity_constraint': safety_coeff * 0.4, # rad/s 'upright_constraint': 1 - safety_coeff * 0.7, # minimum z 'foot_force_constraint': safety_coeff * 300000, # newtons 'action_roc_constraint': safety_coeff * 1.4, } task = RealWorldMove(desired_speed=_RUN_SPEED, random=random, safety_spec=safety_spec, delay_spec=delay_spec, noise_spec=noise_spec, perturb_spec=perturb_spec, dimensionality_spec=dimensionality_spec, multiobj_spec=multiobj_spec) environment_kwargs = environment_kwargs or {} if log_output: logger = loggers.PickleLogger(path=log_output) else: logger = None return wrappers.LoggingEnv(physics, task, logger=logger, time_limit=time_limit, control_timestep=_CONTROL_TIMESTEP, **environment_kwargs)
def realworld_walk(time_limit=_DEFAULT_TIME_LIMIT, random=None, log_output=None, environment_kwargs=None, safety_spec=None, delay_spec=None, noise_spec=None, perturb_spec=None, dimensionality_spec=None, multiobj_spec=None, combined_challenge=None): """Returns the Walk task. Args: time_limit: Integer length of task random: random seed (unsure) log_output: String of path for pickle data logging, None disables logging environment_kwargs: additional kwargs for environment. safety_spec: dictionary that specifies the safety specifications. delay_spec: dictionary that specifies the delay specifications. noise_spec: dictionary that specifies the noise specifications. perturb_spec: dictionary that specifies the perturbations specifications. dimensionality_spec: dictionary that specifies extra observation features. multiobj_spec: dictionary that specifies complementary objectives. combined_challenge: string that can be 'easy', 'medium', or 'hard'. Specifying the combined challenge (can't be used with any other spec). """ xml_string = quadruped.make_model(floor_size=_DEFAULT_TIME_LIMIT * _WALK_SPEED) physics = quadruped.Physics.from_xml_string(xml_string, common.ASSETS) safety_spec = safety_spec or {} delay_spec = delay_spec or {} noise_spec = noise_spec or {} perturb_spec = perturb_spec or {} dimensionality_spec = dimensionality_spec or {} multiobj_spec = multiobj_spec or {} # Check and update for combined challenge. (delay_spec, noise_spec, perturb_spec, dimensionality_spec) = (realworld_env.get_combined_challenge( combined_challenge, delay_spec, noise_spec, perturb_spec, dimensionality_spec)) # Updating perturbation parameters if combined_challenge. if combined_challenge == 'easy': perturb_spec.update({ 'param': 'shin_length', 'min': 0.25, 'max': 0.3, 'std': 0.005 }) elif combined_challenge == 'medium': perturb_spec.update({ 'param': 'shin_length', 'min': 0.25, 'max': 0.8, 'std': 0.05 }) elif combined_challenge == 'hard': perturb_spec.update({ 'param': 'shin_length', 'min': 0.25, 'max': 1.4, 'std': 0.1 }) task = RealWorldMove(desired_speed=_WALK_SPEED, random=random, safety_spec=safety_spec, delay_spec=delay_spec, noise_spec=noise_spec, perturb_spec=perturb_spec, dimensionality_spec=dimensionality_spec, multiobj_spec=multiobj_spec) environment_kwargs = environment_kwargs or {} if log_output: logger = loggers.PickleLogger(path=log_output) else: logger = None return wrappers.LoggingEnv(physics, task, logger=logger, time_limit=time_limit, control_timestep=_CONTROL_TIMESTEP, **environment_kwargs)
def realworld_walk(time_limit=_DEFAULT_TIME_LIMIT, random=None, log_output=None, environment_kwargs=None, safety_spec=None, delay_spec=None, noise_spec=None, perturb_spec=None, dimensionality_spec=None, multiobj_spec=None, combined_challenge=None): """Returns the Walk task with specified real world attributes. Args: time_limit: Integer length of task random: random seed (unsure) log_output: String of path for pickle data logging, None disables logging environment_kwargs: additional kwargs for environment. safety_spec: dictionary that specifies the safety specifications. delay_spec: dictionary that specifies the delay specifications. noise_spec: dictionary that specifies the noise specifications. perturb_spec: dictionary that specifies the perturbations specifications. dimensionality_spec: dictionary that specifies extra observation features. multiobj_spec: dictionary that specifies complementary objectives. combined_challenge: string that can be 'easy', 'medium', or 'hard'. Specifying the combined challenge (can't be used with any other spec). """ physics = humanoid.Physics.from_xml_string( *humanoid.get_model_and_assets()) safety_spec = safety_spec or {} delay_spec = delay_spec or {} noise_spec = noise_spec or {} perturb_spec = perturb_spec or {} dimensionality_spec = dimensionality_spec or {} multiobj_spec = multiobj_spec or {} # Check and update for combined challenge. (delay_spec, noise_spec, perturb_spec, dimensionality_spec) = (realworld_env.get_combined_challenge( combined_challenge, delay_spec, noise_spec, perturb_spec, dimensionality_spec)) # Updating perturbation parameters if combined_challenge. if combined_challenge == 'easy': perturb_spec.update({ 'param': 'contact_friction', 'min': 0.6, 'max': 0.8, 'std': 0.02 }) elif combined_challenge == 'medium': perturb_spec.update({ 'param': 'contact_friction', 'min': 0.5, 'max': 0.9, 'std': 0.04 }) elif combined_challenge == 'hard': perturb_spec.update({ 'param': 'contact_friction', 'min': 0.4, 'max': 1.0, 'std': 0.06 }) if 'limits' not in safety_spec: if 'safety_coeff' in safety_spec: if safety_spec['safety_coeff'] < 0 or safety_spec[ 'safety_coeff'] > 1: raise ValueError( 'safety_coeff should be in [0,1], but got {}'.format( safety_spec['safety_coeff'])) safety_coeff = safety_spec['safety_coeff'] else: safety_coeff = 1 safety_spec['limits'] = { 'joint_pos_constraint': safety_coeff * np.pi, # rad 'joint_velocity_constraint': safety_coeff * 90, # rad/s 'foot_force_constraint': safety_coeff * 8000, # newtons 'dangerous_fall_constraint': safety_coeff * 100, # newtons 'torso_upright_constraint': (1 - safety_coeff), # vector magnitude 'action_roc_constraint': safety_coeff * 1.85, } task = RealWorldHumanoid(move_speed=1, pure_state=False, random=random, safety_spec=safety_spec, delay_spec=delay_spec, noise_spec=noise_spec, perturb_spec=perturb_spec, dimensionality_spec=dimensionality_spec, multiobj_spec=multiobj_spec) environment_kwargs = environment_kwargs or {} if log_output: logger = loggers.PickleLogger(path=log_output) else: logger = None return wrappers.LoggingEnv(physics, task, logger=logger, time_limit=time_limit, control_timestep=_CONTROL_TIMESTEP, **environment_kwargs)