Skip to content

Commit

Permalink
Big commit: Running and plotting thesis experiments
Browse files Browse the repository at this point in the history
Signed-off-by: An Thai Le <an.thai.le97@gmail.com>
  • Loading branch information
anindex committed Sep 19, 2021
1 parent f3b3a3e commit 4f042b6
Show file tree
Hide file tree
Showing 233 changed files with 1,004 additions and 48 deletions.
Binary file modified data/tasks/pick/demos/sample.p
Binary file not shown.
Binary file removed data/tasks/pick/demos/sample1.p
Binary file not shown.
Binary file removed data/tasks/pick/demos/sample2.p
Binary file not shown.
Binary file added data/tasks/pick/experiments/adaptation.p
Binary file not shown.
Binary file added data/tasks/pick/experiments/adaptation_diff_15.p
Binary file not shown.
Binary file not shown.
Binary file added data/tasks/pick/experiments/tracking.p
Binary file not shown.
Binary file added data/tasks/pick/experiments/tracking_baseline.p
Binary file not shown.
Binary file removed data/tasks/pick/models/dynamics_sample2.p
Binary file not shown.
Binary file removed data/tasks/pick/models/dynamics_sample3.p
Binary file not shown.
Binary file added data/tasks/pick/models/dynamics_sample_11.p
Binary file not shown.
Binary file added data/tasks/pick/models/dynamics_sample_13.p
Binary file not shown.
Binary file added data/tasks/pick/models/dynamics_sample_15.p
Binary file not shown.
Binary file added data/tasks/pick/models/dynamics_sample_5.p
Binary file not shown.
Binary file added data/tasks/pick/models/dynamics_sample_7.p
Binary file not shown.
Binary file added data/tasks/pick/models/dynamics_sample_9.p
Binary file not shown.
Binary file removed data/tasks/pick/models/tphsmm_sample2.p
Binary file not shown.
Binary file removed data/tasks/pick/models/tphsmm_sample3.p
Binary file not shown.
Binary file added data/tasks/pick/models/tphsmm_sample_11.p
Binary file not shown.
Binary file added data/tasks/pick/models/tphsmm_sample_13.p
Binary file not shown.
Binary file added data/tasks/pick/models/tphsmm_sample_15.p
Binary file not shown.
Binary file added data/tasks/pick/models/tphsmm_sample_5.p
Binary file not shown.
Binary file added data/tasks/pick/models/tphsmm_sample_7.p
Binary file not shown.
Binary file added data/tasks/pick/models/tphsmm_sample_9.p
Binary file not shown.
Binary file removed data/tasks/test/demos/test.p
Binary file not shown.
Binary file removed data/tasks/test/demos/test1.p
Binary file not shown.
Binary file removed data/tasks/test/demos/test2.p
Binary file not shown.
Binary file removed data/tasks/test/demos/test3.p
Binary file not shown.
Binary file added data/tasks/test/experiments/adaptation_2d.p
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added data/tasks/test/experiments/tracking_2d.p
Binary file not shown.
Binary file added data/tasks/test/experiments/tracking_2d_baseline.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_C1_11.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_C1_13.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_C1_15.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_C1_5.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_C1_7.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_C1_9.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_C_11.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_C_13.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_C_15.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_C_5.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_C_7.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_C_9.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_G_11.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_G_13.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_G_15.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_G_5.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_G_7.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_G_9.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_I1_11.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_I1_13.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_I1_15.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_I1_5.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_I1_7.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_I1_9.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_I_11.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_I_13.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_I_15.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_I_5.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_I_7.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_I_9.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_J_11.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_J_13.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_J_15.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_J_5.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_J_7.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_J_9.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_L1_11.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_L1_13.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_L1_15.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_L1_5.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_L1_7.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_L1_9.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_L_11.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_L_13.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_L_15.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_L_5.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_L_7.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_L_9.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_P_11.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_P_13.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_P_15.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_P_5.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_P_7.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_P_9.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_S1_11.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_S1_13.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_S1_15.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_S1_5.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_S1_7.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_S1_9.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_S2_11.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_S2_13.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_S2_15.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_S2_5.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_S2_7.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_S2_9.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_S_11.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_S_13.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_S_15.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_S_5.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_S_7.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_S_9.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_U_11.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_U_13.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_U_15.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_U_5.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_U_7.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_U_9.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_hat1_11.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_hat1_13.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_hat1_15.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_hat1_5.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_hat1_7.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_hat1_9.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_hat_11.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_hat_13.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_hat_15.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_hat_5.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_hat_7.p
Binary file not shown.
Binary file added data/tasks/test/models/dynamics_hat_9.p
Binary file not shown.
Binary file removed data/tasks/test/models/dynamics_test2.p
Binary file not shown.
Binary file removed data/tasks/test/models/dynamics_test3.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_C1_11.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_C1_13.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_C1_15.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_C1_5.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_C1_7.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_C1_9.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_C_11.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_C_13.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_C_15.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_C_5.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_C_7.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_C_9.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_G_11.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_G_13.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_G_15.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_G_5.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_G_7.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_G_9.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_I1_11.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_I1_13.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_I1_15.p
Binary file not shown.
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_I1_7.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_I1_9.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_I_11.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_I_13.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_I_15.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_I_5.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_I_7.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_I_9.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_J_11.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_J_13.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_J_15.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_J_5.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_J_7.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_J_9.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_L1_11.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_L1_13.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_L1_15.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_L1_5.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_L1_7.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_L1_9.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_L_11.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_L_13.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_L_15.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_L_5.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_L_7.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_L_9.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_P_11.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_P_13.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_P_15.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_P_5.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_P_7.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_P_9.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_S1_11.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_S1_13.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_S1_15.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_S1_5.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_S1_7.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_S1_9.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_S2_11.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_S2_13.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_S2_15.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_S2_5.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_S2_7.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_S2_9.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_S_11.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_S_13.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_S_15.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_S_5.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_S_7.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_S_9.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_U_11.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_U_13.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_U_15.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_U_5.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_U_7.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_U_9.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_hat1_11.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_hat1_13.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_hat1_15.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_hat1_5.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_hat1_7.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_hat1_9.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_hat_11.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_hat_13.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_hat_15.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_hat_5.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_hat_7.p
Binary file not shown.
Binary file added data/tasks/test/models/tphsmm_hat_9.p
Binary file not shown.
Binary file removed data/tasks/test/models/tphsmm_test2.p
Binary file not shown.
74 changes: 74 additions & 0 deletions scripts/experiments/experiment_2d.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import sys
import argparse
from os.path import join, dirname, abspath
import matplotlib
import numpy as np
import logging
import time
import pickle
logging.basicConfig()
logging.getLogger().setLevel(logging.INFO)
matplotlib.rcParams['pdf.fonttype'] = 42
matplotlib.rcParams['ps.fonttype'] = 42
matplotlib.rcParams['font.size'] = 16

ROOT_DIR = join(dirname(abspath(__file__)), '..', '..')
sys.path.append(ROOT_DIR)
from tprmp.utils.experiment import Experiment # noqa

parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter,
description='Example run: python experiment.py 1')
parser.add_argument('--mode', help='Load or not', type=int, default=1)
args = parser.parse_args()

task = 'test'
demo_type = '2D'
demo_names = ['C', 'C1', 'G', 'hat', 'hat1', 'I', 'I1', 'J', 'L', 'L1', 'P', 'S', 'S1', 'S2', 'U']
start_random_radius = 0.01
moving_goal_radius = 0.2
disturb_magnitude = 10.
disturb_period = [50, 150]
disturb = True
v_eps = 5e-2
goal_eps = 0.2
Kp = 1 * np.eye(2)
Kd = 0.1 * np.eye(2)
worker = Experiment(task=task, demo_type=demo_type, demo_names=demo_names, start_random_radius=start_random_radius, moving_goal_radius=moving_goal_radius,
disturb_magnitude=disturb_magnitude, disturb_period=disturb_period, v_eps=v_eps, goal_eps=goal_eps)
worker.load_demos()

if args.mode == 1:
print('Start training models...')
worker.train()
elif args.mode == 2:
print('Tracking experiment...')
error = worker.tracking_experiment()
elif args.mode == 3:
print('Tracking baseline experiment...')
error = worker.tracking_baseline_experiment(Kp, Kd, dt=0.005)
elif args.mode == 4:
print('Adaptation experiment...')
error = worker.adaptation_experiment(disturb=disturb)
elif args.mode == 5:
print('Adaptation with increasing disturb force experiment...')
disturb = True
test_comps = [9]
worker.test_comps = test_comps
disturb_magnitude = 10. * np.arange(1, 10)
error = {}
for dm in disturb_magnitude:
worker.disturb_magnitude = dm
error[dm] = worker.adaptation_experiment(disturb=disturb)
elif args.mode == 6:
print('Adaptation with increasing degree of difference experiment...')
disturb = False
test_comps = [9]
worker.test_comps = test_comps
moving_goal_radius = 0.1 * np.arange(1, 10)
error = {}
for r in moving_goal_radius:
worker.moving_goal_radius = r
error[r] = worker.adaptation_experiment(disturb=disturb)
filename = join(worker.experiment_path, 'experiment_' + str(args.mode) + '_' + str(time.time()) + '.p')
with open(filename, 'wb') as f:
pickle.dump(error, f)
90 changes: 90 additions & 0 deletions scripts/experiments/experiment_6d.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import sys
import argparse
from os.path import join, dirname, abspath
import matplotlib
import numpy as np
import logging
import time
import pickle
logging.basicConfig()
logging.getLogger().setLevel(logging.INFO)
matplotlib.rcParams['pdf.fonttype'] = 42
matplotlib.rcParams['ps.fonttype'] = 42
matplotlib.rcParams['font.size'] = 16

ROOT_DIR = join(dirname(abspath(__file__)), '..', '..')
sys.path.append(ROOT_DIR)
from tprmp.utils.experiment import Experiment # noqa

parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter,
description='Example run: python experiment.py 1')
parser.add_argument('--mode', help='Load or not', type=int, default=1)
args = parser.parse_args()

task = 'pick'
demo_type = '6D'
demo_names = ['sample']
goal_frame = 'obj_frame'
start_random_radius = 0.01
omega = 30 * np.pi
N = 10
moving_goal_radius = 0.1
disturb_magnitude = 10.
disturb_period = [50, 150]
disturb = False
v_eps = 5e-2
goal_eps = 0.2
mass_scale = 0.2
Kp = 1 * np.eye(6)
Kd = 0.1 * np.eye(6)
worker = Experiment(task=task, demo_type=demo_type, demo_names=demo_names, start_random_radius=start_random_radius, moving_goal_radius=moving_goal_radius,
omega=omega, disturb_magnitude=disturb_magnitude, disturb_period=disturb_period, v_eps=v_eps, goal_eps=goal_eps, goal_frame=goal_frame)
worker.load_demos()

if args.mode == 1:
print('Start training models...')
worker.train()
elif args.mode == 2:
print('Tracking experiment...')
error = worker.tracking_experiment()
elif args.mode == 3:
print('Tracking baseline experiment...')
error = worker.tracking_baseline_experiment(Kp, Kd, dt=0.005)
elif args.mode == 4:
print('Adaptation experiment...')
error = []
for n in range(N):
test_omega = omega + np.random.uniform(low=-5, high=5) * np.pi
worker.omega = test_omega
error.append(worker.adaptation_experiment(disturb=disturb))
elif args.mode == 5:
print('Adaptation with increasing disturb force experiment...')
disturb = True
error = []
test_comps = [15]
worker.test_comps = test_comps
disturb_magnitude = 10. * np.arange(1, 50, 5)
for n in range(N):
test_omega = omega + np.random.uniform(low=-5, high=5) * np.pi
worker.omega = test_omega
error.append({})
for dm in disturb_magnitude:
worker.disturb_magnitude = dm
error[n][dm] = worker.adaptation_experiment(disturb=disturb)
elif args.mode == 6:
print('Adaptation with increasing degree of difference experiment...')
disturb = False
test_comps = [15]
worker.test_comps = test_comps
moving_goal_radius = 0.1 * np.arange(1, 10)
error = []
for n in range(N):
test_omega = omega + np.random.uniform(low=-5, high=5) * np.pi
worker.omega = test_omega
error.append({})
for r in moving_goal_radius:
worker.moving_goal_radius = r
error[n][r] = worker.adaptation_experiment(disturb=disturb)
filename = join(worker.experiment_path, 'experiment_' + str(args.mode) + '_' + str(time.time()) + '.p')
with open(filename, 'wb') as f:
pickle.dump(error, f)
52 changes: 52 additions & 0 deletions scripts/experiments/plot_appendix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import sys
from os.path import join, dirname, abspath
import matplotlib
import logging
import numpy as np
import matplotlib.pyplot as plt
logging.basicConfig()
logging.getLogger().setLevel(logging.INFO)
matplotlib.rcParams['pdf.fonttype'] = 42
matplotlib.rcParams['ps.fonttype'] = 42
matplotlib.rcParams['font.size'] = 16

ROOT_DIR = join(dirname(abspath(__file__)), '..', '..')
sys.path.append(ROOT_DIR)
from tprmp.utils.loading import load_demos_2d # noqa
from tprmp.models.tp_rmp import TPRMP # noqa
from tprmp.visualization.dynamics import plot_potential_field, plot_dissipation_field # noqa
mode = 1
task = 'test'
demo_path = join(ROOT_DIR, 'data', 'tasks', task, 'demos')
num_comp = 9
N1, N2 = 3, 5
limits = [0., 4.5]
demo_names = ['C', 'C1', 'G', 'hat', 'hat1', 'I', 'I1', 'J', 'L', 'L1', 'P', 'S', 'S1', 'S2', 'U']
dt = 0.01
res = 0.05

X, Y = np.meshgrid(np.arange(limits[0], limits[1], res), np.arange(limits[0], limits[1], res))
fig, axs = plt.subplots(N1, N2)
for n, name in enumerate(demo_names):
k, m = int(n / N2), n % N2
data_file = join(demo_path, name + '.p')
model_file = name + '_' + str(num_comp) + '.p'
demos = load_demos_2d(data_file, dt=dt)
model = TPRMP.load(task, model_name=model_file)
sample = demos[0]
frames = sample.get_task_parameters()
ax = axs[k, m]
plt.sca(ax)
ax.set_xlim([limits[0], limits[1]])
ax.set_ylim([limits[0], limits[1]])
if mode == 1:
plot_potential_field(model, frames, limits=limits, new_ax=False, res=res)
else:
plot_dissipation_field(model, frames, limits=limits, new_ax=False, res=res)

for ax in fig.axes:
try:
ax.label_outer()
except: # noqa
pass
plt.show()
51 changes: 51 additions & 0 deletions scripts/experiments/plot_explaining_K.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import sys
from os.path import join, dirname, abspath
import matplotlib
import logging
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import make_axes_locatable
logging.basicConfig()
logging.getLogger().setLevel(logging.INFO)
matplotlib.rcParams['pdf.fonttype'] = 42
matplotlib.rcParams['ps.fonttype'] = 42
matplotlib.rcParams['font.size'] = 16

ROOT_DIR = join(dirname(abspath(__file__)), '..', '..')
sys.path.append(ROOT_DIR)
from tprmp.utils.loading import load_demos_2d # noqa
from tprmp.models.tp_rmp import TPRMP # noqa
from tprmp.visualization.demonstration import _plot_traj_global # noqa
from tprmp.visualization.models import _plot_gmm_global # noqa

dt = 0.01
res = 0.05
limits = [0., 4.5]
task = 'test'
demo_path = join(ROOT_DIR, 'data', 'tasks', task, 'demos')
demo_name = 'S'
data_file = join(demo_path, demo_name + '.p')
num_comp = [5, 9, 15]

fig, axs = plt.subplots(1, 3)
X, Y = np.meshgrid(np.arange(limits[0], limits[1], res), np.arange(limits[0], limits[1], res))
for k, n in enumerate(num_comp):
demos = load_demos_2d(data_file, dt=dt)
model_file = demo_name + '_' + str(n) + '.p'
model = TPRMP.load(task, model_name=model_file)
frames = demos[0].get_task_parameters()
ax = axs[k]
ax.set_aspect('equal')
plt.sca(ax)
_plot_traj_global(demos, title=f'{n} components', limits=limits, legend=False, three_d=False, new_ax=False)
_plot_gmm_global(model.model, frames, three_d=False, new_ax=False)
Z = np.zeros_like(X)
model.generate_global_gmm(frames)
for i in range(X.shape[0]):
for j in range(X.shape[1]):
Z[i, j] = model.compute_potential_field(np.array([X[i, j], Y[i, j]]))
c = ax.pcolormesh(X, Y, Z, cmap='RdBu', shading='auto', vmin=0., vmax=50, alpha=0.5)
divider = make_axes_locatable(ax)
cax = divider.append_axes("right", size="5%", pad=0.05)
fig.colorbar(c, cax=cax)
plt.show()
96 changes: 96 additions & 0 deletions scripts/experiments/plot_tracking_results.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import sys
from os.path import join, dirname, abspath
import matplotlib
import logging
import numpy as np
import matplotlib.pyplot as plt
logging.basicConfig()
logging.getLogger().setLevel(logging.INFO)
matplotlib.rcParams['pdf.fonttype'] = 42
matplotlib.rcParams['ps.fonttype'] = 42
matplotlib.rcParams['font.size'] = 16

ROOT_DIR = join(dirname(abspath(__file__)), '..', '..')
sys.path.append(ROOT_DIR)
from tprmp.utils.loading import load_demos_2d # noqa
from tprmp.models.tp_rmp import TPRMP # noqa
from tprmp.demonstrations.base import Demonstration # noqa
from tprmp.visualization.demonstration import plot_frame_2d # noqa
from tprmp.demonstrations.manifold import Manifold # noqa

mode = 1
task = 'test'
demo_path = join(ROOT_DIR, 'data', 'tasks', task, 'demos')
num_comp = 9
N1, N2 = 3, 5
limits = [0., 4.5]
demo_names = ['C', 'C1', 'G', 'hat', 'hat1', 'I', 'I1', 'J', 'L', 'L1', 'P', 'S', 'S1', 'S2', 'U']
dt = 0.01
v_eps = 5e-2
goal_eps = 0.2
wait = 10
res = 0.05
colormap = 'RdBu' if mode == 1 else 'YlOrBr'
manifold = Manifold.get_euclidean_manifold(2)


def execute(model, frames, x0, dx0):
x, dx = x0, dx0
traj = [x]
model.generate_global_gmm(frames)
count = 0
while True:
ddx = model.retrieve(x, dx)
dx = ddx * dt + dx
x = manifold.exp_map(dx * dt, base=x)
traj.append(x)
if np.linalg.norm(dx) < v_eps:
count += 1
if count >= wait:
break
else:
count = 0
return np.array(traj).T


X, Y = np.meshgrid(np.arange(limits[0], limits[1], res), np.arange(limits[0], limits[1], res))
fig, axs = plt.subplots(N1, N2)
for n, name in enumerate(demo_names):
k, m = int(n / N2), n % N2
data_file = join(demo_path, name + '.p')
if k == 2 and m == 0:
model_file = name + '_' + str(7) + '.p'
else:
model_file = name + '_' + str(num_comp) + '.p'
demos = load_demos_2d(data_file, dt=dt)
model = TPRMP.load(task, model_name=model_file)
sample = demos[0]
frames = sample.get_task_parameters()
x0, dx0 = sample.traj[:, 0], sample._d_traj[:, 0]
traj = execute(model, frames, x0, dx0)
ax = axs[k, m]
plt.sca(ax)
ax.set_aspect('equal')
ax.set_xlim([limits[0], limits[1]])
ax.set_ylim([limits[0], limits[1]])
ax.plot(sample.traj[0], sample.traj[1], color="b", linestyle='--', alpha=0.7)
ax.plot(traj[0], traj[1], color="b")
plot_frame_2d(frames.values())
Z = np.zeros_like(X)
for i in range(X.shape[0]):
for j in range(X.shape[1]):
if mode == 1:
Z[i, j] = model.compute_potential_field(np.array([X[i, j], Y[i, j]]))
else:
Z[i, j] = model.compute_dissipation_field(np.array([X[i, j], Y[i, j]]))
c = ax.pcolormesh(X, Y, Z, cmap=colormap, shading='auto', vmin=0., vmax=Z.max(), alpha=0.5)
fig.colorbar(c, ax=ax)
last = demos[0].traj[:, -1]
plt.scatter(last[0], last[1], marker='*', color='r', s=40)

for ax in fig.axes:
try:
ax.label_outer()
except: # noqa
pass
plt.show()
Loading

0 comments on commit 4f042b6

Please sign in to comment.