Ejemplo n.º 1
0
 def setUp(self):
     ball = mnt.OblateEllipsoidFrame(1, 1)
     ball.name = 'ball'
     local = mnt.CartesianCoordinateFrame()
     local.name = 'local'
     ball.add_child(local)
     self.universe = mnt.CoordinateUniverse('uni', ball)
     self.tr1 = self.universe.get_transformation('local', 'ball')
Ejemplo n.º 2
0
def load_mounttree(filename):
    with open(filename) as f:
        tree = yaml.load(f, Loader=yaml.SafeLoader)
    name = tree['description']['name']
    tree = tree['mounttree']
    root_frame = create_from_yaml(tree)
    sensors = find_sensors_in_tree(tree)
    universe = mnt.CoordinateUniverse(name, root_frame, sensors=sensors)
    return universe
Ejemplo n.º 3
0
 def test_forward_shift(self):
     a = mnt.CartesianCoordinateFrame()
     b = mnt.CartesianCoordinateFrame()
     a.name = 'a'
     b.name = 'b'
     b.pos = [1, 2, 0]
     a.add_child(b)
     universe = mnt.CoordinateUniverse('uni', a)
     transform = universe.get_transformation('b', 'a')
     npt.assert_almost_equal(transform.apply_point(1, 0, 0), [2, 2, 0])
Ejemplo n.º 4
0
 def test_backward_rotation(self):
     halo = mnt.CartesianCoordinateFrame()
     halo.name = 'HALO'
     vnir = mnt.CartesianCoordinateFrame()
     vnir.name = 'VNIR'
     vnir.rotation = mnt.Rotation.fromAngle(np.pi / 2, 'z')
     halo.add_child(vnir)
     universe = mnt.CoordinateUniverse('universe', halo)
     transform = universe.get_transformation('HALO', 'VNIR')
     npt.assert_almost_equal(transform.apply_direction(0, 1, 0), [1, 0, 0])
Ejemplo n.º 5
0
 def test_find_path_to_frame(self):
     halo = mnt.CartesianCoordinateFrame()
     halo.name = 'HALO'
     vnir = mnt.CartesianCoordinateFrame()
     vnir.name = 'VNIR'
     halo.add_child(vnir)
     universe = mnt.CoordinateUniverse('universe', halo)
     path = universe.find_path_to_frame('VNIR')
     self.assertIs(vnir, path[0])
     self.assertEqual(len(path), 1)
Ejemplo n.º 6
0
 def test_get_origin_of_subframes(self):
     earth = mnt.coordinate_lib['WGS-84']()
     earth.name = 'earth'
     local = mnt.CartesianCoordinateFrame()
     local.name = 'local'
     local.pos = [45, 45, 0]
     earth.add_child(local)
     universe = mnt.CoordinateUniverse('uni', earth)
     transform = universe.get_transformation('local', 'earth')
     res = transform.apply_point(0, 0, 0)
     npt.assert_almost_equal(
         res,
         universe.get_frame('earth').toCartesian([45, 45, 0]))
Ejemplo n.º 7
0
 def test_double_transform(self):
     halo = mnt.CartesianCoordinateFrame()
     halo.name = 'HALO'
     intermediate = mnt.CartesianCoordinateFrame()
     intermediate.name = 'INTER'
     intermediate.rotation = mnt.Rotation.fromAngle(np.pi / 2, 'z')
     swir = mnt.CartesianCoordinateFrame()
     swir.name = 'SWIR'
     swir.rotation = mnt.Rotation.fromAngle(np.pi / 2, 'z')
     intermediate.add_child(swir)
     halo.add_child(intermediate)
     universe = mnt.CoordinateUniverse('uni', halo)
     transform = universe.get_transformation('HALO', 'SWIR')
     npt.assert_almost_equal(transform.apply_direction(0, 1, 0), [0, -1, 0])
Ejemplo n.º 8
0
 def test_direction(self):
     ned2enu = (mnt.Rotation.fromAngle(np.pi / 2, 'z') *
                mnt.Rotation.fromAngle(np.pi, 'x'))
     earth = mnt.coordinate_lib['WGS-84']()
     earth.name = 'earth'
     local = mnt.CartesianCoordinateFrame()
     local.name = 'local'
     local.pos = [45, 45, 0]
     local.rotation = ned2enu
     earth.add_child(local)
     check_result = [-0.5, -0.5, np.sqrt(0.5)]
     universe = mnt.CoordinateUniverse('uni', earth)
     transform = universe.get_transformation('local', 'earth')
     npt.assert_almost_equal(transform.apply_direction(0, 1, 0),
                             check_result)
Ejemplo n.º 9
0
 def test_find_path_to_frame_deep(self):
     halo = mnt.CartesianCoordinateFrame()
     halo.name = 'HALO'
     vnir = mnt.CartesianCoordinateFrame()
     vnir.name = 'VNIR'
     swir = mnt.CartesianCoordinateFrame()
     swir.name = 'SWIR'
     containment = mnt.CartesianCoordinateFrame()
     containment.name = 'CONTAINMENT'
     containment.add_child(vnir)
     containment.add_child(swir)
     halo.add_child(containment)
     universe = mnt.CoordinateUniverse('universe', halo)
     path = universe.find_path_to_frame('SWIR')
     path2 = universe.find_path_to_frame('VNIR')
     self.assertIs(swir, path[1])
     self.assertIs(vnir, path2[1])
     self.assertIs(containment, path[0])
     self.assertEqual(len(path), 2)
Ejemplo n.º 10
0
 def setUp(self):
     earth = mnt.coordinate_lib['WGS-84']()
     earth.name = 'earth'
     stabilized = mnt.CartesianCoordinateFrame()
     stabilized.name = 'stabilized'
     self.lat = 10.
     self.lon = 15.
     self.height = 7000.
     self.roll = np.pi / 6.
     self.pitch = 0  # np.pi/9.
     self.yaw = -np.pi
     stabilized.pos = [self.lat, self.lon, self.height]
     stabilized.euler = [0, 0, mnt.rad2deg(self.yaw)]
     halo = mnt.CartesianCoordinateFrame()
     halo.name = 'HALO'
     halo.euler = [mnt.rad2deg(self.roll), mnt.rad2deg(self.pitch), 0]
     stabilized.add_child(halo)
     earth.add_child(stabilized)
     self.universe = mnt.CoordinateUniverse('uni', earth)
Ejemplo n.º 11
0
 def test_position_transform_nested_on_north_pole(self):
     ball = mnt.OblateEllipsoidFrame(1, 1)
     ball.name = 'ball'
     intermediate = mnt.CartesianCoordinateFrame()
     intermediate.name = 'intermediate'
     local = mnt.CartesianCoordinateFrame()
     local.name = 'local'
     local.pos = [1, 0, 1]
     intermediate.add_child(local)
     ball.add_child(intermediate)
     universe = mnt.CoordinateUniverse('uni', ball)
     tr1 = universe.get_transformation('local', 'ball')
     res1 = tr1.apply_point(0., 0., 0.)
     npt.assert_almost_equal(res1, [0, 0, 1])
     res2 = tr1.apply_point(1., 0., 0.)
     npt.assert_almost_equal(res2, [0, 0, 2])
     res3 = tr1.apply_point(0., 1., 0.)
     npt.assert_almost_equal(res3, [0, 1, 1])
     res4 = tr1.apply_point(-1, 0, 0)
     npt.assert_almost_equal(np.linalg.norm(res4), 1e-9)