publish_pose.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 import rospy
4 import tf
5 from geometry_msgs.msg import PoseStamped
6 
7 if __name__ == '__main__':
8  rospy.init_node('publish_pose', anonymous=True)
9  worldFrame = rospy.get_param("~worldFrame", "/world")
10  name = rospy.get_param("~name")
11  r = rospy.get_param("~rate")
12  x = rospy.get_param("~x")
13  y = rospy.get_param("~y")
14  z = rospy.get_param("~z")
15 
16  rate = rospy.Rate(r)
17 
18  msg = PoseStamped()
19  msg.header.seq = 0
20  msg.header.stamp = rospy.Time.now()
21  msg.header.frame_id = worldFrame
22  msg.pose.position.x = x
23  msg.pose.position.y = y
24  msg.pose.position.z = z
25  quaternion = tf.transformations.quaternion_from_euler(0, 0, 0)
26  msg.pose.orientation.x = quaternion[0]
27  msg.pose.orientation.y = quaternion[1]
28  msg.pose.orientation.z = quaternion[2]
29  msg.pose.orientation.w = quaternion[3]
30 
31  pub = rospy.Publisher(name, PoseStamped, queue_size=1)
32 
33  while not rospy.is_shutdown():
34  msg.header.seq += 1
35  msg.header.stamp = rospy.Time.now()
36  pub.publish(msg)
37  rate.sleep()


crazyflie_demo
Author(s): Wolfgang Hoenig
autogenerated on Mon Sep 28 2020 03:40:12