Update: Make matplot as an option
This commit is contained in:
parent
593fb0478e
commit
30aade3ea7
|
|
@ -1,4 +1,4 @@
|
|||
import numpy as np
|
||||
from __version__ import __version__
|
||||
|
||||
from core import *
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ Optional library: matplotlib
|
|||
*** IMPORTS ***
|
||||
'''
|
||||
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
'''
|
||||
|
|
@ -1301,7 +1302,11 @@ def InverseDynamicsTrajectory(thetamat, dthetamat, ddthetamat, g, \
|
|||
Tau2 = taumat[:, 1]
|
||||
Tau3 = taumat[:, 2]
|
||||
timestamp = np.linspace(0, Tf, N)
|
||||
try:
|
||||
import matplotlib.pyplot as plt
|
||||
except:
|
||||
print 'The result will not be plotted due to a lack of package matplotlib'
|
||||
else:
|
||||
plt.plot(timestamp, Tau1, label = "Tau1")
|
||||
plt.plot(timestamp, Tau2, label = "Tau2")
|
||||
plt.plot(timestamp, Tau3, label = "Tau3")
|
||||
|
|
@ -1355,7 +1360,6 @@ def ForwardDynamicsTrajectory(thetalist, dthetalist, taumat, g, Ftipmat, \
|
|||
|
||||
Example Inputs (3 Link Robot):
|
||||
import modern_robotics as mr
|
||||
import matplotlib.pyplot as plt
|
||||
thetalist = np.array([0.1, 0.1, 0.1])
|
||||
dthetalist = np.array([0.1, 0.2, 0.3])
|
||||
taumat = np.array([[3.63, -6.58, -5.57], [3.74, -5.55, -5.5],
|
||||
|
|
@ -1406,6 +1410,11 @@ def ForwardDynamicsTrajectory(thetalist, dthetalist, taumat, g, Ftipmat, \
|
|||
N = np.array(taumat).shape[0]
|
||||
Tf = np.array(taumat).shape[0] * dt
|
||||
timestamp = np.linspace(0, Tf, N)
|
||||
try:
|
||||
import matplotlib.pyplot as plt
|
||||
except:
|
||||
print 'The result will not be plotted due to a lack of package matplotlib'
|
||||
else:
|
||||
plt.plot(timestamp, theta1, label = "Theta1")
|
||||
plt.plot(timestamp, theta2, label = "Theta2")
|
||||
plt.plot(timestamp, theta3, label = "Theta3")
|
||||
|
|
@ -1861,11 +1870,15 @@ def SimulateControl(thetalist, dthetalist, g, Ftipmat, Mlist, Glist, \
|
|||
thetamat[:, i] = thetacurrent
|
||||
eint = np.add(eint, dt * np.subtract(thetamatd[:, i], thetacurrent))
|
||||
#Output using matplotlib to plot
|
||||
try:
|
||||
import matplotlib.pyplot as plt
|
||||
except:
|
||||
print 'The result will not be plotted due to a lack of package matplotlib'
|
||||
else:
|
||||
links = np.array(thetamat).shape[0]
|
||||
N = np.array(thetamat).shape[1]
|
||||
Tf = N * dt
|
||||
timestamp = np.linspace(0, Tf, N)
|
||||
#timestampd = np.linspace(0,Tf,(N/intRes))
|
||||
for i in range(links):
|
||||
col = [np.random.uniform(0, 1), np.random.uniform(0, 1),
|
||||
np.random.uniform(0, 1)]
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ from setuptools import setup
|
|||
|
||||
setup(
|
||||
name = "modern_robotics",
|
||||
version = "1.0.0",
|
||||
version = "__version__",
|
||||
author = "Huan Weng, Mikhail Todes, Jarvis Schultz, Bill Hunt",
|
||||
author_email = "huanweng@u.northwestern.edu",
|
||||
description = ("Modern Robotics: Mechanics, Planning, and Control: Code Library"),
|
||||
|
|
@ -16,8 +16,7 @@ setup(
|
|||
"License :: OSI Approved :: BSD License",
|
||||
],
|
||||
install_requires=[
|
||||
'numpy',
|
||||
'scipy',
|
||||
'numpy'
|
||||
],
|
||||
platforms='Linux, Mac, Windows',
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in New Issue