获取Articulation
from omni.isaac.core.articulations import Articulation
from omni.isaac.core import World
art = Articulation(prim_path=pp)
# or
world = World()
art = world.dc_interface.get_articulation(pp)
获取prim
from omni.isaac.core.utils.prims import get_prim_at_path
joint_prim = get_prim_at_path(pp)
# or
joint_prim = world.stage.GetPrimAtPath(pp)
获取刚体
rg = world.dc_interface.get_rigid_body(pp)
获取/设置物体信息
obj_prim = world.stage.GetPrimAtPath(pp)
translate = prim.GetAttribute("xformOp:translate").Get()
orient = prim.GetAttribute("xformOp:orient").Get()
scale = prim.GetAttribute("xformOp:scale").Get()
prim.GetAttribute("xformOp:translate").Set((1,0,0))
prim.GetAttribute("xformOp:orient").Set(Gf.Quatf(0.5,0.5,0.5,0.5))
prim.GetAttribute("xformOp:scale").Set((1,1,1))
获取/设置位置
import omni.usd
loc, quat = art.get_world_pose()
art.set_world_pose(loc, quat)
# or
world_transform: Gf.Matrix4d = omni.usd.get_world_transform_matrix(joint_prim)
rotation: Gf.Rotation = world_transform.ExtractRotation()
设置力
import carb
force = 10
world.dc_interface.apply_body_force(rg, carb._carb.Float3(force), carb._carb.Float3([0.0, 0.0, 0.0]), False)
获取joint
from omni.isaac.dynamic_control import _dynamic_control
dc = _dynamic_control.acquire_dynamic_control_interface()
art = dc.get_articulation("/Franka")
dof_ptr = dc.find_articulation_dof(art, "panda_joint2")
dc.wake_up_articulation(art)
dc.set_dof_position_target(dof_ptr, -1.5)
dc.set_dof_velocity_target(dof_ptr, 0.2)
# or
linear_vel = world.dc_interface.get_rigid_body_linear_velocity(rg)
获取joint's drive
from pxr import UsdPhysics
drive_api = UsdPhysics.DriveAPI.Get(joint_prim, "angular")
dt = dive_api.GetTypeAttr() # angular or linear
sf = dive_api.GetStiffnessAttr()
tp = dive_api.GetTargetPositionAttr()
vl = dive_api.GetTargetVelocityAttr()
drive = UsdPhysics.DriveAPI.Apply(joint_prim, drive_type) # angular or linear
dive_api.CreateStiffnessAttr(sf)
dive_api.GetStiffnessAttr().Set(sf)
dive_api.CreateTargetPositionAttr(tp)
dive_api.GetTargetPositionAttr().Set(tp)
dive_api.CreateTargetVelocityAttr(vl)
dive_api.GetTargetVelocityAttr().Set(vl)