Major formatting update to Python library
+ Fixed some spelling mistakes + Cleaned up tab/space indentation. Previously some of the samples would not work if copied/pasted into a Python interpreter because of mixed tabs/spaces + Cleared all trailing whitespace + Missing quotation marks in some sample code caused mistakes with printing messages + Added all import statements to some of the examples that already had some import statements
This commit is contained in:
parent
77dcf6617c
commit
36c388aa20
|
|
@ -182,7 +182,7 @@ def MatrixLog3(R):
|
|||
|
||||
def RpToTrans(R, p):
|
||||
"""Converts a rotation matrix and a position vector into homogeneous
|
||||
tranformation matrix
|
||||
transformation matrix
|
||||
|
||||
:param R: A 3x3 rotation matrix
|
||||
:param p: A 3-vector
|
||||
|
|
@ -305,7 +305,7 @@ def Adjoint(T):
|
|||
np.c_[np.dot(VecToso3(p), R), R]]
|
||||
|
||||
def ScrewToAxis(q, s, h):
|
||||
"""Takes a parametric description of a scre axis and converts it to a
|
||||
"""Takes a parametric description of a screw axis and converts it to a
|
||||
normalized screw axis
|
||||
|
||||
:param q: A point lying on the screw axis
|
||||
|
|
@ -323,10 +323,10 @@ def ScrewToAxis(q, s, h):
|
|||
return np.r_[s, np.cross(q, s) + np.dot(h, s)]
|
||||
|
||||
def AxisAng6(expc6):
|
||||
"""Converts a 6-vector of exponenation coordinates into screw axis-angle
|
||||
"""Converts a 6-vector of exponential coordinates into screw axis-angle
|
||||
form
|
||||
|
||||
:param expc6: A 6-vector of exponential corrdinates for rigid-body motion
|
||||
:param expc6: A 6-vector of exponential coordinates for rigid-body motion
|
||||
S*theta
|
||||
:return S: The corresponding normalized screw axis
|
||||
:return theta: The distance traveled along/about S
|
||||
|
|
@ -1251,6 +1251,8 @@ def InverseDynamicsTrajectory(thetamat, dthetamat, ddthetamat, g, \
|
|||
forces/torques at each time step
|
||||
|
||||
Example Inputs (3 Link Robot):
|
||||
from __future__ import print_function
|
||||
import numpy as np
|
||||
import modern_robotics as mr
|
||||
# Create a trajectory to follow using functions from Chapter 9
|
||||
thetastart = np.array([0, 0, 0])
|
||||
|
|
@ -1267,7 +1269,7 @@ def InverseDynamicsTrajectory(thetamat, dthetamat, ddthetamat, g, \
|
|||
dthetamat[i + 1, :] = (thetamat[i + 1, :] - thetamat[i, :]) / dt
|
||||
ddthetamat[i + 1, :] \
|
||||
= (dthetamat[i + 1, :] - dthetamat[i, :]) / dt
|
||||
#Initialise robot descripstion (Example with 3 links)
|
||||
# Initialize robot description (Example with 3 links)
|
||||
g = np.array([0, 0, -9.8])
|
||||
Ftipmat = np.ones((N, 6))
|
||||
M01 = np.array([[1, 0, 0, 0],
|
||||
|
|
@ -1359,6 +1361,8 @@ def ForwardDynamicsTrajectory(thetalist, dthetalist, taumat, g, Ftipmat, \
|
|||
ForwardDynamics.
|
||||
|
||||
Example Inputs (3 Link Robot):
|
||||
from __future__ import print_function
|
||||
import numpy as np
|
||||
import modern_robotics as mr
|
||||
thetalist = np.array([0.1, 0.1, 0.1])
|
||||
dthetalist = np.array([0.1, 0.2, 0.3])
|
||||
|
|
@ -1367,7 +1371,7 @@ def ForwardDynamicsTrajectory(thetalist, dthetalist, taumat, g, Ftipmat, \
|
|||
[5.85, 8.17, -2.59], [5.78, 2.79, -1.7],
|
||||
[4.99, -5.3, -1.19], [4.08, -9.41, 0.07],
|
||||
[3.56, -10.1, 0.97], [3.49, -9.41, 1.23]])
|
||||
#Initialise robot description (Example with 3 links)
|
||||
# Initialize robot description (Example with 3 links)
|
||||
g = np.array([0, 0, -9.8])
|
||||
Ftipmat = np.ones((np.array(taumat).shape[0], 6))
|
||||
M01 = np.array([[1, 0, 0, 0],
|
||||
|
|
@ -1413,7 +1417,7 @@ def ForwardDynamicsTrajectory(thetalist, dthetalist, taumat, g, Ftipmat, \
|
|||
try:
|
||||
import matplotlib.pyplot as plt
|
||||
except:
|
||||
print(The result will not be plotted due to a lack of package matplotlib)
|
||||
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")
|
||||
|
|
@ -1765,10 +1769,12 @@ def SimulateControl(thetalist, dthetalist, g, Ftipmat, Mlist, Glist, \
|
|||
using matplotlib and random libraries.
|
||||
|
||||
Example Input:
|
||||
from __future__ import print_function
|
||||
import numpy as np
|
||||
from modern_robotics import JointTrajectory
|
||||
thetalist = np.array([0.1, 0.1, 0.1])
|
||||
dthetalist = np.array([0.1, 0.2, 0.3])
|
||||
#Initialise robot description (Example with 3 links)
|
||||
# Initialize robot description (Example with 3 links)
|
||||
g = np.array([0, 0, -9.8])
|
||||
M01 = np.array([[1, 0, 0, 0],
|
||||
[0, 1, 0, 0],
|
||||
|
|
|
|||
Loading…
Reference in New Issue