19 from sr_robot_commander
import SrRobotCommander, SrRobotCommanderException
20 from sr_robot_msgs.srv
import ForceController
21 from sr_hand.tactile_receiver
import TactileReceiver
22 from sr_utilities.hand_finder
import HandFinder
28 Commander class for hand 33 def __init__(self, name=None, prefix=None, hand_parameters=None, hand_serial=None, hand_number=0):
35 Initialize the hand commander, using either a name + prefix, or the parameters returned by the hand finder. 36 @param name - name of the MoveIt group 37 @param prefix - prefix used for the tactiles and max_force 38 @param hand_parameters - from hand_finder.get_hand_parameters(). Will overwrite the name and prefix 39 @param hand_serial - which hand are you using 40 @param hand_number - which hand in a multi-hand system to use (starting at 0 and sorted by name/serial). 44 if name
is None and prefix
is None and hand_parameters
is None and hand_serial
is None:
45 hand_finder = HandFinder()
46 if hand_finder.hand_e_available():
47 name, prefix, hand_serial = hand_finder.get_hand_e(number=hand_number)
48 elif hand_finder.hand_h_available():
50 name, prefix, hand_serial = hand_finder.get_hand_h(number=hand_number)
52 rospy.logfatal(
"No hands found and no information given to define hand commander.")
53 raise SrRobotCommanderException(
"No hand found.")
55 elif hand_parameters
is not None:
57 if len(hand_parameters.mapping)
is 0:
58 rospy.logfatal(
"No hand detected")
59 raise SrRobotCommanderException(
"No hand found.")
61 hand_mapping = hand_parameters.mapping[hand_serial]
62 prefix = hand_parameters.joint_prefix[hand_serial]
65 if hand_mapping ==
'rh':
75 super(SrHandCommander, self).
__init__(name)
85 if self.
_topic_prefix and not self._topic_prefix.endswith(
"/"):
96 @return - dictionary with joints efforts 98 return self._get_joints_effort()
102 Set maximum force for hand 103 @param value - maximum force value 107 if not self.__set_force_srv.get(joint_name):
109 "change_force_PID_"+joint_name.upper()
111 rospy.ServiceProxy(service_name,
115 motor_settings =
None 118 joint_name.lower() +
"/pid")
120 rospy.logerr(
"Couldn't get the motor parameters for joint " +
121 joint_name +
" -> " + str(e))
123 motor_settings[
"torque_limit"] = value
128 motor_settings[
"sg_left"],
129 motor_settings[
"sg_right"],
134 motor_settings[
"imax"],
135 motor_settings[
"deadband"],
136 motor_settings[
"sign"],
137 motor_settings[
"torque_limit"],
138 motor_settings[
"torque_limiter_gain"])
139 except rospy.ServiceException, e:
140 rospy.logerr(
"Couldn't set the max force for joint " +
141 joint_name +
": " + str(e))
145 Returns a string indicating the type of tactile sensors present. 146 Possible values are: PST, biotac, UBI0. 148 return self._tactiles.get_tactile_type()
152 Returns an object containing tactile data. The structure of the 153 data is different for every tactile_type. 155 return self._tactiles.get_tactile_state()
159 Strips the prefix from the joint name (e.g. rh_ffj3 -> ffj3) if present, returns the joint name otherwise. 161 We know that all joint names for the shadow hands are 4 char long. So we only keep the last 4 chars. 163 @param joint_name the joint name 164 @return stripped joint name 166 return joint_name[-4:]
169 self._move_group_commander.attach_object(object_name)
172 self._move_group_commander.detach_object(object_name)
def __init__(self, name=None, prefix=None, hand_parameters=None, hand_serial=None, hand_number=0)
def get_hand_serial(self)
def _strip_prefix(self, joint_name)
def attach_object(self, object_name)
def get_joints_effort(self)
def detach_object(self, object_name)
def get_tactile_type(self)
def set_max_force(self, joint_name, value)
dictionary __set_force_srv
def get_tactile_state(self)