IsaacLab icon indicating copy to clipboard operation
IsaacLab copied to clipboard

How to change link colors in IsaacLab during simulation (similar to IsaacGym set_rigid_body_color)

Open SHO252 opened this issue 2 months ago • 1 comments

In IsaacGym, it was possible to dynamically change the color of a rigid body during simulation using:

gym.set_rigid_body_color(env, actor_handle, body_handle, gymapi.MESH_VISUAL, gymapi.Vec3(r, g, b))

This was very useful for visual debugging (e.g., highlighting specific links, showing state-dependent visualization, etc.).

❓ Question

Is there an equivalent or recommended way in IsaacLab + Isaac Sim 5.0 to change the color of individual robot links during simulation?

💡 What I'm looking for

Is there an official API in IsaacLab to modify link colors at runtime (similar to set_rigid_body_color in IsaacGym)?

If not, what is the recommended method for dynamic per-link coloring?

Should materials be edited instead of displayColor?

📝 Notes

I am using an articulated robot spawned from a USD/URDF asset, and I want to update link colors every frame for visualization/debugging purposes.

SHO252 avatar Nov 14 '25 02:11 SHO252

I am using a custom environment based on DirectRLEnv similar to the HumanoidAmpEnv example:

`class HumanoidAmpEnv(DirectRLEnv): cfg: HumanoidAmpEnvCfg

def __init__(self, cfg: HumanoidAmpEnvCfg, render_mode: str | None = None, **kwargs):
    super().__init__(cfg, render_mode, **kwargs)

    dof_lower_limits = self.robot.data.soft_joint_pos_limits[0, :, 0]
    dof_upper_limits = self.robot.data.soft_joint_pos_limits[0, :, 1]
    self.action_offset = 0.5 * (dof_upper_limits + dof_lower_limits)
    self.action_scale = dof_upper_limits - dof_lower_limits

    # ... (motion loader, AMP buffer, etc.)

def _setup_scene(self):
    self.robot = Articulation(self.cfg.robot)

    # ground + lights
    spawn_ground_plane(prim_path="/World/ground", cfg=GroundPlaneCfg(...))
    self.scene.clone_environments(copy_from_source=False)
    self.scene.articulations["robot"] = self.robot
    light_cfg = sim_utils.DomeLightCfg(intensity=2000.0, color=(0.75, 0.75, 0.75))
    light_cfg.func("/World/Light", light_cfg)

# ...

` What I would like to do

For visual debugging, I would like to change the color of specific robot links dynamically during simulation, based on some scalar value R that evolves over time (for example, increasing with each environment step).

Conceptually, something like: `class HumanoidAmpEnv(DirectRLEnv): # ...

def __init__(self, cfg: HumanoidAmpEnvCfg, render_mode: str | None = None, **kwargs):
    super().__init__(cfg, render_mode, **kwargs)
    self.debug_R = torch.zeros((self.num_envs,), device=self.device)

def _post_physics_step(self):
    super()._post_physics_step()

    # Example: R increases over time, just for debugging
    self.debug_R += 0.01

    # Map R to some color and update link visuals
    self._update_link_colors(self.debug_R)

def _update_link_colors(self, R: torch.Tensor):
    """Question: how should this be implemented in IsaacLab?"""
    # For example, I would like to do something like:
    #   - for each env
    #   - for each link name (e.g., "right_thigh", "left_thigh", ...)
    #   - compute a color from R[env]  (e.g., red = clamp(R[env], 0, 1))
    #   - apply that color to the corresponding USD prim / mesh
    pass

`

I previously tried traversing the USD stage and using UsdGeom.Mesh.GetDisplayColorAttr().Set(...) on meshes under the robot, using a custom function that tried to access a root path like self.robot.prim_path. However, the Articulation object does not seem to expose prim_path directly in this version, and I’m not sure if directly editing displayColor every frame is the recommended approach.

SHO252 avatar Nov 14 '25 02:11 SHO252

Thank you for posting this. There is currently no official method documented for direct, persistent, per-step mesh color override on a link without going through USD material manipulation in Isaac Sim 5.0 and Isaac Lab. The main approaches for “highlighting” links at runtime are:

  • Material swap (with some latency) for mesh color,
  • Visualization markers for fast, flexible overlays.

RandomOakForest avatar Nov 17 '25 17:11 RandomOakForest