Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

DistanceCalculator.hpp

Go to the documentation of this file.
00001 
00002 //
00003 //       Title           : DistanceCalculator.hpp
00004 //       Project         : D&D Demos
00005 //       Created         : Jan 20, 1997
00006 //       Author          : Ethan Swint, Andrew Spencer
00007 //       Platforms       :
00008 //       Copyright       : Copyright© The University of Texas at Austin, 2002. All rights reserved.
00009 //                 
00010 //          This software and documentation constitute an unpublished work
00011 //          and contain valuable trade secrets and proprietary information
00012 //          belonging to the University. None of the foregoing material may be
00013 //          copied or duplicated or disclosed without the express, written
00014 //          permission of University. THE UNIVERSITY EXPRESSLY DISCLAIMS ANY
00015 //          AND ALL WARRANTIES CONCERNING THIS SOFTWARE AND DOCUMENTATION,
00016 //          INCLUDING ANY WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00017 //          PARTICULAR PURPOSE, AND WARRANTIES OF PERFORMANCE, AND ANY WARRANTY
00018 //          THAT MIGHT OTHERWISE ARISE FROM COURSE OF DEALING OR USAGE OF TRADE.
00019 //          NO WARRANTY IS EITHER EXPRESS OR IMPLIED WITH RESPECT TO THE USE OF
00020 //          THE SOFTWARE OR DOCUMENTATION. Under no circumstances shall the
00021 //          University be liable for incidental, special, indirect, direct or
00022 //          consequential damages or loss of profits, interruption of business,
00023 //          or related expenses which may arise from use of software or documentation,
00024 //          including but not limited to those resulting from defects in software
00025 //          and/or documentation, or loss or inaccuracy of data of any kind.
00026 //       Purpose         : Container  to hold obstacle information.
00027 //
00028 //
00029 //----------------------------------------------------------------------------
00030 //
00031 //       $Revisions$
00032 //
00033 //       $Log: DistanceCalculator.hpp,v $
00034 //       Revision 1.8  2007/04/23 06:04:05  jknoll
00035 //       Added #include for Polytope.h
00036 //
00037 //       Revision 1.7  2007/03/30 20:41:27  aspencer
00038 //       Changed obstacle avoidance criteria to use the new node structure as the basis for its modeling.
00039 //
00040 //       Revision 1.6  2006/04/09 20:47:59  mitch
00041 //       moved Dhat from ipp (inline) to cpp file
00042 //
00043 //       Revision 1.5  2005/07/13 20:22:33  aspencer
00044 //       Made three Vector3's member variables so that they wouldn't have to be created every time a node-node distance calculation was performed.
00045 //
00046 //       Revision 1.4  2005/06/23 21:28:43  josh
00047 //       Fixed bugs in CalcDist between two nodes. Changed method signatures in DistanceResults.
00048 //
00049 //       Revision 1.3  2005/06/21 15:54:52  aspencer
00050 //       Changed workcell calcdist function so that it now uses a DistanceCalculator object.
00051 //
00052 //       Revision 1.2  2005/06/20 22:38:33  aspencer
00053 //       Added the distance calculator, and tested it. Accounted for a bug in the SOLID software.
00054 //
00055 //       Revision 1.1  2005/06/15 21:53:16  aspencer
00056 //       Initial Commit
00057 //
00058 //
00059 //
00061 
00062 #ifndef DistanceCalculator_h
00063 #define DistanceCalculator_h
00064 
00065 #ifdef _MSC_VER
00066         #pragma warning (disable: 4786)
00067 #endif //_MSC_VER
00068 
00069 #include "DistanceResults.hpp"
00070 #include "Node.hpp"
00071 #include "GeometricFunctions.hpp"
00072 #include "Cylisphere.hpp"
00073 #include "Sphere.hpp"
00074 #include "Plane.hpp"
00075 #include "Cone.hpp"
00076 #include "Box.hpp"
00077 #include "Polytope.h"
00078 
00079 #include "ForwardKinematics/FKAcceleration.h"
00080 #include <set>
00081 
00082 namespace OSCAR {
00083 
00084 class DistanceResults;
00085 
00095 class DistanceCalculator : public Base {
00096 public:
00097 
00107   DistanceCalculator(const String& name= String(), OSCARError& err=DUMMY_ERROR(noError));
00108 
00109   virtual ~DistanceCalculator();
00110 
00111 
00119   virtual bool CalcDist(const Node& from, const Node& to, 
00120                 DistanceResults& results, bool checkSelf = false,
00121                                                                 const std::set<const ModelingObject*>& ignoreSet = std::set<const ModelingObject*>());
00122                   
00134   bool CalcDist(const Primitive& from, const Primitive& to,
00135     Vector3& fromWit, Vector3& toWit,
00136     Vector3& unitVec, double& dist);
00137 
00141 
00156   virtual bool CalcGFunctions(const Node& from, const Node& to, 
00157     DistanceResults& results, FKVelocity* fromFK, bool checkSelf = false,
00158                 const std::set<const ModelingObject*>& ignoreSet = std::set<const ModelingObject*>());
00159 
00176   virtual bool CalcHFunctions(const Node& from, const Node& to, 
00177     DistanceResults& results, FKAcceleration* fromFK, bool checkSelf = false,
00178                 const std::set<const ModelingObject*>& ignoreSet = std::set<const ModelingObject*>());
00179 
00193   bool CalcGFunction(const Primitive& from, const Primitive& to,
00194     DistanceResults& results, FKVelocity* fromFK, unsigned int fromFrame);
00195 
00210   bool CalcHFunction(const Primitive& from, const Primitive& to,
00211     DistanceResults& results, FKVelocity* fromFK, unsigned int fromFrame);
00212                 
00213 protected:
00214 
00215   unsigned int frameNumber; Matrix tempMat;
00216 
00217   Vector3 wit0, wit1, dHat; //Used as scratch Vector3's when doing calculations.
00218   Vector3 tempVec3; Vector3 secTempVec3;
00219 
00220   double sphereSphereDist(const Sphere& from, const Sphere& to,
00221     Vector3& fromWit, Vector3& toWit,
00222     Vector3& unitVec, double& dist);
00223 
00224   double spherePlaneDist(const Sphere& from, const Plane& to,
00225     Vector3& fromWit, Vector3& toWit,
00226     Vector3& unitVec, double& dist);
00227 
00228   double cylisphereCylisphereDist(const Cylisphere& from, const Cylisphere& to,
00229     Vector3& fromWit, Vector3& toWit,
00230     Vector3& unitVec, double& dist);
00231 
00232   double cylisphereSphereDist(const Cylisphere& from, const Sphere& to,
00233     Vector3& fromWit, Vector3& toWit,
00234     Vector3& unitVec, double& dist);
00235 
00236   double cylispherePlaneDist (const Cylisphere& from, const Plane& to,
00237     Vector3& fromWit, Vector3& toWit,
00238     Vector3& unitVec, double& dist,
00239     double& t1, double& t2);
00240 
00241   //note: the H functions are not complete and not currently functional.
00242 
00243   bool pointPointH(Vector3& robPt, Vector3& obstPt, const Primitive& robPrim, const Primitive& obstPrim,
00244                                          DistanceResults& results, double robRadius, double obstRadius, FKAcceleration* fromFK, unsigned int robotFrameNumber);
00245 
00246   bool linePointH(Vector3& robPt, Vector3& obstPt, const Primitive& robPrim, const Primitive& obstPrim,
00247                                          DistanceResults& results, double robRadius, double obstRadius, FKAcceleration* fromFK, unsigned int robotFrameNumber);
00248 
00249   bool lineLineH(Vector3& robPt, Vector3& obstPt, const Primitive& robPrim, const Primitive& obstPrim,
00250       DistanceResults& results, double robRadius, double obstRadius, FKAcceleration* fromFK, unsigned int robotFrameNumber);
00251 
00252   bool LinePlaneH();
00253                   
00254 };
00255 
00256 }  //namespace OSCAR
00257 #endif //DistanceCalculator_h
RRG Homepage OSCAR Overview OSCAR Tutorials Simulations