Example #1
0
def test_jacobian_right():
    rho_vec = np.array([[1, 2]]).T
    theta = 3 * np.pi / 4
    xi_vec = np.vstack((rho_vec, theta))

    J_r = SE2.jac_right(xi_vec)

    # Test the Jacobian numerically.
    delta = 1e-3 * np.ones((3, 1))
    taylor_diff = SE2.Exp(xi_vec + delta) - (SE2.Exp(xi_vec) + J_r @ delta)
    np.testing.assert_almost_equal(taylor_diff, np.zeros((3, 1)), 5)
Example #2
0
def test_jacobian_left():
    rho_vec = np.array([[2, 1]]).T
    theta = np.pi / 4
    xi_vec = np.vstack((rho_vec, theta))

    J_l = SE2.jac_left(xi_vec)

    # Should have J_l(xi_vec) == J_r(-xi_vec).
    np.testing.assert_almost_equal(J_l, SE2.jac_right(-xi_vec), 14)

    # Test the Jacobian numerically (using Exps and Logs, since left oplus and ominus have not been defined).
    delta = 1e-3 * np.ones((3, 1))
    taylor_diff = SE2.Log(
        SE2.Exp(xi_vec + delta)
        @ (SE2.Exp(J_l @ delta) @ SE2.Exp(xi_vec)).inverse())
    np.testing.assert_almost_equal(taylor_diff, np.zeros((3, 1)), 5)