Humanoid Retargeting
Online humanoid retargeting with input joints ordered by human_joint_names.
Lifecycle
__init__stores the robot, configuration, and caller-owned scene.warmup(batch_size)builds batch-shaped buffers and solvers.solve(T_world_human)advances one batched frame from Warp inputs.
Return the interaction task; set its first frame before warmup and update it before each solve.
Fix the online batch size and build its reusable solver state.
Retarget one batched human frame from Warp inputs.
Lifecycle
- Validate the shape fixed by
warmup(...). - Update temporal terms from the previous robot state.
- Compute targets and candidate states.
- Solve once, retain the state, and write the requested output buffer.
Human joint transforms with shape (batch, joints).
Optional human height in meters for each batch element.
Optional caller-owned output with shape (batch, 7 + dofs).
out when provided; otherwise a reusable helper-owned buffer overwritten by the next call.
Convert NumPy inputs, call solve(...), and return a NumPy copy.
Reset temporal state, optionally from an initial floating-base transform.
A robot's human-to-robot mapping, task templates and per-frame solver; offline retargeting reuses the mapping.
Task templates; each names its inputs with HumanoidContext members.
Robot URDF, loaded when the retargeter gets no robot.
Human joint that places the robot base.
Human height in meters when a solve gets no human_heights.
Ground height of the human motion, subtracted from every target height.
Robot collision spheres, needed by a weighted self-collision task.
Target scale per human joint; absent joints use 1.0.
Robot link to the human joint it tracks, in target order.
Link vectors the correspondence task drives toward human joint vectors; None is off (online only).
Interaction-mesh task templates, built at construction so the first frame is set before warmup; empty is off.
Time between frames, for the velocity limits and the output clamp.
Clamp each output step at this fraction of the velocity limits; 0 is off.
Joint velocity limits in rad/s, replacing the URDF's; None uses the URDF's.
Candidate schedule and optimizers of each frame's solve.
Append a task, optionally assigning its input role.
>>> from robokit.terms.dense.configuration_task import ConfigurationTask
>>> config = HumanoidRetargeterOnlineConfig(terms=[]).add(ConfigurationTask(weight=0.1), name="rest")
>>> config.task("rest").weight
0.1from robokit.helpers.humanoid_retargeting.config import HumanoidRetargeterOnlineConfig
from robokit.terms.dense.configuration_task import ConfigurationTask
config = HumanoidRetargeterOnlineConfig(terms=[]).add(ConfigurationTask(weight=0.1), name="rest")
config.task("rest").weightReturn a named task; raise KeyError when absent.
>>> from robokit.terms.dense.configuration_task import ConfigurationTask
>>> config = HumanoidRetargeterOnlineConfig(terms=[]).add(ConfigurationTask(weight=0.2), name="rest")
>>> config.task("rest").weight
0.2from robokit.helpers.humanoid_retargeting.config import HumanoidRetargeterOnlineConfig
from robokit.terms.dense.configuration_task import ConfigurationTask
config = HumanoidRetargeterOnlineConfig(terms=[]).add(ConfigurationTask(weight=0.2), name="rest")
config.task("rest").weightReturn the ordered human joints expected by the solve APIs.
Example
>>> import numpy as np
>>> config = HumanoidRetargeterOnlineConfig(
... link_mapping={"torso": LinkMapping("spine", np.zeros(3), np.zeros(4))},
... )
>>> config.human_joint_names # mapped joints first, then the root
('spine', 'pelvis')from robokit.helpers.humanoid_retargeting.config import HumanoidRetargeterOnlineConfig, LinkMapping
import numpy as np
config = HumanoidRetargeterOnlineConfig(
link_mapping={"torso": LinkMapping("spine", np.zeros(3), np.zeros(4))},
)
config.human_joint_names # mapped joints first, then the rootResolve link_mapping in input human_joint_names order for both solvers' compute_targets_kernel arrays.
Example
>>> import numpy as np
>>> config = HumanoidRetargeterOnlineConfig(
... link_mapping={
... "torso": LinkMapping("spine", np.zeros(3), np.zeros(4)),
... "hip": LinkMapping("pelvis", np.zeros(3), np.zeros(4)),
... },
... scale_table={"spine": 0.9},
... )
>>> arrays = config.target_arrays(config.human_joint_names)
>>> arrays.joint_indices.tolist(), arrays.scales.tolist()
([0, 1], [0.8999999761581421, 1.0])
>>> arrays.root_joint_index, arrays.root_target_index
(1, 1)
>>> arrays.rotation_offsets[0].tolist() # zero offset normalizes to identity
[1.0, 0.0, 0.0, 0.0]from robokit.helpers.humanoid_retargeting.config import HumanoidRetargeterOnlineConfig, LinkMapping
import numpy as np
config = HumanoidRetargeterOnlineConfig(
link_mapping={
"torso": LinkMapping("spine", np.zeros(3), np.zeros(4)),
"hip": LinkMapping("pelvis", np.zeros(3), np.zeros(4)),
},
scale_table={"spine": 0.9},
)
arrays = config.target_arrays(config.human_joint_names)
arrays.joint_indices.tolist(), arrays.scales.tolist()
arrays.root_joint_index, arrays.root_target_index
arrays.rotation_offsets[0].tolist() # zero offset normalizes to identityLoad the config's robot, with its collision spheres when the config names them.
Whole-clip retargeting with input joints ordered by human_joint_names.
Lifecycle
__init__stores the robot and configuration.warmup(batch_size, num_frames)builds shape-specific buffers and optimizers.solve(T_world_human)retargets one fixed-shape Warp trajectory batch.
Build and cache all state for (batch_size, num_frames).
Retarget one padded [B, T, J] Warp trajectory batch.
Lifecycle
- Validate the shape fixed by
warmup(...). - Compute all frame targets and independent IK warm starts.
- Reset the cached trajectory state and valid-frame masks.
- Solve once and write the requested padded output buffer.
Human joint transforms with shape (batch, frames, joints).
Optional valid frame count for each padded batch element.
Optional human height in meters for each batch element.
Optional caller-owned output with shape (batch, frames, 7 + dofs).
Optional (batch, frames, 7) target tracks keyed by robot link; they move the IK warm start and TARGET_POSITIONS, while orientation templates read TARGETS (the mapped poses) unless they read OVERRIDDEN_TARGETS.
out when provided; otherwise a reusable helper-owned buffer overwritten by the next call.
Convert padded [B, T, J, 7] NumPy inputs, warm up for their shape, solve, and return a NumPy copy.
Whole-clip optimizer settings; the paired online config supplies the mapping and velocity limits.
Trajectory task templates; tracking weights are per link, and self-collision costs O(pairs) per frame.
Per-frame IK that seeds the trajectory.
Trajectory solver.
Append a task, optionally assigning its input role.
>>> from robokit.terms.dense.configuration_task import ConfigurationTask
>>> config = HumanoidRetargeterOfflineConfig(terms=[]).add(ConfigurationTask(weight=0.1), name="rest")
>>> config.task("rest").weight
0.1from robokit.helpers.humanoid_retargeting.config import HumanoidRetargeterOfflineConfig
from robokit.terms.dense.configuration_task import ConfigurationTask
config = HumanoidRetargeterOfflineConfig(terms=[]).add(ConfigurationTask(weight=0.1), name="rest")
config.task("rest").weightReturn a named task; raise KeyError when absent.
>>> from robokit.terms.dense.configuration_task import ConfigurationTask
>>> config = HumanoidRetargeterOfflineConfig(terms=[]).add(ConfigurationTask(weight=0.2), name="rest")
>>> config.task("rest").weight
0.2from robokit.helpers.humanoid_retargeting.config import HumanoidRetargeterOfflineConfig
from robokit.terms.dense.configuration_task import ConfigurationTask
config = HumanoidRetargeterOfflineConfig(terms=[]).add(ConfigurationTask(weight=0.2), name="rest")
config.task("rest").weight