Created
January 2, 2017 05:38
-
-
Save WesleyAC/861da6df9b172603536f8b01a9469e79 to your computer and use it in GitHub Desktop.
A hacky script to generate a plot of a trapezoidal motion profile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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