AGENT SKILL

locomotion-modeling

Use Rex-Gym's deterministic kinematics, Bezier gait, constants, and motor model helpers to turn poses or gait parameters into correctly ordered leg commands and bounded torques.

License 许可
Apache-2.0
最近更新
2026-09-03
Stars
★ 351
Forks
27

01 前言 Front Matter

name
locomotion-modeling
license
Apache 2.0
metadata
{ "disco-role": "operating" }
description
Use Rex-Gym's deterministic kinematics, Bezier gait, constants, and motor model helpers to turn poses or gait parameters into correctly ordered leg commands and bounded torques.
disable-model-invocation
true

02 资源文件 6

03 SKILL.md 正文

Rex locomotion modeling

Use this sub-skill when a task mentions Rex-Gym inverse kinematics, Kinematics.solve, Bezier trajectories, GaitPlanner, leg frames, motor PD/torque, walk or gallop phase, mark/motor constants, 12-joint versus 18-motor commands, or action-to-motor conversion. It is a source-backed operating guide, not a simulator lifecycle guide.

Route first

Model pipeline

  1. Choose the mark and command width. The base has 12 leg motors (four legs × three joints); the arm mark has 18 motors and appends six arm joints. Constants and names are in rex_constants and mark_constants; do not invent a second ordering.
  2. Define base pose as orientation=[roll, pitch, yaw] and position=[x, y, z]. Kinematics uses radians and metres. Define four foot frames as a 4×3 matrix in solver order FR, FL, RR, RL.
  3. For a static pose, call Kinematics.solve. For motion, call GaitPlanner.loop to obtain updated frames, then pass those frames to solve.
  4. Convert the solver's four 3-angle results to the environment's motor command order FL, FR, RL, RR, three values per leg. This reorder is required by the task signal code even though the solver returns FR, FL, RR, RL.
  5. In position control, pass desired joint angles to the environment. In torque control, pass one bounded PWM-like value per motor to MotorModel.convert_to_torque; inspect both returned actual and observed torque before applying simulation controls.

Verified recipes

Static IK with default frames:

import numpy as np
from rex_gym.model.kinematics import Kinematics

ik = Kinematics()
fr, fl, rr, rl, transformed = ik.solve(
    orientation=np.zeros(3), position=np.zeros(3)
)
command = np.concatenate([fl, fr, rl, rr])  # 12 values: FL, FR, RL, RR
assert command.shape == (12,)
assert np.asarray(transformed).shape == (4, 3)

A gait-to-command step:

import numpy as np
from rex_gym.model.gait_planner import GaitPlanner
from rex_gym.model.kinematics import Kinematics

planner = GaitPlanner("walk")
ik = Kinematics()
frames = planner.loop(v=0.6, angle=0.0, w_rot=0.0, t=0.65, direction=1.0)
fr, fl, rr, rl, _ = ik.solve(np.zeros(3), np.zeros(3), frames)
command = np.concatenate([fl, fr, rl, rr])

The loop is clock-driven: t is the period in seconds and the phase comes from wall clock time. For reproducible phase diagnostics, use inspect_gait.py, which evaluates bounded fixed phases rather than sleeping or opening PyBullet.

Torque conversion:

import numpy as np
from rex_gym.model.motor import MotorModel

model = MotorModel(motors_num=12, torque_control_enabled=False, kp=1.2, kd=0.0)
tau_actual, tau_observed = model.convert_to_torque(
    motor_commands=np.zeros(12), motor_angle=np.zeros(12),
    motor_velocity=np.zeros(12), true_motor_velocity=np.zeros(12),
)

For position control, motor_commands are target angles. For torque control, construct MotorModel(12, torque_control_enabled=True) and supply PWM-like commands in [-1, 1]; the implementation clips them before its DC-motor calculation. All five input arrays must broadcast to the motor count in normal use.

Constants and limits that matter

  • Kinematics uses body dimensions x_dist=0.23, y_dist=0.185, and default foot height 0.2 metres. Its default frames are [[.115,-.0925,-.2],[.115,.0925,-.2],[-.115,-.0925,-.2],[-.115,.0925,-.2]].
  • mark_constants.MARK_LIST is ['base', 'arm']. MARK_DETAILS['motors_num'] is 12 for base and 18 for arm; the arm's six rest values are [-1.6,-1.6,0,0,1.6,0].
  • INIT_POSES supplies named 12-value poses such as stand, stand_ol, gallop, stand_low, stand_high, and rest_position. These values are radians despite their source being plain arrays. ARM_POSES['rest'] is six radians.
  • Motor defaults are kp=1.2, kd=0, voltage 32, resistance 0.186, torque constant 0.0954, and zero viscous damping. PWM is clipped to [-1,1]; observed torque is clipped to ±5.7; net voltage is clipped to ±50 before the empirical current/torque interpolation. Strength ratios scale actual torque.

Scope boundary and limitations

IK clamps the cosine-law domain to ±0.99 (not ±1) when a target is unreachable, so a returned angle is a bounded fallback rather than proof that the pose is reachable. The solver is a geometric model: it does not validate joint limits, collisions, contact, terrain, balance, or rewards. The gait planner is an open-loop trajectory reference; it does not guarantee foot contact or stable locomotion. The motor helper models torque/PWM and does not itself simulate PyBullet, thermal shutdown, or policy learning. Keep task semantics and evaluation in the routed sibling skills.

Read the detailed links above before changing conventions; then run the relevant self-contained inspector and compare shapes, phase, ordering, and clipping behavior.

04 同仓库更多 Skills

VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-triton-opt

Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-solve

END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-skill

PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-pattern-fusion

Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-orchestrate

Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-feedback

Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).

★ 351