コード例 #1
0
 def __init__(self, data_directory, log_directory):
     # Full path to the final location for the data
     self.data_directory = Path(data_directory, 'directory')
     # Full path to the directory to store log files (append to final output directory)
     self.log_directory = Path(log_directory, 'directory')
     self.all_paths = [self.data_directory, self.log_directory]
     PathCollection.__init__(self)
コード例 #2
0
def test_mpc(waypoints, vehicle, result, plot):
    vehicle_pose = np.array([vehicle['x'], vehicle['y'], vehicle['theta']])

    waypoints_x, waypoints_y = waypoints
    path = Path(waypoints_x, waypoints_y)

    spatial_bicycle_model = SpatialBicycleModel()

    Q = sparse.diags([1., 1.])
    Qn = Q
    R = 0.1*sparse.eye(1)
    prediction_horizon = 2
    kappa_tilde_min = -100
    kappa_tilde_max = 100
    wheelbase = 1

    mpc = MPC(Q, R, Qn, prediction_horizon,
              kappa_tilde_min, kappa_tilde_max, wheelbase)
    mpc.setup_optimization_problem(
        spatial_bicycle_model, vehicle_pose, path.as_array_with_curvature())

    steering_angle = mpc.compute_steering_angle(
        spatial_bicycle_model, vehicle_pose, path.as_array_with_curvature())

    assert steering_angle == result['steering_angle']
コード例 #3
0
 def test_init_valid_paths(self):
     output_paths = OutputPaths(data_directory=DIR_PATH,
                                log_directory=DIR_PATH)
     self.assertEqual(output_paths.data_directory,
                      Path(DIR_PATH, 'directory'))
     self.assertEqual(output_paths.log_directory,
                      Path(DIR_PATH, 'directory'))
コード例 #4
0
 def test_init_valid_paths(self):
     input_paths = InputPaths(data_path=FILE_PATH,
                              reduction_script_path=FILE_PATH,
                              reduction_variables_path=FILE_PATH)
     self.assertEqual(input_paths.data_path, Path(FILE_PATH, 'file'))
     self.assertEqual(input_paths.reduction_script_path,
                      Path(FILE_PATH, 'file'))
     self.assertEqual(input_paths.reduction_variables_path,
                      Path(FILE_PATH, 'file'))
コード例 #5
0
 def test_init_valid_paths(self):
     temp_paths = TemporaryPaths(root_directory=DIR_PATH,
                                 data_directory=DIR_PATH,
                                 log_directory=DIR_PATH)
     self.assertEqual(temp_paths.root_directory,
                      Path(DIR_PATH, 'directory'))
     self.assertEqual(temp_paths.data_directory,
                      Path(DIR_PATH, 'directory'))
     self.assertEqual(temp_paths.log_directory, Path(DIR_PATH, 'directory'))
コード例 #6
0
 def __init__(self, root_directory, data_directory, log_directory):
     # Full path to a temporary root directory (for data before it goes to final destination)
     self.root_directory = Path(root_directory, 'directory')
     # Full file path to the reduction data temporary directory (this is /temp/ + /output_dir/)
     self.data_directory = Path(data_directory, 'directory')
     # Full file path to the script output temporary directory (this is /temp/ + /reduction_log/)
     self.log_directory = Path(log_directory, 'directory')
     self.all_paths = [
         self.root_directory, self.data_directory, self.log_directory
     ]
     PathCollection.__init__(self)
コード例 #7
0
 def __init__(self, data_path, reduction_script_path,
              reduction_variables_path):
     # Full path to the location of the input data FILE
     self.data_path = Path(data_path, 'file')
     # Full path to the location of the reduction script FILE
     self.reduction_script_path = Path(reduction_script_path, 'file')
     # Full path to the location of the reduction script variables
     self.reduction_variables_path = Path(reduction_variables_path, 'file')
     self.all_paths = [
         self.data_path, self.reduction_script_path,
         self.reduction_variables_path
     ]
     PathCollection.__init__(self)
コード例 #8
0
ファイル: test_path.py プロジェクト: whayward-stfc/autoreduce
 def test_valid_init_for_file(self):
     path = Path('/test/path/file.nxs', 'file')
     self.assertEqual(path.type, 'file')
     self.assertEqual(path.value, '/test/path/file.nxs')
     self.assertEqual(path.validate_absolute, True)
     self.assertEqual(path.validate_exists, True)
     self.assertEqual(path.validate_readable, True)
     self.assertEqual(path.validate_type, True)
     self.assertEqual(path.validate_writable, False)
コード例 #9
0
ファイル: test_path.py プロジェクト: whayward-stfc/autoreduce
 def test_path_equality_mismatch_path_value(self):
     path1 = Path(FILE_PATH, 'file')
     path2 = Path(DIR_PATH, 'file')
     self.assertFalse(path1 == path2)
コード例 #10
0
ファイル: test_path.py プロジェクト: whayward-stfc/autoreduce
 def test_not_exist_path(self):
     path = Path(os.path.join(DIR_PATH, 'file_does_not_exist.nxs'), 'file')
     self.assertRaisesRegex(PathError, "Path doesn't exist", path.validate)
コード例 #11
0
ファイル: test_path.py プロジェクト: whayward-stfc/autoreduce
 def test_not_absolute_path(self):
     path = Path(NOT_ABSOLUTE_FILE, 'file')
     self.assertRaisesRegex(PathError, "Path is not absolute", path.validate)
コード例 #12
0
ファイル: test_path.py プロジェクト: whayward-stfc/autoreduce
 def test_not_file_validation(self):
     path = Path(DIR_PATH, 'file')
     self.assertRaisesRegex(PathError, "Path is not a file", path.validate)
コード例 #13
0
ファイル: test_path.py プロジェクト: whayward-stfc/autoreduce
 def test_not_readable_path(self, mock_access):
     mock_access.return_value = False
     path = Path(FILE_PATH, 'file')
     self.assertRaisesRegex(PathError, "Path is not readable", path.validate)
コード例 #14
0
ファイル: test_path.py プロジェクト: whayward-stfc/autoreduce
 def test_not_directory_validation(self):
     path = Path(FILE_PATH, 'dir')
     self.assertRaisesRegex(PathError, "Path is not a directory", path.validate)
コード例 #15
0
import json
import math

simulation_time = 80
dt = 0.1
simulation_steps = int(simulation_time / dt)

lookahead_distance = 10
velocity = 5

with open('./src/paths/simulated_waypoints.json') as f:
    waypoints = json.load(f)
    waypoints_x = waypoints['waypoints_x']
    waypoints_y = waypoints['waypoints_y']

path = Path(waypoints_x=waypoints_x, waypoints_y=waypoints_y)

wheelbase = 1
max_velocity = 10
max_steering_angle = math.pi/4

initial_state = np.array([0, 0, math.pi/2])

vehicle = Vehicle(
    wheelbase=wheelbase, initial_state=initial_state, dt=dt,
    max_velocity=max_velocity, max_steering_angle=max_steering_angle)

vehicle_x = np.zeros(simulation_steps)
vehicle_y = np.zeros(simulation_steps)
steering_angles = np.zeros(simulation_steps)
コード例 #16
0
ファイル: test_path.py プロジェクト: whayward-stfc/autoreduce
 def test_valid_init_for_directory(self):
     path = Path('/test/path/dir/', 'directory')
     self.assertEqual(path.type, 'directory')
     self.assertEqual(path.value, '/test/path/dir/')
コード例 #17
0
ファイル: test_path.py プロジェクト: whayward-stfc/autoreduce
 def test_no_validation(self):
     path = Path('fake/path/directory', 'directory', False, False, False, False, False)
     self.assertTrue(path.validate())
コード例 #18
0
ファイル: test_path.py プロジェクト: whayward-stfc/autoreduce
 def test_path_equality_true(self):
     path1 = Path(FILE_PATH, 'file')
     path2 = Path(FILE_PATH, 'file')
     self.assertTrue(path1 == path2)
コード例 #19
0
simulation_time = 80
dt = 0.1
simulation_steps = int(simulation_time / dt)

Q = sparse.diags([1, 1])
Qn = Q
R = 0.1 * sparse.eye(1)
prediction_horizon = 20
velocity = 5

with open('./src/paths/simulated_waypoints.json') as f:
    waypoints = json.load(f)
    waypoints_x = waypoints['waypoints_x']
    waypoints_y = waypoints['waypoints_y']

path = Path(waypoints_x=waypoints_x, waypoints_y=waypoints_y)

wheelbase = 1
max_velocity = 10
max_steering_angle = math.pi

initial_state = np.array([0, 0, math.pi / 2])

vehicle = Vehicle(
    wheelbase=wheelbase, initial_state=initial_state, dt=dt,
    max_velocity=max_velocity, max_steering_angle=max_steering_angle)

vehicle_x = np.append(initial_state[0], np.zeros(simulation_steps - 1))
vehicle_y = np.append(initial_state[1], np.zeros(simulation_steps - 1))
steering_angles = np.zeros(simulation_steps)
コード例 #20
0
ファイル: test_path.py プロジェクト: whayward-stfc/autoreduce
 def test_path_equality_mismatch_path_type(self):
     path1 = Path(FILE_PATH, 'file')
     path2 = Path(FILE_PATH, 'directory')
     self.assertFalse(path1 == path2)