RobWorkProject  23.9.11-
Public Member Functions | List of all members
Contact Class Reference

A common interface for the most important data for a contact. More...

#include <Contact.hpp>

Inherits Serializable.

Public Member Functions

 Contact ()
 Create new non-initialized contact.
 
virtual ~Contact ()
 Destruct contact.
 
rw::core::Ptr< ContactModelgetModelA () const
 Get the contact model for the first object. More...
 
rw::core::Ptr< ContactModelgetModelB () const
 Get the contact model for the second object. More...
 
const rw::kinematics::FramegetFrameA () const
 Get the frame for the first object. More...
 
const rw::kinematics::FramegetFrameB () const
 Get the frame for the second object. More...
 
const std::string & getNameA () const
 Get the name of the first object. More...
 
const std::string & getNameB () const
 Get the name of the second object. More...
 
rw::math::Transform3D aTb () const
 The relative transform between the two contact models. More...
 
rw::math::Vector3D getPointA () const
 The contact point on the first object. More...
 
rw::math::Vector3D getPointB () const
 The contact point on the second object. More...
 
rw::math::Vector3D getNormal () const
 The contact normal from the first object towards the second object. More...
 
double getDepth () const
 The penetration depth between the two objects. More...
 
void setModelA (rw::core::Ptr< ContactModel > modelA)
 Set the contact model for the first object. More...
 
void setModelB (rw::core::Ptr< ContactModel > modelB)
 Set the contact model for the second object. More...
 
void setFrameA (rw::core::Ptr< const rw::kinematics::Frame > frame)
 Set the frame for the first object. More...
 
void setFrameB (rw::core::Ptr< const rw::kinematics::Frame > frame)
 Set the frame for the second object. More...
 
void setNameA (const std::string &name)
 Set the name of the first object. More...
 
void setNameB (const std::string &name)
 Set the name of the second object. More...
 
bool setFrames (const rw::models::WorkCell &wc)
 Try to set the frame pointers by looking up names in workcell. More...
 
void setTransform (rw::math::Transform3D<> aTb)
 Set the relative transform from the first object to the second object. More...
 
void setPointA (rw::math::Vector3D<> pointA)
 Set the contact point on the first object. More...
 
void setPointB (rw::math::Vector3D<> pointB)
 Set the contact point on the second object. More...
 
void setPoints (rw::math::Vector3D<> pointA, rw::math::Vector3D<> pointB)
 Set the contact points on both objects at the same time. More...
 
void setNormal (rw::math::Vector3D<> normal)
 Set the normal from the first object to the second. More...
 
void setDepth ()
 Calculate penetration depth automatically. More...
 
void setDepth (double depth)
 Set the penetation depth. More...
 
bool operator== (const Contact &b) const
 Check if the contact is exactly the same as other contact. More...
 
bool operator!= (const Contact &b) const
 Check if the contact is different from other contact. More...
 
virtual void read (class rw::common::InputArchive &iarchive, const std::string &id)
 
virtual void write (class rw::common::OutputArchive &oarchive, const std::string &id) const
 
- Public Member Functions inherited from Serializable
virtual ~Serializable ()
 destructor
 

Detailed Description

A common interface for the most important data for a contact.

A contact is given by the two points in contact, a normal, and a depth. Furthermore the contact is generated by a contact strategy, which will use two internal contact models for the geometries in contact. The relative transformation between these contact models is also used to define the contact.

Member Function Documentation

◆ aTb()

rw::math::Transform3D aTb ( ) const

The relative transform between the two contact models.

Returns
the relative transform.

◆ getDepth()

double getDepth ( ) const

The penetration depth between the two objects.

Returns
the penetration depth, positive if penetrating, negative if separated.

◆ getFrameA()

const rw::kinematics::Frame* getFrameA ( ) const

Get the frame for the first object.

Returns
pointer to the frame.

◆ getFrameB()

const rw::kinematics::Frame* getFrameB ( ) const

Get the frame for the second object.

Returns
pointer to the frame.

◆ getModelA()

rw::core::Ptr<ContactModel> getModelA ( ) const

Get the contact model for the first object.

Returns
contact model specific to the strategy that created the contact.

◆ getModelB()

rw::core::Ptr<ContactModel> getModelB ( ) const

Get the contact model for the second object.

Returns
contact model specific to the strategy that created the contact.

◆ getNameA()

const std::string& getNameA ( ) const

Get the name of the first object.

Returns
the name.

◆ getNameB()

const std::string& getNameB ( ) const

Get the name of the second object.

Returns
the name.

◆ getNormal()

rw::math::Vector3D getNormal ( ) const

The contact normal from the first object towards the second object.

Returns
the contact normal.

◆ getPointA()

rw::math::Vector3D getPointA ( ) const

The contact point on the first object.

Returns
the contact point.

◆ getPointB()

rw::math::Vector3D getPointB ( ) const

The contact point on the second object.

Returns
the contact point.

◆ operator!=()

bool operator!= ( const Contact b) const

Check if the contact is different from other contact.

Parameters
b[in] the contact to compare with.
Returns
true if different, false if equal.

◆ operator==()

bool operator== ( const Contact b) const

Check if the contact is exactly the same as other contact.

Parameters
b[in] the contact to compare with.
Returns
true if equal, false if not.

◆ read()

virtual void read ( class rw::common::InputArchive iarchive,
const std::string &  id 
)
virtual

Enable read-serialization of inherited class by implementing this method. Data is read from iarchive and filled into this object.

Parameters
iarchive[in] the InputArchive from which to read data.
id[in] The id of the serialized sobject.
Note
the id can be empty in which case the overloaded method should provide a default identifier. E.g. the Vector3D class defined "Vector3D" as its default id.

Implements Serializable.

◆ setDepth() [1/2]

void setDepth ( )

Calculate penetration depth automatically.

Will calculate the penetration depth from the contact points and the normal.

◆ setDepth() [2/2]

void setDepth ( double  depth)
inline

Set the penetation depth.

Parameters
depth[in] penetration depth. Positive if penetrating, negative if separated.

◆ setFrameA()

void setFrameA ( rw::core::Ptr< const rw::kinematics::Frame frame)

Set the frame for the first object.

Parameters
frame[in] a pointer to the frame.

◆ setFrameB()

void setFrameB ( rw::core::Ptr< const rw::kinematics::Frame frame)

Set the frame for the second object.

Parameters
frame[in] a pointer to the frame.

◆ setFrames()

bool setFrames ( const rw::models::WorkCell wc)

Try to set the frame pointers by looking up names in workcell.

Note that frame pointers will only be set if both frames can be found. The function returns false if no change has been done.

Parameters
wc[in] the workcell.
Returns
true if both frames found, or false otherwise.

◆ setModelA()

void setModelA ( rw::core::Ptr< ContactModel modelA)
inline

Set the contact model for the first object.

Parameters
modelA[in] contact model specific for the contact strategy that generates the contact.

◆ setModelB()

void setModelB ( rw::core::Ptr< ContactModel modelB)
inline

Set the contact model for the second object.

Parameters
modelB[in] contact model specific for the contact strategy that generates the contact.

◆ setNameA()

void setNameA ( const std::string &  name)

Set the name of the first object.

Note
This will remove the pointer to frame A.
Parameters
name[in] the name.

◆ setNameB()

void setNameB ( const std::string &  name)

Set the name of the second object.

Note
This will remove the pointer to frame B.
Parameters
name[in] the name.

◆ setNormal()

void setNormal ( rw::math::Vector3D<>  normal)
inline

Set the normal from the first object to the second.

Parameters
normal[in] contact normal.

◆ setPointA()

void setPointA ( rw::math::Vector3D<>  pointA)
inline

Set the contact point on the first object.

Parameters
pointA[in] contact point.

◆ setPointB()

void setPointB ( rw::math::Vector3D<>  pointB)
inline

Set the contact point on the second object.

Parameters
pointB[in] contact point.

◆ setPoints()

void setPoints ( rw::math::Vector3D<>  pointA,
rw::math::Vector3D<>  pointB 
)

Set the contact points on both objects at the same time.

Parameters
pointA[in] contact point on A.
pointB[in] contact point on B.

◆ setTransform()

void setTransform ( rw::math::Transform3D<>  aTb)
inline

Set the relative transform from the first object to the second object.

Parameters
aTb[in] the relative transform.

◆ write()

virtual void write ( class rw::common::OutputArchive oarchive,
const std::string &  id 
) const
virtual

Enable write-serialization of inherited class by implementing this method. Data is written to oarchive from this object.

Parameters
oarchive[out] the OutputArchive in which data should be written.
id[in] The id of the serialized sobject.
Note
the id can be empty in which case the overloaded method should provide a default identifier. E.g. the Vector3D class defined "Vector3D" as its default id.

Implements Serializable.


The documentation for this class was generated from the following file: