Example #1
0
def main():
    idx = input('Please select the controller -- \n1. Dynamical System\n2. Imitation Learning\n3. Rapidly-Exploring Random Tree\n' + 
                'Enter a number between 1 and 3: ')
    try:
        idx = int(idx)
        assert 1 <= idx <= 3
    except:
        print('Invalid input! The input needs to be a number between 1 and 3. ')
        quit()
    if idx == 1:
        env = RBF2dGymEnv(time_limit=500, oob_termination=False, use_lidar=False)
        controller = DSController()
        controller_kernel = TransitionKernel()
        save_fn = 'samples/ds_prior.pkl'
    elif idx == 2:
        env = RBF2dGymEnv(use_lidar=True)
        controller = ILController()
        controller_kernel = TransitionKernel()
        save_fn = 'samples/il_prior.pkl'
    else:
        env = RBF2dGymEnv(use_lidar=False)
        controller = RRTController()
        controller_kernel = RRTKernelNormal([-1, -1], [1, 1])
        save_fn = 'samples/rrt_prior.pkl'
    env_kernel = RBF2dEnvKernelNormal()
    sample_prior(2000, save_fn, env, controller, env_kernel, controller_kernel)
Example #2
0
def main():
    idx = input(
        'Please choose the controller that you want to sample -- 1. DS, 2. IL, 3. RRT: '
    )
    try:
        idx = int(idx)
        assert 1 <= idx <= 3
    except:
        print(
            'Invalid input! The input needs to be a number between 1 and 3. ')
        quit()
    if idx == 1:
        env = RBF2dGymEnv(time_limit=500,
                          oob_termination=False,
                          use_lidar=False)
        controller = DSController()
        controller_kernel = TransitionKernel()
        save_fn = 'samples/ds_prior.pkl'
    elif idx == 2:
        env = RBF2dGymEnv(use_lidar=True)
        controller = ILController()
        controller_kernel = TransitionKernel()
        save_fn = 'samples/il_prior.pkl'
    else:
        env = RBF2dGymEnv(use_lidar=False)
        controller = RRTController()
        controller_kernel = RRTKernelNormal([-1, -1], [1, 1])
        save_fn = 'samples/rrt_prior.pkl'
    env_kernel = RBF2dEnvKernelNormal()
    sample_prior(2000, save_fn, env, controller, env_kernel, controller_kernel)
Example #3
0
def main():
    idx = input('Please choose the controller that you want to sample -- 1. DS, 2. IL, 3. RRT: ')
    try:
        idx = int(idx)
        assert 1 <= idx <= 3
    except:
        print('Invalid input! The input needs to be a number between 1 and 3. ')
        quit()

    if idx == 1:
        env = RBF2dGymEnv(time_limit=500, oob_termination=False, use_lidar=False)
        controller = DSController()
        controller_kernel = TransitionKernel()
    elif idx == 2:
        env = RBF2dGymEnv(use_lidar=True)
        controller = ILController()
        controller_kernel = TransitionKernel()
    else:
        env = RBF2dGymEnv(use_lidar=False)
        controller = RRTController()
        controller_kernel = RRTKernelNormal([-1, -1], [1, 1])

    while True:
        env.reset(np.random.uniform(low=-0.7, high=0.7, size=(15, 2)))
        traj = controller.get_trajectory(env, controller_kernel)
        plt.imshow(env.arena.occ_grid, origin='lower', extent=[-1.2, 1.2, -1.2, 1.2],
                   cmap='gray_r', vmin=0, vmax=2)
        plt.plot(traj[:, 0], traj[:, 1])
        plt.title('Close this window to view next obstacle configuration. ')
        plt.show()
def main():
    idx = input(
        'Please select the controller -- \n1a. Original Dynamical System\n1b. Improved Dynamical System\n'
        +
        '2.  Reinforcement Learning\n3.  Rapidly-Exploring Random Tree\nEnter your choice: '
    )
    assert idx in ['1a', '1b', '2', '3'
                   ], 'Invalid input! The input needs to be 1a, 1b, 2, or 3. '
    env = PandaEnv()
    env.render()
    env_kernel = ReachingEnvKernelNormal()
    if idx == '1a':
        controller = DSController(typ='original', visualize=True)
        controller_kernel = TransitionKernel()
    elif idx == '1b':
        controller = DSController(typ='improved', visualize=True)
        controller_kernel = TransitionKernel()
    elif idx == '2':
        controller = RLController(visualize=True)
        controller_kernel = TransitionKernel()
    else:
        controller = RRTController(visualize=True)
        controller_kernel = RRTKernelNormal()
    while True:
        env_kernel.sample_prior()
        controller_kernel.sample_prior()
        env.reset(target_loc=env_kernel.value)
        controller.get_trajectory(env, controller_kernel)
Example #5
0
def rrt_max_illegibility():
    name = f'samples/{inspect.currentframe().f_code.co_name}.pkl'
    samples = sample(N=10000,
                     alpha=0.1,
                     prior_file='samples/rrt_prior.pkl',
                     N_sigma=1000,
                     behavior_func=behavior.illegibility_behavior,
                     env=PandaEnv(),
                     env_kernel=ReachingEnvKernelNormal(),
                     controller=RRTController(),
                     controller_kernel=RRTKernelNormal(),
                     target_type='maximal',
                     save=name)
Example #6
0
def rrt_min_ee_distance():
    name = f'samples/{inspect.currentframe().f_code.co_name}.pkl'
    samples = sample(N=10000,
                     alpha=0.1,
                     prior_file='samples/rrt_prior.pkl',
                     N_sigma=1000,
                     behavior_func=behavior.ee_distance_behavior,
                     env=PandaEnv(),
                     env_kernel=ReachingEnvKernelNormal(),
                     controller=RRTController(),
                     controller_kernel=RRTKernelNormal(),
                     target_type='match',
                     target_behavior=0,
                     save=name)
Example #7
0
def main():
    idx = input(
        'Please select the controller type: \n1. Dynamical System\n2. Imitation Learning\n3. Rapidly-Exploring Random Tree\n'
        + 'Enter a number between 1 and 3: ')
    try:
        idx = int(idx)
        assert 1 <= idx <= 3
    except:
        print(
            'Invalid input! The input needs to be a number between 1 and 3. ')
        quit()
    if idx == 1:
        env = RBF2dGymEnv(time_limit=500,
                          oob_termination=False,
                          use_lidar=False)
        controller = DSController()
        controller_kernel = TransitionKernel()
    elif idx == 2:
        env = RBF2dGymEnv(use_lidar=True)
        controller = ILController()
        controller_kernel = TransitionKernel()
    else:
        env = RBF2dGymEnv(use_lidar=False)
        controller = RRTController()
        controller_kernel = RRTKernelNormal([-1, -1], [1, 1])
    env_kernel = RBF2dEnvKernelNormal()
    while True:
        env_kernel.sample_prior()
        controller_kernel.sample_prior()
        env.reset(env_kernel.value)
        traj = controller.get_trajectory(env, controller_kernel)
        plt.imshow(env.arena.occ_grid,
                   origin='lower',
                   extent=[-1.2, 1.2, -1.2, 1.2],
                   cmap='gray_r',
                   vmin=0,
                   vmax=2)
        plt.plot(traj[:, 0], traj[:, 1])
        plt.title('Close this window to view next obstacle configuration. ')
        plt.show()
Example #8
0
def main():
	idx = input('Please select the controller -- \n1a. Original Dynamical System\n1b. Improved Dynamical System\n' + 
				'2. Reinforcement Learning\n3. Rapidly-Exploring Random Tree\nEnter your choice: ')
	assert idx in ['1a', '1b', '2', '3'], 'Invalid input! The input needs to be 1a, 1b, 2, or 3. '
	env = PandaEnv()
	env_kernel = ReachingEnvKernelNormal()
	if idx == '1a':
		controller = DSController(typ='original')
		controller_kernel = TransitionKernel()
		save_fn = 'samples/ds_original_prior.pkl'
	elif idx == '1b':
		controller = DSController(typ='improved')
		controller_kernel = TransitionKernel()
		save_fn = 'samples/ds_improved_prior.pkl'
	elif idx == '2':
		controller = RLController()
		controller_kernel = TransitionKernel()
		save_fn = 'samples/rl_prior.pkl'
	else:
		controller = RRTController()
		controller_kernel = RRTKernelNormal()
		save_fn = 'samples/rrt_prior.pkl'
	sample_prior(2000, save_fn, env, controller, env_kernel, controller_kernel)