### Install PyMLG Package Source: https://context7.com/decargroup/pymlg/llms.txt Installs the PyMLG package in editable mode using pip. This command is typically run from the project's root directory. ```bash pip install -e . ``` -------------------------------- ### SO2 Vee Operator and Exponential Map Source: https://context7.com/decargroup/pymlg/llms.txt Performs the inverse of the wedge operator (vee) to get the scalar angle from a so(2) Lie algebra element and computes the exponential map to return to SO2. Requires the SO2 module. ```python from pymlg import SO2 # Vee operator: so(2) -> R phi = SO2.vee(Xi) # Exp/log maps C = SO2.exp(Xi) Xi = SO2.log(C) ``` -------------------------------- ### SO3 Class Methods Source: https://github.com/decargroup/pymlg/blob/main/docs/source/_autosummary/pymlg.SO3.md This section details the static methods available for the SO3 class, including transformations between group elements and their corresponding Lie algebra representations, as well as utility functions. ```APIDOC ## SO3 Class Methods ### Description This section details the static methods available for the SO3 class, including transformations between group elements and their corresponding Lie algebra representations, as well as utility functions. ### Methods #### `Exp(x)` **Description:** Maps elements of the vector Lie algebra so(3) to the group. **Method:** STATIC **Endpoint:** N/A (Class method) **Parameters:** None **Request Example:** ```json { "example": "pymlg.SO3.Exp(so3_element)" } ``` **Response:** #### Success Response (200) - **type**: np.ndarray Description: The corresponding group element. #### Response Example: ```json { "example": "group_element_matrix" } ``` #### `Log(x)` **Description:** Shortcut method: group to R^n directly. $$ \mathrm{Log}: G \to \mathbb{R}^n $$ **Method:** STATIC **Endpoint:** N/A (Class method) **Parameters:** #### Path Parameters None #### Query Parameters None #### Request Body - **X** (np.ndarray) - Required - Element of the group. **Request Example:** ```json { "X": "[[...], [...], [...]]" } ``` **Response:** #### Success Response (200) - **type**: np.ndarray Description: Vector of exponential coordinates with shape (n,1). #### Response Example: ```json { "example": "[[...]]" } ``` #### `adjoint(x)` **Description:** Adjoint representation of *group* element. $$ \mathrm{Ad}(\mathbf{X}) $$ **Method:** STATIC **Endpoint:** N/A (Class method) **Parameters:** #### Path Parameters None #### Query Parameters None #### Request Body - **X** (np.ndarray) - Required - Element of the group. **Request Example:** ```json { "X": "[[...], [...], [...]]" } ``` **Response:** #### Success Response (200) - **type**: np.ndarray Description: The matrix $\mathrm{Ad}(\mathbf{X})$ with shape (dof,dof). #### Response Example: ```json { "example": "[[...], [...], [...]]" } ``` #### `adjoint_algebra(x)` **Description:** Adjoint representation of *algebra* element. $$ \mathrm{ad}(\mathbf{\Xi}) $$ **Method:** STATIC **Endpoint:** N/A (Class method) **Parameters:** #### Path Parameters None #### Query Parameters None #### Request Body - **Xi** (np.ndarray) - Required - Element of the Lie algebra. **Request Example:** ```json { "Xi": "[[...], [...], [...]]" } ``` **Response:** #### Success Response (200) - **type**: np.ndarray Description: The matrix $\mathrm{ad}(\mathbf{\Xi})$. #### Response Example: ```json { "example": "[[...], [...], [...]]" } ``` #### `cross(xi)` **Description:** Alternate name for SO3.wedge. **Method:** STATIC **Endpoint:** N/A (Class method) **Parameters:** None **Request Example:** ```json { "example": "pymlg.SO3.cross(xi_element)" } ``` **Response:** #### Success Response (200) - **type**: Any Description: Result of the wedge operation. #### Response Example: ```json { "example": "result" } ``` #### `exp(x)` **Description:** Maps elements of the matrix Lie algebra so(3) to the group. From Section 8.3 of Lie Groups for Computer Vision by Ethan Eade. When theta is small, use Taylor series expansion given in Section 11. **Method:** STATIC **Endpoint:** N/A (Class method) **Parameters:** None **Request Example:** ```json { "example": "pymlg.SO3.exp(so3_algebra_element)" } ``` **Response:** #### Success Response (200) - **type**: np.ndarray Description: The corresponding group element. #### Response Example: ```json { "example": "group_element_matrix" } ``` #### `from_euler(angles, order=[3, 2, 1])` **Description:** Creates a DCM from a 3-element vector of euler angles with specified order. **Method:** STATIC **Endpoint:** N/A (Class method) **Parameters:** #### Path Parameters None #### Query Parameters None #### Request Body - **angles** (list or np.ndarray) - Required - Euler angle values. - **order** (list) - Optional - Euler angle sequence. For example, the default order=[3,2,1] rotates the third axis, followed by the second, followed by the first. **Request Example:** ```json { "angles": [0.1, 0.2, 0.3], "order": [3, 2, 1] } ``` **Response:** #### Success Response (200) - **type**: np.ndarray Description: DCM corresponding to euler angles with shape (3,3). #### Response Example: ```json { "example": "[[...], [...], [...]]" } ``` #### `from_quat(q, order='wxyz')` **Description:** Returns the DCM corresponding to the quaternion representation q. $$ \mathbf{C} = (1 - 2 \mathbf{\epsilon}^T \mathbf{\epsilon}) \mathbf{1} + 2 \mathbf{\epsilon \epsilon}^T + 2 \eta \mathbf{\epsilon}^{\times} $$ Note that the final term is positive to abide by robotics convention. This differs from Barfoot (2019). **Method:** STATIC **Endpoint:** N/A (Class method) **Parameters:** #### Path Parameters None #### Query Parameters None #### Request Body - **q** (list or np.ndarray) - Required - Quaternion of size 4. - **order** (str) - Optional - Quaternion element order “xyzw” or “wxyz”, by default “wxyz”. **Request Example:** ```json { "q": [0.1, 0.2, 0.3, 0.4], "order": "wxyz" } ``` **Response:** #### Success Response (200) - **type**: np.ndarray Description: DCM corresponding to q with shape (3,3). #### Response Example: ```json { "example": "[[...], [...], [...]]" } ``` #### `from_ros(q)` **Description:** Converts a ROS quaternion to a DCM. **Method:** STATIC **Endpoint:** N/A (Class method) **Parameters:** #### Path Parameters None #### Query Parameters None #### Request Body - **q** (geometry_msgs.msg.Quaternion) - Required - ROS quaternion. **Request Example:** ```json { "q": "{x: 0.1, y: 0.2, z: 0.3, w: 0.4}" } ``` **Response:** #### Success Response (200) - **type**: np.ndarray Description: DCM corresponding to q with shape (3,3). #### Response Example: ```json { "example": "[[...], [...], [...]]" } ``` #### `identity()` **Description:** Returns an identity matrix of the group. **Method:** STATIC **Endpoint:** N/A (Class method) **Parameters:** None **Request Example:** ```json { "example": "pymlg.SO3.identity()" } ``` **Response:** #### Success Response (200) - **type**: np.ndarray Description: Identity matrix of the group with shape (n,n). #### Response Example: ```json { "example": "[[1, 0, 0], [0, 1, 0], [0, 0, 1]]" } ``` #### `inverse(x)` **Description:** Group inverse. **Method:** STATIC **Endpoint:** N/A (Class method) **Parameters:** #### Path Parameters None #### Query Parameters None #### Request Body - **X** (np.ndarray) - Required - Element of the group. **Request Example:** ```json { "X": "[[...], [...], [...]]" } ``` **Response:** #### Success Response (200) - **type**: np.ndarray Description: Element of the group with shape (n,n). #### Response Example: ```json { "example": "[[...], [...], [...]]" } ``` #### `left_jacobian(x)` **Description:** Computes the Left Jacobian of SO(3). From Section 9.3 of Lie Groups for Computer Vision by Ethan Eade. When angle is small, use Taylor series expansion given in Section 11. **Method:** STATIC **Endpoint:** N/A (Class method) **Parameters:** None **Request Example:** ```json { "example": "pymlg.SO3.left_jacobian(group_element)" } ``` **Response:** #### Success Response (200) - **type**: np.ndarray Description: The Left Jacobian matrix. #### Response Example: ```json { "example": "[[...], [...], [...]]" } ``` #### `left_jacobian_inv(x)` **Description:** Computes the inverse of the left Jacobian of SO(3). From Section 9.3 of Lie Groups for Computer Vision by Ethan Eade. When angle is small, use Taylor series expansion given in Section 11. **Method:** STATIC **Endpoint:** N/A (Class method) **Parameters:** None **Request Example:** ```json { "example": "pymlg.SO3.left_jacobian_inv(group_element)" } ``` **Response:** #### Success Response (200) - **type**: np.ndarray Description: The inverse of the Left Jacobian matrix. #### Response Example: ```json { "example": "[[...], [...], [...]]" } ``` #### `log(x)` **Description:** Logarithmic map from algebra to group. $$ \mathrm{log}: G \to \mathfrak{g} $$ **Method:** STATIC **Endpoint:** N/A (Class method) **Parameters:** #### Path Parameters None #### Query Parameters None #### Request Body - **X** (np.ndarray) - Required - Element of the group. **Request Example:** ```json { "X": "[[...], [...], [...]]" } ``` **Response:** #### Success Response (200) - **type**: np.ndarray Description: Element of the Lie algebra with shape (n,n). #### Response Example: ```json { "example": "[[...], [...], [...]]" } ``` #### `normalize(X)` **Description:** Eliminates rounding errors: ensures matrix is proper group element. **Method:** STATIC **Endpoint:** N/A (Class method) **Parameters:** #### Path Parameters None #### Query Parameters None #### Request Body - **X** (np.ndarray) - Required - Element of the group. **Request Example:** ```json { "X": "[[...], [...], [...]]" } ``` **Response:** #### Success Response (200) - **type**: np.ndarray Description: Element of the group with shape (n,n). #### Response Example: ```json { "example": "[[...], [...], [...]]" } ``` ``` -------------------------------- ### Configure GoogleTest and Build Test Executable with CMake Source: https://github.com/decargroup/pymlg/blob/main/tests/cpp/CMakeLists.txt This script uses FetchContent to download and build GoogleTest from a specific release. It then defines an executable for Lie group tests, links the necessary Eigen and GTest libraries, and registers the tests with CTest. ```cmake include(FetchContent) FetchContent_Declare( googletest URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip ) # For Windows: Prevent overriding the parent project's compiler/linker settings set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) FetchContent_MakeAvailable(googletest) include(GoogleTest) add_executable(test_liegroups test_so3.cpp test_se3.cpp) target_link_libraries(test_liegroups PRIVATE GTest::gtest_main Eigen3::Eigen) target_include_directories(test_liegroups PRIVATE ${CMAKE_SOURCE_DIR}/pymlg/cpp ) gtest_discover_tests(test_liegroups) ``` -------------------------------- ### Accessing Backend-Specific Implementations Source: https://github.com/decargroup/pymlg/blob/main/README.md Shows how to import specific Lie group implementations for Numpy, C++, and Jax backends. The API remains consistent regardless of the chosen backend. ```python # Explicit Numpy implementation from pymlg.numpy import SO2, SO3, SE2, SE3, SE23 # Explicit C++ implementation from pymlg.cpp import SO3, SE3, SE23 # Explicit Jax implementation from pymlg.jax import SE2 ``` -------------------------------- ### SE3.to_ros Source: https://github.com/decargroup/pymlg/blob/main/docs/source/_autosummary/pymlg.SE3.md Constructs a ROS Pose message from an SE(3) matrix. ```APIDOC ## static to_ros(T) ### Description Constructs a ROS Pose message from an SE(3) matrix. ### Method Static ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **ros_pose_message** (geometry_msgs.msg.Pose) - The ROS Pose message. #### Response Example ```json { "ros_pose_message": "[ROS Pose message object]" } ``` ``` -------------------------------- ### SE3 Composition and Adjoint Matrices Source: https://context7.com/decargroup/pymlg/llms.txt Demonstrates composing SE(3) transformations using standard matrix multiplication and calculates both the Adjoint matrix and the algebra adjoint matrix. Requires the SE3 module. ```python from pymlg import SE3 # Compose transformations T_ab = SE3.random() T_bc = SE3.random() T_ac = T_ab @ T_bc # standard matrix multiplication # Adjoint matrix (6x6) Ad = SE3.adjoint(T) # Algebra adjoint (6x6) ad = SE3.adjoint_algebra(Xi) ``` -------------------------------- ### SE2 from Components and Wedge/Vee Operators Source: https://context7.com/decargroup/pymlg/llms.txt Creates an SE(2) pose from a rotation matrix and translation vector, or directly from an angle and translation vector. Also demonstrates the wedge and vee operators for SE(2). Requires the SE2 module and numpy. ```python from pymlg import SE2 import numpy as np # Create pose from rotation matrix and translation C = np.array([[np.cos(0.5), -np.sin(0.5)], [np.sin(0.5), np.cos(0.5)]]) r = np.array([1.0, 2.0]) T = SE2.from_components(C, r) # Also accepts rotation angle directly T = SE2.from_components(0.5, r) # angle in radians # Wedge/vee operators Xi = SE2.wedge(xi) # 3x3 Lie algebra element xi = SE2.vee(Xi) # shape (3, 1) vector ``` -------------------------------- ### Robotics Pose Composition and Perturbation Source: https://context7.com/decargroup/pymlg/llms.txt Illustrates common robotics workflows for composing poses, applying perturbations in body or world frames, and calculating relative pose errors using SE(3). ```python from pymlg import SE3 import numpy as np T_world_body1 = SE3.random() T_body1_body2 = SE3.from_components(np.eye(3), np.array([1.0, 0.0, 0.0])) # Compose and perturb T_world_body2 = T_world_body1 @ T_body1_body2 delta_xi = np.array([0.01, 0.02, 0.03, 0.1, 0.2, 0.3]) T_perturbed = T_world_body2 @ SE3.Exp(delta_xi) # Error calculation xi_error = SE3.Log(SE3.inverse(T_world_body1) @ T_perturbed) ``` -------------------------------- ### State Estimation with Jacobians Source: https://context7.com/decargroup/pymlg/llms.txt Demonstrates the use of Lie group Jacobians for linearizing measurement models in state estimation problems, comparing analytical left Jacobians with numerical approximations. ```python from pymlg import SE3 import numpy as np T_est = SE3.random() xi_est = SE3.Log(T_est) p_world = np.array([5.0, 3.0, 1.0]) # Compute Jacobian J_left = SE3.left_jacobian(xi_est) # Numerical validation h = 1e-8 # ... (loop to compute numerical Jacobian) ``` -------------------------------- ### Cross-Backend API Usage Source: https://context7.com/decargroup/pymlg/llms.txt Shows how to utilize different backends (NumPy, C++, JAX, PyTorch) within the pymlg library to balance performance requirements and gradient computation needs. ```python from pymlg.numpy import SO3 as SO3_np from pymlg.cpp import SO3 as SO3_cpp from pymlg.jax import SO3 as SO3_jax from pymlg.torch import SO3 as SO3_torch # Consistent API across backends C = SO3_np.random() phi = SO3_np.Log(C) ``` -------------------------------- ### SO3 Quaternion and Euler Angle Conversions (NumPy) Source: https://context7.com/decargroup/pymlg/llms.txt Provides utilities for converting between rotation matrices, quaternions (wxyz and xyzw orders), and Euler angles (3-2-1 and 1-2-3 sequences) for the SO(3) group using NumPy. ```python from pymlg import SO3 import numpy as np # Create rotation matrix from quaternion (wxyz order) q_wxyz = np.array([0.707, 0.0, 0.707, 0.0]) # 90 degree rotation about y-axis C = SO3.from_quat(q_wxyz, order="wxyz") # Output: 3x3 rotation matrix # Create rotation matrix from quaternion (xyzw order) q_xyzw = np.array([0.0, 0.707, 0.0, 0.707]) C = SO3.from_quat(q_xyzw, order="xyzw") # Output: 3x3 rotation matrix # Convert rotation matrix to quaternion q = SO3.to_quat(C, order="wxyz") # Output: shape (4, 1) quaternion [w, x, y, z] q = SO3.to_quat(C, order="xyzw") # Output: shape (4, 1) quaternion [x, y, z, w] # Create rotation matrix from Euler angles (default 3-2-1 sequence: yaw-pitch-roll) angles = np.array([0.1, 0.2, 0.3]) # [roll, pitch, yaw] C = SO3.from_euler(angles, order=[3, 2, 1]) # Output: 3x3 rotation matrix # Convert rotation matrix to Euler angles (3-2-1 sequence) rpy = SO3.to_euler(C, order="321") # Output: [roll, pitch, yaw] array # Convert to Euler angles (1-2-3 sequence) rpy = SO3.to_euler(C, order="123") # Output: [roll, pitch, yaw] array ``` -------------------------------- ### SE3 ROS Integration: To ROS Pose Source: https://context7.com/decargroup/pymlg/llms.txt Converts an SE(3) transformation matrix to a ROS Pose message. Requires the SE3 module. ```python from pymlg import SE3 # Convert SE3 matrix to ROS Pose # pose_msg = SE3.to_ros(T) ``` -------------------------------- ### SE2 Algebra Adjoint and Jacobians Source: https://context7.com/decargroup/pymlg/llms.txt Calculates the algebra adjoint matrix and the left/right Jacobians (and their inverses) for SE(2) transformations. Requires the SE2 module. ```python from pymlg import SE2 # Algebra adjoint (3x3) ad = SE2.adjoint_algebra(Xi) # Jacobians J_L = SE2.left_jacobian(xi) J_R = SE2.right_jacobian(xi) J_L_inv = SE2.left_jacobian_inv(xi) J_R_inv = SE2.right_jacobian_inv(xi) ``` -------------------------------- ### SE3.synthesize Source: https://github.com/decargroup/pymlg/blob/main/docs/source/_autosummary/pymlg.SE3.md Deprecated method to construct an SE(3) matrix from a rotation matrix and translation vector. Use SE3.from_components(C,r) instead. ```APIDOC ## static synthesize(C, r) ### Description Deprecated. Use SE3.from_components(C,r) instead. Construct an SE(3) matrix from a rotation matrix and translation vector. ### Method Static ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **return_value** (np.ndarray) - The constructed SE(3) matrix. #### Response Example ```json { "return_value": "[numpy array representing the SE(3) matrix]" } ``` ``` -------------------------------- ### SE2 Exponential/Logarithm Maps and Adjoint Source: https://context7.com/decargroup/pymlg/llms.txt Computes the exponential and logarithm maps for SE(2) transformations and calculates the Adjoint matrix for SE(2). Requires the SE2 module. ```python from pymlg import SE2 # Exp/log maps T = SE2.exp(Xi) Xi = SE2.log(T) # Adjoint matrix (3x3) Ad = SE2.adjoint(T) ``` -------------------------------- ### Lie Group Operations for SE(2,3) and SL(3) Source: https://context7.com/decargroup/pymlg/llms.txt Demonstrates core Lie group operations including exponential/logarithmic maps, wedge/vee operators, and adjoint computations for SE(2,3) and SL(3) groups. These operations are essential for handling transformations and coordinate representations in 3D space. ```python from pymlg import SE23, SL3 import numpy as np # SE(2,3) operations xi = np.array([0.1, 0.2, 0.3, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0]) X = SE23.Exp(xi) Xi = SE23.wedge(xi) Ad = SE23.adjoint(X) # SL(3) operations H = SL3.random() xi_sl3 = SL3.Log(H) Xi_sl3 = SL3.wedge(xi_sl3) p = np.array([1.0, 2.0, 1.0]) p_odot = SL3.odot(p) ``` -------------------------------- ### SE3 Exponential/Logarithm Maps and Inverse Source: https://context7.com/decargroup/pymlg/llms.txt Computes the exponential and logarithm maps for SE(3) transformations and calculates the inverse of a transformation matrix. Requires the SE3 module. ```python from pymlg import SE3 # Exp/log maps T = SE3.exp(Xi) Xi = SE3.log(T) # Inverse transformation T_inv = SE3.inverse(T) ``` -------------------------------- ### Import Lie Groups with PyTorch Backend Source: https://context7.com/decargroup/pymlg/llms.txt Imports Lie group classes from the PyTorch backend of PyMLG. This backend is suitable for gradient computation in deep learning workflows. ```python from pymlg.torch import SO2, SO3, SE2, SE3 ``` -------------------------------- ### Perform Lie Group Operations with PyMLG Source: https://github.com/decargroup/pymlg/blob/main/README.md Demonstrates core Lie group operations such as exponential maps, logarithmic maps, wedge/vee operators, and Jacobians using the SE3 group. ```python from pymlg import SE3 import numpy as np # Random pose T = SE3.random() # R^n to group directly x = np.array([0.1, 0.2, 0.3, 4, 5, 6]) T = SE3.Exp(x) # Group to R^n directly x = SE3.Log(T) # Wedge, vee Xi = SE3.wedge(x) x = SE3.vee(Xi) # Actual exp/log maps T = SE3.exp(Xi) Xi = SE3.log(T) # Adjoint matrix representation A = SE3.adjoint(T) ad = SE3.adjoint_algebra(Xi) # Inverse of group element T_inv = SE3.inverse(T) # Group left/right jacobians J_L = SE3.left_jacobian(x) J_R = SE3.right_jacobian(x) ``` -------------------------------- ### Import Lie Groups with JAX Backend Source: https://context7.com/decargroup/pymlg/llms.txt Imports Lie group classes from the JAX backend of PyMLG. This backend supports JIT compilation for accelerated computations. ```python from pymlg.jax import SO2, SO3, SE2, SE3, SE23, SL3 ``` -------------------------------- ### SE3 Component Decomposition and Wedge/Vee Operators Source: https://context7.com/decargroup/pymlg/llms.txt Decomposes an SE(3) pose into its rotation and translation components and applies the wedge and vee operators for Lie algebra manipulation. Requires the SE3 module and numpy. ```python from pymlg import SE3 import numpy as np # Decompose pose into rotation and translation C, r = SE3.to_components(T) # Wedge operator: R^6 -> se(3) Xi = SE3.wedge(xi) # Vee operator: se(3) -> R^6 xi = SE3.vee(Xi) ``` -------------------------------- ### SE3 Random Pose Generation and Exponential Coordinates Source: https://context7.com/decargroup/pymlg/llms.txt Generates a random SE(3) transformation matrix and creates an SE(3) pose from exponential coordinates (rotation and translation). Requires the SE3 module and numpy. ```python from pymlg import SE3 import numpy as np # Generate random pose T = SE3.random() # Create pose from exponential coordinates [phi (rotation), rho (translation)] xi = np.array([0.1, 0.2, 0.3, 1.0, 2.0, 3.0]) # [phi_x, phi_y, phi_z, x, y, z] T = SE3.Exp(xi) ``` -------------------------------- ### Import Lie Groups with Default Backend Source: https://context7.com/decargroup/pymlg/llms.txt Imports common Lie group classes (SO2, SO3, SE2, SE3, SE23, SL3) and the base MatrixLieGroup class. This uses the default C++/NumPy backend. ```python from pymlg import SO2, SO3, SE2, SE3, SE23, SL3, MatrixLieGroup ``` -------------------------------- ### Mathematical Operations API Source: https://github.com/decargroup/pymlg/blob/main/docs/source/_autosummary/pymlg.SE23.md Endpoints for performing Lie group calculations, including Jacobian inversion and algebraic mapping. ```APIDOC ## POST /right_jacobian_inv ### Description Calculates the inverse of the group right jacobian evaluated at x. ### Method POST ### Endpoint /right_jacobian_inv ### Parameters #### Request Body - **x** (np.ndarray/List[float]) - Required - Input vector of size dof. ### Response #### Success Response (200) - **matrix** (np.ndarray) - The matrix J_r^-1(x) with shape (dof, dof). --- ## POST /wedge ### Description Maps a vector from R^n to the Lie algebra using the wedge operator. ### Method POST ### Endpoint /wedge ### Parameters #### Request Body - **x** (np.ndarray/List[float]) - Required - Vector of size dof. ### Response #### Success Response (200) - **matrix** (np.ndarray) - Element of the Lie algebra with shape (n,n). --- ## POST /vee ### Description Maps an element of the Lie algebra to a vector in R^n using the vee operator. ### Method POST ### Endpoint /vee ### Parameters #### Request Body - **Xi** (np.ndarray) - Required - Element of the Lie algebra with shape (n,n). ### Response #### Success Response (200) - **vector** (np.ndarray) - Vector with shape (n,1). --- ## POST /to_components ### Description Extracts rotation, velocity, and position components from an SE_2(3) matrix. ### Method POST ### Endpoint /to_components ### Parameters #### Request Body - **X** (np.ndarray) - Required - SE_2(3) matrix. ### Response #### Success Response (200) - **components** (object) - Extracted rotation, velocity, and position data. ``` -------------------------------- ### Import Lie Groups with C++ Backend Source: https://context7.com/decargroup/pymlg/llms.txt Imports Lie group classes from the C++ backend of PyMLG. This backend is optimized for performance. ```python from pymlg.cpp import SO3, SE3, SE23, SL3 ``` -------------------------------- ### SO3 ROS Integration (NumPy) Source: https://context7.com/decargroup/pymlg/llms.txt Facilitates conversion between SO(3) rotation matrices and ROS Quaternion messages. Requires the `geometry_msgs.msg.Quaternion` type. ```python from pymlg import SO3 # Requires: from geometry_msgs.msg import Quaternion # Convert ROS quaternion to rotation matrix # ros_quat = Quaternion(x=0.0, y=0.707, z=0.0, w=0.707) # C = SO3.from_ros(ros_quat) # Output: 3x3 rotation matrix # Convert rotation matrix to ROS quaternion # ros_msg = SO3.to_ros(C) # Output: geometry_msgs.msg.Quaternion ``` -------------------------------- ### SO3 - 3D Rotation Group Operations (NumPy) Source: https://context7.com/decargroup/pymlg/llms.txt Demonstrates common operations for the SO(3) 3D rotation group using the NumPy backend. Includes generating random rotations, conversions between rotation vectors and matrices, wedge/vee operators, exponential/logarithmic maps, inverse, adjoint, Jacobians, and identity. ```python from pymlg import SO3 import numpy as np # Generate random rotation matrix C = SO3.random() # Output: 3x3 rotation matrix # Create rotation from rotation vector (angle-axis) phi = np.array([0.1, 0.2, 0.3]) C = SO3.Exp(phi) # Output: 3x3 rotation matrix corresponding to rotation vector # Extract rotation vector from rotation matrix phi = SO3.Log(C) # Output: shape (3, 1) rotation vector # Wedge operator: R^3 -> so(3) (skew-symmetric matrix) Xi = SO3.wedge(phi) # Output: 3x3 skew-symmetric matrix # Vee operator: so(3) -> R^3 phi = SO3.vee(Xi) # Output: shape (3, 1) vector # Exponential map: so(3) -> SO(3) C = SO3.exp(Xi) # Output: 3x3 rotation matrix # Logarithmic map: SO(3) -> so(3) Xi = SO3.log(C) # Output: 3x3 skew-symmetric matrix # Inverse (transpose for rotation matrices) C_inv = SO3.inverse(C) # Output: 3x3 rotation matrix (C^T) # Adjoint representation of group element Ad = SO3.adjoint(C) # Output: 3x3 matrix (equals C for SO3) # Adjoint representation of algebra element ad = SO3.adjoint_algebra(Xi) # Output: 3x3 matrix # Left and right Jacobians J_L = SO3.left_jacobian(phi) J_R = SO3.right_jacobian(phi) J_L_inv = SO3.left_jacobian_inv(phi) J_R_inv = SO3.right_jacobian_inv(phi) # Output: 3x3 Jacobian matrices # Identity element I = SO3.identity() # Output: 3x3 identity matrix ``` -------------------------------- ### SE3.to_components Source: https://github.com/decargroup/pymlg/blob/main/docs/source/_autosummary/pymlg.SE3.md Decomposes an SE(3) matrix into its constituent rotation matrix and translation vector. ```APIDOC ## static to_components(T) ### Description Decompose an SE(3) matrix into a rotation matrix and translation vector. ### Method Static ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **rotation_matrix** (np.ndarray) - The rotation matrix. - **translation_vector** (np.ndarray) - The translation vector. #### Response Example ```json { "rotation_matrix": "[numpy array representing the rotation matrix]", "translation_vector": "[numpy array representing the translation vector]" } ``` ``` -------------------------------- ### SE2 Random Pose and Exponential Coordinates Source: https://context7.com/decargroup/pymlg/llms.txt Generates a random SE(2) transformation matrix and creates an SE(2) pose from exponential coordinates (angle, x, y). Requires the SE2 module and numpy. ```python from pymlg import SE2 import numpy as np # Generate random 2D pose T = SE2.random() # Create pose from exponential coordinates [phi, x, y] xi = np.array([0.1, 2.0, 3.0]) # [rotation angle, x, y] T = SE2.Exp(xi) ``` -------------------------------- ### SO2 - 2D Rotation Group Operations (NumPy) Source: https://context7.com/decargroup/pymlg/llms.txt Demonstrates basic operations for the SO(2) 2D rotation group using the NumPy backend. Includes generating random rotations and creating rotations from angles. ```python from pymlg import SO2 import numpy as np # Generate random 2D rotation C = SO2.random() # Output: 2x2 rotation matrix # Create rotation from angle phi = 0.5 # radians C = SO2.Exp(phi) # Output: 2x2 rotation matrix [[cos, -sin], [sin, cos]] ``` -------------------------------- ### SE2 Lie Group Operations in Python Source: https://github.com/decargroup/pymlg/blob/main/docs/source/index.md Demonstrates common operations for the SE2 Lie group using the pymlg library. This includes generating random poses, converting between group elements and R^n, wedge/vee operations, exponential and logarithm maps, adjoint representation, Jacobians, and the odot operator. It requires numpy and pymlg. ```python from pymlg import SE2 import numpy as np # Random pose T = SE2.random() # R^n to group directly (using "Capital" notation) x = np.array([0.1, 2, 3]) T = SE2.Exp(x) # Group to R^n directly x = SE2.Log(T) # Wedge, vee Xi = SE2.wedge(x) x = SE2.vee(Xi) # Actual exp/log maps T = SE2.exp(Xi) Xi = SE2.log(T) # Adjoint representation of group element A = SE2.adjoint(T) # Group left/right jacobians J_L = SE2.left_jacobian(x) J_R = SE2.right_jacobian(x) J_L_inv = SE2.left_jacobian_inv(x) J_R_inv = SE2.right_jacobian_inv(x) # odot operator (defined such that wedge(a) * b = odot(b) * a) b = np.array([1, 2, 3]) B = SE2.odot(b) ``` -------------------------------- ### SE3 Jacobians and odot Operator Source: https://context7.com/decargroup/pymlg/llms.txt Calculates the left, right, and inverse left/right Jacobians for SE(3) and demonstrates the odot operator for transforming points. Requires the SE3 module and numpy. ```python from pymlg import SE3 import numpy as np # Left/right Jacobians (6x6) J_L = SE3.left_jacobian(xi) J_R = SE3.right_jacobian(xi) J_L_inv = SE3.left_jacobian_inv(xi) J_R_inv = SE3.right_jacobian_inv(xi) # odot operator for point transformation b = np.array([1.0, 2.0, 3.0, 1.0]) # homogeneous point B_odot = SE3.odot(b) ``` -------------------------------- ### SE3 Logarithm and Component Extraction Source: https://context7.com/decargroup/pymlg/llms.txt Extracts exponential coordinates from an SE(3) transformation matrix and creates an SE(3) pose from rotation matrix and translation vector components. Requires the SE3 module and numpy. ```python from pymlg import SE3 import numpy as np # Extract exponential coordinates xi = SE3.Log(T) # Create pose from rotation matrix and translation vector C = np.eye(3) # rotation matrix r = np.array([1.0, 2.0, 3.0]) # translation vector T = SE3.from_components(C, r) ``` -------------------------------- ### SO2 Jacobians and Adjoint Source: https://context7.com/decargroup/pymlg/llms.txt Calculates the left and right Jacobians, as well as the adjoint matrix for SO(2) transformations. These are identity matrices for SO(2). Requires the SO2 module. ```python from pymlg import SO2 # Jacobians (identity for SO2) J_L = SO2.left_jacobian(phi) J_R = SO2.right_jacobian(phi) # Adjoint (identity for SO2) Ad = SO2.adjoint(C) ``` -------------------------------- ### Static Wedge Operator Source: https://github.com/decargroup/pymlg/blob/main/docs/source/_autosummary/pymlg.SE2.md Maps a vector representation to an element of the Lie algebra. ```APIDOC ## STATIC wedge(xi) ### Description The wedge operator maps a vector in R^n to an element of the Lie algebra. ### Method STATIC ### Endpoint wedge(xi) ### Parameters #### Request Body - **xi** (np.ndarray or List[float]) - Required - Vector of size dof. ### Response #### Success Response (200) - **result** (np.ndarray) - Element of the Lie algebra with shape (n,n). ``` -------------------------------- ### SO2 Logarithm and Wedge Operator Source: https://context7.com/decargroup/pymlg/llms.txt Extracts the angle from a rotation matrix (SO2) and computes the wedge operator to map the angle to the so(2) Lie algebra. Requires the SO2 module. ```python from pymlg import SO2 # Extract angle from rotation matrix phi = SO2.Log(C) # Wedge operator: R -> so(2) (2x2 skew-symmetric) Xi = SO2.wedge(phi) ``` -------------------------------- ### SE2 Logarithm and Component Extraction Source: https://context7.com/decargroup/pymlg/llms.txt Extracts exponential coordinates from an SE(2) transformation matrix and decomposes an SE(2) pose into its rotation matrix and translation vector. Requires the SE2 module and numpy. ```python from pymlg import SE2 import numpy as np # Extract exponential coordinates xi = SE2.Log(T) # Decompose pose C, r = SE2.to_components(T) ``` -------------------------------- ### Static Vee Operator Source: https://github.com/decargroup/pymlg/blob/main/docs/source/_autosummary/pymlg.SE2.md Maps an element of the Lie algebra to its vector representation. ```APIDOC ## STATIC vee(Xi) ### Description The vee operator maps an element of the Lie algebra to a vector in R^n. ### Method STATIC ### Endpoint vee(Xi) ### Parameters #### Request Body - **Xi** (np.ndarray) - Required - Element of the Lie algebra with shape (n,n). ### Response #### Success Response (200) - **result** (np.ndarray) - Vector with shape (n,1). ``` -------------------------------- ### Wedge Operator Source: https://github.com/decargroup/pymlg/blob/main/docs/source/_autosummary/pymlg.SO2.md The Wedge operator maps a vector in R^n to an element of the Lie algebra. It is a static method within the Lie algebra class. ```APIDOC ## Wedge Operator ### Description Maps a vector in R^n to an element of the Lie algebra. ### Method `static wedge(phi)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python # Assuming 'phi' is a numpy array or list of floats representing a vector result = LieAlgebraClass.wedge(phi) ``` ### Response #### Success Response (200) - **result** (np.ndarray) - Element of the Lie algebra with shape (n,n). #### Response Example ```json { "result": [[0.0, -1.0, 0.0], [1.0, 0.0, 0.0], [0.0, 0.0, 0.0]] } ``` ``` -------------------------------- ### SE3.wedge Source: https://github.com/decargroup/pymlg/blob/main/docs/source/_autosummary/pymlg.SE3.md Applies the wedge operator, mapping a vector in R^n to an element of the Lie algebra. ```APIDOC ## static wedge(x) ### Description Wedge operator (\cdot)^\wedge: \mathbb{R}^n \to \mathfrak{g}. ### Method Static ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **return_value** (np.ndarray) - Element of the Lie algebra with shape (n,n). #### Response Example ```json { "return_value": "[numpy array representing the Lie algebra element]" } ``` ``` -------------------------------- ### SE23 Random Element and Component Creation Source: https://context7.com/decargroup/pymlg/llms.txt Generates a random element of the SE_2(3) group and creates an SE_2(3) element from its rotation, velocity, and position components. Requires the SE23 module and numpy. ```python from pymlg import SE23 import numpy as np # Generate random SE_2(3) element X = SE23.random() # Create from components (rotation, velocity, position) C = np.eye(3) # rotation matrix v = np.array([1.0, 2.0, 3.0]) # velocity r = np.array([4.0, 5.0, 6.0]) # position X = SE23.from_components(C, v, r) ``` -------------------------------- ### SE3 ROS Integration: From ROS Pose Source: https://context7.com/decargroup/pymlg/llms.txt Converts a ROS Pose message to an SE(3) transformation matrix. This functionality requires the 'geometry_msgs.msg.Pose' type to be available. Requires the SE3 module. ```python from pymlg import SE3 # Requires: from geometry_msgs.msg import Pose # Convert ROS Pose to SE3 matrix # pose_msg = Pose() # pose_msg.position.x, pose_msg.position.y, pose_msg.position.z = 1.0, 2.0, 3.0 # pose_msg.orientation.w, pose_msg.orientation.x = 1.0, 0.0 # pose_msg.orientation.y, pose_msg.orientation.z = 0.0, 0.0 # T = SE3.from_ros(pose_msg) ``` -------------------------------- ### Vee Operator Source: https://github.com/decargroup/pymlg/blob/main/docs/source/_autosummary/pymlg.SO2.md The Vee operator maps an element of the Lie algebra to a vector in R^n. It is a static method within the Lie algebra class. ```APIDOC ## Vee Operator ### Description Maps an element of the Lie algebra to a vector in R^n. ### Method `static vee(X)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python # Assuming 'X' is a numpy array representing an element of the Lie algebra result = LieAlgebraClass.vee(X) ``` ### Response #### Success Response (200) - **result** (np.ndarray) - Vector with shape (n,1). #### Response Example ```json { "result": [[1.0], [2.0], [3.0]] } ``` ``` -------------------------------- ### Import Lie Groups with NumPy Backend Source: https://context7.com/decargroup/pymlg/llms.txt Imports Lie group classes specifically from the NumPy backend of PyMLG. This allows for NumPy-based array operations. ```python from pymlg.numpy import SO2, SO3, SE2, SE3, SE23, SL3 ``` -------------------------------- ### SE23 Component Decomposition Source: https://context7.com/decargroup/pymlg/llms.txt Decomposes an SE_2(3) element into its constituent rotation matrix, velocity vector, and position vector. Requires the SE23 module. ```python from pymlg import SE23 # Decompose into components C, v, r = SE23.to_components(X) ``` -------------------------------- ### SE3.right_jacobian_inv Source: https://github.com/decargroup/pymlg/blob/main/docs/source/_autosummary/pymlg.SE3.md Calculates the inverse of the group right Jacobian evaluated at a given point x. This is derived from the left_jacobian_inv implementation. ```APIDOC ## classmethod right_jacobian_inv(x) ### Description Inverse of group right jacobian evaluated at x in R^n. This is calculated from the left_jacobian_inv() implementation using the fact that $$ mathbf{J}_r^{-1}(\mathbf{x}) = \mathbf{J}_\ell^{-1}(-\mathbf{x}) $$ which holds for all matrix Lie groups. ### Method classmethod ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **return_value** (np.ndarray) - The matrix :math: mathbf{J}_r^{-1}(mathbf{x}) with shape (dof,dof). #### Response Example ```json { "return_value": "[numpy array representing the inverse right Jacobian]" } ``` ``` -------------------------------- ### SE3.vee Source: https://github.com/decargroup/pymlg/blob/main/docs/source/_autosummary/pymlg.SE3.md Applies the vee operator, mapping an element of the Lie algebra to a vector in R^n. ```APIDOC ## static vee(Xi) ### Description Vee operator (\cdot)^\vee: \mathfrak{g} \to \mathbb{R}^n. ### Method Static ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **return_value** (np.ndarray) - Vector with shape (n,1). #### Response Example ```json { "return_value": "[numpy array representing the vector]" } ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.