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:

## Public Member Functions

| PhysicsManager ()
| Constructor. More...
virtual | ~PhysicsManager ()
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 | addComputation (std::shared_ptr< SurgSim::Physics::Computation > computation)
| Add a computation to the list of computations to perform each update. More...
void | setComputations (std::vector< std::shared_ptr< Physics::Computation >> computations)
| Set a group of computations, the computations will be run in the order in the vector. 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< Runtime > | getRuntime () 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...
double | getCpuTime () const
size_t | getUpdateCount () const
void | resetCpuTimeAndUpdateCount ()
| Reset the cpu time and the update count to 0. More...

## Protected Member Functions

bool | executeAdditions (const std::shared_ptr< SurgSim::Framework::Component > &component) override
| Adds a component. More...
bool | executeRemovals (const std::shared_ptr< SurgSim::Framework::Component > &component) override
| Handle representations, override for each thread. More...
bool | doInitialize () override
| Initialize the Physics Manager Derived class(es) should override this method to have a customized list of computations. More...
bool | doStartUp () override
bool | doUpdate (double dt) override
| Implementation of actual work function for this thread, this has a default implementation to handle destruction better, as it could be called while the thread is under destruction, if left unimplemented this would trigger a call to a pure virtual function. More...
void | doBeforeStop () override
| Prepares the thread for its execution to be stopped. More...
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, std::vector< std::shared_ptr< SceneElement >> *inflightElements)
| 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::Logger > | getLogger () const
| Returns this manager's logger. More...
template<class T >
void | retireComponents (const std::vector< std::shared_ptr< T >> &container)
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)

## Protected Attributes

std::vector< std::shared_ptr< Representation > > | m_representations
std::vector< std::shared_ptr< Collision::Representation > > | m_collisionRepresentations
std::vector< std::shared_ptr< Collision::ContactFilter > > | m_contactFilters
std::vector< std::shared_ptr< Particles::Representation > > | m_particleRepresentations
std::vector< std::shared_ptr< ConstraintComponent > > | m_constraintComponents
std::vector< std::shared_ptr< SurgSim::Physics::Computation > > | m_computations
| A list of computations, to perform the physics update. More...
SurgSim::Framework::LockedContainer< SurgSim::Physics::PhysicsManagerState > | m_finalState
| A thread-safe copy of the last PhysicsManagerState in the previous update. More...
Protected Attributes inherited from SurgSim::Framework::ComponentManager
boost::mutex | m_componentMutex
| Blocks protects addition and removal queues. 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
std::vector< std::shared_ptr< SceneElement > > | m_elementCache
Protected Attributes inherited from SurgSim::Framework::BasicThread
Timer | m_timer
| Timer to measure the actual time taken to doUpdate. More...
std::shared_ptr< SurgSim::Framework::Logger > | m_logger
| Logger for this thread. More...

## Friends

class | PhysicsManagerTest

## Detailed Description

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

The PhysicsManager pipeline can be configured, using the addComputation/setComputaton method.

## Constructor & Destructor Documentation

## PhysicsManager()

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

Constructor.

## ~PhysicsManager()

SurgSim::Physics::PhysicsManager::~PhysicsManager | ( |  | ) |

virtual

## Member Function Documentation

## addComputation()

void SurgSim::Physics::PhysicsManager::addComputation | ( | std::shared_ptr< SurgSim::Physics::Computation > | computation | ) |

Add a computation to the list of computations to perform each update.

Note
  The computations will be run in order they were added. This can't be done after initialization

Parameters

  computation | The Computation to add.

## doBeforeStop()

void SurgSim::Physics::PhysicsManager::doBeforeStop | ( |  | ) |

override protected virtual

Prepares the thread for its execution to be stopped.

Note
  Called from this thread before joined

Reimplemented from SurgSim::Framework::ComponentManager.

## doInitialize()

bool SurgSim::Physics::PhysicsManager::doInitialize | ( |  | ) |

override protected virtual

Initialize the Physics Manager Derived class(es) should override this method to have a customized list of computations.

Note
  Current default is to only use DCD contacts

See also
  SurgSim::Physics::Computation

Implements SurgSim::Framework::BasicThread.

Reimplemented in SurgSim::Testing::MockPhysicsManager.

## doStartUp()

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

override protected virtual

Implements SurgSim::Framework::BasicThread.

Reimplemented in SurgSim::Testing::MockPhysicsManager.

## doUpdate()

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

override protected virtual

Implementation of actual work function for this thread, this has a default implementation to handle destruction better, as it could be called while the thread is under destruction, if left unimplemented this would trigger a call to a pure virtual function.

Returns
  false when the thread is done, this will stop execution

Reimplemented from SurgSim::Framework::BasicThread.

Reimplemented in SurgSim::Testing::MockPhysicsManager.

## executeAdditions()

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

override protected virtual

Adds a component.

Parameters

  component | The component to be added.

Returns
  true if the component was scheduled for addition, this does not indicate that the component will actually be added to this manager.

Implements SurgSim::Framework::ComponentManager.

Reimplemented in SurgSim::Testing::MockPhysicsManager.

## executeRemovals()

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

override protected virtual

Handle representations, override for each thread.

Parameters

  component | The component to be removed.

Returns
  true if the component was scheduled for removal, this does not indicate that the component will actually be removed from this manager.

Implements SurgSim::Framework::ComponentManager.

Reimplemented in SurgSim::Testing::MockPhysicsManager.

## getFinalState()

void SurgSim::Physics::PhysicsManager::getFinalState | ( | SurgSim::Physics::PhysicsManagerState * | s | ) | const

Get the last PhysicsManagerState from the previous PhysicsManager update.

Parameters

  [out] | s | pointer to an allocated PhysicsManagerState object.

Warning
  The state contains many pointers. The objects pointed to are not thread-safe.

## getType()

int SurgSim::Physics::PhysicsManager::getType | ( |  | ) | const

override virtual

Overrides ComponentManager::getType()

Implements SurgSim::Framework::ComponentManager.

## setComputations()

void SurgSim::Physics::PhysicsManager::setComputations | ( | std::vector< std::shared_ptr< Physics::Computation >> | computations | ) |

Set a group of computations, the computations will be run in the order in the vector.

Note
  this can't be done after initialization

Parameters

  computations | The computations that you want to set on the physics manager

## Friends And Related Function Documentation

## PhysicsManagerTest

friend class PhysicsManagerTest

friend

## Member Data Documentation

## m_collisionRepresentations

std::vector<std::shared_ptr<Collision::Representation> > SurgSim::Physics::PhysicsManager::m_collisionRepresentations

protected

## m_computations

std::vector<std::shared_ptr<SurgSim::Physics::Computation> > SurgSim::Physics::PhysicsManager::m_computations

protected

A list of computations, to perform the physics update.

## m_constraintComponents

std::vector<std::shared_ptr<ConstraintComponent> > SurgSim::Physics::PhysicsManager::m_constraintComponents

protected

## m_contactFilters

std::vector<std::shared_ptr<Collision::ContactFilter> > SurgSim::Physics::PhysicsManager::m_contactFilters

protected

## m_finalState

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

protected

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

## m_particleRepresentations

std::vector<std::shared_ptr<Particles::Representation> > SurgSim::Physics::PhysicsManager::m_particleRepresentations

protected

## m_representations

std::vector<std::shared_ptr<Representation> > SurgSim::Physics::PhysicsManager::m_representations

protected

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

- SurgSim/Physics/PhysicsManager.h
- SurgSim/Physics/PhysicsManager.cpp