iMSTK
Interactive Medical Simulation Toolkit
|
This class defines grasping of a PbdObject via different picking methods. Where grasping is define as grabbing & attaching of a PbdObject's mesh to points. More...
#include <imstkPbdObjectGrasping.h>
Public Types | |
enum | GraspMode { Vertex, Cell, RayPoint, RayCell } |
![]() | |
using | Observer = std::tuple< bool, std::weak_ptr< EventObject >, std::function< void(Event *)> > |
Public Member Functions | |
PbdObjectGrasping (std::shared_ptr< PbdObject > graspedObject, std::shared_ptr< PbdObject > grasperObject=nullptr) | |
Construct PbdObjectGrasping with a object to grasp and and optionally an object that does the grasping. Whilst grasping can work with any grasping criteria, if you want a two-way response you must supply an object to grasp with. | |
void | beginVertexGrasp (std::shared_ptr< AnalyticalGeometry > geometry) |
Begin a vertex grasp (picking will begin on the next update) More... | |
void | beginCellGrasp (std::shared_ptr< AnalyticalGeometry > geometry, std::string cdType="") |
Begin a cell grasp (picking will begin on the next update) Also works for rigid on rigid. More... | |
void | beginRayPointGrasp (std::shared_ptr< AnalyticalGeometry > geometry, const Vec3d &rayStart, const Vec3d &rayDir, const double maxDist=-1.0) |
Begin a ray point grasp (picking will begin on the next update) More... | |
void | beginRayCellGrasp (std::shared_ptr< AnalyticalGeometry > geometry, const Vec3d &rayStart, const Vec3d &rayDir, const double maxDist=-1.0) |
Begin a ray point grasp (picking will begin on the next update) More... | |
void | regrasp () |
if you already started a grasp, recalculates grasping points As the currently grasped points are already constrained to the object this will capture those point plus any new candidates | |
void | endGrasp () |
End a grasp (picking will end on next update) | |
void | addPickConstraints () |
Compute/generate the constraints for picking. | |
void | removePickConstraints () |
Remove the constraints for picking. | |
virtual void | addPointToPointConstraint (const std::vector< PbdParticleId > &ptsA, const std::vector< double > &weightsA, const std::vector< PbdParticleId > &ptsB, const std::vector< double > &weightsB, const double stiffnessA, const double stiffnessB) |
Add constraint between a point on each element given via barycentric coordinates pt position = weightA_0 * ptsA_0 + weightA_1 * ptsA_1 + ... | |
virtual void | addBodyToBodyConstraint (const PbdParticleId &graspedBodyId, const PbdParticleId &grasperBodyId, const Vec3d &pointOnBodies, const double compliance) |
Add 0 distance constraint between two points defined on two separate bodies. | |
virtual void | addPointToBodyConstraint (const PbdParticleId &graspedParticleId, const PbdParticleId &grasperBodyId, const Vec3d &pointOnBody, const double compliance) |
Add a 0 distance constraint between a deformable point and a point on a body. | |
void | setGeometryToPick (std::shared_ptr< Geometry > geomToPick, std::shared_ptr< PointwiseMap > map) |
Set a different geometry to pick with and a mapping back to the physics geometry to select the correct vertices. | |
std::shared_ptr< TaskNode > | getPickingNode () const |
void | initGraphEdges (std::shared_ptr< TaskNode > source, std::shared_ptr< TaskNode > sink) override |
Setup connectivity of the compute graph. | |
bool | hasConstraints () const |
Returns if any grasp constraints are present. | |
bool | getGraspState () const |
Returns true if currently grasping, else false. | |
void | setStiffness (const double stiffness) |
Set/Get the stiffness, 0-1 value that alters the step size in the solver. | |
double | getStiffness () const |
void | setCompliance (const double compliance) |
Set/Get the compliance. | |
double | getCompliance () const |
void | setPickingAlgorithm (std::shared_ptr< PickingAlgorithm > pickMethod) |
Get/Set the method use for picking, default is CellPicker. | |
std::shared_ptr< PickingAlgorithm > | getPickingAlgorithm () const |
![]() | |
SceneObject (const std::string &name="SceneObject") | |
std::shared_ptr< TaskGraph > | getTaskGraph () const |
Get the computational graph. | |
std::shared_ptr< Geometry > | getVisualGeometry () const |
Sets the visual geometry, adds (sets the first) VisualModel. | |
void | setVisualGeometry (std::shared_ptr< Geometry > geometry) |
std::shared_ptr< VisualModel > | getVisualModel (const int index) const |
Get/add visual model. | |
void | addVisualModel (std::shared_ptr< VisualModel > visualModel) |
void | removeVisualModel (std::shared_ptr< VisualModel > visualModel) |
std::shared_ptr< TaskNode > | getUpdateNode () const |
Returns the computational node for updating. | |
std::shared_ptr< TaskNode > | getUpdateGeometryNode () const |
Returns the computational node for updating geometry. | |
virtual void | update () |
Update the SceneObject, called during scene update. | |
virtual void | visualUpdate () |
Update the visuals, called before render. | |
virtual void | updateGeometries () |
Update the geometries. | |
virtual bool | initialize () |
Initialize the scene object. | |
void | initGraphEdges () |
Initializes the edges of the SceneObject's computational graph. | |
virtual void | reset () |
![]() | |
Entity (const std::string &name="Entity") | |
SIGNAL (Entity, modified) | |
EntityID | getID () const |
Get ID (ALWAYS query the ID in your code, DO NOT hardcode it) More... | |
virtual const std::string | getTypeName () const |
template<typename T > | |
std::shared_ptr< T > | addComponent () |
Create and return a component on this entity. | |
template<typename T > | |
std::shared_ptr< T > | addComponent (std::string name) |
void | addComponent (std::shared_ptr< Component > component) |
Add existing component to entity. | |
std::shared_ptr< Component > | getComponent (const unsigned int index) const |
Get a component by index. | |
template<typename T > | |
std::shared_ptr< T > | getComponent () const |
Get the first component of type T. | |
template<typename T > | |
std::shared_ptr< T > | getComponentN (const int index) const |
Get's the Nth component of type T. | |
template<class T > | |
bool | containsComponent () const |
Check if contains component of type T. | |
bool | containsComponent (std::shared_ptr< Component > component) const |
Check if contains given component. | |
template<typename T > | |
std::vector< std::shared_ptr< T > > | getComponents () const |
Get all components of type T. | |
const std::vector< std::shared_ptr< Component > > & | getComponents () |
void | removeComponent (std::shared_ptr< Component > component) |
Remove component if it exists. | |
const std::string & | getName () const |
Get/Set the name of the entity. | |
void | setName (const std::string &name) |
![]() | |
template<typename T > | |
void | postEvent (const T &e) |
Emits the event Direct observers will be immediately called, in sync Queued observers will receive the Command in their queue for later execution, reciever must implement doEvent. | |
template<typename T > | |
void | queueEvent (const T &e) |
Queues event directly to this. | |
void | doEvent () |
Do an event, if none exists return. | |
void | doAllEvents () |
Do all the events in the event queue. | |
void | foreachEvent (std::function< void(Command cmd)> func) |
Thread safe loop over all event commands, one can implement a custom handler. | |
void | rforeachEvent (std::function< void(Command cmd)> func) |
thread safe reverse loop over all event commands, one can implement a custom handler | |
void | clearEvents () |
Removes all events from queue cleans up copies of the event. | |
Protected Member Functions | |
virtual void | updatePicking () |
Update picking state, this should move grasp points. | |
void | updateConstraints () |
Update the constraints used for picking. | |
![]() | |
virtual void | postModifiedAll () |
Posts modified for all geometries. | |
Protected Attributes | |
std::shared_ptr< TaskNode > | m_pickingNode = nullptr |
std::shared_ptr< Geometry > | m_geomToPick = nullptr |
std::shared_ptr< PointwiseMap > | m_geometryToPickMap = nullptr |
std::shared_ptr< PbdObject > | m_objectToGrasp = nullptr |
std::shared_ptr< PbdObject > | m_grasperObject = nullptr |
std::shared_ptr< AnalyticalGeometry > | m_graspGeom = nullptr |
std::shared_ptr< PickingAlgorithm > | m_pickMethod = nullptr |
GraspMode | m_graspMode = GraspMode::Cell |
bool | m_isGrasping = false |
bool | m_regrasp = false |
Add grasped points to the current grasp. | |
bool | m_isPrevGrasping = false |
double | m_stiffness = 0.4 |
double | m_compliance = 0.0001 |
std::vector< std::tuple< PbdParticleId, Vec3d > > | m_constraintPts |
Vec of virtual particle grasp point ids, and local positions when grasped. | |
std::vector< std::shared_ptr< PbdConstraint > > | m_constraints |
List of PBD constraints. | |
![]() | |
std::shared_ptr< TaskGraph > | m_taskGraph = nullptr |
Computational Graph. | |
![]() | |
std::vector< std::shared_ptr< Component > > | m_components |
EntityID | m_ID |
unique ID of entity | |
std::string | m_name |
Not unique name. | |
![]() | |
ParallelUtils::SpinLock | eventQueueLock |
std::deque< Command > | eventQueue |
std::vector< std::pair< std::string, std::vector< Observer > > > | queuedObservers |
std::vector< std::pair< std::string, std::vector< Observer > > > | directObservers |
Additional Inherited Members | |
![]() | |
static std::atomic< EntityID > | m_count { 0 } |
current count of entities | |
This class defines grasping of a PbdObject via different picking methods. Where grasping is define as grabbing & attaching of a PbdObject's mesh to points.
Given an input PickData the appropriate grasping will be produced.
Definition at line 32 of file imstkPbdObjectGrasping.h.
void imstk::PbdObjectGrasping::beginCellGrasp | ( | std::shared_ptr< AnalyticalGeometry > | geometry, |
std::string | cdType = "" |
||
) |
Begin a cell grasp (picking will begin on the next update) Also works for rigid on rigid.
Geometry | attached/grasped too |
The | intersection type/class name |
Definition at line 247 of file imstkPbdObjectGrasping.cpp.
void imstk::PbdObjectGrasping::beginRayCellGrasp | ( | std::shared_ptr< AnalyticalGeometry > | geometry, |
const Vec3d & | rayStart, | ||
const Vec3d & | rayDir, | ||
const double | maxDist = -1.0 |
||
) |
Begin a ray point grasp (picking will begin on the next update)
Geometry | attached/grasped too |
Global | space ray start |
Global | space ray direction |
Definition at line 284 of file imstkPbdObjectGrasping.cpp.
void imstk::PbdObjectGrasping::beginRayPointGrasp | ( | std::shared_ptr< AnalyticalGeometry > | geometry, |
const Vec3d & | rayStart, | ||
const Vec3d & | rayDir, | ||
const double | maxDist = -1.0 |
||
) |
Begin a ray point grasp (picking will begin on the next update)
Geometry | attached/grasped too |
Global | space ray start |
Global | space ray direction |
Definition at line 271 of file imstkPbdObjectGrasping.cpp.
void imstk::PbdObjectGrasping::beginVertexGrasp | ( | std::shared_ptr< AnalyticalGeometry > | geometry | ) |
Begin a vertex grasp (picking will begin on the next update)
Geometry | attached/grasped too |
Definition at line 234 of file imstkPbdObjectGrasping.cpp.
|
protected |
Stiffness of grasp, when 1 the position is completely moved too the grasp point when stiffness < 1 it will slowly converge on the grasp point
Definition at line 218 of file imstkPbdObjectGrasping.h.