4 sys
.path
.insert(0, os
.getcwd())
5 prefix
= os
.path
.join(sys
.path
[0], "build")
6 if not os
.path
.exists(prefix
):
11 import matplotlib
.pyplot
as plt
12 except Exception as e
:
19 data
= np
.arange(t
[0], t
[1], 0.01)
20 traj
= a
.trajpoly3(t
[1] - t
[0], p
[0], p
[1], v
[0], v
[1])
23 text_p
+= "%g" % (traj
.p
[0])
25 text_p
+= "%+g%s" % (traj
.p
[1], "t")
27 text_p
+= "%+g%s" % (traj
.p
[2], "t^2")
29 text_p
+= "%+g%s" % (traj
.p
[3], "t^3")
30 text_p
= text_p
.replace("=+", "=")
33 text_v
+= "%g" % (traj
.v
[0])
35 text_v
+= "%+g%s" % (traj
.v
[1], "t")
37 text_v
+= "%+g%s" % (traj
.v
[2], "t^2")
38 text_v
= text_v
.replace("=+", "=")
41 text_a
+= "%g" % (traj
.a
[0])
43 text_a
+= "%+g%s" % (traj
.a
[1], "t")
44 text_a
= text_a
.replace("=+", "=")
45 plt
.figure("3 polynomial trajectory")
48 plt
.title("cubic polynomial trajectory")
49 plt
.ylabel("Position")
50 plt
.plot(data
, traj
.pos(data
), "r-", label
=text_p
)
54 plt
.ylabel("Velocity")
55 plt
.plot(data
, traj
.vel(data
), "b-", label
=text_v
)
59 plt
.ylabel("Acceleration")
60 plt
.plot(data
, traj
.acc(data
), "g-", label
=text_a
)
64 plt
.savefig(os
.path
.join(prefix
, "trajectory_polynomial_3.png"))