code
stringlengths
17
6.64M
class Episode(): def __init__(self, task_name, initial_full_state, task_params=None, world_params=None): '\n The structure in which the data from each episode\n will be logged.\n\n :param task_name: (str) task generator name\n :param initial_full_state: (dict) dict specifying ...
class TaskStats(): def __init__(self, task): '\n\n :param task: (str) task generator name.\n ' self.task_name = task._task_name self.task_params = task.get_task_params() self.time_steps = 0 self.num_resets = 0 def add_episode_experience(self, time_steps)...
class Tracker(): def __init__(self, task=None, file_path=None, world_params=None): '\n\n :param task: (causal_world.BaseTask) task to be tracked\n :param file_path: (str) path of the tracker to be loaded.\n :param world_params: (dict) causal world parameters.\n ' self....
class MeanAccumulatedRewardMetric(BaseMetric): def __init__(self): '\n The MeanAccumulatedRewardMetric to be used to calculate the mean\n accumlated reward over all episodes processed.\n ' super(MeanAccumulatedRewardMetric, self).__init__(name='mean_accumulated_reward_rate') ...
class MeanFullIntegratedFractionalSuccess(BaseMetric): def __init__(self): '\n The MeanFullIntegratedFractionalSuccess to be used to calculate the mean\n of sum of fractional success over all episodes processed.\n ' super(MeanFullIntegratedFractionalSuccess, self).__init__(na...
class MeanLastFractionalSuccess(BaseMetric): def __init__(self): '\n The MeanLastFractionalSuccess to be used to calculate the mean\n last fractional success over all episodes processed.\n ' super(MeanLastFractionalSuccess, self).__init__(name='last_fractional_success') ...
class MeanLastIntegratedFractionalSuccess(BaseMetric): def __init__(self): '\n The MeanLastIntegratedFractionalSuccess to be used to calculate the mean\n over last 20 fractional successes over all episodes processed.\n ' super(MeanLastIntegratedFractionalSuccess, self).__init...
class BaseMetric(object): def __init__(self, name): '\n The metric base to be used for any metric to calculate over the\n episodes evaluated.\n\n :param name: (str) metric name.\n ' self.name = name return def process_episode(self, episode_obj): '\...
class TransferReal(object): def __init__(self, env): '\n This wrapper makes the environment to execute actions on the real robot\n instead, to be used when performing sim2real experiments.\n\n :param env: (causal_world.CausalWorld) the environment to convert.\n ' self....
class RealisticRobotWrapper(gym.Wrapper): def __init__(self, env): '\n This wrapper makes the simulated environment close to the real robot.\n\n :param env: (causal_world.CausalWorld) the environment to make realistic.\n ' super(RealisticRobotWrapper, self).__init__(env) ...
class CreativeStackedBlocksGeneratorTask(BaseTask): def __init__(self, variables_space='space_a_b', fractional_reward_weight=1, dense_reward_weights=np.array([]), activate_sparse_reward=False, tool_block_mass=0.08, joint_positions=None, blocks_min_size=0.035, num_of_levels=8, max_level_width=0.12): '\n ...
class GeneralGeneratorTask(BaseTask): def __init__(self, variables_space='space_a_b', fractional_reward_weight=1, dense_reward_weights=np.array([]), activate_sparse_reward=False, tool_block_mass=0.08, joint_positions=None, tool_block_size=0.05, nums_objects=5): "\n This task generator generates a ...
class PickingTaskGenerator(BaseTask): def __init__(self, variables_space='space_a_b', fractional_reward_weight=1, dense_reward_weights=np.array([250, 0, 125, 0, 750, 0, 0, 0.005]), activate_sparse_reward=False, tool_block_mass=0.02, joint_positions=None, tool_block_position=np.array([0, 0, 0.0325]), tool_block_o...
class ReachingTaskGenerator(BaseTask): def __init__(self, variables_space='space_a_b', fractional_reward_weight=1, dense_reward_weights=np.array([100000, 0, 0, 0]), default_goal_60=np.array([0, 0, 0.1]), default_goal_120=np.array([0, 0, 0.13]), default_goal_300=np.array([0, 0, 0.16]), joint_positions=None, activ...
class StackedBlocksGeneratorTask(BaseTask): def __init__(self, variables_space='space_a_b', fractional_reward_weight=1, dense_reward_weights=np.array([]), activate_sparse_reward=False, tool_block_mass=0.08, joint_positions=None, blocks_min_size=0.035, num_of_levels=5, max_level_width=0.25): "\n Th...
class Stacking2TaskGenerator(BaseTask): def __init__(self, variables_space='space_a_b', fractional_reward_weight=1, dense_reward_weights=np.array([750, 250, 250, 125, 0.005]), activate_sparse_reward=False, tool_block_mass=0.02, tool_block_size=0.065, joint_positions=None, tool_block_1_position=np.array([0, 0, 0....
def generate_task(task_generator_id='reaching', **kwargs): '\n\n :param task_generator_id: picking, pushing, reaching, pick_and_place,\n stacking2, stacked_blocks, towers, general or\n creative_stacked_blocks.\n :param kwargs: args that are specific ...
class TowersGeneratorTask(BaseTask): def __init__(self, variables_space='space_a_b', fractional_reward_weight=1, dense_reward_weights=np.array([]), activate_sparse_reward=False, tool_block_mass=0.08, number_of_blocks_in_tower=np.array([1, 1, 5]), tower_dims=np.array([0.035, 0.035, 0.175]), tower_center=np.array(...
def save_config_file(section_names, config_dicts, file_path): '\n\n :param section_names:\n :param config_dicts:\n :param file_path:\n :return:\n ' config = ConfigParser() for i in range(len(section_names)): section_name = section_names[i] config.add_section(section_name) ...
def read_config_file(file_path): '\n\n :param file_path:\n :return:\n ' section_names = [] config_dicts = [] config = ConfigParser() config.read(file_path) for section in config.sections(): section_names.append(section) config_dicts.append(dict()) for option in...
def load_world(tracker_relative_path, enable_visualization=False): '\n Loads a world again at the same state as when it was saved.\n\n :param tracker_relative_path: (str) path specifying where the tracker\n saved.\n :param enable_visualization: (bool) True if enabli...
def scale(x, space): '\n\n :param x:\n :param space:\n :return:\n ' return (((2.0 * (x - space.low)) / (space.high - space.low)) - 1.0)
def unscale(y, space): '\n\n :param y:\n :param space:\n :return:\n ' return (space.low + (((y + 1.0) / 2.0) * (space.high - space.low)))
def combine_spaces(space_1, space_2): '\n\n :param space_1:\n :param space_2:\n :return:\n ' lower_bound = np.concatenate((space_1.low, space_2.low)) upper_bound = np.concatenate((space_1.high, space_2.high)) return spaces.Box(low=lower_bound, high=upper_bound, dtype=np.float64)
def initialize_intervention_actors(actors_params): '\n\n :param actors_params:\n :return:\n ' intervention_actors_list = [] for actor_param in actors_params: if (actor_param == 'random_actor'): intervention_actors_list.append(RandomInterventionActorPolicy(**actors_params[actor...
class CrossEntropyMethod(object): def __init__(self, planning_horizon, max_iterations, population_size, num_elite, action_upper_bound, action_lower_bound, model, epsilon=0.001, alpha=0.25): '\n Cross entropy method optimizer to be used.\n\n :param planning_horizon: (int) horizon for plannin...
def get_intersection(bb1, bb2): '\n\n :param bb1:\n :param bb2:\n :return:\n ' x_left = max(bb1[0][0], bb2[0][0]) x_right = min(bb1[1][0], bb2[1][0]) y_top = max(bb1[0][1], bb2[0][1]) y_bottom = min(bb1[1][1], bb2[1][1]) z_up = max(bb1[0][2], bb2[0][2]) z_down = min(bb1[1][2], ...
def get_iou(bb1, bb2, area1, area2): '\n\n :param bb1:\n :param bb2:\n :param area1:\n :param area2:\n :return:\n ' intersection_area = get_intersection(bb1, bb2) return (intersection_area / float(((area1 + area2) - intersection_area)))
def get_bounding_box_volume(bb): '\n\n :param bb:\n :return:\n ' width = (bb[1][0] - bb[0][0]) depth = (bb[1][1] - bb[0][1]) height = (bb[1][2] - bb[0][2]) return ((width * depth) * height)
def view_episode(episode, env_wrappers=np.array([]), env_wrappers_args=np.array([])): '\n Visualizes a logged episode in the GUI\n\n :param episode: (Episode) the logged episode\n :param env_wrappers: (list) a list of gym wrappers\n :param env_wrappers_args: (list) a list of kwargs for the gym wrapper...
def view_policy(task, world_params, policy_fn, max_time_steps, number_of_resets, env_wrappers=np.array([]), env_wrappers_args=np.array([])): '\n Visualizes a policy for a specified environment in the GUI\n\n :param task: (Task) the task of the environment\n :param world_params: (dict) the world_params of...
def record_video_of_policy(task, world_params, policy_fn, file_name, number_of_resets, max_time_steps=100, env_wrappers=np.array([]), env_wrappers_args=np.array([])): '\n Records a video of a policy for a specified environment\n\n :param task: (Task) the task of the environment\n :param world_params: (di...
def record_video_of_random_policy(task, world_params, file_name, number_of_resets, max_time_steps=100, env_wrappers=np.array([]), env_wrappers_args=np.array([])): '\n Records a video of a random policy for a specified environment\n\n :param task: (Task) the task of the environment\n :param world_params: ...
def record_video_of_episode(episode, file_name, env_wrappers=np.array([]), env_wrappers_args=np.array([])): '\n Records a video of a logged episode for a specified environment\n\n :param episode: (Episode) the logged episode\n :param file_name: (str) full path where the video is being stored.\n :p...
def get_world(task_generator_id, task_params, world_params, enable_visualization=False, env_wrappers=np.array([]), env_wrappers_args=np.array([])): '\n Returns a particular CausalWorld instance with optional wrappers\n\n :param task_generator_id: (str) id of the task of the environment\n :param task_para...
def record_video(env, policy, file_name, number_of_resets=1, max_time_steps=None): '\n Records a video of a policy for a specified environment\n :param env: (causal_world.CausalWorld) the environment to use for\n recording.\n :param policy: the policy to be evalu...
class DeltaActionEnvWrapper(gym.ActionWrapper): def __init__(self, env): '\n A delta action wrapper for the environment to turn the actions\n to a delta wrt the previous action executed.\n\n :param env: (causal_world.CausalWorld) the environment to convert.\n ' super(D...
class MovingAverageActionEnvWrapper(gym.ActionWrapper): def __init__(self, env, widow_size=8, initial_value=0): '\n\n :param env: (causal_world.CausalWorld) the environment to convert.\n :param widow_size: (int) the window size for avergaing and smoothing\n t...
class CurriculumWrapper(gym.Wrapper): def __init__(self, env, intervention_actors, actives): '\n\n :param env: (causal_world.CausalWorld) the environment to convert.\n :param intervention_actors: (list) list of intervention actors\n :param actives: (list of tuples) each tuple indicat...
class HERGoalEnvWrapper(gym.Env): def __init__(self, env, activate_sparse_reward=False): '\n\n :param env: (causal_world.CausalWorld) the environment to convert.\n :param activate_sparse_reward: (bool) True to activate sparse rewards.\n ' super(HERGoalEnvWrapper, self).__init...
class ObjectSelectorActorPolicy(BaseInterventionActorPolicy): def __init__(self): '\n\n ' super(ObjectSelectorActorPolicy, self).__init__() self.low_joint_positions = None self.current_action = None self.selected_object = None def initialize_actor(self, env): ...
class ObjectSelectorWrapper(gym.Wrapper): def __init__(self, env): '\n\n :param env: (causal_world.CausalWorld) the environment to convert.\n ' super(ObjectSelectorWrapper, self).__init__(env) self.env = env self.env.set_skip_frame(1) self.intervention_actor ...
class MovingAverageActionWrapperActorPolicy(BaseActorPolicy): def __init__(self, policy, widow_size=8, initial_value=0): '\n\n :param policy: (causal_world.actors.BaseActorPolicy) policy to be used.\n :param widow_size: (int) the window size for avergaing and smoothing\n ...
class ProtocolWrapper(gym.Wrapper): def __init__(self, env, protocol): '\n\n :param env: (causal_world.CausalWorld) the environment to convert.\n :param protocol: (causal_world.evaluation.ProtocolBase) protocol to evaluate.\n ' super(ProtocolWrapper, self).__init__(env) ...
def train_policy(num_of_envs, log_relative_path, maximum_episode_length, skip_frame, seed_num, her_config, total_time_steps, validate_every_timesteps, task_name): task = generate_task(task_generator_id=task_name, dense_reward_weights=np.array([100000, 0, 0, 0]), fractional_reward_weight=0) env = CausalWorld(t...
def train_policy(num_of_envs, log_relative_path, maximum_episode_length, skip_frame, seed_num, ppo_config, total_time_steps, validate_every_timesteps, task_name): def _make_env(rank): def _init(): task = generate_task(task_generator_id=task_name, dense_reward_weights=np.array([100000, 0, 0, ...
def train_policy(num_of_envs, log_relative_path, maximum_episode_length, skip_frame, seed_num, ddpg_config, total_time_steps, validate_every_timesteps, task_name): print('Using MPI for multiprocessing with {} workers'.format(MPI.COMM_WORLD.Get_size())) rank = MPI.COMM_WORLD.Get_rank() print('Worker rank: ...
def train_policy(num_of_envs, log_relative_path, maximum_episode_length, skip_frame, seed_num, her_config, total_time_steps, validate_every_timesteps, task_name): task = generate_task(task_generator_id=task_name, dense_reward_weights=np.array([0, 0, 0, 0, 0, 0, 0, 0]), fractional_reward_weight=1, goal_height=0.15...
def train_policy(num_of_envs, log_relative_path, maximum_episode_length, skip_frame, seed_num, ppo_config, total_time_steps, validate_every_timesteps, task_name): def _make_env(rank): def _init(): task = generate_task(task_generator_id=task_name, dense_reward_weights=np.array([250, 0, 125, 0...
def train_policy(num_of_envs, log_relative_path, maximum_episode_length, skip_frame, seed_num, sac_config, total_time_steps, validate_every_timesteps, task_name): task = generate_task(task_generator_id=task_name, dense_reward_weights=np.array([250, 0, 125, 0, 750, 0, 0, 0.005]), fractional_reward_weight=1, goal_h...
def _make_env(rank): task = generate_task(task_generator_id='picking', dense_reward_weights=np.array([250, 0, 125, 0, 750, 0, 0, 0.005]), fractional_reward_weight=1, goal_height=0.15, tool_block_mass=0.02) env = CausalWorld(task=task, skip_frame=3, enable_visualization=False, seed=0, max_episode_length=600) ...
def build_and_train(): p = psutil.Process() cpus = p.cpu_affinity() affinity = dict(cuda_idx=None, master_cpus=cpus, workers_cpus=list(([x] for x in cpus)), set_affinity=True) sampler = CpuSampler(EnvCls=_make_env, env_kwargs=dict(rank=0), batch_T=1, batch_B=4, max_decorrelation_steps=0, CollectorCls=...
def _make_env(rank): task = generate_task('pushing', dense_reward_weights=np.array([2500, 2500, 0]), variables_space='space_a', fractional_reward_weight=100) env = CausalWorld(task=task, skip_frame=3, enable_visualization=False, seed=(0 + rank)) env = CurriculumWrapper(env, intervention_actors=[GoalInterv...
def build_and_train(): p = psutil.Process() cpus = p.cpu_affinity() affinity = dict(cuda_idx=None, master_cpus=cpus, workers_cpus=list(([x] for x in cpus)), set_affinity=True) sampler = CpuSampler(EnvCls=_make_env, env_kwargs=dict(rank=0), max_decorrelation_steps=0, batch_T=6000, batch_B=len(cpus)) ...
def baseline_model(model_num, task): if (task == 'pushing'): benchmarks = utils.sweep('benchmarks', [PUSHING_BENCHMARK]) task_configs = [{'task_configs': {'variables_space': 'space_a', 'fractional_reward_weight': 1, 'dense_reward_weights': [750, 250, 0]}}] elif (task == 'picking'): ben...
def checkpoints_in_folder(folder): def is_checkpoint_file(f): full_path = os.path.join(folder, f) return (os.path.isfile(full_path) and f.startswith('model_') and f.endswith('_steps.zip')) filenames = [f for f in os.listdir(folder) if is_checkpoint_file(f)] regex = re.compile('\\d+') ...
def get_latest_checkpoint_path(model_path): (filenames, numbers) = checkpoints_in_folder(model_path) if (len(filenames) == 0): return (None, 0) else: ckpt_name = filenames[np.argmax(numbers)] ckpt_step = numbers[np.argmax(numbers)] ckpt_path = os.path.join(model_path, ckpt_...
def save_model_settings(file_path, model_settings): model_settings['intervention_actors'] = [actor.__class__.__name__ for actor in model_settings['intervention_actors']] with open(file_path, 'w') as fout: json.dump(model_settings, fout, indent=4, default=(lambda x: x.__dict__))
def sweep(key, values): return [{key: value} for value in values]
def outer_product(list_of_settings): if (len(list_of_settings) == 1): return list_of_settings[0] result = [] other_items = outer_product(list_of_settings[1:]) for first_dict in list_of_settings[0]: for second_dict in other_items: result_dict = dict() result_dict...
class PrintTimestepCallback(BaseCallback): def _on_step(self) -> bool: print(self.model.num_timesteps, flush=True)
def get_single_process_env(model_settings, model_path, ckpt_step): task = generate_task(model_settings['benchmarks']['task_generator_id'], **model_settings['task_configs']) env = CausalWorld(task=task, **model_settings['world_params'], seed=model_settings['world_seed']) env = CurriculumWrapper(env, interv...
def get_multi_process_env(model_settings, model_path, num_of_envs, ckpt_step): def _make_env(rank): def _init(): task = generate_task(model_settings['benchmarks']['task_generator_id'], **model_settings['task_configs']) env = CausalWorld(task=task, **model_settings['world_params']...
def get_TD3_model(model_settings, model_path, ckpt_path, ckpt_step, tb_path): policy_kwargs = dict(layers=model_settings['NET_LAYERS']) env = get_single_process_env(model_settings, model_path, ckpt_step) n_actions = env.action_space.shape[(- 1)] action_noise = NormalActionNoise(mean=np.zeros(n_actions...
def get_SAC_model(model_settings, model_path, ckpt_path, ckpt_step, tb_path): policy_kwargs = dict(layers=model_settings['NET_LAYERS']) env = get_single_process_env(model_settings, model_path, ckpt_step) if (ckpt_path is not None): print("Loading model from checkpoint '{}'".format(ckpt_path)) ...
def get_PPO_model(model_settings, model_path, ckpt_path, ckpt_step, num_of_envs, tb_path): policy_kwargs = dict(act_fun=tf.nn.tanh, net_arch=model_settings['NET_LAYERS']) env = get_multi_process_env(model_settings, model_path, num_of_envs, ckpt_step) if (ckpt_path is not None): print("Loading mode...
def train_model(model_settings, output_path, tensorboard_logging=False): num_of_envs = model_settings['num_of_envs'] model_path = os.path.join(output_path, 'model') if tensorboard_logging: tb_path = model_path else: tb_path = None try: os.makedirs(model_path) ckpt_p...
def get_mean_scores(scores_list): scores_mean = dict() num_scores = len(scores_list) for key in list(scores_list[0].keys())[:]: scores_mean[key] = {} for sub_key in scores_list[0][key].keys(): scores_mean[key][sub_key] = np.mean([scores_list[i][key][sub_key] for i in range(num_...
@pytest.fixture(scope='module') def as_jp_norm(): return TriFingerAction(action_mode='joint_positions', normalize_actions=True)
@pytest.fixture(scope='module') def as_jp_full(): return TriFingerAction(action_mode='joint_positions', normalize_actions=False)
@pytest.fixture(scope='module') def as_jt_norm(): return TriFingerAction(action_mode='joint_torques', normalize_actions=True)
@pytest.fixture(scope='module') def as_jt_full(): return TriFingerAction(action_mode='joint_torques', normalize_actions=False)
@pytest.fixture(scope='module') def as_default(): return TriFingerAction()
@pytest.fixture(scope='module') def as_custom(): return TriFingerAction(normalize_actions=False)
def test_set_action_space(as_custom): as_custom.set_action_space(custom_action_lower_bound, custom_action_upper_bound) assert (as_custom.get_action_space().low == custom_action_lower_bound).all() assert (as_custom.get_action_space().high == custom_action_upper_bound).all() assert (as_custom.normalize_...
def test_get_action_space(as_default, as_jt_full, as_jt_norm, as_jp_full, as_jp_norm): assert (as_default.get_action_space().low == (- 1.0)).all() assert (as_jp_norm.get_action_space().low == (- 1.0)).all() assert (as_jt_norm.get_action_space().low == (- 1.0)).all() assert (as_default.get_action_space...
def test_is_normalized(as_default, as_jt_full, as_jt_norm, as_jp_full, as_jp_norm): assert as_default.is_normalized() assert as_jt_norm.is_normalized() assert (not as_jt_full.is_normalized()) assert as_jt_norm.is_normalized() assert (not as_jp_full.is_normalized())
def test_satisfy_constraints(as_default, as_jt_full, as_jt_norm, as_jp_full, as_jp_norm): assert as_default.satisfy_constraints(upper_99_normalized_action) assert (not as_default.satisfy_constraints(upper_100_normalized_action)) assert (not as_default.satisfy_constraints(upper_101_normalized_action)) ...
def test_clip_action(as_default, as_jt_full, as_jt_norm, as_jp_full, as_jp_norm): assert (as_default.clip_action(upper_99_normalized_action) == upper_99_normalized_action).all() assert (as_default.clip_action(lower_99_normalized_action) == lower_99_normalized_action).all() assert (as_default.clip_action(u...
def test_normalize_action(as_default, as_jt_full, as_jt_norm, as_jp_full, as_jp_norm): assert (as_default.normalize_action(upper_100_denormalized_jp_action) == upper_100_normalized_action).all() assert (as_jp_full.normalize_action(upper_100_denormalized_jp_action) == upper_100_normalized_action).all() ass...
def test_denormalize_action(as_default, as_jt_full, as_jt_norm, as_jp_full, as_jp_norm): assert (as_default.denormalize_action(upper_100_normalized_action) == pytest.approx(upper_100_denormalized_jp_action)) assert (as_jp_full.denormalize_action(upper_100_normalized_action) == pytest.approx(upper_100_denormal...
@pytest.fixture(scope='module') def os_camera_full(): return TriFingerObservations(observation_mode='pixel', normalize_observations=False)
@pytest.fixture(scope='module') def os_structured_full(): return TriFingerObservations(observation_mode='structured', observation_keys=['action_joint_positions', 'joint_velocities', 'joint_torques'], normalize_observations=False)
@pytest.fixture(scope='module') def os_default(): return TriFingerObservations()
@pytest.fixture(scope='module') def os_custom_keys_norm(): return TriFingerObservations(observation_mode='structured', normalize_observations=True, observation_keys=['end_effector_positions', 'action_joint_positions'])
def test_get_observation_spaces(os_default, os_camera_full, os_structured_full, os_custom_keys_norm): assert (os_default.get_observation_spaces().low == (- 1.0)).all() assert (os_custom_keys_norm.get_observation_spaces().low == (- 1.0)).all() assert (os_default.get_observation_spaces().high == 1.0).all() ...
def test_is_normalized(os_default, os_camera_full, os_structured_full, os_custom_keys_norm): assert os_default.is_normalized() assert os_custom_keys_norm.is_normalized() assert (not os_camera_full.is_normalized()) assert (not os_structured_full.is_normalized())
def test_normalize_observation(os_structured_full, os_custom_keys_norm): assert (os_structured_full.normalize_observation(upper_obs_space_structured_full) == upper_100_structured_norm).all() assert (os_structured_full.normalize_observation(lower_obs_space_structured_full) == lower_100_structured_norm).all() ...
def test_denormalize_observation(os_structured_full, os_custom_keys_norm): assert (os_structured_full.denormalize_observation(np.array(([1.0] * 27))) == pytest.approx(upper_obs_space_structured_full)) assert (os_structured_full.denormalize_observation(np.array(([(- 1.0)] * 27))) == pytest.approx(lower_obs_spa...
def test_satisfy_constraints(os_default, os_structured_full): assert os_default.satisfy_constraints(upper_99_structured_norm) assert (not os_default.satisfy_constraints(upper_100_structured_norm)) assert (not os_default.satisfy_constraints(upper_101_structured_norm)) assert os_structured_full.satisfy_...
def test_clip_observation(os_default, os_structured_full): assert (os_default.clip_observation(upper_99_structured_norm) == upper_99_structured_norm).all() assert (os_default.clip_observation(lower_99_structured_norm) == lower_99_structured_norm).all() assert (os_default.clip_observation(upper_100_structu...
def test_add_and_remove_observation(os_custom_keys_norm): os_custom_keys_norm.add_observation('joint_torques') assert (os_custom_keys_norm._observations_keys == ['end_effector_positions', 'action_joint_positions', 'joint_torques']) assert (len(os_custom_keys_norm.get_observation_spaces().low) == 27) a...
@pytest.fixture(scope='module') def robot_jp_structured(): task = generate_task(task_generator_id='pushing') return CausalWorld(task=task, enable_visualization=False, observation_mode='structured')
@pytest.fixture(scope='module') def robot_jp_camera(): task = generate_task(task_generator_id='pushing') return CausalWorld(task=task, enable_visualization=False, observation_mode='pixel')
def test_action_mode_switching(robot_jp_structured): robot_jp_structured.set_action_mode('joint_torques') assert (robot_jp_structured.get_action_mode() == 'joint_torques') robot_jp_structured.set_action_mode('joint_positions') assert (robot_jp_structured.get_action_mode() == 'joint_positions')
def test_pd_gains(): np.random.seed(0) task = generate_task(task_generator_id='pushing') skip_frame = 1 env = CausalWorld(task=task, enable_visualization=False, skip_frame=skip_frame, normalize_observations=False, normalize_actions=False, seed=0) zero_hold = int((5000 / skip_frame)) obs = env....
class TestWorld(unittest.TestCase): def setUp(self): return def tearDown(self): return def test_determinism(self): task = generate_task(task_generator_id='stacked_blocks') observations_v1 = [] observations_v2 = [] observations_v3 = [] rewards_v1 =...
class TestCreativeStackedBlocks(unittest.TestCase): def setUp(self): self.task = generate_task(task_generator_id='creative_stacked_blocks') self.env = CausalWorld(task=self.task, enable_visualization=False) return def tearDown(self): self.env.close() return def t...
class TestGeneral(unittest.TestCase): def setUp(self): self.task = generate_task(task_generator_id='general') self.env = CausalWorld(task=self.task, enable_visualization=False) self.env.reset() return def tearDown(self): self.env.close() return def test_d...
class TestPickAndPlace(unittest.TestCase): def setUp(self): self.task = generate_task(task_generator_id='pick_and_place') self.env = CausalWorld(task=self.task, enable_visualization=False) return def tearDown(self): self.env.close() return def test_determinism(se...