Skip to content

[Core] Refactor and cleanup core subpackage for 3.0 [12/N] - #8094

Merged
StafaH merged 3 commits into
isaac-sim:developfrom
StafaH:core-cleanup/12-actuators-controllers
Sep 28, 2026
Merged

StafaH merged 3 commits into
isaac-sim:developfrom
StafaH:core-cleanup/12-actuators-controllers

Conversation

@StafaH

@StafaH StafaH commented Sep 27, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Part 12 of the core cleanup split from #7949. This PR covers isaaclab.actuators and isaaclab.controllers. It is rebased onto the current develop and ports only the parts of the original cleanup that still apply there.

Actuators

  • ActuatorCollection:
    • Iterates the shared _JOINT_PROPERTY_KEYS tuple (same order) instead of repeating the key list.
    • Inlines the one-line _resolve_joint_property wrapper.
    • _joint_indices_as_wp now reuses _joint_indices_as_torch.
    • The six ActuatorTargetCommand.set_{position,velocity,effort}_{index,mask} methods share _set_index / _set_mask. Selector resolution, shape checks, kernels and command staging are unchanged.
  • DCMotor: removed the unused _zeros_effort buffer.
  • DelayedPDActuator: removed the unused _ALL_INDICES tensor, and reset now loops over the three delay buffers.
  • Newton adapter: defaultdict is now imported at module level.

Controllers

  • DifferentialIKController:
    • Compacted _compute_delta_joint_pos: IK params are read once, .mT is used, and there is a single unsqueeze/squeeze.
    • Removed the duplicated ee_quat_des write in position mode.
    • Fixed a docstring typo.
  • OperationalSpaceController: the three copies of the 2 * sqrt(kp) * zeta damping-gain formula now share _critically_damped_gains. The gains are still written in place, so _frame_matrices and the LEAPP export annotator keep referencing the live buffer.
  • PinkIKController:
    • Calls set_target_from_configuration directly instead of through getattr.
    • Builds joint-name mismatches with a comprehension.
    • except (AssertionError, Exception) is now except Exception.
    • Logs solver failures with logger.warning instead of print.
    • The explicit None checks and their ValueErrors are kept.
  • RmpFlowController: logs the URDF path with logger.info instead of print, and selects active and watched joints with combined indexing (all_pos[i, idx] instead of all_pos[i][idx]).
  • controllers.utils:
    • change_revolute_to_fixed_regex resolves the matching joints and delegates to change_revolute_to_fixed.
    • The ISAAC_PATH lookup shared by the RMPFlow and lula discovery helpers is now _isaac_path().

Not ported from #7949

  • Deprecated limit-alias refactors in _compat, ActuatorBase, and ImplicitActuator: these paths will be removed.
  • DCMotor clip compaction: develop has since reworked _clip_effort to take joint_vel.
  • OSC rotation and identity-frame changes: develop already covers them.
  • Removal of Pink IK's None checks: it would turn ValueError into TypeError.

Type of change

  • Refactor, plus one user-visible logging change (print → logging in Pink IK and RMPFlow).

Verification

  • Bitwise equivalence against develop (same seeded inputs run through both source trees, compared with torch.equal including dtype and shape): 566 outputs, 0 differences, on CPU and CUDA. Covered:
    • DifferentialIKController.set_command + compute for all 5 IK methods × pose/position × absolute/relative, batch sizes 1, 64, 512 and 4096, 6–9 joints, including near-singular and rank-deficient Jacobians; plus _compute_delta_joint_pos with 3- and 6-row Jacobians.
    • OperationalSpaceController init gains, set_command (task and root-frame gains) and compute torques in fixed, variable_kp and variable impedance modes, with and without inertial decoupling, gravity compensation and null-space control. _motion_d_gains_task stays the same tensor object.
    • ActuatorTargetCommand position/velocity/effort index setters (full and selected) and mask setters.
  • Performance against develop (median of 5 alternating runs; 4096 envs): IK compute (all methods), OSC set_command (all modes), and the target-command setters are within run-to-run noise on CPU and CUDA (ratios 0.96–1.04; a dedicated 10-run setter benchmark gave matching medians of ~53.6 µs CPU / ~17.0 µs CUDA).
  • Tests:
    • source/isaaclab/test/actuators, test_articulation_iface.py, test_joint_impedance.py, test_local_frame_task.py, test_null_space_posture_task.py, test_pink_ik_components.py: pass. When these files run in one process, 3 test_action_gravity_compensation_with_migrated_robot_configs[...GR1T2_HIGH_PD_CFG] cases fail on develop and on this branch alike; they pass when run on their own.
    • test_controller_utils.py (22), test_differential_ik.py (40), test_operational_space.py (47), test_pink_ik.py (19 passed, 1 skipped): pass.
    • test_newton_actuators_newton.py (38) and test_newton_actuators_physx.py (35): pass.
  • ruff check and ruff format are clean.

Checklist

  • I have read and understood the contribution guidelines
  • I have run the pre-commit checks with ./isaaclab.sh --format
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • I have added a changelog fragment

Release backport

  • Backport this pull request to the active release branch after it merges into develop

@StafaH
StafaH requested a review from a team September 27, 2026 23:16
@github-actions github-actions Bot added the isaac-lab Related to Isaac Lab team label Sep 27, 2026
@greptile-apps

greptile-apps Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

[Medium risk] Refactors actuators and controllers with logic changes and output behavior shifts.

The PR appears safe to merge; the extra URDF read is a non-blocking quality concern.

Findings

  1. P2 URDF read twice ▶

Summary

This PR consolidates actuator command handling and controller calculations, removes unused actuator state, and routes Pink IK and RMPFlow messages through module loggers.

  • The reviewed computation and buffer refactors preserve their existing behavior.
  • URDF regex conversion now performs an extra read before rewriting the file.

Reviews (1) · Last reviewed commit: "Clean up actuator and controller interna..."

file.write(content)
# convert the revolute joints that match any of the fixed joint patterns
matched_joints = [joint for joint in revolute_joints if any(re.match(pattern, joint) for pattern in fixed_joints)]
change_revolute_to_fixed(urdf_path, matched_joints, verbose)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 URDF read twice

change_revolute_to_fixed_regex reads the URDF to find matching joints, then this helper reads it again before writing. That adds file I/O on every call. If another process changes the file between reads, the selected names may no longer match what gets rewritten. Consider reusing the content from the first read.

@isaaclab-review-bot isaaclab-review-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isaac Lab Review Bot

The refactor largely preserves actuator and controller behavior, but the consolidated actuator command setters introduce a string-to-attribute mapping and reflective buffer lookup solely to reduce repetition, contrary to the repository’s preference against packing containers for shortening code.

  • Design and architecture: Shared helpers for actuator command writes, OSC damping gains, and Isaac Sim path discovery reduce duplication without changing the traced data flow. However, _COMMAND_BUFFER_NAMES plus _target_buffer() obscures the direct relationship between each public command setter and its backing buffer; each setter should pass the explicit buffer to the shared helper.
  • API: Public setter signatures and selector semantics remain unchanged. The DiffIK reset annotation, controller logging changes, regex utility delegation, and mathematical refactors do not introduce an evidenced public API compatibility issue.
  • Implementation: The MLP gather preserves the prior history ordering, the DiffIK and OSC rewrites preserve their output shapes and live-buffer aliasing, and the exception simplification is equivalent because AssertionError derives from Exception. The actuator command-buffer lookup should be made explicit rather than using the new suffix map and getattr, improving rename safety and compliance with repository style guidance.

Minor fixes needed. Posted 1 actionable finding inline.

Automated review; human maintainers own approval decisions.

return mask
def _target_buffer(self, command_name: str) -> wp.array(dtype=wp.float32):
"""Return the raw command buffer for ``command_name``."""
return getattr(self._collection, f"_joint_{_COMMAND_BUFFER_NAMES[command_name]}_target")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Suggestion · Implementation — Reflective lookup replaces explicit command buffer argument

_target_buffer resolves _joint_pos_target / _joint_vel_target / _joint_effort_target via getattr with an f-string keyed by the new _COMMAND_BUFFER_NAMES map, while the removed helpers took the buffer as a parameter. The repository style rule says not to add packing containers or reflective access just to shorten code: the buffer names are no longer greppable and a rename fails at runtime rather than statically. Pass the buffer explicitly from each setter into _set_index/_set_mask.

@StafaH

StafaH commented Sep 28, 2026

Copy link
Copy Markdown
Collaborator Author

run-ci

@isaaclab-bot isaaclab-bot Bot added ci:run-docker Trigger the on-demand Docker and GPU CI workflow and removed ci:run-docker Trigger the on-demand Docker and GPU CI workflow labels Sep 28, 2026
@StafaH
StafaH merged commit 85dad89 into isaac-sim:develop Sep 28, 2026
53 checks passed
@StafaH
StafaH deleted the core-cleanup/12-actuators-controllers branch September 28, 2026 00:54
@isaaclab-bot

isaaclab-bot Bot commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

Backported to release/3.0.0 as 0a457af.

isaaclab-bot Bot pushed a commit that referenced this pull request Sep 28, 2026
# Description

Part 12 of the core cleanup split from #7949. This PR covers
`isaaclab.actuators` and `isaaclab.controllers`. It is rebased onto the
current `develop` and ports only the parts of the original cleanup that
still apply there.

**Actuators**
- `ActuatorCollection`:
- Iterates the shared `_JOINT_PROPERTY_KEYS` tuple (same order) instead
of repeating the key list.
  - Inlines the one-line `_resolve_joint_property` wrapper.
  - `_joint_indices_as_wp` now reuses `_joint_indices_as_torch`.
- The six
`ActuatorTargetCommand.set_{position,velocity,effort}_{index,mask}`
methods share `_set_index` / `_set_mask`. Selector resolution, shape
checks, kernels and command staging are unchanged.
- `DCMotor`: removed the unused `_zeros_effort` buffer.
- `DelayedPDActuator`: removed the unused `_ALL_INDICES` tensor, and
`reset` now loops over the three delay buffers.
- Newton adapter: `defaultdict` is now imported at module level.

**Controllers**
- `DifferentialIKController`:
- Compacted `_compute_delta_joint_pos`: IK params are read once, `.mT`
is used, and there is a single `unsqueeze`/`squeeze`.
  - Removed the duplicated `ee_quat_des` write in position mode.
  - Fixed a docstring typo.
- `OperationalSpaceController`: the three copies of the `2 * sqrt(kp) *
zeta` damping-gain formula now share `_critically_damped_gains`. The
gains are still written in place, so `_frame_matrices` and the LEAPP
export annotator keep referencing the live buffer.
- `PinkIKController`:
- Calls `set_target_from_configuration` directly instead of through
`getattr`.
  - Builds joint-name mismatches with a comprehension.
  - `except (AssertionError, Exception)` is now `except Exception`.
  - Logs solver failures with `logger.warning` instead of `print`.
  - The explicit `None` checks and their `ValueError`s are kept.
- `RmpFlowController`: logs the URDF path with `logger.info` instead of
`print`, and selects active and watched joints with combined indexing
(`all_pos[i, idx]` instead of `all_pos[i][idx]`).
- `controllers.utils`:
- `change_revolute_to_fixed_regex` resolves the matching joints and
delegates to `change_revolute_to_fixed`.
- The `ISAAC_PATH` lookup shared by the RMPFlow and lula discovery
helpers is now `_isaac_path()`.

**Not ported from #7949**
- Deprecated limit-alias refactors in `_compat`, `ActuatorBase`, and
`ImplicitActuator`: these paths will be removed.
- DCMotor clip compaction: `develop` has since reworked `_clip_effort`
to take `joint_vel`.
- OSC rotation and identity-frame changes: `develop` already covers
them.
- Removal of Pink IK's `None` checks: it would turn `ValueError` into
`TypeError`.

## Type of change

- Refactor, plus one user-visible logging change (`print` → `logging` in
Pink IK and RMPFlow).

## Verification

- Bitwise equivalence against `develop` (same seeded inputs run through
both source trees, compared with `torch.equal` including dtype and
shape): **566 outputs, 0 differences**, on CPU and CUDA. Covered:
- `DifferentialIKController.set_command` + `compute` for all 5 IK
methods × pose/position × absolute/relative, batch sizes 1, 64, 512 and
4096, 6–9 joints, including near-singular and rank-deficient Jacobians;
plus `_compute_delta_joint_pos` with 3- and 6-row Jacobians.
- `OperationalSpaceController` init gains, `set_command` (task and
root-frame gains) and `compute` torques in fixed, variable_kp and
variable impedance modes, with and without inertial decoupling, gravity
compensation and null-space control. `_motion_d_gains_task` stays the
same tensor object.
- `ActuatorTargetCommand` position/velocity/effort index setters (full
and selected) and mask setters.
- Performance against `develop` (median of 5 alternating runs; 4096
envs): IK `compute` (all methods), OSC `set_command` (all modes), and
the target-command setters are within run-to-run noise on CPU and CUDA
(ratios 0.96–1.04; a dedicated 10-run setter benchmark gave matching
medians of ~53.6 µs CPU / ~17.0 µs CUDA).
- Tests:
- `source/isaaclab/test/actuators`, `test_articulation_iface.py`,
`test_joint_impedance.py`, `test_local_frame_task.py`,
`test_null_space_posture_task.py`, `test_pink_ik_components.py`: pass.
When these files run in one process, 3
`test_action_gravity_compensation_with_migrated_robot_configs[...GR1T2_HIGH_PD_CFG]`
cases fail on `develop` and on this branch alike; they pass when run on
their own.
- `test_controller_utils.py` (22), `test_differential_ik.py` (40),
`test_operational_space.py` (47), `test_pink_ik.py` (19 passed, 1
skipped): pass.
- `test_newton_actuators_newton.py` (38) and
`test_newton_actuators_physx.py` (35): pass.
- `ruff check` and `ruff format` are clean.

## Checklist

- [x] I have read and understood the contribution guidelines
- [x] I have run the `pre-commit` checks with `./isaaclab.sh --format`
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [x] I have added a changelog fragment

## Release backport

- [x] <!-- backport-active-release --> Backport this pull request to the
active release branch after it merges into `develop`

(cherry picked from commit 85dad89)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants