Пример #1
0
    def log_diagnostics(self, paths, logger=default_logger):
        super().log_diagnostics(paths)
        MultitaskEnv.log_diagnostics(self, paths)
        xvels = get_stat_in_paths(paths, 'env_infos', 'xvel')
        desired_xvels = get_stat_in_paths(paths, 'env_infos', 'desired_xvel')
        xvel_errors = get_stat_in_paths(paths, 'env_infos', 'xvel_error')

        statistics = OrderedDict()
        for stat, name in [
            (xvels, 'xvels'),
            (desired_xvels, 'desired xvels'),
            (xvel_errors, 'xvel errors'),
        ]:
            statistics.update(
                create_stats_ordered_dict(
                    '{}'.format(name),
                    stat,
                    always_show_all_stats=True,
                ))
            statistics.update(
                create_stats_ordered_dict(
                    'Final {}'.format(name),
                    [s[-1] for s in stat],
                    always_show_all_stats=True,
                ))
        for key, value in statistics.items():
            logger.record_tabular(key, value)
Пример #2
0
    def log_diagnostics(self, paths, logger=default_logger):
        super().log_diagnostics(paths)
        MultitaskEnv.log_diagnostics(self, paths)

        statistics = OrderedDict()
        for name_in_env_infos, name_to_log in [
            ('x_pos', 'X Position'),
            ('y_pos', 'Y Position'),
            ('dist_from_origin', 'Distance from Origin'),
            ('desired_x_pos', 'Desired X Position'),
            ('desired_y_pos', 'Desired Y Position'),
            ('desired_dist_from_origin', 'Desired Distance from Origin'),
            ('pos_error', 'Distance to goal'),
        ]:
            stat = get_stat_in_paths(paths, 'env_infos', name_in_env_infos)
            statistics.update(create_stats_ordered_dict(
                name_to_log,
                stat,
                always_show_all_stats=True,
                exclude_max_min=True,
            ))
        for name_in_env_infos, name_to_log in [
            ('dist_from_origin', 'Distance from Origin'),
            ('desired_dist_from_origin', 'Desired Distance from Origin'),
            ('pos_error', 'Distance to goal'),
        ]:
            stat = get_stat_in_paths(paths, 'env_infos', name_in_env_infos)
            statistics.update(create_stats_ordered_dict(
                'Final {}'.format(name_to_log),
                [s[-1] for s in stat],
                always_show_all_stats=True,
            ))
        for key, value in statistics.items():
            logger.record_tabular(key, value)
Пример #3
0
 def __init__(self, min_distance=0, max_distance=2, use_low_gear_ratio=True):
     Serializable.quick_init(self, locals())
     self.max_distance = max_distance
     self.min_distance = min_distance
     MultitaskEnv.__init__(self)
     super().__init__(use_low_gear_ratio=use_low_gear_ratio)
     self.set_goal(np.array([self.max_distance, self.max_distance]))
Пример #4
0
 def __init__(
         self,
         max_speed=0.05,
         max_distance=1,
         use_low_gear_ratio=True,
         speed_weight=0.9,
         done_threshold=0.005,
         goal_dim_weights=None,
 ):
     Serializable.quick_init(self, locals())
     self.max_distance = max_distance
     self.max_speed = max_speed
     self.speed_weight = speed_weight
     self.done_threshold = done_threshold
     self.initializing = True
     # TODO: fix this hack
     if speed_weight is None:
         self.speed_weight = 0.9  # just for init to work
     MultitaskEnv.__init__(self, goal_dim_weights=goal_dim_weights)
     super().__init__(use_low_gear_ratio=use_low_gear_ratio)
     self.set_goal(np.array([
         self.max_distance,
         self.max_distance,
         self.max_speed,
         self.max_speed,
     ]))
     self.initializing = False
     if speed_weight is None:
         assert (
                        self.goal_dim_weights[0] == self.goal_dim_weights[1]
                ) and (
                        self.goal_dim_weights[2] == self.goal_dim_weights[3]
                )
         self.speed_weight = self.goal_dim_weights[2]
     assert 0 <= self.speed_weight <= 1
Пример #5
0
 def __init__(self, distance_metric_order=None, goal_dim_weights=None):
     self._desired_xyz = np.zeros(3)
     Serializable.quick_init(self, locals())
     MultitaskEnv.__init__(
         self,
         distance_metric_order=distance_metric_order,
         goal_dim_weights=goal_dim_weights,
     )
     mujoco_env.MujocoEnv.__init__(
         self,
         get_asset_xml('reacher_7dof.xml'),
         5,
     )
     self.observation_space = Box(
         np.array([
             -2.28,
             -0.52,
             -1.4,
             -2.32,
             -1.5,
             -1.094,
             -1.5,  # joint
             -3,
             -3,
             -3,
             -3,
             -3,
             -3,
             -3,  # velocity
             -0.75,
             -1.25,
             -0.2,  # EE xyz
         ]),
         np.array([
             1.71,
             1.39,
             1.7,
             0,
             1.5,
             0,
             1.5,  # joints
             3,
             3,
             3,
             3,
             3,
             3,
             3,  # velocity
             0.75,
             0.25,
             0.6,  # EE xyz
         ]))
Пример #6
0
    def log_diagnostics(self, paths, logger=default_logger):
        super().log_diagnostics(paths)
        MultitaskEnv.log_diagnostics(self, paths)

        statistics = OrderedDict()
        for stat_name in [
            'pos_error',
            'vel_error',
            'weighted_pos_error',
            'weighted_vel_error',
        ]:
            stat = get_stat_in_paths(paths, 'env_infos', stat_name)
            statistics.update(create_stats_ordered_dict(
                '{}'.format(stat_name),
                stat,
                always_show_all_stats=True,
            ))
            statistics.update(create_stats_ordered_dict(
                'Final {}'.format(stat_name),
                [s[-1] for s in stat],
                always_show_all_stats=True,
            ))
        weighted_error = (
            get_stat_in_paths(paths, 'env_infos', 'weighted_pos_error')
            + get_stat_in_paths(paths, 'env_infos', 'weighted_vel_error')
        )
        statistics.update(create_stats_ordered_dict(
            "Weighted Error",
            weighted_error,
            always_show_all_stats=True,
        ))
        statistics.update(create_stats_ordered_dict(
            "Final Weighted Error",
            [s[-1] for s in weighted_error],
            always_show_all_stats=True,
        ))

        for key, value in statistics.items():
            logger.record_tabular(key, value)
Пример #7
0
 def set_goal(self, goal):
     MultitaskEnv.set_goal(self, goal)
     self.target_x_vel = goal
Пример #8
0
 def __init__(self):
     Serializable.quick_init(self, locals())
     self.target_x_vel = np.random.uniform(-MAX_SPEED, MAX_SPEED)
     super().__init__()
     MultitaskEnv.__init__(self)
     self.set_goal(np.array([5]))