Tesseract 0.28.4
Loading...
Searching...
No Matches
tesseract::collision::PerThreadContactManager< ManagerT > Class Template Reference

One contact manager per calling thread, all cloned from one configured prototype. More...

#include <per_thread_contact_manager.h>

Public Types

using Ptr = std::shared_ptr<PerThreadContactManager<ManagerT>>
using ConstPtr = std::shared_ptr<const PerThreadContactManager<ManagerT>>
using UPtr = std::unique_ptr<PerThreadContactManager<ManagerT>>
using ConstUPtr = std::unique_ptr<const PerThreadContactManager<ManagerT>>

Public Member Functions

 PerThreadContactManager (std::unique_ptr< const ManagerT > prototype)
 Take ownership of a configured prototype.
 PerThreadContactManager (const PerThreadContactManager &)=delete
PerThreadContactManager & operator= (const PerThreadContactManager &)=delete
 PerThreadContactManager (PerThreadContactManager &&)=delete
PerThreadContactManager & operator= (PerThreadContactManager &&)=delete
ManagerT & get () const
 The calling thread's manager, cloned from the prototype on this thread's first call.
std::size_t size () const
 The number of managers cloned so far: one per thread that has called get().

Detailed Description

template<typename ManagerT>
class tesseract::collision::PerThreadContactManager< ManagerT >

One contact manager per calling thread, all cloned from one configured prototype.

A contact manager is not thread safe: a contact test reads the transforms the last setCollisionObjectsTransform wrote. Code that may be called from several threads at once (a motion planner's collision evaluators, state validators, edge evaluators) holds one of these instead of a manager, and calls get() to obtain the calling thread's own manager.

  • The prototype is configured once, before construction, and is never handed out or used for a contact test.
  • A thread's manager is cloned from the prototype on that thread's first call to get(), keyed by std::thread::id.
  • Managers live until this object is destroyed. A thread that is given the id of a thread that has exited reuses that thread's manager, which is safe because no two live threads share an id.
  • A thread's manager keeps the state that thread left in it, such as object transforms. Callers set every transform they rely on before each contact test.
Template Parameters
ManagerTDiscreteContactManager or ContinuousContactManager

Constructor & Destructor Documentation

◆ PerThreadContactManager()

template<typename ManagerT>
tesseract::collision::PerThreadContactManager< ManagerT >::PerThreadContactManager ( std::unique_ptr< const ManagerT > prototype)
inlineexplicit

Take ownership of a configured prototype.

Parameters
prototypeThe manager every thread's manager is cloned from
Exceptions
std::invalid_argumentif prototype is null

Member Function Documentation

◆ get()

template<typename ManagerT>
ManagerT & tesseract::collision::PerThreadContactManager< ManagerT >::get ( ) const
inline

The calling thread's manager, cloned from the prototype on this thread's first call.

Thread safe. The returned manager is only ever returned to the calling thread.