Exemplo n.º 1
0
MC_SAMPLES = 64             # monte carlo samples
N_INITIAL_SAMPLES = 10      # samples to initialize GP
PLOT_RESULTS = False        # whether to plot results
SAVE_RESULTS = True         # whether to save results
N_WAYPOINTS = 100           # resampled waypoints
SCALE = 0.95                # shrinking factor for track width
LASTIDX = 0                 # fixed node at the end DO NOT CHANGE

# define indices for the nodes
NODES = [7, 21, 37, 52, 66, 81, 97, 111, 136, 160, 175, 191, 205, 220, 236, 250, 275, 299, 337, 376]

#####################################################################
# track specific data

params = ORCA()
track = ETHZMobil()

track_width = track.track_width*SCALE
theta = track.theta_track[NODES]
N_DIMS = len(NODES)
n_waypoints = N_DIMS

rand_traj = randomTrajectory(track=track, n_waypoints=n_waypoints)

bounds = torch.tensor([[-track_width/2] * N_DIMS, [track_width/2] * N_DIMS], device=device, dtype=dtype)

def evaluate_y(x_eval, mean_y=None, std_y=None):
    """ evaluate true output for given x (distance of nodes from center line)
        TODO: parallelize evaluations
    """
    if type(x_eval) is torch.Tensor:
N_SAMPLES = 400
THRESHOLD = 0.25

#####################################################################
# load vehicle parameters

params = ORCA(control='pwm')
model = Dynamic(**params)

#####################################################################
# load track

if TRACK_NAME == 'ETHZ':
    track = ETHZ(reference='optimal')  # ETHZ() or ETHZMobil()
elif TRACK_NAME == 'ETHZMobil':
    track = ETHZMobil(reference='optimal')  # ETHZ() or ETHZMobil()

#####################################################################
# load inputs used to simulate Dynamic model

data = np.load('../data/DYN-{}-{}.npz'.format(CTYPE, TRACK_NAME))
time = data['time'][:N_SAMPLES + 1]

states = np.zeros([7, N_SAMPLES + 1])
states[:6, :] = data['states'][:6, :N_SAMPLES + 1]
states[6, 1:] = data['inputs'][1, :N_SAMPLES]

inputs = data['inputs'][:, :N_SAMPLES]
inputs[1, 0] = inputs[1, 0]
inputs[1, 1:] = np.diff(inputs[1])
inputs[1] /= SAMPLING_TIME
Exemplo n.º 3
0
SAMPLING_TIME = 0.02
TRACK_NAME = 'ETHZMobil'

filepath = 'track_training'
N_SAMPLES = 301

#####################################################################
# load vehicle parameters

params = ORCA(control='pwm')
model = Dynamic(**params)

#####################################################################
# load track

track = ETHZMobil(reference='optimal')

#####################################################################
# load inputs used to simulate Dynamic model

data = np.load('../data/DYN-{}-{}.npz'.format(CTYPE, TRACK_NAME))
time = data['time'][:N_SAMPLES + 1]

states = np.zeros([7, N_SAMPLES + 1])
states[:6, :] = data['states'][:6, :N_SAMPLES + 1]
states[6, 1:] = data['inputs'][1, :N_SAMPLES]

inputs = data['inputs'][:, :N_SAMPLES]
inputs[1, 0] = inputs[1, 0]
inputs[1, 1:] = np.diff(inputs[1])
inputs[1] /= SAMPLING_TIME