generate_plot.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. from AGV import *
  2. from CBD.simulator import Simulator
  3. from CBD.realtime.plotting import PlotManager, LinePlot
  4. import matplotlib.pyplot as plt
  5. from itertools import cycle
  6. import pandas as pd
  7. DELTA_T = 0.2
  8. END = 650.0
  9. if __name__ == '__main__':
  10. fig = plt.figure(figsize=(5, 5), dpi=100)
  11. ax = fig.add_subplot(111)
  12. ax.set_xlim((-.45, .45))
  13. ax.set_ylim((-.35, .55))
  14. lines = ["-","--","-.",":"]
  15. linecycler = cycle(lines)
  16. model = AGVVirtual("AGV", path_file="paths/falcon.csv", Kp=0.0, Ki=0.0, Kd=-0.02, v=0.001, T=35,
  17. wheel_radius=0.016512, wheel_axis=0.1944, initial=[0, -.3, 0])
  18. traj = model.findBlock("environment")[0].path
  19. ax.plot([x for x, _ in traj], [y for _, y in traj], c='salmon', label="path")
  20. sets = {
  21. "012": -0.02,
  22. "072": -0.12,
  23. "084": -0.14,
  24. "102": -0.17
  25. }
  26. for d, Kd in sets.items():
  27. data = pd.read_csv(f"tuning6/path-00{d}.csv")
  28. ax.plot(data["x"], data["y"], next(linecycler), lw=2, label="Kd = " + str(Kd))
  29. # data012 = pd.read_csv("tuning6/path-00012.csv")
  30. # data072 = pd.read_csv("tuning6/path-00072.csv")
  31. # data082 = pd.read_csv("tuning6/path-00084.csv")
  32. # data102 = pd.read_csv("tuning6/path-00102.csv")
  33. # print(data012)
  34. # manager = PlotManager()
  35. # manager.register("plot", model.findBlock("plot")[0], (fig, ax), LinePlot())
  36. #
  37. # sim = Simulator(model)
  38. # sim.setDeltaT(DELTA_T)
  39. # # sim.setProgressBar()
  40. # # sim.setRealTimePlatformGameLoop()
  41. # sim.setRealTime(scale=.01)
  42. # sim.run(END)
  43. #
  44. fig.tight_layout()
  45. ax.legend(loc="upper left")
  46. plt.show()