Update: Make matplot as an option

This commit is contained in:
HuanWeng 2018-07-24 14:41:57 -05:00
parent 593fb0478e
commit 30aade3ea7
3 changed files with 58 additions and 46 deletions

View File

@ -1,4 +1,4 @@
import numpy as np from __version__ import __version__
from core import * from core import *

View File

@ -18,6 +18,7 @@ Optional library: matplotlib
*** IMPORTS *** *** IMPORTS ***
''' '''
import numpy as np
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
''' '''
@ -1301,7 +1302,11 @@ def InverseDynamicsTrajectory(thetamat, dthetamat, ddthetamat, g, \
Tau2 = taumat[:, 1] Tau2 = taumat[:, 1]
Tau3 = taumat[:, 2] Tau3 = taumat[:, 2]
timestamp = np.linspace(0, Tf, N) timestamp = np.linspace(0, Tf, N)
try:
import matplotlib.pyplot as plt 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, Tau1, label = "Tau1")
plt.plot(timestamp, Tau2, label = "Tau2") plt.plot(timestamp, Tau2, label = "Tau2")
plt.plot(timestamp, Tau3, label = "Tau3") plt.plot(timestamp, Tau3, label = "Tau3")
@ -1355,7 +1360,6 @@ def ForwardDynamicsTrajectory(thetalist, dthetalist, taumat, g, Ftipmat, \
Example Inputs (3 Link Robot): Example Inputs (3 Link Robot):
import modern_robotics as mr import modern_robotics as mr
import matplotlib.pyplot as plt
thetalist = np.array([0.1, 0.1, 0.1]) thetalist = np.array([0.1, 0.1, 0.1])
dthetalist = np.array([0.1, 0.2, 0.3]) dthetalist = np.array([0.1, 0.2, 0.3])
taumat = np.array([[3.63, -6.58, -5.57], [3.74, -5.55, -5.5], 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] N = np.array(taumat).shape[0]
Tf = np.array(taumat).shape[0] * dt Tf = np.array(taumat).shape[0] * dt
timestamp = np.linspace(0, Tf, N) 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, theta1, label = "Theta1")
plt.plot(timestamp, theta2, label = "Theta2") plt.plot(timestamp, theta2, label = "Theta2")
plt.plot(timestamp, theta3, label = "Theta3") plt.plot(timestamp, theta3, label = "Theta3")
@ -1861,11 +1870,15 @@ def SimulateControl(thetalist, dthetalist, g, Ftipmat, Mlist, Glist, \
thetamat[:, i] = thetacurrent thetamat[:, i] = thetacurrent
eint = np.add(eint, dt * np.subtract(thetamatd[:, i], thetacurrent)) eint = np.add(eint, dt * np.subtract(thetamatd[:, i], thetacurrent))
#Output using matplotlib to plot #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] links = np.array(thetamat).shape[0]
N = np.array(thetamat).shape[1] N = np.array(thetamat).shape[1]
Tf = N * dt Tf = N * dt
timestamp = np.linspace(0, Tf, N) timestamp = np.linspace(0, Tf, N)
#timestampd = np.linspace(0,Tf,(N/intRes))
for i in range(links): for i in range(links):
col = [np.random.uniform(0, 1), np.random.uniform(0, 1), col = [np.random.uniform(0, 1), np.random.uniform(0, 1),
np.random.uniform(0, 1)] np.random.uniform(0, 1)]

View File

@ -2,7 +2,7 @@ from setuptools import setup
setup( setup(
name = "modern_robotics", name = "modern_robotics",
version = "1.0.0", version = "__version__",
author = "Huan Weng, Mikhail Todes, Jarvis Schultz, Bill Hunt", author = "Huan Weng, Mikhail Todes, Jarvis Schultz, Bill Hunt",
author_email = "huanweng@u.northwestern.edu", author_email = "huanweng@u.northwestern.edu",
description = ("Modern Robotics: Mechanics, Planning, and Control: Code Library"), description = ("Modern Robotics: Mechanics, Planning, and Control: Code Library"),
@ -16,8 +16,7 @@ setup(
"License :: OSI Approved :: BSD License", "License :: OSI Approved :: BSD License",
], ],
install_requires=[ install_requires=[
'numpy', 'numpy'
'scipy',
], ],
platforms='Linux, Mac, Windows', platforms='Linux, Mac, Windows',
) )