|
1 | 1 | #!/usr/bin/env python |
2 | 2 |
|
| 3 | +from roboticstoolbox.robot.ELink import ELink |
3 | 4 | import numpy as np |
4 | 5 | from roboticstoolbox.robot.ERobot import ERobot |
| 6 | +import spatialmath as sm |
5 | 7 |
|
6 | 8 |
|
7 | 9 | class YuMi(ERobot): |
@@ -36,17 +38,48 @@ def __init__(self): |
36 | 38 | "yumi_description/urdf/yumi.urdf" |
37 | 39 | ) |
38 | 40 |
|
| 41 | + # We wish to add an intermediate link between gripper_r_base and |
| 42 | + # @gripper_r_finger_r/l |
| 43 | + # This is because gripper_r_base contains a revolute joint which is |
| 44 | + # a part of the core kinematic chain and not the gripper. |
| 45 | + # So we wish for gripper_r_base to be part of the robot and |
| 46 | + # @gripper_r_finger_r/l to be in the gripper underneath a parent ELink |
| 47 | + |
| 48 | + gripper_r_base = links[16] |
| 49 | + gripper_l_base = links[19] |
| 50 | + |
| 51 | + # Find the finger links |
| 52 | + r_gripper_links = [link for link in links if link.parent == gripper_r_base] |
| 53 | + l_gripper_links = [link for link in links if link.parent == gripper_l_base] |
| 54 | + |
| 55 | + # New intermediate links |
| 56 | + r_gripper = ELink(name="r_gripper", parent=gripper_l_base) |
| 57 | + l_gripper = ELink(name="l_gripper", parent=gripper_r_base) |
| 58 | + links.append(r_gripper) |
| 59 | + links.append(l_gripper) |
| 60 | + |
| 61 | + # Set the finger link parent to be the new gripper base link |
| 62 | + for g_link in r_gripper_links: |
| 63 | + g_link._parent = r_gripper |
| 64 | + |
| 65 | + for g_link in l_gripper_links: |
| 66 | + g_link._parent = l_gripper |
| 67 | + |
39 | 68 | super().__init__( |
40 | 69 | links, |
41 | 70 | name=name, |
42 | 71 | manufacturer="ABB", |
43 | | - gripper_links=[links[20]], |
| 72 | + gripper_links=[r_gripper, l_gripper], |
44 | 73 | urdf_string=urdf_string, |
45 | 74 | urdf_filepath=urdf_filepath, |
46 | 75 | ) |
47 | 76 |
|
48 | | - self.addconfiguration("qz", np.zeros((14,))) |
49 | | - self.addconfiguration("qr", np.array([0, -0.3, 0, -2.2, 0, 2.0, np.pi / 4])) |
| 77 | + # Set the default tool transform for the end-effectors |
| 78 | + self.grippers[0].tool = sm.SE3.Tz(0.13) |
| 79 | + self.grippers[1].tool = sm.SE3.Tz(0.13) |
| 80 | + |
| 81 | + # self.addconfiguration("qz", np.zeros((14,))) |
| 82 | + # self.addconfiguration("qr", np.array([0, -0.3, 0, -2.2, 0, 2.0, np.pi / 4])) |
50 | 83 |
|
51 | 84 |
|
52 | 85 | if __name__ == "__main__": # pragma nocover |
|
0 commit comments