22 DEFAULT_TIMEOUT = 60.0
30 ros_pack = rospkg.RosPack()
31 ethercat_path = ros_pack.get_path(
'sr_ethercat_hand_config')
37 ethercat_path +
'/controls/' +
'friction_compensation.yaml' 38 host_path = ethercat_path +
'/controls/host/' + mapping[hand] +
'/' 40 [host_path +
'sr_edc_calibration_controllers.yaml',
41 host_path +
'sr_edc_joint_velocity_controllers_PWM.yaml',
42 host_path +
'sr_edc_effort_controllers_PWM.yaml',
43 host_path +
'sr_edc_joint_velocity_controllers.yaml',
44 host_path +
'sr_edc_effort_controllers.yaml',
45 host_path +
'sr_edc_mixed_position_velocity_' 46 'joint_controllers_PWM.yaml',
47 host_path +
'sr_edc_joint_position_controllers_PWM.yaml',
48 host_path +
'sr_edc_mixed_position_velocity_' 49 'joint_controllers.yaml',
50 host_path +
'sr_edc_joint_position_controllers.yaml']
53 ethercat_path +
'/controls/motors/' +\
54 mapping[hand] +
'/motor_board_effort_controllers.yaml' 62 ros_pack = rospkg.RosPack()
63 ethercat_path = ros_pack.get_path(
'sr_ethercat_hand_config')
67 ethercat_path +
'/calibrations/' + mapping[hand] +
'/' \
79 for serial_id
in mapping:
80 if mapping[serial_id] ==
'':
81 self.
mapping[serial_id] = str(serial_id)
83 self.
mapping[serial_id] = mapping[serial_id]
91 joints = [
'FFJ1',
'FFJ2',
'FFJ3',
'FFJ4',
'MFJ1',
'MFJ2',
'MFJ3',
92 'MFJ4',
'RFJ1',
'RFJ2',
'RFJ3',
'RFJ4',
'LFJ1',
'LFJ2',
93 'LFJ3',
'LFJ4',
'LFJ5',
'THJ1',
'THJ2',
'THJ3',
'THJ4',
94 'THJ5',
'WRJ1',
'WRJ2']
97 def __init__(self, mapping, joint_prefix, timeout=DEFAULT_TIMEOUT):
104 TIMEOUT_WAIT_FOR_PARAMS_IN_SECS = timeout
105 start_time = rospy.get_time()
106 while not rospy.has_param(
"robot_description"):
107 if (rospy.get_time() - start_time > TIMEOUT_WAIT_FOR_PARAMS_IN_SECS):
108 rospy.logwarn(
"No robot_description found on parameter server." 109 "Joint names are loaded for 5 finger hand")
113 if hand
in joint_prefix:
115 hand_joints.append(joint_prefix[hand] + joint)
117 rospy.logwarn(
"Cannot find serial " + hand +
118 "in joint_prefix parameters")
119 self.
joints[mapping[hand]] = hand_joints
124 robot_description = rospy.get_param(
'robot_description')
128 if hand
in joint_prefix:
130 hand_joints.append(joint_prefix[hand] + joint)
132 rospy.logwarn(
"Cannot find serial " + hand +
133 "in joint_prefix parameters")
136 hand_urdf = URDF.from_xml_string(robot_description)
139 self.
joints[mapping[hand]] = []
140 for joint
in hand_urdf.joints:
141 if joint.type !=
'fixed':
142 prefix = joint.name[:3]
144 if "" in joint_prefix.values():
145 joints_tmp.append(joint.name)
146 elif prefix
not in joint_prefix.values():
147 rospy.logdebug(
"joint " + joint.name +
" has invalid " 149 elif prefix == joint_prefix[hand]:
150 joints_tmp.append(joint.name)
151 for joint_unordered
in hand_joints:
152 if joint_unordered
in joints_tmp:
153 self.
joints[mapping[hand]].append(joint_unordered)
158 The HandFinder is a utility library for detecting Shadow Hands running on 159 the system. The idea is to make it easier to write generic code, 160 using this library to handle prefixes, joint prefixes etc... 165 Parses the parameter server to extract the necessary information. 172 TIMEOUT_WAIT_FOR_PARAMS_IN_SECS = timeout
182 start_time = rospy.get_time()
183 while not rospy.has_param(
"/hand")
and not rospy.has_param(
"/fh_hand"):
184 if (rospy.get_time() - start_time > timeout_in_secs):
185 rospy.logerr(
"No hand is detected")
189 if rospy.has_param(
"/hand"):
190 rospy.loginfo(
"Found hand E")
193 elif rospy.has_param(
"/fh_hand"):
194 rospy.loginfo(
"Found hand H")
200 rospy.logerr(
"No Hand E present - can't get calibration path")
206 rospy.logerr(
"No Hand E present - can't get hand joints")
211 rospy.logerr(
"No Hand E present - can't get hand parameters")
216 rospy.logerr(
"No Hand E present - can't get hand control_tuning")
228 serial = sorted(hand_parameters.mapping.keys())[number]
229 name =
"right_hand" if hand_parameters.mapping[serial] ==
"rh" else "left_hand" 230 prefix = hand_parameters.joint_prefix[serial]
231 return name, prefix, serial
238 return "hand_h", prefix, serial
245 serial = sorted(hand_parameters.mapping.keys())[number]
246 return hand_parameters.joint_prefix[serial]
def get_hand_e(self, number=0, serial=None)
def wait_for_hand_params(self, timeout_in_secs)
def __init__(self, mapping, joint_prefix, timeout=DEFAULT_TIMEOUT)
def hand_h_available(self)
def get_hand_control_tuning(self)
def get_hand_joints(self)
def get_hand_h(self, number=0, name=None)
def __init__(self, mapping, joint_prefix)
def get_available_prefix(self, number=0, serial=None, name=None)
def __init__(self, timeout=DEFAULT_TIMEOUT)
def __init__(self, mapping)
def hand_e_available(self)
def __init__(self, mapping)
def get_default_joints(cls)
def get_hand_parameters(self)
def get_calibration_path(self)