Constraints#
Constraint definitions and utilities.
Constraint sets for conditioning motion generation (root 2D, full body, end-effectors).
- kimodo.constraints.create_pairs(tensor_A, tensor_B)[source]#
Form all (a, b) pairs from two 1D tensors; output shape (len(A)*len(B), 2).
- kimodo.constraints.compute_global_heading(global_joints_positions, skeleton)[source]#
Compute global root heading (cos, sin) from global joint positions using skeleton.
- class kimodo.constraints.Root2DConstraintSet(
- skeleton,
- frame_indices,
- smooth_root_2d,
- to_crop=False,
- global_root_heading=None,
Bases:
objectConstraint set fixing root (x, z) trajectory and optionally global heading on given frames.
- name = 'root2d'#
- __init__(
- skeleton,
- frame_indices,
- smooth_root_2d,
- to_crop=False,
- global_root_heading=None,
- update_constraints(data_dict, index_dict)[source]#
Append this constraint’s smooth_root_2d (and optional global_root_heading) to data/index dicts.
- crop_move(start, end)[source]#
Return a new constraint set for the cropped frame range [start, end).
- class kimodo.constraints.FullBodyConstraintSet(
- skeleton,
- frame_indices,
- global_joints_positions,
- global_joints_rots,
- smooth_root_2d=None,
- to_crop=False,
Bases:
objectConstraint set fixing full-body global positions and rotations on given keyframes.
- name = 'fullbody'#
- __init__(
- skeleton,
- frame_indices,
- global_joints_positions,
- global_joints_rots,
- smooth_root_2d=None,
- to_crop=False,
- update_constraints(data_dict, index_dict)[source]#
Append global positions, smooth root 2D, root y, and global heading to data/index dicts.
- crop_move(start, end)[source]#
Return a new FullBodyConstraintSet for the cropped frame range [start, end).
- class kimodo.constraints.EndEffectorConstraintSet(
- skeleton,
- frame_indices,
- global_joints_positions,
- global_joints_rots,
- smooth_root_2d,
- *,
- joint_names,
- to_crop=False,
Bases:
objectConstraint set fixing selected end-effector positions and rotations on given frames.
- name = 'end-effector'#
- __init__(
- skeleton,
- frame_indices,
- global_joints_positions,
- global_joints_rots,
- smooth_root_2d,
- *,
- joint_names,
- to_crop=False,
- update_constraints(data_dict, index_dict)[source]#
Append constrained joint positions/rots, smooth root 2D, root y, and heading to data/index dicts.
- crop_move(start, end)[source]#
Return a new EndEffectorConstraintSet for the cropped frame range [start, end).
- class kimodo.constraints.LeftHandConstraintSet(*args, **kwargs)[source]#
Bases:
EndEffectorConstraintSetEnd-effector constraint for the left hand only.
- name = 'left-hand'#
- joint_names = ['LeftHand']#
- class kimodo.constraints.RightHandConstraintSet(*args, **kwargs)[source]#
Bases:
EndEffectorConstraintSetEnd-effector constraint for the right hand only.
- name = 'right-hand'#
- joint_names = ['RightHand']#
- class kimodo.constraints.LeftFootConstraintSet(*args, **kwargs)[source]#
Bases:
EndEffectorConstraintSetEnd-effector constraint for the left foot only.
- name = 'left-foot'#
- joint_names = ['LeftFoot']#
- class kimodo.constraints.RightFootConstraintSet(*args, **kwargs)[source]#
Bases:
EndEffectorConstraintSetEnd-effector constraint for the right foot only.
- name = 'right-foot'#
- joint_names = ['RightFoot']#
- kimodo.constraints.load_constraints_lst(path_or_data, skeleton, device=None, dtype=None)[source]#
Load a list of constraints from JSON path or list of dicts.
- Parameters:
path_or_data – Path to constraints.json or list of constraint dicts.
skeleton – Skeleton instance (used for from_dict).
device – If set, move all constraint tensors and skeleton to this device.
dtype – If set, cast constraint tensors to this dtype.