Pywayne VIO SO3:专业 3D 旋转与李代数工具包 - Openclaw Skills

作者:互联网

2026-03-31

AI教程

什么是 Pywayne VIO SO3?

Pywayne VIO SO3 是一个专门为从事 3D 空间计算、机器人和计算机视觉的开发人员设计的实用程序库。它提供了一套强大的函数来处理 SO(3) 旋转矩阵,促进李群和李代数之间的无缝转换。通过将此技能集成到 Openclaw Skills 中,开发人员可以高精度地自动化复杂的运动学计算和数学工作流。

该库在验证旋转矩阵、执行对数和指数映射以及处理反对称运算方面表现出色。无论您是在构建 SLAM(即时定位与地图构建)系统还是机器人仿真,此技能都能确保所有旋转相关任务的数学一致性和性能。

下载入口:https://github.com/openclaw/skills/tree/main/skills/wangyendt/so3

安装与下载

1. ClawHub CLI

从源直接安装技能的最快方式。

npx clawhub@latest install so3

2. 手动安装

将技能文件夹复制到以下位置之一

全局模式 ~/.openclaw/skills/ 工作区 /skills/

优先级:工作区 > 本地 > 内置

3. 提示词安装

将此提示词复制到 OpenClaw 即可自动安装。

请帮我使用 Clawhub 安装 so3。如果尚未安装 Clawhub,请先安装(npm i -g clawhub)。

Pywayne VIO SO3 应用场景

  • 在 SLAM 流水线中验证 SO(3) 旋转矩阵的正交性和行列式要求。
  • 在旋转矩阵、四元数(Hamilton 约定)、欧拉角和轴角表示之间进行转换。
  • 执行李群和李代数运算,如用于优化和运动插值的 Log 和 Exp 映射。
  • 计算多个旋转矩阵的平均值,用于传感器融合或降噪应用。
  • 从 3D 向量生成反对称矩阵,以简化运动学中的叉乘运算。
Pywayne VIO SO3 工作原理
  1. 该技能接收旋转输入,输入可以是单个矩阵 (3,3)、一批矩阵 (N,3,3) 或四元数、向量等替代表示。
  2. 内部验证函数(如 check_SO3)确保输入符合特殊正交群的数学要求。
  3. 该技能应用变换算法,例如使用对数映射将旋转矩阵转换为李代数(旋转向量),或使用指数映射进行逆向转换。
  4. 输出以结构化的 NumPy 数组形式生成,保持指定的约定(例如四元数的 Hamilton wxyz),并支持高性能批量操作。

Pywayne VIO SO3 配置指南

要在您的项目环境中使用此技能,请确保通过 pip 安装以下依赖项:

pip install numpy qmt scipy

安装完成后,您可以在 Openclaw Skills 脚本中访问核心功能:

from pywayne.vio.SO3 import SO3_skew, SO3_Exp, SO3_Log

Pywayne VIO SO3 数据架构与分类体系

该技能使用特定的数组维度和元数据标准管理空间数据:

数据类型 形状 要求
旋转矩阵 (3, 3) / (N, 3, 3) 正交;行列式 = 1
旋转向量 (3,) / (N, 3) 模长表示弧度单位的角度
四元数 (4,) / (N, 4) Hamilton 约定 [w, x, y, z]
欧拉角 (3,) / (N, 3) 可配置序列(如 'zyx')
name: pywayne-vio-so3
description: SO(3) rotation matrix utilities including Lie group/ Lie algebra operations, rotation representation conversions, skew-symmetric matrix operations, and rotation averaging. Use when working with 3D rotations, robot kinematics, computer vision, SLAM, or any task requiring SO(3) matrix validation and manipulation, quaternion/ axis-angle/ Euler angle conversions, Lie algebra Log/Exp mapping, skew-symmetric matrix operations, or rotation matrix averaging

Pywayne VIO SO3

Overview

Complete SO(3) rotation matrix toolkit for 3D rotations with Lie group/ Lie algebra operations, rotation representation conversions, skew-symmetric matrix operations, and rotation averaging.

Quick Start

from pywayne.vio.SO3 import SO3_skew, SO3_Exp, SO3_Log, SO3_to_quat
import numpy as np

# Skew-symmetric matrix
vec = np.array([1, 2, 3])
skew = SO3_skew(vec)  # Returns 3x3 skew-symmetric matrix

# Log/Exp mapping
R = np.eye(3)
rotvec = SO3_Log(R)  # Rotation vector (Lie algebra)
R_recon = SO3_Exp(rotvec)  # Back to rotation matrix

# Quaternion conversion
quat = SO3_to_quat(R)  # Returns [w, x, y, z]

Core Functions

Basic Operations

check_SO3(R)

Check if matrix is a valid SO(3) rotation matrix.

  • Validates shape (3, 3)
  • Checks R.T @ R = I (orthogonality)

SO3_mul(R1, R2)

Multiply two rotation matrices: R1 @ R2.

SO3_diff(R1, R2, from_1_to_2=True)

Compute relative rotation between two matrices.

  • from_1_to_2=True: Returns R1.T @ R2
  • from_1_to_2=False: Returns R2.T @ R1

SO3_inv(R)

Compute inverse of rotation matrix (transpose).

  • Supports single (3, 3) or batch (N, 3, 3) inputs

Skew-Symmetric Matrices

SO3_skew(vec)

Convert 3D vector to skew-symmetric matrix.

vec = [x, y, z] -> [[ 0, -z,  y],
                    [ z,  0, -x],
                    [-y,  x,  0]]
  • Supports single vector (3,) or batch (N, 3)

SO3_unskew(skew)

Extract vector from skew-symmetric matrix.

  • Single matrix (3, 3) -> vector (3,)
  • Batch (N, 3, 3) -> vectors (N, 3)

Rotation Representation Conversions

Quaternion

  • SO3_from_quat(q) - Quaternion [w, x, y, z] to rotation matrix
  • SO3_to_quat(R) - Rotation matrix to quaternion [w, x, y, z]
  • Uses Hamilton convention (wxyz)

Axis-Angle

  • SO3_from_axis_angle(axis, angle) - Axis-angle to rotation matrix
  • SO3_to_axis_angle(R) - Returns (axis, angle) tuple

Euler Angles

  • SO3_from_euler(euler_angles, axes='zyx', intrinsic=True) - Euler to matrix
  • SO3_to_euler(R, axes='zyx', intrinsic=True) - Matrix to Euler
  • Supports all rotation sequences

Lie Group/ Lie Algebra Mapping

SO3_Log(R)

SO(3) to so(3) log map, returns rotation vector (3D).

  • Input: (3, 3) or (N, 3, 3)
  • Output: (3,) or (N, 3)

SO3_log(R)

SO(3) to so(3) log map, returns skew-symmetric matrix (3x3).

  • Equivalent to SO3_skew(SO3_Log(R))

SO3_Exp(rotvec)

so(3) to SO(3) exp map from rotation vector.

  • Handles zero vectors gracefully
  • Input: (3,) or (N, 3)
  • Output: (3, 3) or (N, 3, 3)

SO3_exp(omega_hat)

so(3) to SO(3) exp map from skew-symmetric matrix.

  • Equivalent to SO3_Exp(SO3_unskew(omega_hat))

Averaging

SO3_mean(R)

Compute mean rotation matrix from multiple rotations.

  • Uses scipy Rotation.mean()
  • Input: (N, 3, 3)
  • Output: (3, 3)

Data Formats

Single vs Batch

  • Single matrix: shape (3, 3)
  • Batch: shape (N, 3, 3)

Most functions handle both automatically.

SO(3) Matrix Properties

R @ R.T = I  (orthogonal)
det(R) = 1   (special)

Lie Algebra Vector

Rotation vector where direction is axis, magnitude is angle.

Dependencies

Required packages:

  • numpy - Array operations
  • qmt - Quaternion utilities
  • scipy - Rotation averaging

Install with:

pip install numpy qmt scipy

Example Usage

# Create rotation from axis-angle
axis = np.array([0, 0, 1])  # Z-axis
angle = np.pi / 4  # 45 degrees
R = SO3_from_axis_angle(axis, angle)

# Verify it's valid
print(check_SO3(R))  # True

# Get Lie algebra representation
rotvec = SO3_Log(R)
print(f"Rotation vector: {rotvec}")

# Convert back
R_recon = SO3_Exp(rotvec)
print(f"Reconstruction error: {np.linalg.norm(R - R_recon):.2e}")

# Batch averaging
R_batch = np.array([R, SO3_inv(R), SO3_mul(R, R)])
R_mean = SO3_mean(R_batch)