Kernels are mostly internal data structures for dealing with the exponential map and logarithm of Lie groups such as and . The gtsam.so3 classes evaluate the scalar functions used by the exponential-map Jacobian and its inverse: Kernel represents a forward kernel, while InvJKernel couples the inverse Jacobian to its forward counterpart for stable evaluation.
import gtsam
import numpy as npObtaining the kernels¶
Users normally obtain these objects from so3.DexpFunctor, which precomputes coefficients for a rotation vector and handles the near-zero series expansions.
omega = np.array([0.1, -0.2, 0.3])
dexp = gtsam.so3.DexpFunctor(omega)
jacobian_kernel = dexp.Jacobian()
inverse_kernel = dexp.InvJacobian()so3.Kernel¶
left() and right() return the left and right Jacobian matrices. applyLeft(v) and applyRight(v) apply those matrices to a vector without requiring callers to form the product themselves. frechet() and applyFrechet() expose derivatives of the kernel action.
J_left = jacobian_kernel.left()
vector = np.array([1.0, 2.0, -1.0])
np.testing.assert_allclose(
jacobian_kernel.applyLeft(vector), J_left @ vector, atol=1e-12
)
print("left Jacobian:")
print(J_left)so3.InvJKernel¶
left() and right() return inverse Jacobians, and applyLeft()/applyRight() apply them. Its public J property retains the associated forward kernel.
J_left_inverse = inverse_kernel.left()
np.testing.assert_allclose(J_left_inverse @ J_left, np.eye(3), atol=1e-12)
np.testing.assert_allclose(
inverse_kernel.applyLeft(vector), J_left_inverse @ vector, atol=1e-12
)