Drake
Model Class Referenceabstract

#include <drake/systems/plants/collision/Model.h>

Inheritance diagram for Model:
Collaboration diagram for Model:

Public Member Functions

 Model ()
 
virtual ~Model ()
 
virtual ElementId addElement (const Element &element)
 Add a collision element to this model. More...
 
bool removeElement (const ElementId &id)
 
virtual const ElementreadElement (ElementId id) const
 Get a read-only pointer to a collision element in this model. More...
 
virtual void getTerrainContactPoints (ElementId id0, Eigen::Matrix3Xd &terrain_points)
 
virtual void updateModel ()=0
 Perform any operations needed to bring the model up-to-date after making changes to its collision elements. More...
 
virtual bool updateElementWorldTransform (const ElementId id, const Eigen::Isometry3d &T_local_to_world)
 Change the element-to-world transform of a specified collision element. More...
 
virtual bool closestPointsAllToAll (const std::vector< ElementId > &ids_to_check, const bool use_margins, std::vector< PointPair > &closest_points)=0
 Compute the points of closest approach between all eligible pairs of collision elements drawn from a specified set of elements. More...
 
virtual bool ComputeMaximumDepthCollisionPoints (const bool use_margins, std::vector< PointPair > &closest_points)=0
 Computes the point of closest approach between collision elements that are in contact. More...
 
virtual bool closestPointsPairwise (const std::vector< ElementIdPair > &id_pairs, const bool use_margins, std::vector< PointPair > &closest_points)=0
 Compute the points of closest approach between specified pairs of collision elements. More...
 
virtual void ClearCachedResults (bool use_margins)=0
 Clears possibly cached results so that a fresh computation can be performed. More...
 
virtual void collisionDetectFromPoints (const Eigen::Matrix3Xd &points, bool use_margins, std::vector< PointPair > &closest_points)=0
 Compute closest distance from each point to any surface in the collision model utilizing Bullet's collision detection code. More...
 
virtual std::vector< PointPairpotentialCollisionPoints (bool use_margins)=0
 Compute the set of potential collision points for all eligible pairs of collision geometries in this model. More...
 
virtual std::vector< size_t > collidingPoints (const std::vector< Eigen::Vector3d > &input_points, double collision_threshold)=0
 Given a vector of points in world coordinates, returns the indices of those points within a specified distance of any collision geometry in the model. More...
 
virtual bool collidingPointsCheckOnly (const std::vector< Eigen::Vector3d > &input_points, double collision_threshold)=0
 Tests if any of the points supplied in input_points collides with any part of the model within a given threshold. More...
 
virtual bool collisionRaycast (const Eigen::Matrix3Xd &origin, const Eigen::Matrix3Xd &ray_endpoint, bool use_margins, Eigen::VectorXd &distances, Eigen::Matrix3Xd &normals)=0
 Performs raycasting collision detecting (like a LIDAR / laser rangefinder) More...
 
virtual bool transformCollisionFrame (const DrakeCollision::ElementId &eid, const Eigen::Isometry3d &transform_body_to_joint)
 Modifies a collision element's local transform to be relative to a joint's frame rather than a link's frame. More...
 

Protected Attributes

std::unordered_map< ElementId, std::unique_ptr< Element > > elements
 

Friends

DRAKECOLLISION_EXPORT std::ostream & operator<< (std::ostream &, const Model &)
 A toString method for this class. More...
 

Constructor & Destructor Documentation

Model ( )
inline
virtual ~Model ( )
inlinevirtual

Here is the call graph for this function:

Member Function Documentation

ElementId addElement ( const Element element)
virtual

Add a collision element to this model.

Parameters
elementthe collision element to be added to this model
Returns
an ElementId that uniquely identifies the added element within this model

Reimplemented in BulletModel.

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void ClearCachedResults ( bool  use_margins)
pure virtual

Clears possibly cached results so that a fresh computation can be performed.

Parameters
use_margins[in]If true, the cache of the model with margins is cleared. If false, the cache of the model without margins is cleared.

Depending on the implementation, the collision model may cache results on each dispatch. For instance, Bullet uses cached results to warm-start its LCP solvers.

Clearing cached results allows the collision model to perform a fresh computation without any coupling with previous history.

See also
drake/systems/plants/collision/test/model_test.cc.

Implemented in BulletModel.

virtual bool closestPointsAllToAll ( const std::vector< ElementId > &  ids_to_check,
const bool  use_margins,
std::vector< PointPair > &  closest_points 
)
pure virtual

Compute the points of closest approach between all eligible pairs of collision elements drawn from a specified set of elements.

Parameters
ids_to_checkthe vector of ElementId for which the all-to-all collision detection should be performed
use_marginsflag indicating whether or not to use the version of this model with collision margins
[out]closest_pointsreference to a vector of PointPair objects that contains the closest point information after this method is called
Returns
true if this method ran successfully

Implemented in BulletModel.

virtual bool closestPointsPairwise ( const std::vector< ElementIdPair > &  id_pairs,
const bool  use_margins,
std::vector< PointPair > &  closest_points 
)
pure virtual

Compute the points of closest approach between specified pairs of collision elements.

Parameters
id_pairsvector of ElementIdPair specifying which pairs of elements to consider
use_marginsflag indicating whether or not to use the version of this model with collision margins
[out]closest_pointsreference to a vector of PointPair objects that contains the closest point information after this method is called
Returns
true if this method ran successfully

Implemented in BulletModel.

virtual std::vector<size_t> collidingPoints ( const std::vector< Eigen::Vector3d > &  input_points,
double  collision_threshold 
)
pure virtual

Given a vector of points in world coordinates, returns the indices of those points within a specified distance of any collision geometry in the model.

In other words, this method tests if a sphere of radius collision_threshold located at input_points[i] collides with any part of the model. The result is returned as a vector of indexes in input_points that do collide with the model. Points are not checked against one another but only against the existing model.

Parameters
input_pointsThe list of points to check for collisions against the model.
collision_thresholdThe radius of a control sphere around each point used to check for collisions with the model.
Returns
A vector with indexes in input_points of all those points that do collide with the model within the specified threshold.
See also
systems/plants/test/collidingPointsTest.m for a Matlab test.

Implemented in BulletModel.

virtual bool collidingPointsCheckOnly ( const std::vector< Eigen::Vector3d > &  input_points,
double  collision_threshold 
)
pure virtual

Tests if any of the points supplied in input_points collides with any part of the model within a given threshold.

In other words, this method tests if any of the spheres of radius collision_threshold located at input_points[i] collides with any part of the model. This method returns as soon as any of these spheres collides with the model. Points are not checked against one another but only against the existing model.

Parameters
input_pointsThe list of points to check for collisions against the model.
collision_thresholdThe radius of a control sphere around each point used to check for collisions with the model.
Returns
true if any of the points positively checks for collision. false otherwise.

Implemented in BulletModel.

virtual void collisionDetectFromPoints ( const Eigen::Matrix3Xd &  points,
bool  use_margins,
std::vector< PointPair > &  closest_points 
)
pure virtual

Compute closest distance from each point to any surface in the collision model utilizing Bullet's collision detection code.

Parameters
pointsMatrix of points computing distance from.
use_marginsflag indicating whether or not to use the version of this model with collision margins
[out]closest_pointsa vector of PointPair objects containing the signed distances

Implemented in BulletModel.

virtual bool collisionRaycast ( const Eigen::Matrix3Xd &  origin,
const Eigen::Matrix3Xd &  ray_endpoint,
bool  use_margins,
Eigen::VectorXd &  distances,
Eigen::Matrix3Xd &  normals 
)
pure virtual

Performs raycasting collision detecting (like a LIDAR / laser rangefinder)

Parameters
origin3 x N matrix in which each column specifies the position of a ray's origin in world coordinates. if origin is 3x1, then the same origin is used for all raycasts
ray_endpoint3 x N matrix in which each column specifies a second point on the corresponding ray
use_marginsflag indicating whether or not to use the version of this model with collision margins
[out]distanceto the first collision, or -1 on no collision
Returns
true if this method ran successfully

Implemented in BulletModel.

virtual bool ComputeMaximumDepthCollisionPoints ( const bool  use_margins,
std::vector< PointPair > &  closest_points 
)
pure virtual

Computes the point of closest approach between collision elements that are in contact.

Parameters
[in]use_marginsIf true the model uses the representation with margins. If false, the representation without margins is used instead.
[out]closest_pointsreference to a vector of PointPair objects that contains the closest point information after this method is called.
Returns
true if this method ran successfully and false otherwise.

Implemented in BulletModel.

void getTerrainContactPoints ( ElementId  id0,
Eigen::Matrix3Xd &  terrain_points 
)
virtual

Here is the call graph for this function:

virtual std::vector<PointPair> potentialCollisionPoints ( bool  use_margins)
pure virtual

Compute the set of potential collision points for all eligible pairs of collision geometries in this model.

This includes the points of closest approach, but may also include additional points that are "close" to being in contact. This can be useful when simulating scenarios in which two collision elements have more than one point of contact.

Parameters
use_marginsflag indicating whether or not to use the version of this model with collision margins
Returns
a vector of PointPair objects containing the potential collision points

Implemented in BulletModel.

const Element * readElement ( ElementId  id) const
virtual

Get a read-only pointer to a collision element in this model.

Parameters
idan ElementId corresponding to the desired collision element
Returns
a read-only pointer to the collision element corresponding to the given id or nullptr if no such collision element is present in the model.
bool removeElement ( const ElementId id)
bool transformCollisionFrame ( const DrakeCollision::ElementId eid,
const Eigen::Isometry3d &  transform_body_to_joint 
)
virtual

Modifies a collision element's local transform to be relative to a joint's frame rather than a link's frame.

This is necessary because Drake requires that link frames by defined by their parent joint frames.

Parameters
eidThe ID of the collision element to update.
transform_body_to_jointThe transform from the collision element's link's frame to the joint's coordinate frame.
trueif the collision element was successfully updated.
bool updateElementWorldTransform ( const ElementId  id,
const Eigen::Isometry3d &  T_local_to_world 
)
virtual

Change the element-to-world transform of a specified collision element.

Parameters
idan ElementId corresponding to the element to be updated
T_local_to_worldthe new value for the element-to-world transform

Reimplemented in BulletModel.

Here is the caller graph for this function:

virtual void updateModel ( )
pure virtual

Perform any operations needed to bring the model up-to-date after making changes to its collision elements.

Implemented in BulletModel.

Friends And Related Function Documentation

DRAKECOLLISION_EXPORT std::ostream& operator<< ( std::ostream &  os,
const Model model 
)
friend

A toString method for this class.

Member Data Documentation

std::unordered_map<ElementId, std::unique_ptr<Element> > elements
protected

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