5 from math
import cos, sin, pi
7 if __name__ ==
"__main__":
8 rospy.init_node(
"pose_with_covariance_sample")
9 pub = rospy.Publisher(
"~output", PoseWithCovarianceStamped)
14 while not rospy.is_shutdown():
15 counter = counter + 10
16 theta = counter / 180.0 * pi
19 var = abs(cos(theta / 2))
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