17 from __future__
import absolute_import
20 from moveit_msgs.msg
import PlanningScene
21 from sr_robot_commander.sr_arm_commander
import SrArmCommander
22 from sr_robot_commander.sr_hand_commander
import SrHandCommander
23 from sr_robot_commander.sr_robot_commander
import SrRobotCommander
24 from geometry_msgs.msg
import PoseStamped, Pose
25 from rospy
import get_rostime
26 from actionlib_msgs.msg
import GoalStatusArray
27 from unittest
import TestCase
32 Tests the Hand and Arm in Sim 37 rospy.wait_for_message(
'/move_group/status', GoalStatusArray)
38 cls.
scene = rospy.get_param(
'~test_hand_and_arm_sim/scene')
43 rospy.Subscriber(
'/move_group/monitored_planning_scene', PlanningScene, cls.
scene_data_cb)
57 expected_and_final_joint_value_diff = 0
58 for expected_value, recieved_value
in zip(sorted(expected_joint_values), sorted(recieved_joint_values)):
59 expected_and_final_joint_value_diff += abs(expected_joint_values[expected_value] -
60 recieved_joint_values[recieved_value])
61 return expected_and_final_joint_value_diff
65 while counter < timeout:
67 if len(current_value) != 0:
75 'la_shoulder_lift_joint': -1.89,
'la_wrist_1_joint': -2.1,
76 'la_wrist_2_joint': -1.5708,
'la_wrist_3_joint': 2,
77 'ra_shoulder_pan_joint': 0.00,
'ra_elbow_joint': 2.0,
78 'ra_shoulder_lift_joint': -1.25,
'ra_wrist_1_joint': -1,
79 'ra_wrist_2_joint': 1.5708,
'ra_wrist_3_joint': -2}
82 self.assertAlmostEqual(expected_and_actual_home_angles, 0, delta=0.2)
86 self.
scene = rospy.get_param(
'~test_hand_and_arm_sim/scene')
88 if self.
scene is True:
90 elif self.
scene is False:
94 arm_joints_target = {
'la_shoulder_pan_joint': 0.00,
'la_elbow_joint': -1.43,
95 'la_shoulder_lift_joint': -1.82,
'la_wrist_1_joint': 3.24,
96 'la_wrist_2_joint': -1.57,
'la_wrist_3_joint': 3.13,
97 'ra_shoulder_pan_joint': 0.00,
'ra_elbow_joint': 1.43,
98 'ra_shoulder_lift_joint': -1.27,
'ra_wrist_1_joint': -0.1,
99 'ra_wrist_2_joint': 1.57,
'ra_wrist_3_joint': 3.13}
101 self.
arm_commander.move_to_joint_value_target(arm_joints_target, wait=
True)
103 final_arm_joint_values = self.
arm_commander.get_current_state()
105 expected_and_final_joint_value_diff_arm = self.
joints_error_check(arm_joints_target, final_arm_joint_values)
107 self.assertAlmostEqual(expected_and_final_joint_value_diff_arm, 0, delta=0.2)
110 hand_joints_target = {
'THJ1': 0.52,
'THJ2': 0.61,
'THJ3': 0.0,
'THJ4': 1.20,
'THJ5': 0.17,
111 'FFJ1': 1.5707,
'FFJ2': 1.5707,
'FFJ3': 1.5707,
'FFJ4': 0.0,
112 'MFJ1': 1.5707,
'MFJ2': 1.5707,
'MFJ3': 1.5707,
'MFJ4': 0.0,
113 'RFJ1': 1.5707,
'RFJ2': 1.5707,
'RFJ3': 1.5707,
'RFJ4': 0.0,
114 'LFJ1': 0.0,
'LFJ2': 0.0,
'LFJ3': 0.0,
'LFJ4': 0.0,
115 'LFJ5': 0.0,
'WRJ1': 0.0,
'WRJ2': 0.0}
117 hand_joints_target_no_id = hand_joints_target
119 hand_joints_target_left = {}
120 for key, value
in hand_joints_target_no_id.items():
121 hand_joints_target_left[
'lh' +
'_' + key] = value
123 hand_joints_target_right = {}
124 for key, value
in hand_joints_target_no_id.items():
125 hand_joints_target_right[
'rh' +
'_' + key] = value
127 hands_joints_target = {**hand_joints_target, **arm_joints_target}
129 self.
hand_commander.move_to_joint_value_target(hands_joints_target, wait=
True)
133 expected_and_final_joint_value_diff_hand = self.
joints_error_check(hands_joints_target, final_hand_joint_values)
135 self.assertAlmostEqual(expected_and_final_joint_value_diff_hand, 0, delta=0.5)
138 hand_joints_target = {
'THJ1': 0.52,
'THJ2': 0.61,
'THJ3': 0.0,
'THJ4': 1.20,
'THJ5': 0.17,
139 'FFJ1': 1.5707,
'FFJ2': 1.5707,
'FFJ3': 1.5707,
'FFJ4': 0.0,
140 'MFJ1': 1.5707,
'MFJ2': 1.5707,
'MFJ3': 1.5707,
'MFJ4': 0.0,
141 'RFJ1': 0.0,
'RFJ2': 0.0,
'RFJ3': 0.0,
'RFJ4': 0.0,
142 'LFJ1': 0.0,
'LFJ2': 0.0,
'LFJ3': 0.0,
'LFJ4': 0.0,
143 'LFJ5': 0.0,
'WRJ1': 0.0,
'WRJ2': 0.0}
145 arm_joints_target_right = {
'ra_shoulder_pan_joint': 0.00,
'ra_elbow_joint': 2.0,
146 'ra_shoulder_lift_joint': -1.25,
'ra_wrist_1_joint': -0.733,
147 'ra_wrist_2_joint': 1.578,
'ra_wrist_3_joint': -3.1416}
149 arm_joints_target_left = {
'la_shoulder_pan_joint': 0.0,
'la_elbow_joint': -2.0,
150 'la_shoulder_lift_joint': -1.89,
'la_wrist_1_joint': 3.8,
151 'la_wrist_2_joint': -1.5708,
'la_wrist_3_joint': 3.1416}
153 hand_joints_target_no_id = hand_joints_target
155 hand_joints_target_left = {}
156 for key, value
in hand_joints_target_no_id.items():
157 hand_joints_target_left[
'lh' +
'_' + key] = value
159 hand_joints_target_right = {}
160 for key, value
in hand_joints_target_no_id.items():
161 hand_joints_target_right[
'rh' +
'_' + key] = value
163 hands_and_arms_joints_target = {**hand_joints_target_right, **arm_joints_target_right,
164 **hand_joints_target_left, **arm_joints_target_left}
166 self.
robot_commander.move_to_joint_value_target_unsafe(hands_and_arms_joints_target, 10.0,
True)
170 final_hand_and_arm_joint_values = self.
robot_commander.get_current_state()
172 final_hand_and_arm_joint_values)
174 self.assertAlmostEqual(joint_value_diff_arm_and_hand, 0, delta=0.4)
177 if __name__ ==
"__main__":
178 PKGNAME =
'sr_robot_launch' 179 NODENAME =
'test_bimanual_hand_and_arm' 181 rospy.init_node(NODENAME, anonymous=
True)
182 rostest.rosrun(PKGNAME, NODENAME, TestBiHandAndArmSim)
def scene_data_cb(cls, result)
def wait_for_topic_with_scene(self, timeout=50)
def joints_error_check(self, expected_joint_values, recieved_joint_values)
def test_5_arms_and_hands(self)
def test_1_home_position(self)