4 base
= os
.path
.dirname(__file__
)
5 path
= os
.path
.dirname(base
)
6 path
= os
.path
.dirname(path
)
7 sys
.path
.insert(0, path
)
10 import matplotlib
.pyplot
as plt
11 except Exception as e
:
15 import liba
# type: ignore
17 traj
= liba
.trajtrap()
18 traj
.gen(2, 2, -2, 0, 4)
19 data
= np
.arange(0, traj
.t
, traj
.t
/ 1000)
21 plt
.figure("trapezoidal velocity trajectory")
24 plt
.title("trapezoidal velocity trajectory")
25 plt
.ylabel("Position")
26 plt
.plot(data
, np
.array(traj
.pos(data
), copy
=False), "r-", label
="q")
30 plt
.ylabel("Velocity")
31 plt
.plot(data
, np
.array(traj
.vel(data
), copy
=False), "b-", label
="v")
35 plt
.ylabel("Acceleration")
36 plt
.plot(data
, np
.array(traj
.acc(data
), copy
=False), "g-", label
="a")
40 plt
.savefig(os
.path
.join(base
, "trajectory_trapezoidal.png"))