Hi, I’m trying to import urdf file using python script in Isaac sim (2021.2.1 version). The code inside ‘omni.isaac.examples/omni/isaac/examples/hello_world/hello_world.py’ is as belows (only for 'setup_scene 'method)
def setup_scene(self):
world = self.get_world()
print("world:", world)
world.scene.add_default_ground_plane()
# fancy_cube = world.scene.add(
# DynamicCuboid(
# prim_path="/World/random_cube", # The prim path of the cube in the USD stage
# name="fancy_cube", # The unique name used to retrieve the object from the scene later on
# position=np.array([0, 0, 1.0]), # Using the current stage units which is in meters by default.
# size=np.array([0.5015, 0.5015, 0.5015]), # most arguments accept mainly numpy arrays.
# color=np.array([0, 0, 1.0]), # RGB channels, going from 0-1
# ))
urdf_interface = _urdf.acquire_urdf_interface()
import_config = _urdf.ImportConfig()
import_config.merge_fixed_joints = False
import_config.convex_decomp = False
import_config.import_inertia_tensor = True
import_config.fix_base = False
import_config.make_default_prim = True
import_config.self_collision = False
import_config.create_physics_scene = True
import_config.import_inertia_tensor = False
import_config.default_drive_strength = 1047.19751
import_config.default_position_drive_damping = 52.35988
import_config.default_drive_type = _urdf.UrdfJointTargetType.JOINT_DRIVE_POSITION
import_config.distance_scale = 1
result, path_usd = omni.kit.commands.execute(
"URDFParseAndImportFile",
urdf_path="/home/robot/Downloads/models/000/textured.urdf",
import_config=import_config,
)
print("result:", result)
print('path_usd', path_usd)
ob1 = XFormPrim(path_usd+"/baseLink")
print("ob1 pose:\n",ob1.get_local_pose())
print("ob1 scale:\n",ob1.get_local_scale())
ob1.set_world_pose(np.array([0, 0, 20]), np.array([1, 0, 0, 0]))
print("ob1 material?:\n",ob1.is_visual_material_applied())
print("ob1\n", ob1.get_applied_visual_material())
pbr = OmniPBR(prim_path='/omniPBR', texture_path='/home/robot/Downloads/models/000/texture_map.png')
ob1.apply_visual_material(pbr)
ob1.set_local_scale(np.array([100, 100, 100]))
# get stage handle
stage = omni.usd.get_context().get_stage()
# enable physics
scene = UsdPhysics.Scene.Define(stage, Sdf.Path("/physicsScene"))
# set gravity
scene.CreateGravityDirectionAttr().Set(Gf.Vec3f(0.0, 0.0, -1.0))
scene.CreateGravityMagnitudeAttr().Set(9.81)
# add ground plane
PhysicsSchemaTools.addGroundPlane(stage, "/World/groundPlane", "Z", 1500, Gf.Vec3f(0, 0, -50), Gf.Vec3f(0.5))
return
When I run the code from Isaac Example → Hello Wolrd, the object comes out with given translation. However, the texture of the object has some problem so that it just look like black object
When I create OmniPBR inside the isaac sim UI and give the texture file(.png) exactly as same as above, and change the visuals/material of imported urdf, the expected texture then visualized.
How can I import urdf files with texture using python script?