def test_from_rotation_matrix_preset(self): """Tests that Euler angles can be retrieved from rotation matrices.""" matrix = test_helpers.generate_preset_test_rotation_matrices_3d() predicted_angles = euler.from_rotation_matrix(matrix) reconstructed_matrices = rotation_matrix_3d.from_euler(predicted_angles) self.assertAllClose(reconstructed_matrices, matrix, rtol=1e-3)
def test_from_rotation_matrix_jacobian_preset(self): """Test the Jacobian of the from_rotation_matrix function.""" x_init = test_helpers.generate_preset_test_rotation_matrices_3d() x = tf.convert_to_tensor(value=x_init) y = euler.from_rotation_matrix(x) self.assert_jacobian_is_finite(x, x_init, y)
def test_inverse_jacobian_preset(self): """Test the Jacobian of the inverse function.""" x_init = test_helpers.generate_preset_test_rotation_matrices_3d() x = tf.convert_to_tensor(value=x_init) y = rotation_matrix_3d.inverse(x) self.assert_jacobian_is_correct(x, x_init, y)
def test_rotate_jacobian_preset(self): """Test the Jacobian of the rotate function.""" x_matrix_init = test_helpers.generate_preset_test_rotation_matrices_3d() tensor_shape = x_matrix_init.shape[:-1] x_point_init = np.random.uniform(size=tensor_shape) self.assert_jacobian_is_correct_fn(rotation_matrix_3d.rotate, [x_point_init, x_matrix_init])
def test_from_quaternion_preset(self): """Tests that a quaternion maps to correct matrix.""" preset_quaternions = test_helpers.generate_preset_test_quaternions() preset_matrices = test_helpers.generate_preset_test_rotation_matrices_3d() self.assertAllClose(preset_matrices, rotation_matrix_3d.from_quaternion(preset_quaternions))
def test_from_rotation_matrix_jacobian_preset(self): """Test the Jacobian of the from_rotation_matrix function.""" if tf.executing_eagerly(): self.skipTest(reason="Graph mode only test") with tf.compat.v1.Session() as sess: x_init = np.array( sess.run(test_helpers.generate_preset_test_rotation_matrices_3d())) x = tf.convert_to_tensor(value=x_init) y = quaternion.from_rotation_matrix(x) self.assert_jacobian_is_finite(x, x_init, y)
def test_rotate_jacobian_preset(self): """Test the Jacobian of the rotate function.""" x_matrix_init = test_helpers.generate_preset_test_rotation_matrices_3d( ) x_matrix = tf.convert_to_tensor(value=x_matrix_init) tensor_shape = x_matrix.shape[:-1] x_point_init = np.random.uniform(size=tensor_shape) x_point = tf.convert_to_tensor(value=x_point_init) y = rotation_matrix_3d.rotate(x_point, x_matrix) self.assert_jacobian_is_correct(x_matrix, x_matrix_init, y) self.assert_jacobian_is_correct(x_point, x_point_init, y)
def test_inverse_jacobian_preset(self): """Test the Jacobian of the inverse function.""" x_init = test_helpers.generate_preset_test_rotation_matrices_3d() self.assert_jacobian_is_correct_fn(rotation_matrix_3d.inverse, [x_init])