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

CollisionDetection.h

Go to the documentation of this file.
00001 
00002 //
00003 //       Title           : CollisionDetection.h
00004 //       Project         : OSCAR
00005 //       Created         : April 14, 2007
00006 //       Author          : Jonathan Knoll
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         : Class to provide collision detection capabilities to an OSCAR Workcell.
00027 //
00028 //
00029 //----------------------------------------------------------------------------
00030 //
00031 //       $Revisions$
00032 //
00033 //       $Log: CollisionDetection.h,v $
00034 //       
00035 //
00036 //
00038 
00039 #ifndef CollisionDetection_h
00040 #define CollisionDetection_h
00041 
00042 #include "Workcell.hpp"
00043 //#include <utility>
00044 //#include <vector>
00045 
00046 #if defined _SOLID
00047 #include "solid-3.5/include/SOLID.h"
00048 DT_Bool CollisionCallback(void *client_data, void *object1, void *object2, const DT_CollData *coll_data);
00049 #endif
00050 
00052 namespace OSCAR {
00053 
00054   class CollisionPoint;
00055 
00060   class CollisionDetection : public Base {
00061   public:
00062 
00063     enum ResponseType { WITNESSED, DEPTH };
00076     CollisionDetection(WorkCell* workcell, ResponseType type=WITNESSED, OSCARError& err=DUMMY_ERROR(noError), const String& name= String());
00077 
00081     virtual ~CollisionDetection();
00082 
00083     std::vector<CollisionPoint*>& GetCollisionPoints() { return collisionpoints; }
00084 
00085 
00089     void OutputCollisionPoints();
00090 
00091    
00092         
00093         
00094         bool CheckManipulatorSelfCollisions( String manip );
00095 
00100         bool CheckWorkcellCollisions();
00101 
00106         bool RemoveWorkcellCollisionPair( Polytope* obj1, Polytope* obj2 );
00107 
00108 
00113     bool AddWorkcellCollisionPair( Polytope* obj1, Polytope* obj2 );
00114 
00115     bool RemoveManipulatorCollisionPair( Polytope* obj1, Polytope* obj2, Node* manip );
00116 
00117     bool AddManipulatorCollisionPair( Polytope* obj1, Polytope* obj2, Node* manip );
00118 
00119     bool GetDistance( const Polytope& obj1, const Polytope& obj2, 
00120                       Vector3& obj1Wit, Vector3& obj2Wit, 
00121                       Vector3& unitVec, double& dist );
00122 
00123     ResponseType GetResponseType() {return resptype;}
00124 
00125 private:
00126 
00127   WorkCell*                                cell;
00128   std::vector< CollisionPoint* >           collisionpoints;
00129   DistanceCalculator                       distancecalculator;
00130   ResponseType                             resptype;
00131 #ifdef _SOLID
00132   DT_SceneHandle                           scene;
00133   DT_RespTableHandle                       globalRespTable;   // This response table tracks global collisions
00134   std::vector< std::pair<Node*,DT_RespTableHandle> > manipRespTables;   // These response tables track the manipulator self-collisions
00135 
00141   CollisionDetection(const CollisionDetection& cd);
00142 
00147   CollisionDetection& operator= (const CollisionDetection& cd);
00148 
00149   void AddEnvironmentPolytopes(Node* node);
00150 
00151   void AddManipulatorPolytopes(Node* node);
00152 
00153   bool RemoveManipulatorAttachmentCollisions(Node* currentnode, 
00154                                                Node* previousnode, 
00155                                                DT_RespTableHandle resptable);
00156 
00157    void RemoveNodePolytopes(Node* node);
00158 #endif
00159 
00160 };
00161 
00162 
00163         class CollisionPoint {
00164         public:
00165     CollisionPoint() {}
00166     CollisionPoint( const String& obj1, const String& obj2, const Vector3& pnt1, const Vector3& pnt2=Vector3() );
00167     ~CollisionPoint()   {}
00168     String GetObject1() const { return objname1; }
00169     String GetObject2() const { return objname2; }
00170     Vector3 GetPoint1() { return point1; }
00171     Vector3 GetPoint2() { return point2; }
00172     //the following are defined so we can use this class with STL algorithms
00173     bool operator<(const CollisionPoint& pt) const;
00174     bool IsSame(const CollisionPoint& pt) const;
00175 
00176         private:
00177                 String         objname1;
00178                 String         objname2;
00179                 Vector3        point1;
00180     Vector3        point2;  // note: point2 - point1 = normal, where point1 and point2 are penetration points
00181         };
00182 
00183 
00184 }  //namespace OSCAR
00185 #endif //CollisionDetection_h
RRG Homepage OSCAR Overview OSCAR Tutorials Simulations