time_visualizer.py 707 B

12345678910111213141516171819202122232425262728293031
  1. #!/usr/bin/env python
  2. import rospy
  3. import numpy as np
  4. import matplotlib.pyplot as plt
  5. from mpl_toolkits.mplot3d import Axes3D
  6. from synchronization.msg import time_monitor
  7. def callback(data):
  8. rospy.loginfo(rospy.get_caller_id()+"I heardaa")
  9. def visualizer():
  10. x = np.arange(-3,3,0.1)
  11. y = np.sin(x)
  12. plt.draw()
  13. time.sleep(0.05)
  14. plt.plot(x, y)
  15. plt.axis([0, 1000, 0, 1])
  16. plt.ion()
  17. plt.show()
  18. for i in range(1000):
  19. y = np.random.random()
  20. plt.scatter(i, y)
  21. rospy.init_node('time_visualizer', anonymous=False)
  22. rospy.Subscriber("/synchronization/obj_car/times", time_monitor, callback)
  23. rospy.spin()
  24. if __name__ == '__main__':
  25. visualizer()