Hi,
I noticed when adding an URDF using the GUI, it by default, adds it under the default /World
prim.
However, when I load the URDF using the Python, i.e.,
status, stage_path = omni.kit.commands.execute(
"URDFParseAndImportFile",
urdf_path=urdf_path,
import_config=import_config,
)
It loads at the same level as the /World
prim. My question is how can the URDF loaded object be included into the /World
prim?
Thanks in advance! For your reference, the entire code I am using is
from isaacsim import SimulationApp
kit = SimulationApp({"renderer": "RayTracedLighting", "headless": False})
import omni.kit.commands
from omni.importer.urdf import _urdf
from omni.isaac.core import World
from omni.isaac.core.articulations import Articulation
from pxr import Gf, PhysxSchema, Sdf, UsdLux, UsdPhysics
my_world = World(stage_units_in_meters=1.0)
my_world.scene.add_default_ground_plane()
status, import_config = omni.kit.commands.execute("URDFCreateImportConfig")
import_config.fix_base = False
import_config.default_drive_type = _urdf.UrdfJointTargetType.JOINT_DRIVE_VELOCITY
turtlebot3_urdf_path = "/home/bolun/Documents/IsaacSim-ros_workspaces/humble_ws/src/turtlebot3/turtlebot3_description/urdf/turtlebot3_burger.urdf"
# Import URDF, stage_path contains the path the path to the usd prim in the stage.
status, stage_path = omni.kit.commands.execute(
"URDFParseAndImportFile",
urdf_path=turtlebot3_urdf_path,
import_config=import_config,
)
# 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)
# Set solver settings
PhysxSchema.PhysxSceneAPI.Apply(stage.GetPrimAtPath("/physicsScene"))
physxSceneAPI = PhysxSchema.PhysxSceneAPI.Get(stage, "/physicsScene")
physxSceneAPI.CreateEnableCCDAttr(True)
physxSceneAPI.CreateEnableStabilizationAttr(True)
physxSceneAPI.CreateEnableGPUDynamicsAttr(False)
physxSceneAPI.CreateBroadphaseTypeAttr("MBP")
physxSceneAPI.CreateSolverTypeAttr("TGS")
# Add ground plane
omni.kit.commands.execute(
"AddGroundPlaneCommand",
stage=stage,
planePath="/groundPlane",
axis="Z",
size=1500.0,
position=Gf.Vec3f(0, 0, -50),
color=Gf.Vec3f(0.5),
)
# Add lighting
distantLight = UsdLux.DistantLight.Define(stage, Sdf.Path("/DistantLight"))
distantLight.CreateIntensityAttr(500)
my_world.reset()
art = Articulation(prim_path=stage_path)
art.initialize()
if not art.handles_initialized:
print(f"{stage_path} is not an articulation")
else:
print(f"Got articulation {stage_path}")
# perform simulation
while kit.is_running():
my_world.step(render=True)
# Shutdown and exit
kit.close()