pose_with_covariance_sample.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 import rospy
4 from geometry_msgs.msg import PoseWithCovarianceStamped
5 from math import cos, sin, pi
6 
7 if __name__ == "__main__":
8  rospy.init_node("pose_with_covariance_sample")
9  pub = rospy.Publisher("~output", PoseWithCovarianceStamped)
10  r = rospy.Rate(20)
11  counter = 0
12  rad = 2.0
13  var = 0.3
14  while not rospy.is_shutdown():
15  counter = counter + 10
16  theta = counter / 180.0 * pi
17  if counter > 360:
18  counter = 0
19  var = abs(cos(theta / 2))
20  x = rad * cos(theta)
21  y = rad * sin(theta)
22  msg = PoseWithCovarianceStamped()
23  msg.header.stamp = rospy.Time.now()
24  msg.header.frame_id = "odom"
25  msg.pose.pose.orientation.w = 1.0
26  msg.pose.pose.position.x = x
27  msg.pose.pose.position.y = y
28  msg.pose.covariance[0] = var
29  msg.pose.covariance[7] = var
30  msg.pose.covariance[14] = var
31  msg.pose.covariance[21] = var
32  msg.pose.covariance[28] = var
33  msg.pose.covariance[35] = var
34  pub.publish(msg)
35  r.sleep()


jsk_pcl_ros
Author(s): Yohei Kakiuchi
autogenerated on Mon May 3 2021 03:03:47