Repository: Genesis-Embodied-AI/Genesis
File: genesis/utils/usd/usd_rigid_entity.py (Python)

Code before:
    gs.JOINT_TYPE.REVOLUTE: (("angular",),),
    gs.JOINT_TYPE.PRISMATIC: (("linear",),),
    gs.JOINT_TYPE.SPHERICAL: (
        ("rotX",),
        ("rotY",),
        ("rotZ",),
    ),
    gs.JOINT_TYPE.FIXED: (),
    gs.JOINT_TYPE.FREE: (
        ("transX",),
        ("transY",),
        ("transZ",),
        ("rotX",),
        ("rotY",),
        ("rotZ",),
    ),
}


def _parse_joint_axis_pos(
    context: UsdContext, joint: UsdPhysics.Joint, child_link: Usd.Prim, is_body1: bool
) -> Tuple[str, np.ndarray, np.ndarray]:
    joint_pos_attr = joint.GetLocalPos1Attr() if is_body1 else joint.GetLocalPos0Attr()
    joint_pos = usd_pos_to_numpy(joint_pos_attr.Get() if joint_pos_attr.HasValue() else None)
    if joint_pos is None:
        joint_pos = gu.zero_pos()
    T = context.compute_transform(child_link)
    joint_pos = gu.transform_by_T(joint_pos, T)
    Q, S = context.compute_gs_transform(child_link)
    Q_inv = np.linalg.inv(Q)
    joint_pos = Q_inv[:3, :3] @ (joint_pos - Q[:3, 3])

    if isinstance(joint, (UsdPhysics.PrismaticJoint, UsdPhysics.RevoluteJoint)):
        joint_quat = usd_quat_to_numpy((joint.GetLocalRot1Attr() if is_body1 else joint.GetLocalRot0Attr()).Get())
        joint_axis_str = joint.GetAxisAttr().Get() or "X"
        joint_axis = gu.transform_by_quat(AXES_VECTOR[joint_axis_str], joint_quat)
        joint_axis = gu.transform_by_R(joint_axis, T[:3, :3])
        joint_axis = Q_inv[:3, :3] @ joint_axis
        if np.linalg.norm(joint_axis) < gs.EPS:
            gs.raise_exception(f"Joint axis is zero for joint {joint.GetPath()}.")
        joint_axis /= np.linalg.norm(joint_axis)
    else:
        joint_axis_str, joint_axis = None, None

    return joint_axis_str, joint_axis, joint_pos


def _parse_link(
    context: UsdContext,
    link: Usd.Prim,
    joints: List[Tuple[Usd.Prim, int, bool]],

Review comment (suggestion):
Just do:
```python
joint_pos = usd_pos_to_numpy(joint_pos_attr.Get()) if joint_pos_attr.HasValue() else gu.zero_pos()
```

Code after:
DRIVE_NAMES = {
    gs.JOINT_TYPE.REVOLUTE: (("angular",),),
    gs.JOINT_TYPE.PRISMATIC: (("linear",),),
    gs.JOINT_TYPE.SPHERICAL: (
        ("rotX",),
        ("rotY",),
        ("rotZ",),
    ),
    gs.JOINT_TYPE.FIXED: (),
    gs.JOINT_TYPE.FREE: (
        ("transX",),
        ("transY",),
        ("transZ",),
        ("rotX",),
        ("rotY",),
        ("rotZ",),
    ),
}


def _parse_joint_axis_pos(
    context: UsdContext, joint: UsdPhysics.Joint, child_link: Usd.Prim, is_body1: bool
) -> Tuple[str, np.ndarray, np.ndarray]:
    joint_pos_attr = joint.GetLocalPos1Attr() if is_body1 else joint.GetLocalPos0Attr()
    joint_pos = usd_pos_to_numpy(joint_pos_attr.Get()) if joint_pos_attr.HasValue() else gu.zero_pos()
    T = context.compute_transform(child_link)
    joint_pos = gu.transform_by_T(joint_pos, T)
    Q, S = context.compute_gs_transform(child_link)
    Q_inv = np.linalg.inv(Q)
    joint_pos = Q_inv[:3, :3] @ (joint_pos - Q[:3, 3])

    if isinstance(joint, (UsdPhysics.PrismaticJoint, UsdPhysics.RevoluteJoint)):
        joint_quat = usd_quat_to_numpy((joint.GetLocalRot1Attr() if is_body1 else joint.GetLocalRot0Attr()).Get())
        joint_axis_str = joint.GetAxisAttr().Get() or "X"
        joint_axis = gu.transform_by_quat(AXES_VECTOR[joint_axis_str], joint_quat)
        joint_axis = gu.transform_by_R(joint_axis, T[:3, :3])
        joint_axis = Q_inv[:3, :3] @ joint_axis
        if np.linalg.norm(joint_axis) < gs.EPS:
            gs.raise_exception(f"Joint axis is zero for joint {joint.GetPath()}.")
        joint_axis /= np.linalg.norm(joint_axis)
    else:
        joint_axis_str, joint_axis = None, None

    return joint_axis_str, joint_axis, joint_pos


def _parse_link(
    context: UsdContext,
    link: Usd.Prim,
    joints: List[Tuple[Usd.Prim, int, bool]],
    links: List[Usd.Prim],