Skip to content

Commit

Permalink
Resolves stepjam#9. Resolves stepjam#13. Multiple arm bug fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
stepjam committed Jul 2, 2019
1 parent cdff137 commit 07033dd
Show file tree
Hide file tree
Showing 20 changed files with 47 additions and 8 deletions.
4 changes: 2 additions & 2 deletions pyrep/robots/arms/arm.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __init__(self, count: int, name: str, num_joints: int,
base_name: str = None,
max_velocity=1.0, max_acceleration=4.0, max_jerk=1000):
"""Count is used for when we have multiple copies of arms"""
joint_names = [name + '_joint' + str(i+1) for i in range(num_joints)]
joint_names = ['%s_joint%d' % (name, i+1) for i in range(num_joints)]
super().__init__(count, name, joint_names, base_name)

# Used for motion planning
Expand All @@ -30,7 +30,7 @@ def __init__(self, count: int, name: str, num_joints: int,
self.max_jerk = max_jerk

# Motion planning handles
suffix = '' if count == 0 else '#%d' % count
suffix = '' if count == 0 else '#%d' % (count - 1)
self._ik_target = Dummy('%s_target%s' % (name, suffix))
self._ik_tip = Dummy('%s_tip%s' % (name, suffix))
self._ik_group = vrep.simGetIkGroupHandle('%s_ik%s' % (name, suffix))
Expand Down
9 changes: 5 additions & 4 deletions pyrep/robots/end_effectors/gripper.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ class Gripper(RobotComponent):

def __init__(self, count: int, name: str, joint_names: List[str]):
super().__init__(count, name, joint_names)
prox_name = '%s_attachProxSensor' % name
attach_name = '%s_attachPoint' % name
prox_name = prox_name if count == 0 else prox_name + '%d' % (count - 1)
attach_name = attach_name if count == 0 else attach_name + '%d' % (count - 1)
suffix = '' if count == 0 else '#%d' % (count - 1)
prox_name = '%s_attachProxSensor%s' % (name, suffix)
attach_name = '%s_attachPoint%s' % (name, suffix)
# prox_name = prox_name if count == 0 else prox_name + '%d' % (count - 1)
# attach_name = attach_name if count == 0 else attach_name + '%d' % (count - 1)
self._proximity_sensor = ProximitySensor(prox_name)
self._attach_point = ForceSensor(attach_name)
self._old_parents = []
Expand Down
24 changes: 22 additions & 2 deletions pyrep/robots/robot_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,34 @@ class RobotComponent(Object):

def __init__(self, count: int, name: str, joint_names: List[str],
base_name: str = None):
super().__init__(name if base_name is None else base_name)
suffix = '' if count == 0 else '#%d' % (count - 1)
super().__init__(
name + suffix if base_name is None else base_name + suffix)
self._num_joints = len(joint_names)

# Joint handles
suffix = '' if count == 0 else '%d' % (count - 1)
self.joints = [Joint(jname + suffix)
for jname in joint_names]

def copy(self) -> 'RobotComponent':
"""Copy and pastes the arm in the scene.
The arm is copied together with all its associated calculation
objects and associated scripts.
:return: The new pasted arm.
"""
# Copy whole model
handle = vrep.simCopyPasteObjects([self._handle], 1)[0]
name = vrep.simGetObjectName(handle)
# Find the number of this arm
num = name[name.rfind('#') + 1:]
if len(num) > 0:
num = int(num) + 1
else:
num = 0
return self.__class__(num)

def get_type(self) -> ObjectType:
"""Gets the type of the object.
Expand Down
Binary file modified robot_ttms/arms/Baxter.ttm
Binary file not shown.
Binary file modified robot_ttms/arms/Jaco.ttm
Binary file not shown.
Binary file modified robot_ttms/arms/LBR_iiwa_14_R820.ttm
Binary file not shown.
Binary file modified robot_ttms/arms/LBR_iiwa_7_R800.ttm
Binary file not shown.
Binary file modified robot_ttms/arms/Mico.ttm
Binary file not shown.
Binary file modified robot_ttms/arms/Panda.ttm
Binary file not shown.
Binary file modified robot_ttms/arms/Sawyer.ttm
Binary file not shown.
Binary file modified robot_ttms/arms/UR10.ttm
Binary file not shown.
Binary file modified robot_ttms/arms/UR3.ttm
Binary file not shown.
Binary file modified robot_ttms/arms/UR5.ttm
Binary file not shown.
Binary file modified robot_ttms/end_effectors/BaxterGripper.ttm
Binary file not shown.
Binary file modified robot_ttms/end_effectors/JacoHand.ttm
Binary file not shown.
Binary file modified robot_ttms/end_effectors/MicoHand.ttm
Binary file not shown.
Binary file modified robot_ttms/end_effectors/PandaGripper.ttm
Binary file not shown.
Binary file modified tests/assets/test_scene_robots.ttt
Binary file not shown.
9 changes: 9 additions & 0 deletions tests/test_arms_and_configuration_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,15 @@ def test_get_linear_path_visualize(self):
# Check that it does not error
path.visualize()

def test_get_duplicate_arm(self):
arm = UR3(1)
self.assertIsInstance(arm, UR3)

def test_copy_arm(self):
arm = UR10()
new_arm = arm.copy()
self.assertNotEqual(arm, new_arm)


if __name__ == '__main__':
unittest.main()
9 changes: 9 additions & 0 deletions tests/test_grippers.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ def test_close_open_gripper(self):
self.assertAlmostEqual(
gripper.get_open_amount()[0], 0.8, delta=0.05)

def test_get_duplicate_gripper(self):
g = BaxterGripper(1)
self.assertIsInstance(g, BaxterGripper)

def test_copy_gripper(self):
g = JacoGripper()
new_g = g.copy()
self.assertNotEqual(g, new_g)


if __name__ == '__main__':
unittest.main()

0 comments on commit 07033dd

Please sign in to comment.