amcl_resample.py
Go to the documentation of this file.
1 #!/usr/bin/python
2 
3 import rospy
4 import geometry_msgs.msg
5 
6 rospy.init_node('amcl_resample', anonymous=True)
7 pub = None
8 rate = rospy.Duration(5)
9 last = rospy.Time.now()
10 
11 def callback(msg):
12  global last
13  if rospy.Time.now() - last < rate:
14  return
15 
16  if pub == None:
17  return
18 
19  new_msg = msg
20  new_msg.pose.covariance = list(new_msg.pose.covariance)
21  last = rospy.Time.now()
22  for i in range(len(new_msg.pose.covariance)):
23  new_msg.pose.covariance[i] /= 2.0
24 
25  pub.publish(new_msg)
26  #rospy.loginfo('publico')
27 
28 def listener():
29  global pub
30 
31  pub = rospy.Publisher('initialpose', geometry_msgs.msg.PoseWithCovarianceStamped, queue_size=1)
32  rospy.Subscriber('amcl_pose', geometry_msgs.msg.PoseWithCovarianceStamped, callback)
33  rospy.spin()
34 
35 if __name__ == '__main__':
36  listener()
def callback(msg)


rb1_base_localization
Author(s):
autogenerated on Sun Dec 6 2020 03:58:46