Example #1
0
 def test_location(self):
     forward = 51.2
     up = 153.3
     left = -126.07
     pose = tum_loader.make_camera_pose(-1 * left, -1 * up, forward, 0, 0,
                                        0, 1)
     self.assertNPEqual((forward, left, up), pose.location)
Example #2
0
    def test_make_camera_pose_changes_rotation_each_axis(self):
        # Roll, rotation around z-axis
        quat = tf3d.quaternions.axangle2quat((0, 0, 1), np.pi / 6)
        pose = tum_loader.make_camera_pose(10, -22.4, 13.2, quat[0], quat[1],
                                           quat[2], quat[3])
        self.assertNPClose((np.pi / 6, 0, 0), pose.euler)

        # Pitch, rotation around x-axis
        quat = tf3d.quaternions.axangle2quat((1, 0, 0), np.pi / 6)
        pose = tum_loader.make_camera_pose(10, -22.4, 13.2, quat[0], quat[1],
                                           quat[2], quat[3])
        self.assertNPClose((0, -np.pi / 6, 0), pose.euler)

        # Yaw, rotation around y-axis
        quat = tf3d.quaternions.axangle2quat((0, 1, 0), np.pi / 6)
        pose = tum_loader.make_camera_pose(10, -22.4, 13.2, quat[0], quat[1],
                                           quat[2], quat[3])
        self.assertNPClose((0, 0, -np.pi / 6), pose.euler)
Example #3
0
 def test_orientation(self):
     angle = np.pi / 7
     forward = 51.2
     up = 153.3
     left = -126.07
     quat = tf3d.quaternions.axangle2quat((-1 * left, -1 * up, forward),
                                          angle)
     pose = tum_loader.make_camera_pose(0, 0, 0, quat[0], quat[1], quat[2],
                                        quat[3])
     self.assertNPEqual((0, 0, 0), pose.location)
     self.assertNPEqual(
         tf3d.quaternions.axangle2quat((forward, left, up), angle),
         pose.rotation_quat(True))
Example #4
0
 def test_randomized(self):
     for _ in range(10):
         loc = np.random.uniform(-1000, 1000, 3)
         rot_axis = np.random.uniform(-1, 1, 3)
         rot_angle = np.random.uniform(-np.pi, np.pi)
         quat = tf3d.quaternions.axangle2quat(
             (-rot_axis[1], -rot_axis[2], rot_axis[0]), rot_angle, False)
         pose = tum_loader.make_camera_pose(-loc[1], -loc[2], loc[0],
                                            quat[0], quat[1], quat[2],
                                            quat[3])
         self.assertNPEqual(loc, pose.location)
         self.assertNPClose(
             tf3d.quaternions.axangle2quat(rot_axis, rot_angle, False),
             pose.rotation_quat(True))
Example #5
0
 def test_both(self):
     forward = 51.2
     up = 153.3
     left = -126.07
     angle = np.pi / 7
     o_forward = 1.151325
     o_left = 5.1315
     o_up = -0.2352323
     quat = tf3d.quaternions.axangle2quat(
         (-1 * o_left, -1 * o_up, o_forward), angle)
     pose = tum_loader.make_camera_pose(-1 * left, -1 * up, forward,
                                        quat[0], quat[1], quat[2], quat[3])
     self.assertNPEqual((forward, left, up), pose.location)
     self.assertNPEqual(
         tf3d.quaternions.axangle2quat((o_forward, o_left, o_up), angle),
         pose.rotation_quat(True))
Example #6
0
 def test_make_camera_pose_location_coordinates(self):
     # Order here is right, down, forward
     pose = tum_loader.make_camera_pose(10, -22.4, 13.2, 0, 0, 0, 1)
     # Change coordinate order to forward, left, up
     self.assertNPEqual((13.2, -10, 22.4), pose.location)
Example #7
0
 def test_make_camera_pose_returns_transform_object(self):
     pose = tum_loader.make_camera_pose(10, -22.4, 13.2, 0, 0, 0, 1)
     self.assertIsInstance(pose, tf.Transform)