28 ros_pack = rospkg.RosPack()
29 ethercat_path = ros_pack.get_path(
'sr_ethercat_hand_config')
35 ethercat_path +
'/controls/' +
'friction_compensation.yaml' 36 host_path = ethercat_path +
'/controls/host/' + mapping[hand] +
'/' 38 [host_path +
'sr_edc_calibration_controllers.yaml',
39 host_path +
'sr_edc_joint_velocity_controllers_PWM.yaml',
40 host_path +
'sr_edc_effort_controllers_PWM.yaml',
41 host_path +
'sr_edc_joint_velocity_controllers.yaml',
42 host_path +
'sr_edc_effort_controllers.yaml',
43 host_path +
'sr_edc_mixed_position_velocity_' 44 'joint_controllers_PWM.yaml',
45 host_path +
'sr_edc_joint_position_controllers_PWM.yaml',
46 host_path +
'sr_edc_mixed_position_velocity_' 47 'joint_controllers.yaml',
48 host_path +
'sr_edc_joint_position_controllers.yaml']
51 ethercat_path +
'/controls/motors/' +\
52 mapping[hand] +
'/motor_board_effort_controllers.yaml' 60 ros_pack = rospkg.RosPack()
61 ethercat_path = ros_pack.get_path(
'sr_ethercat_hand_config')
65 ethercat_path +
'/calibrations/' + mapping[hand] +
'/' \
77 for serial_id
in mapping:
78 if mapping[serial_id] ==
'':
79 self.
mapping[serial_id] = str(serial_id)
81 self.
mapping[serial_id] = mapping[serial_id]
89 joints = [
'FFJ1',
'FFJ2',
'FFJ3',
'FFJ4',
'MFJ1',
'MFJ2',
'MFJ3',
90 'MFJ4',
'RFJ1',
'RFJ2',
'RFJ3',
'RFJ4',
'LFJ1',
'LFJ2',
91 'LFJ3',
'LFJ4',
'LFJ5',
'THJ1',
'THJ2',
'THJ3',
'THJ4',
92 'THJ5',
'WRJ1',
'WRJ2']
103 if rospy.has_param(
'robot_description'):
104 robot_description = rospy.get_param(
'robot_description')
108 if hand
in joint_prefix:
110 hand_joints.append(joint_prefix[hand] + joint)
112 rospy.logwarn(
"Cannot find serial " + hand +
113 "in joint_prefix parameters")
116 hand_urdf = URDF.from_xml_string(robot_description)
119 self.
joints[mapping[hand]] = []
120 for joint
in hand_urdf.joints:
121 if joint.type !=
'fixed':
122 prefix = joint.name[:3]
124 if "" in joint_prefix.values():
125 joints_tmp.append(joint.name)
126 elif prefix
not in joint_prefix.values():
127 rospy.logdebug(
"joint " + joint.name +
" has invalid " 129 elif prefix == joint_prefix[hand]:
130 joints_tmp.append(joint.name)
131 for joint_unordered
in hand_joints:
132 if joint_unordered
in joints_tmp:
133 self.
joints[mapping[hand]].append(joint_unordered)
136 rospy.logwarn(
"No robot_description found on parameter server." 137 "Joint names are loaded for 5 finger hand")
142 if hand
in joint_prefix:
144 hand_joints.append(joint_prefix[hand] + joint)
146 rospy.logwarn(
"Cannot find serial " + hand +
147 "in joint_prefix parameters")
148 self.
joints[mapping[hand]] = hand_joints
153 The HandFinder is a utility library for detecting Shadow Hands running on 154 the system. The idea is to make it easier to write generic code, 155 using this library to handle prefixes, joint prefixes etc... 160 Parses the parameter server to extract the necessary information. 164 if rospy.has_param(
"/hand"):
166 hand_parameters = rospy.get_param(
"/hand")
169 hand_parameters = {
'joint_prefix': {},
'mapping': {}}
171 if rospy.has_param(
"/fh_hand"):
179 rospy.logerr(
"No hand is detected")
182 hand_parameters[
"joint_prefix"])
189 rospy.logerr(
"No Hand E present - can't get calibration path")
195 rospy.logerr(
"No Hand E present - can't get hand joints")
200 rospy.logerr(
"No Hand E present - can't get hand parameters")
205 rospy.logerr(
"No Hand E present - can't get hand control_tuning")
217 serial = sorted(hand_parameters.mapping.keys())[number]
218 name =
"right_hand" if hand_parameters.mapping[serial] ==
"rh" else "left_hand" 219 prefix = hand_parameters.joint_prefix[serial]
220 return name, prefix, serial
224 name = sorted(self._hand_h_parameters.keys())[number]
227 return "hand_h", prefix, serial
234 serial = sorted(hand_parameters.mapping.keys())[number]
235 return hand_parameters.joint_prefix[serial]
238 name = sorted(self._hand_h_parameters.keys())[number]
def get_hand_e(self, number=0, serial=None)
def __init__(self, mapping, joint_prefix)
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, 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)