26 import rosgraph.masterapi
27 from sr_robot_msgs.msg
import sendupdate, joint, joints_data
33 def __init__(self, name="", motor="", min=0, max=90):
43 Interface to the Cyberglove publisher. 46 def __init__(self, max_values=2, nb_sensors=22):
49 "G_ThumbMPJ":
Joint(),
52 "G_IndexMPJ":
Joint(),
53 "G_IndexPIJ":
Joint(),
54 "G_IndexDIJ":
Joint(),
55 "G_MiddleMPJ":
Joint(),
56 "G_MiddlePIJ":
Joint(),
57 "G_MiddleDIJ":
Joint(),
58 "G_MiddleIndexAb":
Joint(),
62 "G_RingMiddleAb":
Joint(),
63 "G_PinkieMPJ":
Joint(),
64 "G_PinkiePIJ":
Joint(),
65 "G_PinkieDIJ":
Joint(),
66 "G_PinkieRingAb":
Joint(),
67 "G_PalmArch":
Joint(),
68 "G_WristPitch":
Joint(),
69 "G_WristYaw":
Joint()}
72 "G_ThumbMPJ":
Joint(),
75 "G_IndexMPJ":
Joint(),
76 "G_IndexPIJ":
Joint(),
78 "G_MiddleMPJ":
Joint(),
79 "G_MiddlePIJ":
Joint(),
81 "G_MiddleIndexAb":
Joint(),
85 "G_RingMiddleAb":
Joint(),
86 "G_PinkieMPJ":
Joint(),
87 "G_PinkiePIJ":
Joint(),
89 "G_PinkieRingAb":
Joint(),
90 "G_PalmArch":
Joint(),
91 "G_WristPitch":
Joint(),
92 "G_WristYaw":
Joint()}
101 self.
raw = rospy.Subscriber(
102 'rh_cyberglove/raw/joint_states', JointState, self.
callback_raw)
105 threading.Thread(
None, rospy.spin)
110 raise Exception(
"No glove found")
114 Adds the last values received to the list of raw values 115 @param data: the message which called the callback 121 Adds the last values received to the list of calibrated values 122 @param data: the message which called the callback 128 Fills a vector with the received values, and replaces the old values 129 when the vector is full 130 @param vector : the vector to fill (raw or calibrated) 131 @param value : the value to add 141 Maps the name of the joints to their index in the message 149 return the raw value of a given joint 151 @param joint_name: the name of the glove of the Cyberglove 154 joint_index = self.
map[joint_name]
156 raw_value = raw_value + \
165 return the current positions for the given joint_name 167 @param joint_name: the name of the joint 168 @return: the corresponding position 173 joint_index = self.
map[joint_name]
175 calibrated_value = calibrated_value + \
180 return calibrated_value
184 Return an array containing the Cyberglove joints names 186 @return: the joints names array 188 return self.joints.keys()
192 @return: True if a cyberglove is detected by ROS 198 master = rosgraph.masterapi.Master(
'rostopic list')
199 self.
liste = master.getPublishedTopics(
'')
201 for topic_typ
in self.
liste:
202 for topic
in topic_typ:
203 if 'cyberglove/raw' in topic:
def callback_raw(self, data)
def read_calibrated_average_value(self, joint_name)
def callback_calibrated(self, data)
def get_joints_names(self)
def read_raw_average_value(self, joint_name)
def __init__(self, max_values=2, nb_sensors=22)
def __init__(self, name="", motor="", min=0, max=90)
def addValue(self, vector, value)