how to set my path time, and how can i show it in map? [closed]
Hi, all:
I'm trying to write a path_recorder to recorder the path where turtlebot have arrived and show it in map.
Unfortunately, i got a trouble in how to set time for a path, i checked the message come from topic '/move_base/DWAPlannerROS/global_plan' and set all poses time to when the message is publishing.
However, when i launched AMCL and published my Path message to '/move_base/DWAPlannerROS/global_plan' to test my message, there was nothing happened... it supported to at least have a line in map, right?..... i don't know if i did the right thing..
and the other problem is i don't know how to show the path in map. (ps: i did add a path element when i use rviz and subscribe to my topic 'path_recorder', but it did not work. )
here is my code:
def define(self):
self.path=Path()
self.pose=PoseStamped()
self.pose_list=[]
self.path.poses=[]
#self.path.header.stamp=rospy.Time.now()
self.pub = rospy.Publisher('path_recorder', Path, queue_size=10)
def timer_callback(self,event):
if self.current_pose.pose.pose not in self.pose_list:
self.pose_list.append(self.current_pose.pose.pose)
self.pose.pose=self.current_pose.pose.pose
self.pose.header.frame_id='map'
#self.pose.header.stamp=rospy.Time.now()
self.pose.header.seq=0
self.path.poses.append(self.pose)
else:
pass
self.path.header.frame_id='map'
self.path.header.stamp=rospy.Time.now()
for element in self.path.poses:
element.header.stamp=self.path.header.stamp
print len(self.path.poses)
self.pub.publish(self.path)
def odom_callback(self,odom):
self.current_pose=Odometry()
self.current_pose.pose.pose.position.x=round(odom.pose.pose.position.x,5)
self.current_pose.pose.pose.position.y=round(odom.pose.pose.position.y,5)
self.current_pose.pose.pose.position.z=round(odom.pose.pose.position.z,5)
self.current_pose.pose.pose.orientation.x=round(odom.pose.pose.orientation.x,5)
self.current_pose.pose.pose.orientation.y=round(odom.pose.pose.orientation.y,5)
self.current_pose.pose.pose.orientation.z=round(odom.pose.pose.orientation.z,5)
self.current_pose.pose.pose.orientation.w=round(odom.pose.pose.orientation.w,5)
def start(self):
self.define()
rospy.Subscriber("odom",Odometry, self.odom_callback)
rospy.Timer(rospy.Duration(0.5), self.timer_callback,oneshot=False)
rospy.spin()
ur...i figured out a method to show path... but, i'm not sure if it's a good way to do it
my method is setting all points of a path to now(), and then publish those points throw marker