Repository navigation
feat: add differentiable forward kinematics with a MotrixSim tree loader - #163
Merged
Merged
Conversation
WP-B of the SuperMimic MBRL backend plan (PR-3 + PR-4): - env_core/math: KinematicTree (pure torch data: parents, joint axes, fixed offsets in repo-wide xyzw) with differentiable positions()/forward() tree recursions; gradients flow to the root state and joint states. axis_angle_to_mat lives in the torch-native math.rotation module. Tests pin a planar 3-link arm against closed forms and finite differences in float64. - env_motrixsim: kinematic_tree() extracts the tree from the compiled engine model (single source of truth): fixed links fold into offsets of their nearest moving descendant, moving links carry exactly one 1-DoF hinge joint, q-vector order is exposed as tree.joint_names. Acceptance: on G1 with random root pose/velocities and joint states, tree FK matches simulator link positions, rotations, link-origin linear and angular velocities. - KinematicTreeQuery(body, device): core ModelQuery exposing the backend-neutral tree via SimModel.others, so consumers (future MBRL providers) never touch a simulator model.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
摘要
为任务侧提供 learner 可用的纯 torch 可微正向运动学:给定 root 状态与关节状态,直接求 link 位姿/速度,梯度贯通到全部输入。同时提供从 MotrixSim 编译后模型抽取运动树的能力,并以 backend 无关的查询接口暴露。
改动
motrix_env_core/math— 可微 FK 引擎KinematicTree(math/kinematics.py):纯 torch 数据类(parent、关节轴、固定偏移;偏移四元数用仓库统一 xyzw 惯例);positions()只算 link 原点(含叶节点旋转剪枝),forward()全套位姿/速度,梯度流向 root 状态与关节状态axis_angle_to_mat放在 torch-native 的math/rotation.py(与双命名空间的quaternion.py分工)motrix_env_motrixsim— 编译模型 → 树 loaderkinematic_tree(model, base_link)从编译后引擎模型抽树(单一事实来源,不重新解析模型文件):fixed link 折叠进最近 moving 后代的 offset,moving link 必须恰好一个 1-DoF hinge,q 向量顺序以tree.joint_names暴露公共暴露
KinematicTreeQuery(body, device)(coreModelQuery):经SimModel.others返回 backend 无关的树,消费方不接触任何 simulator 模型验收
tree.forward()吻合(atol 1e-4)测试
prek(ruff check/format、copyright、license)全部通过。
备注
Link.joints文档与运行时不符(实际为方法)