Matrix Lie groups in Jax
Project description
jaxlie
[ API reference ] [ PyPI ]
jaxlie
is a Lie theory library for rigid body transformations and optimization
in JAX.
Current functionality:
- SO(2), SE(2), SO(3), and SE(3) Lie groups implemented as high-level dataclasses.
exp()
,log()
,adjoint()
,multiply()
,inverse()
, andidentity()
implementations for each Lie group.- Pytree registration for all dataclasses.
- Helpers + analytical Jacobians for on-manifold optimization
(
jaxlie.manifold
).
Install (Python >=3.6)
pip install jaxlie
Example usage
import numpy as onp
from jaxlie import SE3
#############################
# (1) Constructing transforms
#############################
# We can compute a w<-b transform by integrating over an se(3) screw, equivalent
# to `SE3.from_matrix(expm(wedge(twist)))`
twist = onp.array([1.0, 0.0, 0.2, 0.0, 0.5, 0.0])
T_w_b = SE3.exp(twist)
p_b = onp.random.randn(3)
# We can print the (quaternion) rotation term; this is a `SO3` object:
print(T_w_b.rotation)
# Or print the translation; this is a simple array with shape (3,):
print(T_w_b.translation)
# Or the underlying parameters; this is a length-7 (translation, quaternion) array:
print(T_w_b.xyz_wxyz) # SE3-specific field
print(T_w_b.parameters) # Alias shared by all groups
# There are also other helpers to generate transforms, eg from matrices:
T_w_b = SE3.from_matrix(T_w_b.as_matrix())
# Or from explicit rotation and translation terms:
T_w_b = SE3.from_rotation_and_translation(
rotation=T_w_b.rotation,
translation=T_w_b.translation,
)
# Or with the dataclass constructor + the underlying length-7 parameterization:
T_w_b = SE3(xyz_wxyz=T_w_b.xyz_wxyz)
#############################
# (2) Applying transforms
#############################
# Transform points with the `@` operator:
p_w = T_w_b @ p_b
print(p_w)
# or `.apply()`:
p_w = T_w_b.apply(p_b)
print(p_w)
# or the homogeneous matrix form:
p_w = (T_w_b.as_matrix() @ onp.append(p_b, 1.0))[:-1]
print(p_w)
#############################
# (3) Composing transforms
#############################
# Compose transforms with the `@` operator:
T_b_a = SE3.identity()
T_w_a = T_w_b @ T_b_a
print(T_w_a)
# or `.multiply()`:
T_w_a = T_w_b.multiply(T_b_a)
print(T_w_a)
#############################
# (4) Misc
#############################
# Compute inverses:
T_b_w = T_w_b.inverse()
identity = T_w_b @ T_b_w
print(identity)
# Compute adjoints:
adjoint_T_w_b = T_w_b.adjoint()
print(adjoint_T_w_b)
# Recover our twist, equivalent to `vee(logm(T_w_b.as_matrix()))`:
twist = T_w_b.log()
print(twist)
Misc
jaxlie
is heavily inspired by the C++ library
Sophus.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
jaxlie-0.0.2.tar.gz
(12.0 kB
view details)
Built Distribution
jaxlie-0.0.2-py3-none-any.whl
(14.3 kB
view details)
File details
Details for the file jaxlie-0.0.2.tar.gz
.
File metadata
- Download URL: jaxlie-0.0.2.tar.gz
- Upload date:
- Size: 12.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 98ba50e13bda4adace738d586b6a2a310a18d2cfdc76f1f9ca29fbd6f3ed0bdd |
|
MD5 | 429d5edb9f2bfe68599c8cdd25ce065c |
|
BLAKE2b-256 | 22f39685191412fddf75a3204e78c59d7779597f0084489b77ffb38b7951c4d6 |
File details
Details for the file jaxlie-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: jaxlie-0.0.2-py3-none-any.whl
- Upload date:
- Size: 14.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d57d76d98e14aa33b863e189048be8907ef33b6cb47d45bc9fd94f5bcd7e96a |
|
MD5 | c71a90589d8e6524812e8744174a0fbc |
|
BLAKE2b-256 | 25fed175bba733bf5e10e67fc4cbd059a538b866faa3b266d9317e598b82b299 |