Exemplo n.º 1
0
def generate_initial_condition(config=None, T_aug_enabled=True, N=10):
    T_aug = None
    if T_aug_enabled:
        bound = 0.25
        pos_min = np.array([-bound, -bound, 0])
        pos_max = np.array([bound, bound, 0])
        yaw_min = 0
        yaw_max = 2 * np.pi
        T_aug = MultiEpisodeDataset.sample_T_aug(
            pos_min=pos_min,
            pos_max=pos_max,
            yaw_min=yaw_min,
            yaw_max=yaw_max,
        )

    q_slider = sample_slider_position(T_aug=T_aug)
    d = sample_pusher_position_and_velocity(T_aug=T_aug)

    action_sequence = torch.Tensor(d['v_pusher']).unsqueeze(0).expand([N, -1])

    return {
        'q_slider': q_slider,
        'q_pusher': d['q_pusher'],
        'v_pusher': d['v_pusher'],
        'action_sequence': action_sequence,
    }
Exemplo n.º 2
0
def generate_initial_condition(
    config=None,
    T_aug_enabled=True,
    push_length=0.4,
    N=None,
    n_his=0,  # whether to add some zero actions at the beginning
    randomize_velocity=False,
    randomize_sdf=True,
    randomize_color=True,
    upright=False,
):
    T_aug = np.eye(4)
    if T_aug_enabled:
        bound = 0.25
        pos_min = np.array([-bound, -bound, 0])
        pos_max = np.array([bound, bound, 0])
        yaw_min = 0
        yaw_max = 2 * np.pi
        T_aug = MultiEpisodeDataset.sample_T_aug(
            pos_min=pos_min,
            pos_max=pos_max,
            yaw_min=yaw_min,
            yaw_max=yaw_max,
        )

    q_slider = sample_object_position(T_aug=T_aug, upright=upright)

    vel_avg = 0.2
    dt = config['env']['step_dt']

    if N is None:
        N = math.ceil(push_length / (vel_avg * dt))

    d = sample_pusher_position_and_velocity(
        T_aug=T_aug, N=N, n_his=n_his, randomize_velocity=randomize_velocity)

    action_sequence = None
    action_sequence = d['action_sequence']

    config_copy = copy.deepcopy(config)
    if randomize_sdf:
        config_copy['env']['model']['sdf'] = sample_random_mug()

    if randomize_color:
        config_copy['env']['model']['color'] = sample_random_color()

    return {
        'q_slider': q_slider,
        'q_object': q_slider,
        'q_pusher': d['q_pusher'],
        'v_pusher': d['v_pusher'],
        'action_sequence': action_sequence,
        'config': config_copy,
    }
Exemplo n.º 3
0
def generate_initial_condition(config=None,
                               T_aug_enabled=True):
    T_aug = None
    if T_aug_enabled:
        aug_config = config['dataset']['data_augmentation']
        bound = 0.25
        pos_min = np.array([-bound, -bound, 0])
        pos_max = np.array([bound, bound, 0])
        yaw_min = 0
        yaw_max = 2*np.pi
        T_aug = MultiEpisodeDataset.sample_T_aug(pos_min=pos_min,
                                                 pos_max=pos_max,
                                                 yaw_min=yaw_min,
                                                 yaw_max=yaw_max,)


    q_slider = sample_slider_position(T_aug=T_aug)
    d = sample_pusher_position_and_velocity(T_aug=T_aug)

    return {'q_slider': q_slider,
            'q_pusher': d['q_pusher'],
            'v_pusher': d['v_pusher'],
            'action_seq': d['action_seq'],
            }
Exemplo n.º 4
0
def generate_initial_condition(config=None,
                               T_aug_enabled=True,
                               N=10):
    T_aug = None
    if T_aug_enabled:
        pos_min = config['eval']['T_aug']['pos_min']
        pos_max = config['eval']['T_aug']['pos_max']
        yaw_min = config['eval']['T_aug']['yaw_min']
        yaw_max = config['eval']['T_aug']['yaw_max']
        T_aug = MultiEpisodeDataset.sample_T_aug(pos_min=pos_min,
                                                 pos_max=pos_max,
                                                 yaw_min=yaw_min,
                                                 yaw_max=yaw_max, )

    q_slider = sample_slider_position(T_aug=T_aug)
    d = sample_pusher_position_and_velocity(T_aug=T_aug)

    action_sequence = torch.Tensor(d['v_pusher']).unsqueeze(0).expand([N, -1])

    return {'q_slider': q_slider,
            'q_pusher': d['q_pusher'],
            'v_slider': d['v_pusher'],
            'action_sequence': action_sequence,
            }