00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 import numpy as np, math
00029 import roslib; roslib.load_manifest('hrl_lib')
00030 import hrl_lib.transforms as tr
00031
00032
00033
00034 def residualXform( residuals ):
00035 '''
00036 residuals are np.array([ Rz2, Rx, Rz1, dx, dy, dz ])
00037 returns rotResid, dispResid
00038 '''
00039 rotResid = tr.Rz( residuals[0] ) * tr.Rx( residuals[1] ) * tr.Rz( residuals[2] )
00040 dispResid = np.matrix([ residuals[3], residuals[4], residuals[5] ]).T
00041 return rotResid, dispResid
00042
00043 def camTlaser( res = np.zeros(7) ):
00044
00045 rot = tr.Ry( math.radians( 0.0 + res[0] )) * tr.Rz( math.radians( 0.0 + res[1] )) * tr.Rx( math.radians( -90.0 + res[2] )) * tr.Rz( math.radians( -90.0 + res[3]))
00046 disp = np.matrix([ res[4], res[5], res[6] ]).T + np.matrix([ 0.0, 0.0, 0.0 ]).T
00047 return tr.composeHomogeneousTransform(rot, disp)
00048
00049 def rollTtool_pointer( residuals = np.zeros(6) ):
00050 rotResid, dispResid = residualXform( residuals )
00051 rot = rotResid * tr.Rz( math.radians( -10.0 ))
00052 disp = dispResid + np.matrix([ 0.008, 0.0, 0.0 ]).T
00053 return tr.composeHomogeneousTransform(rot, disp)
00054
00055 def rollTtool_MA( residuals = np.zeros(6) ):
00056 rotResid, dispResid = residualXform( residuals )
00057 rot = rotResid * tr.Ry( math.radians( -90.0 ))
00058 disp = dispResid + np.matrix([ 0.0476, 0.0, 0.0 ]).T
00059 return tr.composeHomogeneousTransform(rot, disp)
00060
00061
00062 def panTroll(rollAng, residuals = np.zeros(6) ):
00063 rotResid, dispResid = residualXform( residuals )
00064 rot = rotResid * tr.Rx( -1.0 * rollAng )
00065 disp = dispResid + np.matrix([0.02021, 0.0, 0.04236 ]).T
00066 return tr.composeHomogeneousTransform(rot, disp)
00067
00068 def tiltTpan(panAng, residuals = np.zeros(6) ):
00069 rotResid, dispResid = residualXform( residuals )
00070 rot = rotResid * tr.Rz( -1.0 * panAng )
00071 disp = dispResid + np.matrix([ 0.07124, 0.0, 0.02243 ]).T
00072 return tr.composeHomogeneousTransform(rot, disp)
00073
00074 def laserTtilt(tiltAng, residuals = np.zeros(6) ):
00075 rotResid, dispResid = residualXform( residuals )
00076 rot = rotResid * tr.Ry( +1.0 * tiltAng )
00077 disp = dispResid + np.matrix([ 0.03354, 0.0, 0.23669 ]).T
00078 return tr.composeHomogeneousTransform(rot, disp)
00079
00080 def laserTtool_pointer(rollAng, panAng, tiltAng, residuals = np.zeros([4,6])):
00081 '''
00082 This is specifically for the off-axis laser pointer! Tool coordinate frame will change for each tool.
00083 Here, residuals are 4x6 array where:
00084 res[0] = rollTtool
00085 res[1] = panTroll
00086 res[2] = tiltTpan
00087 res[3] = laserTtilt
00088 '''
00089 res = residuals
00090 return laserTtilt(tiltAng, res[3] ) * tiltTpan(panAng, res[2] ) * panTroll(rollAng, res[1] ) * rollTtool_pointer(res[0])
00091
00092 def tool_pointerTlaser(rollAng, panAng, tiltAng, residuals = np.zeros([4,6])):
00093 return tr.invertHomogeneousTransform( laserTtool_pointer(rollAng, panAng, tiltAng, residuals) )
00094
00095
00096 def laserTtool_MA(rollAng, panAng, tiltAng, residuals = np.zeros([4,6])):
00097 '''
00098 This is specifically for the multi-antenna (MA) tool attachment! Tool coordinate frame will change for each tool.
00099 Here, residuals are 4x6 array where:
00100 res[0] = rollTtool
00101 res[1] = panTroll
00102 res[2] = tiltTpan
00103 res[3] = laserTtilt
00104 '''
00105 res = residuals
00106 return laserTtilt(tiltAng, res[3] ) * tiltTpan(panAng, res[2] ) * panTroll(rollAng, res[1] ) * rollTtool_MA(res[0])
00107
00108 def tool_MATlaser(rollAng, panAng, tiltAng, residuals = np.zeros([4,6])):
00109 return tr.invertHomogeneousTransform( laserTtool_MA(rollAng, panAng, tiltAng, residuals) )
00110