hand_position_publisher_example.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 import roslib
3 import rospy
4 import math
5 import tf
6 import geometry_msgs.msg
7 
8 if __name__ == '__main__':
9  rospy.init_node('hand_position_pub')
10 
11  listener = tf.TransformListener()
12 
13  left_pose_pub = rospy.Publisher('/sciurus17/hand_pos/left', geometry_msgs.msg.Pose,queue_size=1)
14  right_pose_pub = rospy.Publisher('/sciurus17/hand_pos/right', geometry_msgs.msg.Pose,queue_size=1)
15 
16  rate = rospy.Rate(10.0)
17  while not rospy.is_shutdown():
18  try:
19  (trans,rot) = listener.lookupTransform('base_link', 'l_link7', rospy.Time(0))
21  continue
22 
23  #rospy.loginfo("pos[x=%f y=%f z=%f] rot[x=%f y=%f z=%f w=%f]" % (trans[0],trans[1],trans[2],rot[0],rot[1],rot[2],rot[3]))
24  left_pose = geometry_msgs.msg.Pose()
25  left_pose.position.x = trans[0]
26  left_pose.position.y = trans[1]
27  left_pose.position.z = trans[2]
28  left_pose.orientation.x = rot[0]
29  left_pose.orientation.y = rot[1]
30  left_pose.orientation.z = rot[2]
31  left_pose.orientation.w = rot[3]
32  left_pose_pub.publish( left_pose )
33 
34  try:
35  (trans,rot) = listener.lookupTransform('base_link', 'r_link7', rospy.Time(0))
37  continue
38 
39  #rospy.loginfo("pos[x=%f y=%f z=%f] rot[x=%f y=%f z=%f w=%f]" % (trans[0],trans[1],trans[2],rot[0],rot[1],rot[2],rot[3]))
40  right_pose = geometry_msgs.msg.Pose()
41  right_pose.position.x = trans[0]
42  right_pose.position.y = trans[1]
43  right_pose.position.z = trans[2]
44  right_pose.orientation.x = rot[0]
45  right_pose.orientation.y = rot[1]
46  right_pose.orientation.z = rot[2]
47  right_pose.orientation.w = rot[3]
48  right_pose_pub.publish( right_pose )
49 
50  rate.sleep()
51 


sciurus17_examples
Author(s): Daisuke Sato , Hiroyuki Nomura
autogenerated on Sun Oct 2 2022 02:21:39