How to read msg from /odom at time series n and (n-1)
Hi there, I hope to compare the message from the consecutive time series n and (n-1) from /odom in python. I am confused about how to store the msg at time n-1 and time n at the same time, especially for the time sequence t=1.
def listener():
rospy.init_node('listener', anonymous=True)
rospy.Subscriber("/odom", Odometry, simple_callback)
rospy.spin()
def simple_callback():
if __name__== '__main__':
listener()
The problem which confused me is that: I was thinking to use some variables to store the msg at sequence n-1 and n like : current_odom=[ ] and last_odom=[ ]. However, I don't how to store the msg at time t=1, because listener() and simple_callback are in loop, I don't know when to pass the data in current_odom=[ ] and last_odom=[ ]. Could you please give me any hints?
Thank you.