2 """Plot wheel angle and speed of the scenario.
6 ./sp_and_wa_plot.py some-generated-file.traj.json
9 from matplotlib import pyplot as plt
14 def ticks_to_seconds(t):
15 return t * 0.02 # one tick is 20 ms
26 if __name__ == "__main__":
27 if len(sys.argv) != 2:
31 with open(f"{sys.argv[1]}", "r") as f:
35 plt.rc('axes', unicode_minus=False)
38 ax = fig.add_subplot(111)
39 ax.set_title("Wheel Angle and Speed in time")
40 ax.set_xlabel("Time [s]")
41 ax.set_ylabel("Wheel Angle [deg]")
44 ax2.set_ylabel("Speed [kmph]")
46 t = [ticks_to_seconds(i) for i in range(len(plan["traj"]))]
47 wa = [rad_to_deg(t[3]) for t in plan["traj"]]
48 sp = [mps_to_kmph(t[4]) for t in plan["traj"]]
50 p1 = ax.plot(t, wa, 'b-', label="Wheel Angle [deg]")
51 p2 = ax2.plot(t, sp, 'r-', label="Speed [kmph]")
54 labs = [l.get_label() for l in lns]
55 ax.legend(lns, labs, loc=0)
56 ax.grid(True, "both", linestyle=":", color="tab:gray")