Commit 54bb6af6 authored by florent's avatar florent Committed by florent
Browse files

Copy implementation of class ChppBody from hppModel

  * include/hppModel/hppModel/hppBody.h,
  * src/hppBody.cpp.
parent 4830b2d9
......@@ -12,25 +12,46 @@
INCLUDE
**************************************/
#include "KineoWorks2/kwsInterface.h"
#include "KineoUtility/kitDefine.h"
#include "KineoUtility/kitInterface.h"
#include "kcd2/kcdInterface.h"
#include "KineoWorks2/kwsKCDBody.h"
#include "kcd2/kcdAnalysisType.h"
#include "kwsKcd2/kwsKCDBody.h"
#include "KineoModel/kppSolidComponentRef.h"
KIT_PREDEF_CLASS(ChppBody);
KIT_PREDEF_CLASS(CkcdObject);
KIT_PREDEF_CLASS(CkppSolidComponentRef);
class CkitMat4;
/*************************************
CLASS
**************************************/
/**
\brief This class represents bodies (solid components attached to a joint). It derives from
KineoWorks CkwsKCDBody class. In order to store more information, we have derived CkwsKCDBody class.
A name is given at the creation of the body (ChppBody::create(std::string inName)).
The constructor is protected and method create returns a shared pointer to the device.
\sa Smart pointers documentation: http://www.boost.org/libs/smart_ptr/smart_ptr.htm
\brief This class represents bodies (geometric objects attached to a joint).
It derives from KineoWorks CkwsKCDBody class and from an implementation of
CjrlJoint.
Objects attached to a body (called inner objects) are used for collision
checking with selected objects of the environment (called outer objects).
To attach an object to the body, call addInnerObject(). To select an object
for collision checking with the body, call addOuterObject().
Distances between pairs of inner objects and outer objects can also
be computed. Setting <code>inDistanceComputation</code> to true in
addInnerObject() or addOuterObject() specifies that distances should
be computed for these objects. Each pair of such specified (inner,
outer) objects gives rise to one distance computation when calling
distAndPairsOfPoints(). The number of such pairs can be retrieved by
calling nbDistPairs(). distAndPairsOfPoints() also returns distances
and pairs of closest points for each computed pair.
The constructor is protected and method create returns a shared
pointer to the device.
\sa Smart pointers documentation:
http://www.boost.org/libs/smart_ptr/smart_ptr.htm
*/
class ChppBody : public CkwsKCDBody
......@@ -49,156 +70,131 @@ public:
const std::string& name() {return attName;};
/**
\name Collision lists
\name Define inner and outer objects
@{
*/
/**
\brief Attach objects to the body.
\param inInnerObjects list of objects to attach to the body
\brief Add a geometric object to the body
\param inSolidComponentRef Reference to the solid component to add.
\param inPosition Position of the object before attaching it to the body
(default value=Identity).
\param inDistanceComputation whether this object should be put in the
distance computation analysis.
Previous objects if any are detached.
\return true if success, false otherwise.
Objects are put in the left test tree of attExactAnalyzer for exact distance computation.
*/
The object is added to the inner object list of the body.
void setInnerObjects (const std::vector< CkcdObjectShPtr > &inInnerObjects);
\note The body must be attached to a joint.
*/
bool addInnerObject(const CkppSolidComponentRefShPtr& inSolidComponentRef,
const CkitMat4& inPosition=CkitMat4(),
bool inDistanceComputation=false);
/**
\brief Attach objects to the body in specified position
\param inInnerObjects list of objects to attach to the body
\param inPlacementVector Vector of homogeneous matrix specifying the position of each object in inInnerObjects.
Previous objects if any are detached.
\brief Add an object for collision testing with the body
Objects are put in the left test tree of attExactAnalyzer for exact distance computation.
\param inOuterObject new object
\param inDistanceComputation whether distance analyses should be added for
this object.
*/
void setInnerObjects (const std::vector< CkcdObjectShPtr > &inInnerObjects,
const std::vector< CkitMat4 > &inPlacementVector);
void addOuterObject(const CkcdObjectShPtr& inOuterObject,
bool inDistanceComputation=true);
/**
\brief Defines the list of objects to be tested for collision with this body.
\param inOuterObjects list of objects to be tested for collision for this body
Previous objects if any are removed.
Objects are put in the right test tree of attExactAnalyzer for exact distance computation.
\brief Reset the list of outer objects
*/
void setOuterObjects (const std::vector< CkcdObjectShPtr > &inOuterObjects);
void resetOuterObjects();
/**
@}
*/
/**
\brief Add geometry to the body
\param inSolidComponentRef Reference to the solid component to add.
\param inPosition Position of the object before attaching it to the body (default value=Identity).
\return true if success, false otherwise.
The input solid component is dynamically cast into
\li a CkppKCDPolyhedron or
\li a CkppKCDAssembly
The object is then added to the inner object list of the body.
The collision analyser attExactAnalyzer is also updated.
\note The body must be attached to a joint.
/**
\name Distance computation
@{
*/
bool addSolidComponent(const CkppSolidComponentRefShPtr& inSolidComponentRef, const CkitMat4& inPosition=CkitMat4());
/**
\name Collision and distance computation
@{
\brief Get the number of pairs of object for which distance is computed
*/
inline unsigned int nbDistPairs() { return attDistCompPairs.size(); };
/**
\brief Compute exact distance and closest points between body and set of outer objects.
\param inPairId id of the pair of objects
\param inType Type of distance computation
(either CkcdAnalysisType::EXACT_DISTANCE or
CkcdAnalysisType::ESTIMATED_DISTANCE)
\retval outDistance Distance between body and outer objects
\retval outPointBody Closest point on body
\retval outPointEnv Closest point in outer object set
\retval outPointBody Closest point on body (in global reference frame)
\retval outPointEnv Closest point in outer object set (in global reference frame)
\retval outObjectBody Closest object on body
\retval outObjectEnv Closest object in outer object list
*/
ktStatus getExactDistance(double& outDistance, CkitPoint3& outPointBody, CkitPoint3& outPointEnv,
CkcdObjectShPtr &outObjectBody, CkcdObjectShPtr &outObjectEnv);
ktStatus distAndPairsOfPoints(unsigned int inPairId,
double& outDistance,
CkitPoint3& outPointBody,
CkitPoint3& outPointEnv,
CkcdObjectShPtr &outObjectBody,
CkcdObjectShPtr &outObjectEnv,
CkcdAnalysisType::Type inType=
CkcdAnalysisType::EXACT_DISTANCE);
/**
\brief Compute a lower bound of distance between body and set of outer objects.
\retval outDistance Distance between body and outer objects
\retval outPointBody Closest point on body
\retval outPointEnv Closest point in outer object set
\retval outObjectBody Closest object on body
\retval outObjectEnv Closest object in outer object list
@}
*/
ktStatus getEstimatedDistance(double &outDistance,
CkcdObjectShPtr &outObjectBody, CkcdObjectShPtr &outObjectEnv);
protected:
/**
\brief Compute the set of inner and outer objects that are in collision with each other.
\retval outNbCollision Number of pairs of objects in collision.
\retval outObjectBodyVector Vector of objects in collision of the body.
\retval outObjectEnvVector Vector of objects in collision in the outer object list.
\return Whether there is a collision.
\brief Constructor by name.
*/
bool getCollisionVec(unsigned int &outNbCollision, std::vector<CkcdObjectShPtr>& outObjectBodyVector,
std::vector<CkcdObjectShPtr>& outObjectEnvVector);
ChppBody(std::string inName), attName(inName) {};
/**
\brief Compute collision and return the two first objects found in collision.
\retval outNbCollision Number of pairs of object in collision found.
\retval outObjectBody First object of the body found in collision.
\retval outObjectEnv First object in the body outer list found in collision.
\brief Initialization of body
\return Whether there is a collision.
\param inBodyWkPtr weak pointer to itself
*/
bool getCollision(unsigned int& outNbCollision,
CkcdObjectShPtr &outObjectBody, CkcdObjectShPtr &outObjectEnv);
bool printCollisionStatus(const bool& detailInfoFlag = false);
void printCollisionStatusFast();
ktStatus init(const ChppBodyWkPtr inBodyWkPtr);
private:
/**
\brief Compute the minimum distance to the obstacle
\return the minimum distance to the obstacle
\brief Name of the body.
*/
double getMinDistance();
std::string attName;
/**
@}
\brief Set of inner objects for which distance computation is performed
*/
protected:
std::vector<CkcdObjectShPtr> attInnerObjForDist;
/**
\brief Constructor by name.
\brief Set of outer objects for which distance computation is performed
*/
ChppBody(std::string inName) : attName(inName) {};
std::vector<CkcdObjectShPtr> attOuterObjForDist;
/**
\brief Initialization of body
*/
ktStatus init(const ChppBodyWkPtr bodyWkPtr);
private:
\brief Collision analyses for this body
/**
\brief Name of the body.
Each pair (inner object, outer object) potentially defines an exact
distance analysis. Only inner objects specified in attDistanceObjects
define analyses.
*/
std::string attName;
std::vector<CkcdAnalysisShPtr> attDistCompPairs;
/**
\brief Collision analyser for this body
\brief Weak pointer to itself
*/
CkcdAnalysisShPtr attExactAnalyzer;
ChppBodyWkPtr attWeakPtr;
};
......
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment