Exemplo n.º 1
0
  def test_from_quaternion_jacobian_random(self):
    """Test the Jacobian of the from_quaternion function.

    Note:
      Preset angles are not tested as the gradient of tf.norm is NaN a 0.
    """
    x_init = test_helpers.generate_random_test_quaternions()

    self.assert_jacobian_is_finite_fn(
        lambda x: axis_angle.from_quaternion(x)[0], [x_init])
    self.assert_jacobian_is_finite_fn(
        lambda x: axis_angle.from_quaternion(x)[1], [x_init])
Exemplo n.º 2
0
  def test_from_quaternion_normalized_random(self):
    """Tests that from_quaternion returns normalized axis-angles."""
    random_quaternions = test_helpers.generate_random_test_quaternions()

    random_axis, random_angle = axis_angle.from_quaternion(random_quaternions)

    self.assertAllEqual(
        axis_angle.is_normalized(random_axis, random_angle),
        np.ones(random_angle.shape))
Exemplo n.º 3
0
  def test_from_quaternion_normalized_preset(self):
    """Tests that from_quaternion returns normalized axis-angles."""
    euler_angles = test_helpers.generate_preset_test_euler_angles()

    quat = quaternion.from_euler(euler_angles)
    axis, angle = axis_angle.from_quaternion(quat)

    self.assertAllEqual(
        axis_angle.is_normalized(axis, angle), np.ones(angle.shape, dtype=bool))
Exemplo n.º 4
0
    def test_from_quaternion_random(self):
        """Tests that axis_angle.from_quaternion produces the expected result."""
        random_euler_angles = test_helpers.generate_random_test_euler_angles()

        random_quaternions = quaternion.from_euler(random_euler_angles)
        random_axis_angle = axis_angle.from_euler(random_euler_angles)

        self.assertAllClose(random_axis_angle,
                            axis_angle.from_quaternion(random_quaternions),
                            rtol=1e-3)
Exemplo n.º 5
0
    def test_from_quaternion_preset(self):
        """Tests that axis_angle.from_quaternion produces the expected result."""
        preset_euler_angles = test_helpers.generate_preset_test_euler_angles()

        preset_quaternions = quaternion.from_euler(preset_euler_angles)
        preset_axis_angle = axis_angle.from_euler(preset_euler_angles)

        self.assertAllClose(preset_axis_angle,
                            axis_angle.from_quaternion(preset_quaternions),
                            rtol=1e-3)
Exemplo n.º 6
0
    def test_from_quaternion_jacobian_random(self):
        """Test the Jacobian of the from_quaternion function.

    Note:
      Preset angles are not tested as the gradient of tf.norm is NaN a 0.
    """
        x_init = test_helpers.generate_random_test_quaternions()
        x = tf.convert_to_tensor(value=x_init)

        y_axis, y_angle = axis_angle.from_quaternion(x)

        self.assert_jacobian_is_finite(x, x_init, y_axis)
        self.assert_jacobian_is_finite(x, x_init, y_angle)