Advertisement
Guest User

Untitled

a guest
Apr 26th, 2017
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. import rospy
  2. from std_msgs.msg import Header
  3. from geometry_msgs.msg import Pose, Point, Quaternion, PoseWithCovariance, PoseWithCovarianceStamped
  4. from tf.transformations import quaternion_from_euler
  5.  
  6.  
  7. def publish_pose(x, y, z, yaw):
  8. pub = rospy.Publisher('initialpose', PoseWithCovarianceStamped, queue_size=10)
  9. point = Point(x, y, z)
  10. q = quaternion_from_euler(0.0, 0.0, yaw).tolist()
  11. q = Quaternion(0, 0, q[2], q[3])
  12. data = PoseWithCovarianceStamped(
  13. Header(0, rospy.Time().now(), '/map'),
  14. PoseWithCovariance(
  15. Pose(point, q),
  16. [0] * 36
  17. )
  18. )
  19. pub.publish(data)
  20.  
  21.  
  22. if __name__ == '__main__':
  23. pub_pose = PubPose()
  24. pub_pose.publish_pose(0, 0, 0, 0, 0, 0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement