1- from isaaclab_assets import UR10_CFG , FRANKA_PANDA_HIGH_PD_CFG
1+ import torch
2+ import argparse
3+ import sys
4+ import os
5+
6+ from isaaclab .app import AppLauncher
7+
8+ parser = argparse .ArgumentParser (description = "Robot Arm with Task Space IK Control" )
9+ parser .add_argument ("--robot" , type = str , default = "ur10" , help = "Name of the robot." )
10+ AppLauncher .add_app_launcher_args (parser )
11+ args_cli = parser .parse_args ()
12+
13+ app_launcher = AppLauncher (args_cli )
14+ simulation_app = app_launcher .app
15+
16+ # ALL imports go AFTER this line
217from isaaclab .utils .math import subtract_frame_transforms
318from isaaclab .utils .assets import ISAAC_NUCLEUS_DIR
419from isaaclab .utils import configclass
924from isaaclab .controllers import DifferentialIKController , DifferentialIKControllerCfg
1025from isaaclab .assets import AssetBaseCfg
1126import isaaclab .sim as sim_utils
12- import torch
13- import argparse
14- from isaaclab .app import AppLauncher
15-
16- parser = argparse .ArgumentParser (
17- description = "Robot Arm with Task Space IK Control" )
18- parser .add_argument (
19- "--robot" ,
20- type = str ,
21- default = "franka_panda" ,
22- help = "Name of the robot." )
23- AppLauncher .add_app_launcher_args (parser )
24- args_cli = parser .parse_args ()
25-
26- app_launcher = AppLauncher (args_cli )
27- simulation_app = app_launcher .app
2827
28+ sys .path .append (os .path .abspath (os .path .join (os .path .dirname (__file__ ),
29+ "../../Humanoid_Wato/HumanoidRL/HumanoidRLPackage/HumanoidRLSetup/modelCfg" )))
30+ from humanoid_arm_only import ARM_CFG
2931
3032##
3133# Pre-defined configs
@@ -53,37 +55,22 @@ class TableTopSceneCfg(InteractiveSceneCfg):
5355 0.75 ,
5456 0.75 )))
5557
56- # mount
57- table = AssetBaseCfg (
58- prim_path = "{ENV_REGEX_NS}/Table" ,
59- spawn = sim_utils .UsdFileCfg (
60- usd_path = f"{ ISAAC_NUCLEUS_DIR } /Props/Mounts/Stand/stand_instanceable.usd" ,
61- scale = (
62- 2.0 ,
63- 2.0 ,
64- 2.0 )),
65- )
66-
6758 # Cube
6859 cube = AssetBaseCfg (
6960 prim_path = "/World/cube" ,
7061 spawn = sim_utils .CuboidCfg (
7162 size = [0.1 , 0.1 , 0.1 ]
7263 ),
73- init_state = AssetBaseCfg .InitialStateCfg (pos = (0.5 , 0.0 , 0.5 )),
64+ init_state = AssetBaseCfg .InitialStateCfg (pos = (- 0.3 , 0.0 , 0.3 )),
65+ # Making this the initial state is important because at certain initial states,
66+ # mainly on the positive x-axis, the IK breaks and the simulation bugs out a lot
7467 )
7568
7669 # articulation
77- if args_cli .robot == "franka_panda" :
78- robot = FRANKA_PANDA_HIGH_PD_CFG .replace (
79- prim_path = "{ENV_REGEX_NS}/Robot" )
80- elif args_cli .robot == "ur10" :
81- robot = UR10_CFG .replace (prim_path = "{ENV_REGEX_NS}/Robot" )
82- else :
83- raise ValueError (
84- f"Robot { args_cli .robot } is not supported. Valid: franka_panda, ur10" )
85- # robot = UR10_CFG.replace(prim_path="{ENV_REGEX_NS}/Robot")
86-
70+ robot = ARM_CFG .replace (
71+ prim_path = "{ENV_REGEX_NS}/Robot" ,
72+
73+ )
8774
8875def run_simulator (sim : sim_utils .SimulationContext , scene : InteractiveScene ):
8976
@@ -106,18 +93,12 @@ def run_simulator(sim: sim_utils.SimulationContext, scene: InteractiveScene):
10693 prim_path = "/Visuals/ee_goal" ))
10794
10895 # Specify robot-specific parameters
109- if args_cli .robot == "franka_panda" :
110- robot_entity_cfg = SceneEntityCfg (
111- "robot" ,
112- joint_names = ["panda_joint.*" ],
113- body_names = ["panda_hand" ])
114- elif args_cli .robot == "ur10" :
115- robot_entity_cfg = SceneEntityCfg (
116- "robot" , joint_names = [".*" ], body_names = ["ee_link" ])
117- else :
118- raise ValueError (
119- f"Robot { args_cli .robot } is not supported. Valid: franka_panda, ur10" )
120- # robot_entity_cfg = SceneEntityCfg("robot", joint_names=[".*"], body_names=["ee_link"])
96+ robot_entity_cfg = SceneEntityCfg (
97+ "robot" ,
98+ joint_names = ["shoulder_flexion_extension" , "shoulder_abduction_adduction" ,
99+ "shoulder_rotation" , "elbow_flexion_extension" ,
100+ "forearm_rotation" , "wrist_extension" ],
101+ body_names = ["PALM_GAVIN_1DoF_Hinge_v2_1" ])
121102
122103 # Resolving the scene entities
123104 robot_entity_cfg .resolve (scene )
@@ -134,22 +115,9 @@ def run_simulator(sim: sim_utils.SimulationContext, scene: InteractiveScene):
134115 sim_dt = sim .get_physics_dt ()
135116
136117 # May have to set initial position first
137- if args_cli .robot == "franka_panda" :
138- joint_position = robot .data .default_joint_pos .clone ()
139- joint_vel = robot .data .default_joint_vel .clone ()
140- robot .write_joint_state_to_sim (joint_position , joint_vel )
141- else :
142- joint_position_index = 0
143- joint_position_list = [
144- [0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 ],
145- ]
146- joint_position = torch .tensor (
147- joint_position_list [joint_position_index ],
148- device = sim .device )
149- joint_vel = robot .data .default_joint_vel .clone ()
150- joint_pos_des = joint_position .unsqueeze (
151- 0 )[:, robot_entity_cfg .joint_ids ].clone ()
152- robot .write_joint_state_to_sim (joint_pos_des , joint_vel )
118+ joint_position = robot .data .default_joint_pos .clone ()
119+ joint_vel = robot .data .default_joint_vel .clone ()
120+ robot .write_joint_state_to_sim (joint_position , joint_vel )
153121
154122 while simulation_app .is_running ():
155123 # Get cube/target_point coordinates
0 commit comments