pose_stamped_publisher.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 import rospy
4 import sys
5 from geometry_msgs.msg import PoseStamped
6 from tf.transformations import quaternion_from_euler
7 
8 def usage():
9  "print usage"
10  print "Usage: pose_stamped_publisher.py x y z roll pitch yaw from_frame rate"
11 
12 def eulerToQuaternion(roll, pitch, yaw):
13  "convert roll-pitch-yaw to quaternion"
14  return quaternion_from_euler(roll, pitch, yaw)
15 
16 if __name__ == "__main__":
17  rospy.init_node("pose_stamped_publisher")
18  argv = rospy.myargv()
19  if len(argv) != 9:
20  usage()
21  sys.exit(1)
22  x = float(argv[1])
23  y = float(argv[2])
24  z = float(argv[3])
25  roll = float(argv[4])
26  pitch = float(argv[5])
27  yaw = float(argv[6])
28  frame = argv[7]
29  rate = float(argv[8])
30  pose = PoseStamped()
31 
32  pose.header.frame_id = frame
33  pose.pose.position.x = x
34  pose.pose.position.y = y
35  pose.pose.position.z = z
36  # roll, pitch, yaw to quaternion
37  q = eulerToQuaternion(roll, pitch, yaw)
38  pose.pose.orientation.x = q[0]
39  pose.pose.orientation.y = q[1]
40  pose.pose.orientation.x = q[2]
41  pose.pose.orientation.w = q[3]
42  r = rospy.Rate(rate)
43  pub = rospy.Publisher("~output", PoseStamped)
44  while not rospy.is_shutdown():
45  pose.header.stamp = rospy.Time.now()
46  pub.publish(pose)
47  r.sleep()
def eulerToQuaternion(roll, pitch, yaw)


jsk_topic_tools
Author(s): Kei Okada , Yusuke Furuta
autogenerated on Tue Feb 6 2018 03:45:19