@@ -24,16 +24,27 @@ def make_transparent(link):
24
24
for link in visual_data :
25
25
make_transparent (link )
26
26
27
-
28
- def test_jacobian_follower ():
27
+ def create_test_chain (robot = "kuka_iiwa" , device = "cpu" ):
28
+ if robot == "kuka_iiwa" :
29
+ urdf = "kuka_iiwa/model.urdf"
30
+ search_path = pybullet_data .getDataPath ()
31
+ full_urdf = os .path .join (search_path , urdf )
32
+ chain = pk .build_serial_chain_from_urdf (open (full_urdf ).read (), "lbr_iiwa_link_7" )
33
+ chain = chain .to (device = device )
34
+ elif robot == "widowx" :
35
+ urdf = "widowx/wx250s.urdf"
36
+ full_urdf = urdf
37
+ chain = pk .build_serial_chain_from_urdf (open (full_urdf , "rb" ).read (), "ee_gripper_link" )
38
+ chain = chain .to (device = device )
39
+ else :
40
+ raise NotImplementedError (f"Robot { robot } not implemented" )
41
+ return chain , urdf
42
+
43
+ def test_jacobian_follower (robot = "kuka_iiwa" ):
29
44
pytorch_seed .seed (2 )
30
45
device = "cuda" if torch .cuda .is_available () else "cpu"
31
- # device = "cpu"
32
- urdf = "kuka_iiwa/model.urdf"
33
46
search_path = pybullet_data .getDataPath ()
34
- full_urdf = os .path .join (search_path , urdf )
35
- chain = pk .build_serial_chain_from_urdf (open (full_urdf ).read (), "lbr_iiwa_link_7" )
36
- chain = chain .to (device = device )
47
+ chain , urdf = create_test_chain (robot = robot , device = device )
37
48
38
49
# robot frame
39
50
pos = torch .tensor ([0.0 , 0.0 , 0.0 ], device = device )
@@ -45,7 +56,7 @@ def test_jacobian_follower():
45
56
# generate random goal joint angles (so these are all achievable)
46
57
# use the joint limits to generate random joint angles
47
58
lim = torch .tensor (chain .get_joint_limits (), device = device )
48
- goal_q = torch .rand (M , 7 , device = device ) * (lim [1 ] - lim [0 ]) + lim [0 ]
59
+ goal_q = torch .rand (M , lim . shape [ 1 ] , device = device ) * (lim [1 ] - lim [0 ]) + lim [0 ]
49
60
50
61
# get ee pose (in robot frame)
51
62
goal_in_rob_frame_tf = chain .forward_kinematics (goal_q )
@@ -209,5 +220,6 @@ def test_ik_in_place_no_err():
209
220
210
221
211
222
if __name__ == "__main__" :
212
- test_jacobian_follower ()
223
+ # test_jacobian_follower(robot="kuka_iiwa")
224
+ test_jacobian_follower (robot = "widowx" )
213
225
test_ik_in_place_no_err ()
0 commit comments