def __init__(self):
        np.random.seed(0)

        self._save_dir = os.path.join(params['exp_dir'], params['exp_name'])

        yamls = [
            fname for fname in os.listdir(self._save_dir)
            if '.yaml' in fname and '~' not in fname
        ]
        assert (len(yamls) == 1)
        yaml_path = os.path.join(self._save_dir, yamls[0])
        load_params(yaml_path)
        params['yaml_path'] = yaml_path

        ### turn off noise
        pred_dagger_params = params['prediction']['dagger']
        pred_dagger_params['control_noise']['type'] = 'zero'
        pred_dagger_params['epsilon_greedy'] = None

        ProbcollBebop2d.__init__(self, read_only=True)

        cond_params = copy.deepcopy(pred_dagger_params['conditions'])
        cond_params['repeats'] = 100

        self._conditions = Conditions(cond_params=cond_params)

        self._cost_probcoll_init = None
Exemplo n.º 2
0
def main():
    args = config.load_params()

    if args.seed > 0: 
        seed = args.seed
        seed_torch(seed)
    else:
        seed = random.randint(1, 999999999)
        seed_torch(seed)
    
    config_file = 'program/configs/{}.json'.format(args.config_file)
    hp, template_config, dataset_config_set, model_config_set, criterion_config_set, \
        optimizer_config, trainer_config = config.load_configs(config_file, args.config_file)

    hp.seed = seed
    _trainer = trainer.trainer(hp, 
        template_config,
        dataset_config_set,
        model_config_set,
        criterion_config_set,
        optimizer_config,
        trainer_config,
        resume = args.resume,
        )
    _trainer()
Exemplo n.º 3
0
    def __init__(self, on_replay=False, parent_exp_dir=None):
        self.on_replay = on_replay
        self._save_dir = os.path.join(params['exp_dir'], params['exp_name'])

        yamls = [
            fname for fname in os.listdir(self._save_dir)
            if '.yaml' in fname and '~' not in fname
        ]
        yaml_path = os.path.join(self._save_dir, yamls[0])
        load_params(yaml_path)
        params['yaml_path'] = yaml_path

        if self.on_replay:
            self._save_dir = os.path.join(self._save_dir, 'replay')

        self._logger = get_logger(self.__class__.__name__, 'info')
Exemplo n.º 4
0
        image_msg = image_time_msg[1]
        cmd_vel_msg = cmd_vel_time_msg[1]

        ### image
        im = AgentBebop2d.process_image(image_msg, cvb)
        sample.set_O(im.ravel(), t=t, sub_obs='camera')

        ### collision
        sample.set_O([0], t=t, sub_obs='collision')

        ### linearvel
        sample.set_X([cmd_vel_msg.linear.x, cmd_vel_msg.linear.y], t=t)
        sample.set_U([cmd_vel_msg.linear.x, cmd_vel_msg.linear.y], t=t)
    sample.set_O([int(is_coll)], t=-1, sub_obs='collision')
    # sample.set_O([int(np.random.random() > 0.5)], t=-1, sub_obs='collision') # tmp

    assert(sample.isfinite())

    return sample

if __name__ == '__main__':
    rospy.init_node('rosbag_to_sample', anonymous=True)

    yaml_path = os.path.join(FOLDER, 'params_bebop2d.yaml')
    load_params(yaml_path)

    samples = [rosbag_to_sample(os.path.join(FOLDER, f))
               for f in sorted(os.listdir(FOLDER)) if os.path.splitext(f)[1] == '.bag']
    samples = filter(lambda x: x is not None, samples)
    Sample.save(os.path.join(FOLDER, 'samples.npz'), samples)