scanr_transforms.py
Go to the documentation of this file.
00001 #
00002 # Copyright (c) 2010, Georgia Tech Research Corporation
00003 # All rights reserved.
00004 #
00005 # Redistribution and use in source and binary forms, with or without
00006 # modification, are permitted provided that the following conditions are met:
00007 #     * Redistributions of source code must retain the above copyright
00008 #       notice, this list of conditions and the following disclaimer.
00009 #     * Redistributions in binary form must reproduce the above copyright
00010 #       notice, this list of conditions and the following disclaimer in the
00011 #       documentation and/or other materials provided with the distribution.
00012 #     * Neither the name of the Georgia Tech Research Corporation nor the
00013 #       names of its contributors may be used to endorse or promote products
00014 #       derived from this software without specific prior written permission.
00015 #
00016 # THIS SOFTWARE IS PROVIDED BY GEORGIA TECH RESEARCH CORPORATION ''AS IS'' AND
00017 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00018 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00019 # DISCLAIMED. IN NO EVENT SHALL GEORGIA TECH BE LIABLE FOR ANY DIRECT, INDIRECT,
00020 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00021 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
00022 # OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00023 # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
00024 # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
00025 # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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     # @ Duke, res = np.array([0.8, 0.9, -1.7, 3.1, 0.061, 0.032, -0.035 ])
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 


clutter_segmentation
Author(s): Jason Okerman, Martin Schuster, Advisors: Prof. Charlie Kemp and Jim Regh, Lab: Healthcare Robotics Lab at Georgia Tech
autogenerated on Wed Nov 27 2013 12:07:15