Skip to content

Commit b918c10

Browse files
Merge pull request #41 from WATonomous/ramy
Integrating IK with our model instead of placeholder model
2 parents 8521046 + 3c1096e commit b918c10

2 files changed

Lines changed: 133 additions & 67 deletions

File tree

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
"""This cfg is only used by the task_space_test.py script and
2+
the humanoid arm is only exposing the 6 DOF Arm for control"""
3+
import os
4+
5+
import isaaclab.sim as sim_utils
6+
from isaaclab.actuators import ImplicitActuatorCfg
7+
from isaaclab.assets.articulation import ArticulationCfg
8+
9+
_HUMANOID_WATO_ROOT = os.path.abspath(
10+
os.path.join(os.path.dirname(__file__), "..", "..", "..", "..")
11+
)
12+
_MODEL_ASSETS = os.path.join(_HUMANOID_WATO_ROOT, "ModelAssets")
13+
14+
# Hand Arm
15+
_ARM_USD_PATH = os.path.join(_MODEL_ASSETS, "arm.usd")
16+
ARM_CFG = ArticulationCfg(
17+
spawn=sim_utils.UsdFileCfg(
18+
usd_path=_ARM_USD_PATH,
19+
rigid_props=sim_utils.RigidBodyPropertiesCfg(
20+
disable_gravity=False,
21+
max_depenetration_velocity=5.0,
22+
),
23+
activate_contact_sensors=False,
24+
articulation_props=sim_utils.ArticulationRootPropertiesCfg(
25+
enabled_self_collisions=True
26+
),
27+
),
28+
init_state=ArticulationCfg.InitialStateCfg(
29+
joint_pos={
30+
"shoulder_flexion_extension": 0.0,
31+
"shoulder_abduction_adduction": 0.0,
32+
"shoulder_rotation": 0.0,
33+
"elbow_flexion_extension": 0.0,
34+
"forearm_rotation": 0.0,
35+
"wrist_extension": 0.0,
36+
"mcp_index": 0.0,
37+
"pip_index": 0.0,
38+
"dip_index": 0.0,
39+
"mcp_middle": 0.0,
40+
"pip_middle": 0.0,
41+
"dip_middle": 0.0,
42+
"mcp_ring": 0.0,
43+
"pip_ring": 0.0,
44+
"dip_ring": 0.0,
45+
"mcp_pinky": 0.0,
46+
"pip_pinky": 0.0,
47+
"dip_pinky": 0.0,
48+
"cmc_thumb": 0.0,
49+
"mcp_thumb": 0.79, # within limits [0.785, 2.531]
50+
"ip_thumb": 0.0,
51+
}
52+
),
53+
actuators={
54+
# J≈1.20 kg·m², f=4.0 Hz, ζ=1.0 → k=757.6, d=60.3
55+
"shoulder_fe": ImplicitActuatorCfg(
56+
joint_names_expr=["shoulder_flexion_extension"],
57+
stiffness=757.6,
58+
damping=60.3,
59+
velocity_limit_sim=3.0,
60+
),
61+
# J≈0.95 kg·m², f=4.0 Hz, ζ=1.0 → k=600.0, d=47.7
62+
"shoulder_aa": ImplicitActuatorCfg(
63+
joint_names_expr=["shoulder_abduction_adduction"],
64+
stiffness=600.0,
65+
damping=47.7,
66+
velocity_limit_sim=3.0,
67+
),
68+
# J≈0.77 kg·m², f=4.5 Hz, ζ=1.0 → k=615.5, d=43.5
69+
"shoulder_rot": ImplicitActuatorCfg(
70+
joint_names_expr=["shoulder_rotation"],
71+
stiffness=615.5,
72+
damping=43.5,
73+
velocity_limit_sim=3.0,
74+
),
75+
# J≈0.77 kg·m², f=4.5 Hz, ζ=1.0 → k=615.5, d=43.5
76+
"elbow": ImplicitActuatorCfg(
77+
joint_names_expr=["elbow_flexion_extension"],
78+
stiffness=615.5,
79+
damping=43.5,
80+
velocity_limit_sim=3.0,
81+
),
82+
# J≈0.45 kg·m², f=5.0 Hz, ζ=1.0 → k=444.1, d=28.3
83+
"forearm": ImplicitActuatorCfg(
84+
joint_names_expr=["forearm_rotation"],
85+
stiffness=444.1,
86+
damping=28.3,
87+
velocity_limit_sim=3.0,
88+
),
89+
# J≈0.12 kg·m², f=6.0 Hz, ζ=1.0 → k=170.5, d=9.0
90+
"wrist": ImplicitActuatorCfg(
91+
joint_names_expr=["wrist_extension"],
92+
stiffness=170.5,
93+
damping=9.0,
94+
velocity_limit_sim=3.0,
95+
),
96+
97+
},
98+
)

autonomy/simulation/Wato_additional_scripts/robot_arm_controllers/task_space_test.py

Lines changed: 35 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
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
217
from isaaclab.utils.math import subtract_frame_transforms
318
from isaaclab.utils.assets import ISAAC_NUCLEUS_DIR
419
from isaaclab.utils import configclass
@@ -9,23 +24,10 @@
924
from isaaclab.controllers import DifferentialIKController, DifferentialIKControllerCfg
1025
from isaaclab.assets import AssetBaseCfg
1126
import 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

8875
def 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

Comments
 (0)