Repository navigation
Conversation
qiayuanl
force-pushed
the
qiayuanl/tracking-forward-kinematics
branch
7 times, most recently
from
November 21, 2026 00:07
033dfe1 to
8a0603f
Compare
…atics Motion files hold the root link's world pose and twist and the joint states: root_pos_w, root_quat_w, root_lin_vel_w, root_ang_vel_w, joint_pos, joint_vel, joint_names and fps. MotionLoader keeps these per-frame tensors and body_state(frames) computes the tracked bodies from them with ForwardKinematics. Loading raises a ValueError that names the file when the file lacks one of these keys, and when its joint_names differ from the robot's joint names in column order. MotionLoader takes one npz file, a list, a glob or a packed directory written by pack_motions, which stores one npy array per field. resolve_motion_file expands ~, uses an existing path literally even when it contains glob characters, and raises for a glob without a match. train and play both resolve the motion file with it, so play accepts a glob or a packed directory with a zero or random agent. The loader concatenates the clips, records each clip's exclusive end frame in motion_ends and its name in motion_names, and exposes the frame rate as fps. It raises when a clip has fewer than two frames and when clips have different fps. pack_motions raises on mixed fps and writes fps into the packed directory. The motion_end termination, part of the tracking environment, ends an episode as a time-out on its clip's last frame. A reset frame is at most the frame before its clip's last frame, and the first reference frame of an episode is the reset frame plus one. Reset bins map to frames with integer math that is exact for any bin count. With several clips, sampling_mode="start" resets each env to the first frame of a clip drawn uniformly at random; with one clip it resets to frame 0 and draws no random number. ForwardKinematics is built from the MuJoCo model and the entity indexing. It composes the steps on the paths from the free-joint root to the requested bodies and returns world-frame poses and twists in the body_link_pose_w / body_link_vel_w convention. It raises for a fixed base, for a slide or ball joint on a tracked path, for a first entity body that is not the free-joint root, and for any joint of the entity with more than one degree of freedom, so joint_pos and joint_vel share columns. MotionCommand keeps the tracked bodies as state. set_time_steps(env_ids, frames) writes time_steps and computes the bodies of those envs; resets, the per-step advance and the viewer scrubber go through it, and a direct write to time_steps does not update the bodies. On CUDA the command compiles body_state with torch.compile so each call is one fused kernel. The ONNX export reads the bodies of all frames from body_state. csv_to_npz writes the motion file from the resampled input and builds a scene and a simulation only to render the frames with --render. It raises when the CSV does not have 7 columns plus one per joint. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
qiayuanl
force-pushed
the
qiayuanl/tracking-forward-kinematics
branch
from
November 21, 2026 00:07
8a0603f to
b2e9c8b
Compare
This branch has not been deployed
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.
The tracking task reads one motion clip, and a motion file stores the pose and velocity of every body for every frame. This PR stores only the root and joint states, computes the tracked bodies with forward kinematics, and lets one command track many clips.
A motion file holds
root_pos_w,root_quat_w,root_lin_vel_w,root_ang_vel_w,joint_pos,joint_vel,joint_namesandfps. For the Unitree G1 that is 71 floats per frame, in place of 448 in the file and 630 on the device.csv_to_npzwrites the file from the resampled CSV and builds a scene only for--render.ForwardKinematicsinmjlab.utils.forward_kinematicsis built from the MuJoCo model and returns the world poses and twists of the requested bodies for a batch of root and joint states. It needs a free-joint root, joints with one degree of freedom, and hinge joints on the tracked paths, and raises otherwise.MotionCommandkeeps the tracked bodies as state and updates them inset_time_steps, which resets, the per-step advance and the viewer scrubber share. On CUDA the command compilesbody_statewithtorch.compile, and CI does not run that path.MotionCommandCfg.motion_filetakes a file, a list, a glob, or a directory written by the newpack_motionsscript. On the command line,trainandplaytake a file, a glob or such a directory.MotionLoaderconcatenates the clips, keeps each clip's exclusive end frame inmotion_endsand its name inmotion_names, and raises when clips differ infpsor a clip has fewer than two frames. The newmotion_endtermination ends an episode as a time-out when it reaches the last frame of its clip. Without that termination, the command resamples at the clip end, so an episode never runs from one clip into the next. With several clips,sampling_mode="start"resets to the first frame of a random clip, and the exported ONNX file holds the policy alone and mapsobstoactions. With one clip the export is unchanged.Existing motion files do not load and must be regenerated with
csv_to_npz. An episode that reaches the end of its clip ends as a time-out, where the command used to resample a new frame and continue. A direct write totime_stepsdoes not move the tracked bodies;set_time_stepsdoes. A reset frame is at most the frame before the last frame of its clip.The demo motion in
src/mjlab/scripts/gcs.pyand the registry motions used byscripts/benchmarksneed an upload in the new format before this merges. The demo file needs a new URL, because released versions pin the current one by checksum.🤖 Generated with Claude Code