$search
00001 /* 00002 * Copyright (c) 2011, Thomas Ruehr <ruehr@cs.tum.edu> 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 * 00008 * * Redistributions of source code must retain the above copyright 00009 * notice, this list of conditions and the following disclaimer. 00010 * * Redistributions in binary form must reproduce the above copyright 00011 * notice, this list of conditions and the following disclaimer in the 00012 * documentation and/or other materials provided with the distribution. 00013 * * Neither the name of Willow Garage, Inc. nor the names of its 00014 * contributors may be used to endorse or promote products derived from 00015 * this software without specific prior written permission. 00016 * 00017 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00018 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00019 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00020 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00021 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00022 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00023 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00024 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00025 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00026 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00027 * POSSIBILITY OF SUCH DAMAGE. 00028 */ 00029 00031 00032 #ifndef __GEOMETRY_H__ 00033 #define __GEOMETRY_H__ 00034 00035 #include <ros/ros.h> 00036 00037 #include <tf/transform_listener.h> 00038 00039 class Geometry 00040 { 00041 private: 00042 00043 static tf::TransformListener *listener_; 00044 00045 static Geometry *instance; 00046 00047 Geometry(); 00048 00049 ~Geometry(); 00050 00051 public: 00052 00053 static Geometry* getInstance() 00054 { 00055 if (!instance)instance = new Geometry(); 00056 return instance; 00057 } 00058 00059 static void init(); 00060 00061 //scales the transform, e.g. scale .10 = apply returned transform 10 times on the right side to get the same result as applying in once 00062 static tf::Stamped<tf::Pose> scaleStampedPose(const tf::Stamped<tf::Pose> &in, double scale); 00063 static tf::Stamped<tf::Pose> scaleStampedTransform(const tf::Stamped<tf::Pose> &in, double scale); 00064 00065 static tf::Stamped<tf::Pose> getPoseIn(const char target_frame[], tf::Stamped<tf::Pose> src); 00066 00067 static void printPose(const tf::Stamped<tf::Pose> &toolTargetPose); 00068 00069 static tf::Stamped<tf::Pose> getPose(const char target_frame[],const char lookup_frame[]); 00070 00071 static tf::Stamped<tf::Pose> getRelativeTransform(const char source_frameid[], const char target_frameid[]); 00072 00073 static tf::Stamped<tf::Pose> getTransform(const char baseframe[], const char toolframe[]); 00074 00075 static tf::Stamped<tf::Pose> rotateAroundBaseAxis(tf::Stamped<tf::Pose> toolPose, double r_x,double r_y,double r_z); 00076 static tf::Stamped<tf::Pose> rotateAroundToolframeAxis(tf::Stamped<tf::Pose> toolPose, double r_x,double r_y,double r_z); 00077 static tf::Stamped<tf::Pose> rotateAroundPose(tf::Stamped<tf::Pose> toolPose, tf::Stamped<tf::Pose> pivot, double r_x, double r_y, double r_z); 00078 static tf::Stamped<tf::Pose> rotateAroundPose(tf::Stamped<tf::Pose> toolPose, tf::Stamped<tf::Pose> pivot, btQuaternion qa); 00079 00080 static tf::Stamped<tf::Pose> approach(tf::Stamped<tf::Pose> toolPose, double dist = 0.1); 00081 00082 static tf::Stamped<tf::Pose> make_pose(double x, double y, double z, double ox, double oy, double oz, double ow, const char target_frame[]); 00083 00084 static tf::Stamped<tf::Pose> make_pose(const btTransform &trans, const char target_frame[]); 00085 00086 // given relative pose is relative to the root_frame, return its pose in the frame the root frame is defined in 00087 static tf::Stamped<tf::Pose> getRel(const tf::Stamped<tf::Pose> &root_frame, const tf::Stamped<tf::Pose> &relative_pose); 00088 00089 static tf::Stamped<tf::Pose> getRelInBase(const tf::Stamped<tf::Pose> &root_frame, const btVector3 &dist); 00090 00091 static void printPose(const char title[], tf::Stamped<tf::Pose> pose); 00092 00093 00094 }; 00095 00096 00097 #endif