[Question] How to change USD visual color?
Question
How do we change the visual_material color of the robot? I added visual material to the spawn in ArticulationCfg, the color of the robot doesn't change and causes some environments are not working
spawn=sim_utils.UsdFileCfg(
usd_path=f"{ISAACLAB_NUCLEUS_DIR}/Robots/Unitree/A1/a1.usd",
activate_contact_sensors=True,
rigid_props=sim_utils.RigidBodyPropertiesCfg(
disable_gravity=False,
retain_accelerations=False,
linear_damping=0.0,
angular_damping=0.0,
max_linear_velocity=1000.0,
max_angular_velocity=1000.0,
max_depenetration_velocity=1.0,
),
articulation_props=sim_utils.ArticulationRootPropertiesCfg(
enabled_self_collisions=False, solver_position_iteration_count=4, solver_velocity_iteration_count=0
),
visual_material = sim_utils.PreviewSurfaceCfg(
diffuse_color=(random.random(), random.random(), random.random()), metallic=0.5
),
Since the asset is instanceable, you cannot change the properties of its visual meshes (this includes the material assigned to them). You will first need to make the asset uninstanceable.
For more information: https://openusd.org/dev/api/_usd__page__scenegraph_instancing.html
You can find the following function useful: https://isaac-sim.github.io/IsaacLab/source/api/lab/omni.isaac.lab.sim.html#omni.isaac.lab.sim.utils.make_uninstanceable
Is this also the same reason that the asset is instanceable,
[Warning] [omni.isaac.lab.sim.utils] Could not perform 'modify_collision_properties' on any prims under: '/World/envs/env_0/Animation'. This might be because of the following reasons:
(1) The desired attribute does not exist on any of the prims.
(2) The desired attribute exists on an instanced prim.
How to make_uninstanceable I passed the prims_path, but causes different error
Thanks
Yes, that's the reason why that doesn't work. What error did you get? Can you provide more details?
I tried to make_uninstanceable with this commands:
for prim_path in sim_utils.find_matching_prim_paths("/World/envs/env_.*/Animation/.*/collisions"):
print(prim_path)
sim_utils.make_uninstanceable(prim_path)
and got following error:
/World/envs/env_0/Animation/trunk/collisions
2024-07-05 07:17:27 [11,037ms] [Warning] [omni.physx.tensors.plugin] prim '/World/envs/env_0/Animation/trunk/collisions/mesh_0' was deleted while being used by a shape in a tensor view class. The physics.tensors simulationView was invalidated.
2024-07-05 07:17:27 [11,039ms] [Error] [omni.physx.plugin] PhysX error: PxRigidActor::detachShape: shape is not attached to this actor!, FILE /builds/omniverse/physics/physx/source/physx/src/NpRigidActorTemplate.h, LINE 257
2024-07-05 07:17:27 [11,039ms] [Error] [omni.physx.plugin] PhysX error: PxRigidActor::detachShape: shape is not attached to this actor!, FILE /builds/omniverse/physics/physx/source/physx/src/NpRigidActorTemplate.h, LINE 257
2024-07-05 07:17:27 [11,039ms] [Error] [omni.physx.plugin] PhysX error: PxRigidActor::detachShape: shape is not attached to this actor!, FILE /builds/omniverse/physics/physx/source/physx/src/NpRigidActorTemplate.h, LINE 257
2024-07-05 07:17:27 [11,039ms] [Error] [omni.physx.plugin] PhysX error: PxRigidActor::detachShape: shape is not attached to this actor!, FILE /builds/omniverse/physics/physx/source/physx/src/NpRigidActorTemplate.h, LINE 257
2024-07-05 07:17:27 [11,039ms] [Error] [omni.physx.plugin] PhysX error: PxRigidActor::detachShape: shape is not attached to this actor!, FILE /builds/omniverse/physics/physx/source/physx/src/NpRigidActorTemplate.h, LINE 257
2024-07-05 07:17:27 [11,039ms] [Error] [omni.physx.plugin] PhysX error: PxRigidActor::detachShape: shape is not attached to this actor!, FILE /builds/omniverse/physics/physx/source/physx/src/NpRigidActorTemplate.h, LINE 257
2024-07-05 07:17:27 [11,040ms] [Error] [omni.physx.plugin] PhysX error: PxRigidActor::detachShape: shape is not attached to this actor!, FILE /builds/omniverse/physics/physx/source/physx/src/NpRigidActorTemplate.h, LINE 257
UNITREE_A1_CFG = ArticulationCfg( spawn=sim_utils.UsdFileCfg( usd_path=f"{ISAACLAB_NUCLEUS_DIR}/Robots/Unitree/A1/a1.usd", activate_contact_sensors=True, rigid_props=sim_utils.RigidBodyPropertiesCfg( disable_gravity=False, retain_accelerations=False, linear_damping=0.0, angular_damping=0.0, max_linear_velocity=1000.0, max_angular_velocity=1000.0, max_depenetration_velocity=1.0, ), articulation_props=sim_utils.ArticulationRootPropertiesCfg( enabled_self_collisions=False, solver_position_iteration_count=4, solver_velocity_iteration_count=0 ), visual_material=sim_utils.PreviewSurfaceCfg(diffuse_color=(0.0, 0.0, 1.0)) ), I added "visual_material=sim_utils.PreviewSurfaceCfg(diffuse_color=(0.0, 0.0, 1.0))" in UNITREE_A1_CFG, but the color is still black. And if I create two A1 robots in the scene and set their states separately, one will move according to states I set and the other will standstill as the intial state.
Our apologies we couldn't follow up in a timely manner. Please reopen the issue if you still see this using Isaac Sim 4.2 and Isaac Lab 1.4.0. Thank you.
Since the asset is instanceable, you cannot change the properties of its visual meshes (this includes the material assigned to them). You will first need to make the asset uninstanceable.
For more information: https://openusd.org/dev/api/_usd__page__scenegraph_instancing.html
You can find the following function useful: https://isaac-sim.github.io/IsaacLab/source/api/lab/omni.isaac.lab.sim.html#omni.isaac.lab.sim.utils.make_uninstanceable
Once I have made the asset uninstanceable how can I change the visual material? Here is how I am defining my asset:
table = AssetBaseCfg(
prim_path="{ENV_REGEX_NS}/Table",
spawn=sim_utils.UsdFileCfg(
# usd_path=f"{data_dir}/assets/table/table2_instanceable.usd",
usd_path=f"{data_dir}/assets/table/table2.usd",
rigid_props=sim_utils.RigidBodyPropertiesCfg(
retain_accelerations=False,
solver_position_iteration_count=8,
solver_velocity_iteration_count=0,
max_angular_velocity=1000.0,
max_linear_velocity=1000.0,
max_depenetration_velocity=5.0,
disable_gravity=False,
),
visual_material=sim_utils.PreviewSurfaceCfg(diffuse_color=(1.00, 0.01, 0.01))
),
init_state=AssetBaseCfg.InitialStateCfg(pos=(0.2, 0.0, 0.0)),
)