Merge pull request #9 from jarvisschultz/python_docstring_cleanup
Major formatting update to Python library
This commit is contained in:
commit
174a89066c
|
|
@ -182,7 +182,7 @@ def MatrixLog3(R):
|
||||||
|
|
||||||
def RpToTrans(R, p):
|
def RpToTrans(R, p):
|
||||||
"""Converts a rotation matrix and a position vector into homogeneous
|
"""Converts a rotation matrix and a position vector into homogeneous
|
||||||
tranformation matrix
|
transformation matrix
|
||||||
|
|
||||||
:param R: A 3x3 rotation matrix
|
:param R: A 3x3 rotation matrix
|
||||||
:param p: A 3-vector
|
:param p: A 3-vector
|
||||||
|
|
@ -305,7 +305,7 @@ def Adjoint(T):
|
||||||
np.c_[np.dot(VecToso3(p), R), R]]
|
np.c_[np.dot(VecToso3(p), R), R]]
|
||||||
|
|
||||||
def ScrewToAxis(q, s, h):
|
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
|
normalized screw axis
|
||||||
|
|
||||||
:param q: A point lying on the 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)]
|
return np.r_[s, np.cross(q, s) + np.dot(h, s)]
|
||||||
|
|
||||||
def AxisAng6(expc6):
|
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
|
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
|
S*theta
|
||||||
:return S: The corresponding normalized screw axis
|
:return S: The corresponding normalized screw axis
|
||||||
:return theta: The distance traveled along/about S
|
:return theta: The distance traveled along/about S
|
||||||
|
|
@ -1251,6 +1251,8 @@ def InverseDynamicsTrajectory(thetamat, dthetamat, ddthetamat, g, \
|
||||||
forces/torques at each time step
|
forces/torques at each time step
|
||||||
|
|
||||||
Example Inputs (3 Link Robot):
|
Example Inputs (3 Link Robot):
|
||||||
|
from __future__ import print_function
|
||||||
|
import numpy as np
|
||||||
import modern_robotics as mr
|
import modern_robotics as mr
|
||||||
# Create a trajectory to follow using functions from Chapter 9
|
# Create a trajectory to follow using functions from Chapter 9
|
||||||
thetastart = np.array([0, 0, 0])
|
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
|
dthetamat[i + 1, :] = (thetamat[i + 1, :] - thetamat[i, :]) / dt
|
||||||
ddthetamat[i + 1, :] \
|
ddthetamat[i + 1, :] \
|
||||||
= (dthetamat[i + 1, :] - dthetamat[i, :]) / dt
|
= (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])
|
g = np.array([0, 0, -9.8])
|
||||||
Ftipmat = np.ones((N, 6))
|
Ftipmat = np.ones((N, 6))
|
||||||
M01 = np.array([[1, 0, 0, 0],
|
M01 = np.array([[1, 0, 0, 0],
|
||||||
|
|
@ -1359,6 +1361,8 @@ def ForwardDynamicsTrajectory(thetalist, dthetalist, taumat, g, Ftipmat, \
|
||||||
ForwardDynamics.
|
ForwardDynamics.
|
||||||
|
|
||||||
Example Inputs (3 Link Robot):
|
Example Inputs (3 Link Robot):
|
||||||
|
from __future__ import print_function
|
||||||
|
import numpy as np
|
||||||
import modern_robotics as mr
|
import modern_robotics as mr
|
||||||
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])
|
||||||
|
|
@ -1367,7 +1371,7 @@ def ForwardDynamicsTrajectory(thetalist, dthetalist, taumat, g, Ftipmat, \
|
||||||
[5.85, 8.17, -2.59], [5.78, 2.79, -1.7],
|
[5.85, 8.17, -2.59], [5.78, 2.79, -1.7],
|
||||||
[4.99, -5.3, -1.19], [4.08, -9.41, 0.07],
|
[4.99, -5.3, -1.19], [4.08, -9.41, 0.07],
|
||||||
[3.56, -10.1, 0.97], [3.49, -9.41, 1.23]])
|
[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])
|
g = np.array([0, 0, -9.8])
|
||||||
Ftipmat = np.ones((np.array(taumat).shape[0], 6))
|
Ftipmat = np.ones((np.array(taumat).shape[0], 6))
|
||||||
M01 = np.array([[1, 0, 0, 0],
|
M01 = np.array([[1, 0, 0, 0],
|
||||||
|
|
@ -1413,7 +1417,7 @@ def ForwardDynamicsTrajectory(thetalist, dthetalist, taumat, g, Ftipmat, \
|
||||||
try:
|
try:
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
except:
|
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:
|
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")
|
||||||
|
|
@ -1765,10 +1769,12 @@ def SimulateControl(thetalist, dthetalist, g, Ftipmat, Mlist, Glist, \
|
||||||
using matplotlib and random libraries.
|
using matplotlib and random libraries.
|
||||||
|
|
||||||
Example Input:
|
Example Input:
|
||||||
|
from __future__ import print_function
|
||||||
|
import numpy as np
|
||||||
from modern_robotics import JointTrajectory
|
from modern_robotics import JointTrajectory
|
||||||
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])
|
||||||
#Initialise robot description (Example with 3 links)
|
# Initialize robot description (Example with 3 links)
|
||||||
g = np.array([0, 0, -9.8])
|
g = np.array([0, 0, -9.8])
|
||||||
M01 = np.array([[1, 0, 0, 0],
|
M01 = np.array([[1, 0, 0, 0],
|
||||||
[0, 1, 0, 0],
|
[0, 1, 0, 0],
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue