Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A hacky script to generate a plot of a trapezoidal motion profile
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(0, 10, 1000)
pdot = np.piecewise(x, [x < 4, (x >= 4) & (x <= 6), x > 6], [lambda x: x/2, 2, lambda x: -x/2 + 5])
p = []
psum = 0
for v in pdot:
p.append(psum)
psum += v
plt.plot(pdot)
plt.ylim([0,2.5])
plt.show()
plt.plot(p)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.