3 """ For backwards compatibility with the old driver files 4 Will be DELETED in the future """ 12 from leap_motion.msg
import leap
13 from leap_motion.msg
import leapros
15 FREQUENCY_ROSTOPIC_DEFAULT = 0.01
17 PARAMNAME_FREQ =
'freq' 18 PARAMNAME_FREQ_ENTIRE =
'/' + NODENAME +
'/' + PARAMNAME_FREQ
22 This method publishes the data defined in leapros.msg to /leapmotion/data 24 rospy.loginfo(
"Parameter set on server: PARAMNAME_FREQ={}".format(rospy.get_param(PARAMNAME_FREQ_ENTIRE, FREQUENCY_ROSTOPIC_DEFAULT)))
30 pub_ros = rospy.Publisher(
'leapmotion/data',leapros, queue_size=2)
31 rospy.init_node(NODENAME)
33 while not rospy.is_shutdown():
34 hand_direction_ = li.get_hand_direction()
35 hand_normal_ = li.get_hand_normal()
36 hand_palm_pos_ = li.get_hand_palmpos()
37 hand_pitch_ = li.get_hand_pitch()
38 hand_roll_ = li.get_hand_roll()
39 hand_yaw_ = li.get_hand_yaw()
42 msg.direction.x = hand_direction_[0]
43 msg.direction.y = hand_direction_[1]
44 msg.direction.z = hand_direction_[2]
45 msg.normal.x = hand_normal_[0]
46 msg.normal.y = hand_normal_[1]
47 msg.normal.z = hand_normal_[2]
48 msg.palmpos.x = hand_palm_pos_[0]
49 msg.palmpos.y = hand_palm_pos_[1]
50 msg.palmpos.z = hand_palm_pos_[2]
52 msg.ypr.y = hand_pitch_
53 msg.ypr.z = hand_roll_
55 fingerNames = [
'thumb',
'index',
'middle',
'ring',
'pinky']
56 fingerPointNames = [
'metacarpal',
'proximal',
57 'intermediate',
'distal',
'tip']
58 for fingerName
in fingerNames:
59 for fingerPointName
in fingerPointNames:
60 pos = li.get_finger_point(fingerName, fingerPointName)
61 for iDim, dimName
in enumerate([
'x',
'y',
'z']):
62 setattr(getattr(msg,
'%s_%s' % (fingerName, fingerPointName)),
68 rospy.sleep(rospy.get_param(PARAMNAME_FREQ_ENTIRE, FREQUENCY_ROSTOPIC_DEFAULT))
71 if __name__ ==
'__main__':
74 except rospy.ROSInterruptException: