Skip to content

Commit 2a814c1

Browse files
committed
Tighten task-space-accessor docstrings to focus on the contract
The base-class and per-backend property docstrings for the four new task-space accessors had grown to include rationale prose, industry- library citations, and implementation guidance for backend authors — content that belongs in the PR description / changelog, not the API documentation users read at code-completion time. Trim each docstring to: shape + units + indexing convention + math contract. Per-backend overrides defer to the base contract via ``See :attr:`BaseArticulationData.<name>``` and add only what's specific to that backend (engine call used, any backend-only caveat). No behavior change.
1 parent b0d179f commit 2a814c1

3 files changed

Lines changed: 56 additions & 156 deletions

File tree

source/isaaclab/isaaclab/assets/articulation/base_articulation_data.py

Lines changed: 31 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -628,108 +628,72 @@ def body_incoming_joint_wrench_b(self) -> ProxyArray:
628628
def body_link_jacobian_w(self) -> ProxyArray:
629629
"""Per-body geometric Jacobian referenced at each body's link origin in world frame.
630630
631-
Shape is (num_instances, num_jacobi_bodies, 6, num_joints + num_base_dofs),
632-
dtype = wp.float32. In torch this resolves to
633-
(num_instances, num_jacobi_bodies, 6, num_joints + num_base_dofs).
634-
Linear rows ``[0:3]`` [m/s for unit ``q_dot``], angular rows ``[3:6]`` [rad/s for unit
635-
``q_dot``].
631+
Shape: ``(num_instances, num_jacobi_bodies, 6, num_joints + num_base_dofs)``,
632+
dtype ``wp.float32``. Linear rows ``[0:3]`` [m/s per unit DoF velocity];
633+
angular rows ``[3:6]`` [rad/s per unit DoF velocity].
636634
637-
For any generalized-velocity vector ``v`` of length ``num_joints + num_base_dofs``,
638-
the returned Jacobian ``J`` satisfies:
635+
Contract: for any generalized velocity ``v`` of length
636+
``num_joints + num_base_dofs``,
639637
640638
.. code-block:: text
641639
642640
J[:, jacobi_body_idx, 0:3, :] @ v == body_link_lin_vel_w[:, body_idx]
643641
J[:, jacobi_body_idx, 3:6, :] @ v == body_link_ang_vel_w[:, body_idx]
644642
645-
Linear rows ``[0:3]`` give the velocity at the link origin (the body's USD prim transform
646-
/ actor frame) in world frame. Angular rows ``[3:6]`` give the body's angular velocity in
647-
world frame. The contract matches :attr:`body_link_pos_w` and :attr:`body_link_lin_vel_w`.
648-
For fixed-base articulations, ``jacobi_body_idx`` excludes the fixed root body and is
649-
therefore ``body_idx - 1``. For floating-base articulations, ``jacobi_body_idx ==
650-
body_idx``.
651-
652-
Backends whose native Jacobian is expressed at the body center of mass MUST shift the
653-
linear rows to the link origin before returning so the contract holds across backends.
654-
655-
The DoF axis prepends :attr:`~isaaclab.assets.BaseArticulation.num_base_dofs`
656-
floating-base columns ([lin_x, lin_y, lin_z, ang_x, ang_y, ang_z] in world frame —
657-
0 cols for fixed-base, 6 for floating-base), followed by the actuated-joint columns
658-
in :attr:`joint_names` order. This matches the cross-library industry convention
659-
(Pinocchio, Drake, MuJoCo, RBDL, OCS2, iDynTree). Consumers that index by actuated-
660-
joint id should add ``num_base_dofs`` to the joint id.
643+
Conventions:
644+
* Body axis: ``jacobi_body_idx == body_idx - 1`` for fixed-base (fixed-root
645+
row excluded); ``jacobi_body_idx == body_idx`` for floating-base.
646+
* DoF axis: leading
647+
:attr:`~isaaclab.assets.BaseArticulation.num_base_dofs` floating-base
648+
columns (world-frame ``[lin_x, lin_y, lin_z, ang_x, ang_y, ang_z]``),
649+
then actuated-joint columns in :attr:`joint_names` order.
661650
"""
662651
raise NotImplementedError(f"{type(self).__name__} does not implement body_link_jacobian_w.")
663652

664653
@property
665654
def body_com_jacobian_w(self) -> ProxyArray:
666655
"""Per-body geometric Jacobian referenced at each body's center of mass in world frame.
667656
668-
Shape is (num_instances, num_jacobi_bodies, 6, num_joints + num_base_dofs),
669-
dtype = wp.float32. In torch this resolves to
670-
(num_instances, num_jacobi_bodies, 6, num_joints + num_base_dofs).
671-
Linear rows ``[0:3]`` [m/s for unit ``q_dot``], angular rows ``[3:6]`` [rad/s for unit
672-
``q_dot``].
657+
Same shape and indexing conventions as :attr:`body_link_jacobian_w`. Linear
658+
rows ``[0:3]`` give the velocity at the body's center of mass; angular rows
659+
``[3:6]`` are reference-point invariant (identical to
660+
:attr:`body_link_jacobian_w`).
673661
674-
For any generalized-velocity vector ``v`` of length ``num_joints + num_base_dofs``,
675-
the returned Jacobian ``J`` satisfies:
662+
Contract: for any generalized velocity ``v``,
676663
677664
.. code-block:: text
678665
679666
J[:, jacobi_body_idx, 0:3, :] @ v == body_com_lin_vel_w[:, body_idx]
680667
J[:, jacobi_body_idx, 3:6, :] @ v == body_com_ang_vel_w[:, body_idx]
681-
682-
Linear rows ``[0:3]`` give the velocity at the body's center of mass in world frame.
683-
Angular rows ``[3:6]`` give the body's angular velocity in world frame (reference-point
684-
invariant, identical to the angular rows of :attr:`body_link_jacobian_w`).
685-
686-
This is the form most physics engines compute natively, since dynamics equations decouple
687-
at the COM. Use :attr:`body_link_jacobian_w` for IK / OSC controllers that target the
688-
link-origin pose (USD prim frame).
689-
690-
DoF axis layout matches :attr:`body_link_jacobian_w`: leading
691-
:attr:`~isaaclab.assets.BaseArticulation.num_base_dofs` floating-base columns,
692-
followed by per-actuated-joint columns.
693668
"""
694669
raise NotImplementedError(f"{type(self).__name__} does not implement body_com_jacobian_w.")
695670

696671
@property
697672
def mass_matrix(self) -> ProxyArray:
698-
"""Per-env generalized mass matrix in joint space.
699-
700-
Shape is (num_instances, num_joints + num_base_dofs, num_joints + num_base_dofs),
701-
dtype = wp.float32 [kg·m² or kg, depending on joint type]. In torch this resolves to
702-
(num_instances, num_joints + num_base_dofs, num_joints + num_base_dofs).
673+
"""Per-env generalized mass matrix ``M(q)`` in joint space.
703674
704-
Returns the symmetric positive-definite inertia matrix ``M(q)`` of the articulation in
705-
its generalized joint coordinates. ``M[i, j]`` is the coefficient relating DoF ``j``'s
706-
acceleration to the inertial torque on DoF ``i`` in the equation of motion
707-
``M(q) q_ddot + C(q, q_dot) q_dot + g(q) = tau``. The matrix is reference-point
708-
invariant — joint-space dynamics do not depend on whether body velocities are measured
709-
at the COM or link origin.
675+
Shape: ``(num_instances, num_joints + num_base_dofs, num_joints + num_base_dofs)``,
676+
dtype ``wp.float32`` [kg·m² or kg, per DoF type]. DoF-axis convention matches
677+
:attr:`body_link_jacobian_w`.
710678
711-
The DoF axis matches :attr:`body_link_jacobian_w`: leading
712-
:attr:`~isaaclab.assets.BaseArticulation.num_base_dofs` floating-base rows/cols,
713-
followed by per-actuated-joint rows/cols.
679+
``M(q)`` is symmetric positive-definite. ``M[i, j]`` is the coefficient
680+
relating DoF ``j``'s acceleration to the inertial torque on DoF ``i`` in
681+
``M(q) q_ddot + C(q, q_dot) q_dot + g(q) = tau``.
714682
"""
715683
raise NotImplementedError(f"{type(self).__name__} does not implement mass_matrix.")
716684

717685
@property
718686
def gravity_compensation_forces(self) -> ProxyArray:
719-
"""Per-env gravity compensation torques in joint space.
687+
"""Per-env gravity compensation torques ``g(q)`` in joint space.
720688
721-
Shape is (num_instances, num_joints + num_base_dofs), dtype = wp.float32
722-
[N·m or N, depending on joint type]. In torch this resolves to
723-
(num_instances, num_joints + num_base_dofs).
689+
Shape: ``(num_instances, num_joints + num_base_dofs)``, dtype ``wp.float32``
690+
[N·m or N, per DoF type]. DoF-axis convention matches
691+
:attr:`body_link_jacobian_w`.
724692
725-
Returns ``g(q)`` the joint-space gravity-loading term in the equation of motion
693+
``g(q)`` is the gravity-loading term in
726694
``M(q) q_ddot + C(q, q_dot) q_dot + g(q) = tau``. Applying ``tau = g(q)`` at
727-
``q_dot = 0`` with no external load yields ``q_ddot = 0`` (static equilibrium under
728-
gravity).
729-
730-
The DoF axis matches :attr:`body_link_jacobian_w`: leading
731-
:attr:`~isaaclab.assets.BaseArticulation.num_base_dofs` floating-base entries,
732-
followed by per-actuated-joint entries.
695+
``q_dot = 0`` with no external load yields ``q_ddot = 0`` (static equilibrium
696+
under gravity).
733697
"""
734698
raise NotImplementedError(f"{type(self).__name__} does not implement gravity_compensation_forces.")
735699

source/isaaclab_newton/isaaclab_newton/assets/articulation/articulation_data.py

Lines changed: 15 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -838,22 +838,11 @@ def body_incoming_joint_wrench_b(self) -> ProxyArray:
838838

839839
@property
840840
def body_com_jacobian_w(self) -> ProxyArray:
841-
"""Per-body geometric Jacobian referenced at each body's center of mass in world frame.
841+
"""See :attr:`isaaclab.assets.BaseArticulationData.body_com_jacobian_w`.
842842
843-
Shape is (num_instances, num_jacobi_bodies, 6, num_joints + num_base_dofs),
844-
dtype = wp.float32. In torch this resolves to
845-
(num_instances, num_jacobi_bodies, 6, num_joints + num_base_dofs).
846-
847-
Computed by ``eval_jacobian`` followed by a gather kernel that extracts this view's
848-
rows / columns from the model-sized scratch buffer. Linear rows are referenced at the
849-
body's center of mass; angular rows are reference-point invariant. Use
850-
:attr:`body_link_jacobian_w` for IK / OSC controllers that target the link-origin pose.
851-
852-
For floating-base articulations the leading 6 columns correspond to the floating-base
853-
spatial velocity in world frame (``[lin_x, lin_y, lin_z, ang_x, ang_y, ang_z]``); for
854-
fixed-base articulations there are 0 base columns. Consumers that index by actuated-
855-
joint id should add :attr:`~isaaclab.assets.BaseArticulation.num_base_dofs` to the
856-
joint id.
843+
Newton implementation: ``eval_jacobian`` (writes the model-wide buffer) then a
844+
gather kernel extracts this view's rows. ``link_offset`` drops Newton's fixed-
845+
root row for fixed-base; the DoF axis is preserved in full.
857846
"""
858847
# Newton's eval_jacobian reads ``state.body_q`` (link poses); refresh FK if stale.
859848
# Matches the convention in ``body_link_pose_w`` — Python-guarded lazy refresh.
@@ -882,21 +871,10 @@ def body_com_jacobian_w(self) -> ProxyArray:
882871

883872
@property
884873
def body_link_jacobian_w(self) -> ProxyArray:
885-
"""Per-body geometric Jacobian referenced at each body's link origin in world frame.
886-
887-
Shape is (num_instances, num_jacobi_bodies, 6, num_joints + num_base_dofs),
888-
dtype = wp.float32. In torch this resolves to
889-
(num_instances, num_jacobi_bodies, 6, num_joints + num_base_dofs).
874+
"""See :attr:`isaaclab.assets.BaseArticulationData.body_link_jacobian_w`.
890875
891-
Computed by applying the COM→origin shift to :attr:`body_com_jacobian_w`. The shift
892-
identity ``v_origin = v_com - omega x (R · body_com_pos_b)`` is applied per-column
893-
(each Jacobian column is one DoF's spatial-velocity contribution to a body). Angular
894-
rows are unchanged; linear rows are shifted so the contract
895-
``J · q_dot[body_idx] == body_link_lin_vel_w[body_idx]`` holds.
896-
897-
Column layout matches :attr:`body_com_jacobian_w`: leading
898-
:attr:`~isaaclab.assets.BaseArticulation.num_base_dofs` columns hold the floating-
899-
base spatial velocity (0 for fixed-base), followed by per-actuated-joint columns.
876+
Newton implementation: applies the COM→origin shift kernel to
877+
:attr:`body_com_jacobian_w` (Newton's ``eval_jacobian`` is COM-referenced).
900878
"""
901879
# ``body_link_pose_w`` accessor triggers ``SimulationManager.forward()`` if FK is
902880
# stale (after a manual joint / root write that bypassed the sim step). Reading the
@@ -920,16 +898,10 @@ def body_link_jacobian_w(self) -> ProxyArray:
920898

921899
@property
922900
def mass_matrix(self) -> ProxyArray:
923-
"""Per-env generalized mass matrix in joint space.
924-
925-
Shape is (num_instances, num_joints + num_base_dofs, num_joints + num_base_dofs),
926-
dtype = wp.float32. In torch this resolves to
927-
(num_instances, num_joints + num_base_dofs, num_joints + num_base_dofs).
901+
"""See :attr:`isaaclab.assets.BaseArticulationData.mass_matrix`.
928902
929-
Returns the symmetric positive-definite inertia matrix ``M(q)`` of the articulation in
930-
its generalized joint coordinates. For floating-base articulations the leading 6 rows
931-
and columns correspond to the floating-base spatial velocity in world frame; for
932-
fixed-base articulations there are 0 such rows/cols.
903+
Newton implementation: ``eval_mass_matrix`` (writes the model-wide buffer) then a
904+
gather kernel extracts this view's rows.
933905
"""
934906
# eval_jacobian / eval_mass_matrix read ``state.body_q``; refresh FK if stale.
935907
# Matches the convention in ``body_link_pose_w`` — Python-guarded lazy refresh.
@@ -965,12 +937,12 @@ def mass_matrix(self) -> ProxyArray:
965937

966938
@property
967939
def gravity_compensation_forces(self) -> ProxyArray:
968-
"""Per-env gravity compensation torques in joint space.
940+
"""See :attr:`isaaclab.assets.BaseArticulationData.gravity_compensation_forces`.
969941
970-
Newton's ArticulationView has no ``eval_gravity_compensation`` primitive (only
971-
``eval_fk`` / ``eval_jacobian`` / ``eval_mass_matrix``). Callers that need gravity
972-
compensation must run on PhysX, or set the controller's ``gravity_compensation`` flag
973-
to ``False`` until upstream Newton adds the missing API.
942+
Newton implementation: raises :class:`NotImplementedError` — Newton's
943+
``ArticulationView`` exposes only ``eval_fk`` / ``eval_jacobian`` /
944+
``eval_mass_matrix``. Use PhysX, or set the controller's
945+
``gravity_compensation=False`` until upstream Newton adds the primitive.
974946
"""
975947
raise NotImplementedError(
976948
"Newton has no gravity-compensation primitive. Use PhysX, or set the controller's"

source/isaaclab_physx/isaaclab_physx/assets/articulation/articulation_data.py

Lines changed: 10 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -883,41 +883,19 @@ def body_incoming_joint_wrench_b(self) -> ProxyArray:
883883

884884
@property
885885
def body_com_jacobian_w(self) -> ProxyArray:
886-
"""Per-body geometric Jacobian referenced at each body's center of mass in world frame.
886+
"""See :attr:`isaaclab.assets.BaseArticulationData.body_com_jacobian_w`.
887887
888-
Shape is (num_instances, num_jacobi_bodies, 6, num_joints + num_base_dofs),
889-
dtype = wp.float32. In torch this resolves to
890-
(num_instances, num_jacobi_bodies, 6, num_joints + num_base_dofs).
891-
892-
Linear rows are referenced at the body's center of mass; angular rows are
893-
reference-point invariant. Use :attr:`body_link_jacobian_w` for IK / OSC controllers
894-
that target the link-origin pose.
895-
896-
For floating-base articulations the leading 6 columns correspond to the floating-base
897-
spatial velocity in world frame (``[lin_x, lin_y, lin_z, ang_x, ang_y, ang_z]``); for
898-
fixed-base articulations there are 0 base columns. Consumers that index by actuated-
899-
joint id should add :attr:`~isaaclab.assets.BaseArticulation.num_base_dofs` to the
900-
joint id.
888+
PhysX implementation: passthrough of ``_root_view.get_jacobians()``, which is
889+
natively COM-referenced.
901890
"""
902891
return ProxyArray(self._root_view.get_jacobians())
903892

904893
@property
905894
def body_link_jacobian_w(self) -> ProxyArray:
906-
"""Per-body geometric Jacobian referenced at each body's link origin in world frame.
907-
908-
Shape is (num_instances, num_jacobi_bodies, 6, num_joints + num_base_dofs),
909-
dtype = wp.float32. In torch this resolves to
910-
(num_instances, num_jacobi_bodies, 6, num_joints + num_base_dofs).
895+
"""See :attr:`isaaclab.assets.BaseArticulationData.body_link_jacobian_w`.
911896
912-
Computed by applying the COM→origin shift to :attr:`body_com_jacobian_w`. The shift
913-
identity ``v_origin = v_com - omega x (R · body_com_pos_b)`` is applied per-column
914-
(each Jacobian column is one DoF's spatial-velocity contribution to a body). Angular
915-
rows are unchanged; linear rows are shifted from COM to link origin so the contract
916-
``J · q_dot[body_idx] == body_link_lin_vel_w[body_idx]`` holds.
917-
918-
Column layout matches :attr:`body_com_jacobian_w`: leading
919-
:attr:`~isaaclab.assets.BaseArticulation.num_base_dofs` columns hold the floating-
920-
base spatial velocity (0 for fixed-base), followed by per-actuated-joint columns.
897+
PhysX implementation: applies the COM→origin shift kernel to
898+
:attr:`body_com_jacobian_w` (PhysX's engine output is COM-referenced).
921899
"""
922900
wp.launch(
923901
articulation_kernels.shift_jacobian_com_to_origin,
@@ -935,31 +913,17 @@ def body_link_jacobian_w(self) -> ProxyArray:
935913

936914
@property
937915
def mass_matrix(self) -> ProxyArray:
938-
"""Per-env generalized mass matrix in joint space.
939-
940-
Shape is (num_instances, num_joints + num_base_dofs, num_joints + num_base_dofs),
941-
dtype = wp.float32. In torch this resolves to
942-
(num_instances, num_joints + num_base_dofs, num_joints + num_base_dofs).
916+
"""See :attr:`isaaclab.assets.BaseArticulationData.mass_matrix`.
943917
944-
Returns the symmetric positive-definite inertia matrix ``M(q)`` of the articulation in
945-
its generalized joint coordinates. For floating-base articulations the leading 6 rows
946-
and columns correspond to the floating-base spatial velocity in world frame; for
947-
fixed-base articulations there are 0 such rows/cols.
918+
PhysX implementation: passthrough of ``_root_view.get_generalized_mass_matrices()``.
948919
"""
949920
return ProxyArray(self._root_view.get_generalized_mass_matrices())
950921

951922
@property
952923
def gravity_compensation_forces(self) -> ProxyArray:
953-
"""Per-env gravity compensation torques in joint space.
954-
955-
Shape is (num_instances, num_joints + num_base_dofs), dtype = wp.float32
956-
[N·m or N, depending on joint type]. In torch this resolves to
957-
(num_instances, num_joints + num_base_dofs).
924+
"""See :attr:`isaaclab.assets.BaseArticulationData.gravity_compensation_forces`.
958925
959-
Returns ``g(q)`` — the joint-space gravity-loading term in the equation of motion
960-
``M(q) q_ddot + C(q, q_dot) q_dot + g(q) = tau``. For floating-base articulations the
961-
leading 6 entries correspond to the floating-base spatial velocity in world frame; for
962-
fixed-base articulations there are 0 such entries.
926+
PhysX implementation: passthrough of ``_root_view.get_gravity_compensation_forces()``.
963927
"""
964928
return ProxyArray(self._root_view.get_gravity_compensation_forces())
965929

0 commit comments

Comments
 (0)