yes here’s the main code
kit = OmniKitHelper(config=CONFIG)
editor = omni.kit.editor.get_editor_interface()
stage = kit.get_stage()
physxIFace = _physx.acquire_physx_interface()
dc = _dynamic_control.acquire_dynamic_control_interface()
mp = _motion_planning.acquire_motion_planning_interface()
editor.set_camera_position("/OmniverseKit_Persp", -200, 150, 200, True)
editor.set_camera_target("/OmniverseKit_Persp", 0,0,0, True)
editor.stop()
physxIFace.release_physics_objects()
allegro = MovingArm(stage, editor, dc, mp)
allegro.load_kinova()
urdf = allegro.get_urdf()
kinova_prim = stage.GetDefaultPrim()
config_kinova(stage, dc, editor, kinova_prim) #add drive to arm
setup_physics(stage) #gravity to scene
wristPrim = stage.DefinePrim("/GEN3_6DOF_NO_VISION_URDF_ARM_V01/spherical_wrist_1_link/hand", "Xform")
stage.SetDefaultPrim(wristPrim)
allegro.load_hand()
set_translate(stage.GetDefaultPrim(),Gf.Vec3d(0, 0, 127))
#move path of prims
src="/allegro_hand_right"
dst ="/GEN3_6DOF_NO_VISION_URDF_ARM_V01/spherical_wrist_1_link/hand"
MovePrimCommand(src,dst).do()
scene = PhysicsSchema.PhysicsScene.Define(stage, Sdf.Path("/physicsScene"))
scene.CreateGravityAttr().Set(Gf.Vec3f(0.0, 0.0, -981.0))
physics_api = PhysicsSchema.PhysicsAPI.Apply(kinova_prim)
physics_api.CreateBodyTypeAttr("rigid")
# Enable collision on prim
collision_api = PhysicsSchema.CollisionAPI.Apply(kinova_prim)
collision_api.CreateCollisionEnabledAttr().Set(True)
# Set the collision approximation to convexHull
mesh_collision_api = PhysxSchema.PhysxMeshCollisionAPI.Apply(kinova_prim)
mesh_collision_api.CreatePhysxMeshCollisionApproximationAttr().Set("convexHull")
physicsArticulationAPI = PhysicsSchema.ArticulationAPI.Get(stage, kinova_prim.GetPath())
physicsArticulationAPI.GetFixBaseAttr().Set(True)
editor.play()
update_sub = kit.editor.subscribe_to_update_events(allegro.editor_update)
vid = output.VideoOutput()
for i in range(100):
kit.update()
vid.add_image()
time.sleep(0.01)
vid.save_vid("testvid.mp4")
and here are the additional functions called to load the arm, hand, and to update at each time step
def load_kinova(self):
_urdf_interface = _urdf.acquire_urdf_interface()
urdf_config = _urdf.ImportConfig()
if self._stage:
if UsdGeom.GetStageUpAxis(self._stage) == UsdGeom.Tokens.y:
urdf_config.set_up_vector(0, 1, 0)
if UsdGeom.GetStageUpAxis(self._stage) == UsdGeom.Tokens.z:
urdf_config.set_up_vector(0, 0, 1)
root_path, filename = os.path.split(os.path.abspath(KINOVA_PATH))
import_kinova = _urdf_interface.parse_urdf(root_path, filename, urdf_config)
self.urdf = _urdf_interface.import_robot(root_path, filename, import_kinova, urdf_config)
def load_hand(self):
_urdf_interface = _urdf.acquire_urdf_interface()
urdf_config = _urdf.ImportConfig()
if self._stage:
if UsdGeom.GetStageUpAxis(self._stage) == UsdGeom.Tokens.y:
urdf_config.set_up_vector(0, 1, 0)
if UsdGeom.GetStageUpAxis(self._stage) == UsdGeom.Tokens.z:
urdf_config.set_up_vector(0, 0, 1)
root_path, filename = os.path.split(os.path.abspath(ALLEGRO_PATH))
import_allegro = _urdf_interface.parse_urdf(root_path, filename, urdf_config)
self.urdf = _urdf_interface.import_robot(root_path, filename, import_allegro, urdf_config)
def editor_update(self,step):
import time
print("step", step)
if not self.ar:
self.ar = self._dc.get_articulation("/GEN3_6DOF_NO_VISION_URDF_ARM_V01/shoulder_link/joint_4")
self._dc.wake_up_articulation(self.ar)
joint_target = [np.random.rand(9)*2-1]
print(joint_target)
self._dc.set_articulation_dof_position_targets(self.ar, joint_target)
print("step done", time.time())