Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
SurgSim::Physics::PhysicsManager Class Reference

PhyicsManager handles the physics and motion calculation, it uses Computations to separate the algorithmic steps into smaller pieces. More...

#include <SurgSim/Physics/PhysicsManager.h>

Inheritance diagram for SurgSim::Physics::PhysicsManager:
SurgSim::Framework::ComponentManager SurgSim::Framework::BasicThread SurgSim::Testing::MockPhysicsManager

Public Member Functions

 PhysicsManager ()
 Constructor. More...
 
virtual ~PhysicsManager ()
 
virtual int getType () const override
 Overrides ComponentManager::getType() More...
 
void getFinalState (SurgSim::Physics::PhysicsManagerState *s) const
 Get the last PhysicsManagerState from the previous PhysicsManager update. More...
 
void addExcludedCollisionPair (std::shared_ptr< SurgSim::Collision::Representation > representation1, std::shared_ptr< SurgSim::Collision::Representation > representation2)
 Add an excluded collision pair to the Physics Manager. More...
 
void removeExcludedCollisionPair (std::shared_ptr< SurgSim::Collision::Representation > representation1, std::shared_ptr< SurgSim::Collision::Representation > representation2)
 Remove an excluded collision pair to the Physics Manager. More...
 
- Public Member Functions inherited from SurgSim::Framework::ComponentManager
 ComponentManager (const std::string &name="Unknown Component Manager")
 
virtual ~ComponentManager ()
 
bool enqueueAddComponent (const std::shared_ptr< Component > &component)
 Queues a component to be added later. More...
 
bool enqueueRemoveComponent (const std::shared_ptr< Component > &component)
 Queues a component to be removed. More...
 
std::shared_ptr< RuntimegetRuntime () const
 
void setRuntime (std::shared_ptr< Runtime > val)
 
- Public Member Functions inherited from SurgSim::Framework::BasicThread
 BasicThread (const std::string &name="Unknown Thread")
 
virtual ~BasicThread () noexcept(false)
 C++11 introduced noexcept. More...
 
void start (std::shared_ptr< Barrier > startupBarrier=nullptr, bool isSynchronous=false)
 C++11 introduced noexcept. More...
 
void stop ()
 Stopping the execution, blocks until the running thread has actually stopped,. More...
 
void setIdle (bool isIdle)
 Set/Unset the thread in an idle state (doUpdate() called or not in the update() method) More...
 
bool isIdle ()
 Query if this thread is in idle state or not. More...
 
bool isInitialized ()
 Query if this object is initialized. More...
 
bool isRunning () const
 Query if this object is running. More...
 
void operator() ()
 This is what boost::thread executes on thread creation. More...
 
boost::thread & getThread ()
 
std::string getName () const
 
void setRate (double val)
 Set the update rate of the thread. More...
 
bool setSynchronous (bool val)
 Sets the thread to synchronized execution in concert with the startup barrier, the startup barrier has to exist for this call to succeed. More...
 
bool isSynchronous ()
 Query if this object is synchronized. More...
 

Protected Member Functions

void initializeComputations (bool copyState)
 
bool executeAdditions (const std::shared_ptr< SurgSim::Framework::Component > &component) override
 
bool executeRemovals (const std::shared_ptr< SurgSim::Framework::Component > &component) override
 
virtual bool doInitialize () override
 
virtual bool doStartUp () override
 
virtual bool doUpdate (double dt) override
 
- Protected Member Functions inherited from SurgSim::Framework::ComponentManager
template<class T >
std::shared_ptr< T > tryAddComponent (std::shared_ptr< SurgSim::Framework::Component > component, std::vector< std::shared_ptr< T >> *container)
 Template version of the addComponent method. More...
 
template<class T >
bool tryRemoveComponent (std::shared_ptr< SurgSim::Framework::Component > component, std::vector< std::shared_ptr< T >> *container)
 Template version of the removeComponent method. More...
 
void processComponents ()
 Processes all the components that are scheduled for addition or removal, this needs to be called inside the doUpdate() function. More...
 
void processBehaviors (const double dt)
 Processes behaviors This needs to be called inside doUpdate() function in each 'sub' manager. More...
 
void copyScheduledComponents (std::vector< std::shared_ptr< Component >> *inflightAdditions, std::vector< std::shared_ptr< Component >> *inflightRemovals)
 Helper, blocks access to the additions and removal queue and copies the components from there to the intermediate inflight queues, after this call, the incoming queues will be empty. More...
 
std::shared_ptr< SurgSim::Framework::LoggergetLogger () const
 Returns this manager's logger. More...
 
- Protected Member Functions inherited from SurgSim::Framework::BasicThread
bool initialize ()
 Trigger the initialization of this object, this will be called before all other threads doStartup() are called. More...
 
bool startUp ()
 Trigger the startup of this object, this will be called after all other threads doInit() was called the thread will only enter the run loop triggering upated() if all threads doInit() and doStartup() returned true. More...
 
bool waitForBarrier (bool success)
 

Private Member Functions

std::vector< std::shared_ptr< SurgSim::Collision::CollisionPair > >::iterator findExcludedCollisionPair (std::shared_ptr< SurgSim::Collision::Representation > representation1, std::shared_ptr< SurgSim::Collision::Representation > representation2)
 Get an iterator to an excluded collision pair. More...
 

Private Attributes

std::vector< std::shared_ptr< Representation > > m_representations
 
std::vector< std::shared_ptr< SurgSim::Collision::Representation > > m_collisionRepresentations
 
std::vector< std::shared_ptr< ConstraintComponent > > m_constraintComponents
 
std::vector< std::shared_ptr< SurgSim::Collision::CollisionPair > > m_excludedCollisionPairs
 List of Collision::Representation pairs to be excluded from contact generation. More...
 
boost::mutex m_excludedCollisionPairMutex
 Mutex to protect m_excludedCollisionPairs from being read/written simultaneously. More...
 
SurgSim::Framework::LockedContainer< SurgSim::Physics::PhysicsManagerStatem_finalState
 A thread-safe copy of the last PhysicsManagerState in the previous update. More...
 
std::unique_ptr< PreUpdatem_preUpdateStep
 
std::unique_ptr< FreeMotionm_freeMotionStep
 
std::unique_ptr< DcdCollisionm_dcdCollisionStep
 
std::unique_ptr< ContactConstraintGenerationm_constraintGenerationStep
 
std::unique_ptr< BuildMlcpm_buildMlcpStep
 
std::unique_ptr< SolveMlcpm_solveMlcpStep
 
std::unique_ptr< PushResultsm_pushResultsStep
 
std::unique_ptr< PostUpdatem_postUpdateStep
 
std::unique_ptr< UpdateCollisionRepresentationsm_updateCollisionRepresentationsStep
 

Friends

class PhysicsManagerTest
 

Additional Inherited Members

- Protected Attributes inherited from SurgSim::Framework::ComponentManager
boost::mutex m_componentMutex
 Blocks protects addition and removal queues. More...
 
std::shared_ptr< SurgSim::Framework::Loggerm_logger
 Logger for this class. More...
 
std::vector< std::shared_ptr< SurgSim::Framework::Behavior > > m_behaviors
 Collection of behaviors. More...
 
std::vector< std::shared_ptr< Component > > m_componentAdditions
 
std::vector< std::shared_ptr< Component > > m_componentRemovals
 

Detailed Description

PhyicsManager handles the physics and motion calculation, it uses Computations to separate the algorithmic steps into smaller pieces.

Constructor & Destructor Documentation

SurgSim::Physics::PhysicsManager::PhysicsManager ( )

Constructor.

SurgSim::Physics::PhysicsManager::~PhysicsManager ( )
virtual

Member Function Documentation

void SurgSim::Physics::PhysicsManager::addExcludedCollisionPair ( std::shared_ptr< SurgSim::Collision::Representation representation1,
std::shared_ptr< SurgSim::Collision::Representation representation2 
)

Add an excluded collision pair to the Physics Manager.

The pair will not participate in collisions.

Parameters
representation1The first Collision::Representation for the pair
representation2The second Collision::Representation for the pair
bool SurgSim::Physics::PhysicsManager::doInitialize ( )
overrideprotectedvirtual

Overridden from BasicThread

Implements SurgSim::Framework::BasicThread.

Reimplemented in SurgSim::Testing::MockPhysicsManager.

bool SurgSim::Physics::PhysicsManager::doStartUp ( )
overrideprotectedvirtual

Overridden from BasicThread

Implements SurgSim::Framework::BasicThread.

Reimplemented in SurgSim::Testing::MockPhysicsManager.

bool SurgSim::Physics::PhysicsManager::doUpdate ( double  dt)
overrideprotectedvirtual

Overridden from BasicThread

Reimplemented from SurgSim::Framework::BasicThread.

Reimplemented in SurgSim::Testing::MockPhysicsManager.

bool SurgSim::Physics::PhysicsManager::executeAdditions ( const std::shared_ptr< SurgSim::Framework::Component > &  component)
overrideprotectedvirtual

Overridden from ComponentManager

Implements SurgSim::Framework::ComponentManager.

Reimplemented in SurgSim::Testing::MockPhysicsManager.

bool SurgSim::Physics::PhysicsManager::executeRemovals ( const std::shared_ptr< SurgSim::Framework::Component > &  component)
overrideprotectedvirtual

Overridden from ComponentManager

Implements SurgSim::Framework::ComponentManager.

Reimplemented in SurgSim::Testing::MockPhysicsManager.

std::vector< std::shared_ptr< SurgSim::Collision::CollisionPair > >::iterator SurgSim::Physics::PhysicsManager::findExcludedCollisionPair ( std::shared_ptr< SurgSim::Collision::Representation representation1,
std::shared_ptr< SurgSim::Collision::Representation representation2 
)
private

Get an iterator to an excluded collision pair.

Note
Lock m_excludedCollisionPairMutex before calling
Parameters
representation1The first Collision::Representation for the pair
representation2The second Collision::Representation for the pair
Returns
If the pair is found, an iterator to the excluded collision pair; otherwise an iterator to the container's past-the-end element.
void SurgSim::Physics::PhysicsManager::getFinalState ( SurgSim::Physics::PhysicsManagerState s) const

Get the last PhysicsManagerState from the previous PhysicsManager update.

Parameters
[out]spointer to an allocated PhysicsManagerState object.
Warning
The state contains many pointers. The objects pointed to are not thread-safe.
int SurgSim::Physics::PhysicsManager::getType ( ) const
overridevirtual

Overrides ComponentManager::getType()

Implements SurgSim::Framework::ComponentManager.

void SurgSim::Physics::PhysicsManager::initializeComputations ( bool  copyState)
protected
void SurgSim::Physics::PhysicsManager::removeExcludedCollisionPair ( std::shared_ptr< SurgSim::Collision::Representation representation1,
std::shared_ptr< SurgSim::Collision::Representation representation2 
)

Remove an excluded collision pair to the Physics Manager.

The pair will not be excluded from collisions.

Parameters
representation1The first Collision::Representation for the pair
representation2The second Collision::Representation for the pair

Friends And Related Function Documentation

friend class PhysicsManagerTest
friend

Member Data Documentation

std::unique_ptr<BuildMlcp> SurgSim::Physics::PhysicsManager::m_buildMlcpStep
private

Steps to perform the physics update

std::vector<std::shared_ptr<SurgSim::Collision::Representation> > SurgSim::Physics::PhysicsManager::m_collisionRepresentations
private
std::vector<std::shared_ptr<ConstraintComponent> > SurgSim::Physics::PhysicsManager::m_constraintComponents
private
std::unique_ptr<ContactConstraintGeneration> SurgSim::Physics::PhysicsManager::m_constraintGenerationStep
private

Steps to perform the physics update

std::unique_ptr<DcdCollision> SurgSim::Physics::PhysicsManager::m_dcdCollisionStep
private

Steps to perform the physics update

boost::mutex SurgSim::Physics::PhysicsManager::m_excludedCollisionPairMutex
private

Mutex to protect m_excludedCollisionPairs from being read/written simultaneously.

std::vector<std::shared_ptr<SurgSim::Collision::CollisionPair> > SurgSim::Physics::PhysicsManager::m_excludedCollisionPairs
private

List of Collision::Representation pairs to be excluded from contact generation.

SurgSim::Framework::LockedContainer<SurgSim::Physics::PhysicsManagerState> SurgSim::Physics::PhysicsManager::m_finalState
private

A thread-safe copy of the last PhysicsManagerState in the previous update.

std::unique_ptr<FreeMotion> SurgSim::Physics::PhysicsManager::m_freeMotionStep
private

Steps to perform the physics update

std::unique_ptr<PostUpdate> SurgSim::Physics::PhysicsManager::m_postUpdateStep
private

Steps to perform the physics update

std::unique_ptr<PreUpdate> SurgSim::Physics::PhysicsManager::m_preUpdateStep
private

Steps to perform the physics update

std::unique_ptr<PushResults> SurgSim::Physics::PhysicsManager::m_pushResultsStep
private

Steps to perform the physics update

std::vector<std::shared_ptr<Representation> > SurgSim::Physics::PhysicsManager::m_representations
private
std::unique_ptr<SolveMlcp> SurgSim::Physics::PhysicsManager::m_solveMlcpStep
private

Steps to perform the physics update

std::unique_ptr<UpdateCollisionRepresentations> SurgSim::Physics::PhysicsManager::m_updateCollisionRepresentationsStep
private

Steps to perform the physics update


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