Skip to content

Removes Single Articulation Dependencies in RMPflow - #4800

Merged
kellyguo11 merged 4 commits into
isaac-sim:developfrom
ooctipus:feature/develop/refactor_rmp_flow
Mar 6, 2026
Merged

kellyguo11 merged 4 commits into
isaac-sim:developfrom
ooctipus:feature/develop/refactor_rmp_flow

Conversation

@ooctipus

@ooctipus ooctipus commented Mar 3, 2026 •

Copy link
Copy Markdown
Collaborator

Description

This PR removes SingleArticulation dependencies from isaacsim in rmpflow controller implementation, should make rmpflow dependent environments work again.

this should help #4744

Fixes # (issue)

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Screenshots

Please attach before and after screenshots of the change if applicable.

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 updated the changelog and the corresponding version in the extension's config/extension.toml file
  • I have added my name to the CONTRIBUTORS.md or my name already exists there

@github-actions github-actions Bot added enhancement New feature or request isaac-lab Related to Isaac Lab team labels Mar 3, 2026
@alexmillane

alexmillane commented Mar 5, 2026 •

Copy link
Copy Markdown
Collaborator

@ooctipus Is this good to merge? We (@rebeccazhang0707) tested it and it works on our end :)

@kellyguo11
kellyguo11 marked this pull request as ready for review March 6, 2026 03:32
@kellyguo11
kellyguo11 requested a review from Mayankm96 as a code owner March 6, 2026 03:32
@greptile-apps

greptile-apps Bot commented Mar 6, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR removes the SingleArticulation and ArticulationMotionPolicy dependencies from IsaacSim in the RMPflow controller, replacing them with direct calls to RmpFlow/RmpFlowSmoothed from the Lula motion generation library. The controller's initialize method now accepts num_robots and joint_names directly from the Articulation asset instead of resolving prim paths, and compute now takes explicit joint_positions and joint_velocities tensors — eliminating the need for RMPflow to maintain its own articulation reference. The PR also fixes a pre-existing NameError where joint_vel_des was undefined in the fallback else branch of apply_actions, and cleans up a duplicate import in __init__.pyi.

Key changes:

  • RmpFlowController.initialize(prim_paths_expr) → initialize(num_robots, joint_names): per-robot joint index arrays (_active_indices, _watched_indices) are now built from the articulation's joint name list and used to slice positions/velocities at compute time.
  • RmpFlowController.compute() → compute(joint_positions, joint_velocities): joint state is now explicitly passed in rather than queried internally via ArticulationMotionPolicy.
  • articulation_prim_expr field removed from RMPFlowActionCfg and all downstream task configs.
  • Duplicate from .hydra import resolve_task_config, hydra_task_config removed from utils/__init__.pyi.

Issues found:

  • The new name_to_idx dictionary lookup in initialize raises a bare KeyError with no diagnostic message if an RMPflow joint name is absent from the articulation's joint_names. A pre-validation step with a clear error message is recommended.
  • reset() in RMPFlowAction unconditionally calls initialize() on every invocation — even for partial env_ids subsets — discarding and recreating all robot controllers rather than selectively resetting only the affected environments via reset_idx.

Confidence Score: 3/5

  • This PR is mostly safe to merge as a bug fix, but the unhandled KeyError in initialize and the full-reinitialize-on-every-reset pattern should be addressed before merging to avoid confusing runtime failures and performance regressions.
  • The core approach (removing SingleArticulation by passing joint state directly) is architecturally sound and fixes the reported dependency issue. The logic for slicing active/watched joint indices is correct. However, the new name_to_idx lookup has no error handling, which will produce cryptic failures for any misconfiguration, and reset() reinitializing all policies on every call (including partial resets) is a behavioral issue that could significantly slow down training.
  • source/isaaclab/isaaclab/controllers/rmp_flow.py (joint name validation), source/isaaclab/isaaclab/envs/mdp/actions/rmpflow_task_space_actions.py (reset lifecycle)

Important Files Changed

Filename Overview
source/isaaclab/isaaclab/controllers/rmp_flow.py Core refactor removing SingleArticulation dependency. The initialize method now accepts joint names directly and builds index arrays for active/watched joints. The new name_to_idx lookup introduces an unhandled KeyError when RMPflow joint names don't match the articulation's joints. The compute method correctly accepts joint positions/velocities as arguments, properly slicing via precomputed indices.
source/isaaclab/isaaclab/envs/mdp/actions/rmpflow_task_space_actions.py Action term updated to pass joint positions/velocities to compute() and to call initialize() with joint names instead of a prim expression. Fixes a pre-existing NameError for joint_vel_des in the else branch. However, reset() unconditionally calls initialize() on every reset, even for partial env_ids subsets, unnecessarily discarding and rebuilding all robot controllers.
source/isaaclab/isaaclab/envs/mdp/actions/rmpflow_actions_cfg.py Removes the now-unnecessary articulation_prim_expr field from RMPFlowActionCfg. Clean change with no issues.
source/isaaclab_tasks/isaaclab_tasks/utils/init.pyi Removes a duplicate import of resolve_task_config and hydra_task_config that was already present in the preceding line. Clean fix.
source/isaaclab_tasks/isaaclab_tasks/manager_based/manipulation/stack/config/galbot/stack_rmp_rel_env_cfg.py Removes articulation_prim_expr from both left and right arm RMPFlowActionCfg instantiations. No issues.

Sequence Diagram

sequenceDiagram
    participant Env as ManagerBasedEnv
    participant Action as RMPFlowAction
    participant Controller as RmpFlowController
    participant Lula as RmpFlow (Lula)

    Note over Action,Controller: reset() — called on env reset
    Env->>Action: reset(env_ids)
    Action->>Controller: initialize(num_envs, joint_names)
    loop for each robot
        Controller->>Lula: RmpFlow(...) — new instance
        Controller->>Lula: get_active_joints()
        Controller->>Lula: get_watched_joints()
        Note over Controller: build active_indices, watched_indices<br/>from joint_names lookup (KeyError risk)
    end

    Note over Action,Controller: process_actions() — called each env.step()
    Env->>Action: process_actions(actions)
    Action->>Controller: set_command(ee_pose_des)

    Note over Action,Controller: apply_actions() — called each sim.step()
    Env->>Action: apply_actions()
    Action->>Action: _compute_frame_pose()
    alt ee_quat norm != 0
        Action->>Controller: compute(joint_pos, joint_vel)
        loop for each robot
            Controller->>Lula: set_end_effector_target(pos, orientation)
            Controller->>Controller: slice active_pos, active_vel,<br/>watched_pos, watched_vel via indices
            Controller->>Lula: compute_joint_targets(active_pos, active_vel,<br/>watched_pos, watched_vel, dt)
            Lula-->>Controller: pos_targets, vel_targets
        end
        Controller-->>Action: dof_pos_target, dof_vel_target
    else ee_quat norm == 0
        Action->>Action: joint_pos_des = current joint_pos
        Action->>Action: joint_vel_des = zeros
    end
    Action->>Env: set_joint_position_target_index(...)
    Action->>Env: set_joint_velocity_target_index(...)
Loading

Last reviewed commit: d1f0dc2

Comment on lines +112 to +113
active_indices = np.array([name_to_idx[n] for n in rmpflow.get_active_joints()], dtype=np.intp)
watched_indices = np.array([name_to_idx[n] for n in rmpflow.get_watched_joints()], dtype=np.intp)

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.

KeyError gives no diagnostic context on joint name mismatch

If any joint name returned by rmpflow.get_active_joints() or rmpflow.get_watched_joints() is not present in the joint_names list provided by the articulation, a bare KeyError is raised with no indication of which joint is missing, what the full set of expected joints is, or which robot index caused the failure. This makes misconfiguration extremely hard to debug.

Consider a pre-validation step with an explicit error message:

active_joint_names = rmpflow.get_active_joints()
watched_joint_names = rmpflow.get_watched_joints()
missing = [n for n in active_joint_names + watched_joint_names if n not in name_to_idx]
if missing:
    raise ValueError(
        f"RMPflow joints {missing} not found in articulation joint_names. "
        f"Available joints: {joint_names}"
    )
active_indices = np.array([name_to_idx[n] for n in active_joint_names], dtype=np.intp)
watched_indices = np.array([name_to_idx[n] for n in watched_joint_names], dtype=np.intp)

Comment on lines 194 to +196
def reset(self, env_ids: Sequence[int] | None = None) -> None:
self._raw_actions[env_ids] = 0.0
self._rmpflow_controller.initialize(self.cfg.articulation_prim_expr)
self._rmpflow_controller.initialize(self.num_envs, list(self._asset.joint_names))

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.

initialize called on every reset, even for partial resets

reset is called with a subset of env_ids during normal training (e.g., when only some environments terminate), yet initialize unconditionally rebuilds all num_robots RMPflow policy instances — including downloading/resolving all config files in a loop. This is both expensive and semantically incorrect: environments that are not being reset have their controller state silently discarded and recreated.

The reset_idx method on the controller already handles per-robot policy resets efficiently. Consider only calling initialize once (e.g., during first setup) and forwarding env_ids to reset_idx on subsequent calls:

def reset(self, env_ids: Sequence[int] | None = None) -> None:
    self._raw_actions[env_ids] = 0.0
    if not hasattr(self._rmpflow_controller, 'num_robots'):
        # First-time initialization
        self._rmpflow_controller.initialize(self.num_envs, list(self._asset.joint_names))
    else:
        ids = torch.tensor(list(env_ids), device=self.device) if env_ids is not None else None
        self._rmpflow_controller.reset_idx(ids)

@kellyguo11
kellyguo11 merged commit 311e03e into isaac-sim:develop Mar 6, 2026
8 of 11 checks passed
@ooctipus
ooctipus deleted the feature/develop/refactor_rmp_flow branch March 10, 2026 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants