hand_position_publisher_example.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 # Copyright 2018 RT Corporation
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 
17 import roslib
18 import rospy
19 import math
20 import tf
21 import geometry_msgs.msg
22 
23 if __name__ == '__main__':
24  rospy.init_node('hand_position_pub')
25 
26  listener = tf.TransformListener()
27 
28  left_pose_pub = rospy.Publisher('/sciurus17/hand_pos/left', geometry_msgs.msg.Pose,queue_size=1)
29  right_pose_pub = rospy.Publisher('/sciurus17/hand_pos/right', geometry_msgs.msg.Pose,queue_size=1)
30 
31  rate = rospy.Rate(10.0)
32  while not rospy.is_shutdown():
33  try:
34  (trans,rot) = listener.lookupTransform('base_link', 'l_link7', rospy.Time(0))
36  continue
37 
38  #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]))
39  left_pose = geometry_msgs.msg.Pose()
40  left_pose.position.x = trans[0]
41  left_pose.position.y = trans[1]
42  left_pose.position.z = trans[2]
43  left_pose.orientation.x = rot[0]
44  left_pose.orientation.y = rot[1]
45  left_pose.orientation.z = rot[2]
46  left_pose.orientation.w = rot[3]
47  left_pose_pub.publish( left_pose )
48 
49  try:
50  (trans,rot) = listener.lookupTransform('base_link', 'r_link7', rospy.Time(0))
52  continue
53 
54  #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]))
55  right_pose = geometry_msgs.msg.Pose()
56  right_pose.position.x = trans[0]
57  right_pose.position.y = trans[1]
58  right_pose.position.z = trans[2]
59  right_pose.orientation.x = rot[0]
60  right_pose.orientation.y = rot[1]
61  right_pose.orientation.z = rot[2]
62  right_pose.orientation.w = rot[3]
63  right_pose_pub.publish( right_pose )
64 
65  rate.sleep()
66 
tf2::ExtrapolationException
tf2::LookupException
tf2::ConnectivityException
tf::TransformListener


sciurus17_examples
Author(s): Daisuke Sato , Hiroyuki Nomura
autogenerated on Fri Aug 2 2024 08:37:20