tf_set.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 import roslib; roslib.load_manifest('dynamic_tf_publisher')
3 
4 import sys
5 import rospy
6 import tf
7 from dynamic_tf_publisher.srv import SetDynamicTF
8 from geometry_msgs.msg import *
9 
10 def set_tf(pos, q, parent, child, freq):
11  rospy.wait_for_service('/set_dynamic_tf')
12  try:
13  client = rospy.ServiceProxy('/set_dynamic_tf', SetDynamicTF)
14  pose = TransformStamped()
15  pose.header.frame_id = pa
16  pose.child_frame_id = ch
17  pose.transform.translation = Vector3(*pos)
18  pose.transform.rotation = Quaternion(*q)
19  print pose
20  res = client(freq, pose)
21  return
22  except rospy.ServiceException, e:
23  print "Service call failed: %s"%e
24 
25 def isfloat(str):
26  try:
27  float(str)
28  return True
29  except Exception, e:
30  return False
31 
32 if __name__ == "__main__":
33  try:
34  pos = map(float,sys.argv[1:4])
35  if isfloat(sys.argv[7]): # quaternion
36  q = map(float,sys.argv[4:8])
37  rest = sys.argv[8:]
38  else: # rpy
39  rpy = map(float,sys.argv[4:7])
40  # rpy angle is in "zyx" axis
41  q = tf.transformations.quaternion_from_euler(*rpy, axes="rzyx")
42  print q
43  rest = sys.argv[7:]
44  pa = rest[0]
45  ch = rest[1]
46  hz = 1000.0 / float(rest[2])
47  set_tf(pos, q, pa, ch, hz)
48  except Exception, e:
49  print sys.argv
50  print "args: x y z (r p y)|(x y z w) parent child msec"
51  sys.exit(0)
def set_tf(pos, q, parent, child, freq)
Definition: tf_set.py:10
def isfloat(str)
Definition: tf_set.py:25


dynamic_tf_publisher
Author(s): Manabu Saito
autogenerated on Tue Feb 6 2018 03:44:59