dart
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
dart::simulation::World Class Reference

class World More...

#include <World.hpp>

Inheritance diagram for dart::simulation::World:
Inheritance graph
[legend]
Collaboration diagram for dart::simulation::World:
Collaboration graph
[legend]

Public Types

using NameChangedSignal = common::Signal< void(const std::string &_oldName, const std::string &_newName)>
 

Public Member Functions

 World (const std::string &_name="world")
 Constructor.
 
virtual ~World ()
 Destructor.
 
std::shared_ptr< Worldclone () const
 Create a clone of this World. More...
 
const std::string & setName (const std::string &_newName)
 Set the name of this World.
 
const std::string & getName () const
 Get the name of this World.
 
void setGravity (const Eigen::Vector3d &_gravity)
 Set gravity.
 
const Eigen::Vector3d & getGravity () const
 Get gravity.
 
void setTimeStep (double _timeStep)
 Set time step.
 
double getTimeStep () const
 Get time step.
 
dynamics::SkeletonPtr getSkeleton (std::size_t _index) const
 Get the indexed skeleton.
 
dynamics::SkeletonPtr getSkeleton (const std::string &_name) const
 Find a Skeleton by name. More...
 
std::size_t getNumSkeletons () const
 Get the number of skeletons.
 
std::string addSkeleton (const dynamics::SkeletonPtr &_skeleton)
 Add a skeleton to this world.
 
void removeSkeleton (const dynamics::SkeletonPtr &_skeleton)
 Remove a skeleton from this world.
 
std::set< dynamics::SkeletonPtr > removeAllSkeletons ()
 Remove all the skeletons in this world, and return a set of shared pointers to them, in case you want to recycle them.
 
bool hasSkeleton (const dynamics::ConstSkeletonPtr &skeleton) const
 Returns whether this World contains a Skeleton.
 
bool hasSkeleton (const std::string &skeletonName) const
 Returns whether this World contains a Skeleton named skeletonName.
 
int getIndex (int _index) const
 Get the dof index for the indexed skeleton.
 
dynamics::SimpleFramePtr getSimpleFrame (std::size_t _index) const
 Get the indexed Entity.
 
dynamics::SimpleFramePtr getSimpleFrame (const std::string &_name) const
 Find an Entity by name.
 
std::size_t getNumSimpleFrames () const
 Get the number of Entities.
 
std::string addSimpleFrame (const dynamics::SimpleFramePtr &_frame)
 Add an Entity to this world.
 
void removeSimpleFrame (const dynamics::SimpleFramePtr &_frame)
 Remove a SimpleFrame from this world.
 
std::set< dynamics::SimpleFramePtr > removeAllSimpleFrames ()
 Remove all SimpleFrames in this world, and return a set of shared pointers to them, in case you want to recycle them.
 
bool checkCollision (bool checkAllCollisions)
 Deprecated. Please use checkCollision(~) instead.
 
bool checkCollision (const collision::CollisionOption &option=collision::CollisionOption(false, 1u, nullptr), collision::CollisionResult *result=nullptr)
 Perform collision checking with 'option' over all the feasible collision pairs in this World, and the result will be stored 'result'. More...
 
const collision::CollisionResultgetLastCollisionResult () const
 Return the collision checking result of the last simulation step. More...
 
void reset ()
 Reset the time, frame counter and recorded histories.
 
void step (bool _resetCommand=true)
 Calculate the dynamics and integrate the world for one step. More...
 
void setTime (double _time)
 Set current time.
 
double getTime () const
 Get current time.
 
int getSimFrames () const
 Get the number of simulated frames. More...
 
void setConstraintSolver (dynamics::UniqueConstraintSolverPtr solver)
 Sets the constraint solver. More...
 
dynamics::ConstraintSolvergetConstraintSolver ()
 Get the constraint solver.
 
const dynamics::ConstraintSolvergetConstraintSolver () const
 Get the constraint solver.
 
void bake ()
 Bake simulated current state and store it into mRecording.
 
RecordinggetRecording ()
 Get recording.
 
- Public Member Functions inherited from dart::common::Subject
virtual ~Subject ()
 Destructor will notify all Observers that it is destructing.
 

Static Public Member Functions

template<typename... Args>
static WorldPtr create (Args &&... args)
 Creates World as shared_ptr.
 
static std::shared_ptr< Worldcreate (const std::string &name="world")
 Creates a World.
 

Public Attributes

common::SlotRegister< NameChangedSignalonNameChanged
 

Protected Member Functions

void handleSkeletonNameChange (const dynamics::ConstMetaSkeletonPtr &_skeleton)
 Register when a Skeleton's name is changed.
 
void handleSimpleFrameNameChange (const dynamics::Entity *_entity)
 Register when a SimpleFrame's name is changed.
 
- Protected Member Functions inherited from dart::common::Subject
void sendDestructionNotification () const
 Send a destruction notification to all Observers. More...
 
void addObserver (Observer *_observer) const
 Add an Observer to the list of Observers.
 
void removeObserver (Observer *_observer) const
 Remove an Observer from the list of Observers.
 

Protected Attributes

std::string mName
 Name of this World.
 
std::vector< dynamics::SkeletonPtr > mSkeletons
 Skeletons in this world.
 
std::map< dynamics::ConstMetaSkeletonPtr, dynamics::SkeletonPtr > mMapForSkeletons
 
std::vector< common::ConnectionmNameConnectionsForSkeletons
 Connections for noticing changes in Skeleton names TODO(MXG): Consider putting this functionality into NameManager.
 
dart::common::NameManager< dynamics::SkeletonPtr > mNameMgrForSkeletons
 NameManager for keeping track of Skeletons.
 
std::vector< dynamics::SimpleFramePtr > mSimpleFrames
 Entities in this world.
 
std::vector< common::ConnectionmNameConnectionsForSimpleFrames
 Connections for noticing changes in Frame names TODO(MXG): Consider putting this functionality into NameManager.
 
std::map< const dynamics::SimpleFrame *, dynamics::SimpleFramePtr > mSimpleFrameToShared
 Map from raw SimpleFrame pointers to their shared_ptrs.
 
dart::common::NameManager< dynamics::SimpleFramePtr > mNameMgrForSimpleFrames
 NameManager for keeping track of Entities.
 
std::vector< int > mIndices
 The first indeices of each skeleton's dof in mDofs. More...
 
Eigen::Vector3d mGravity
 Gravity.
 
double mTimeStep
 Simulation time step.
 
double mTime
 Current simulation time.
 
int mFrame
 Current simulation frame number.
 
std::unique_ptr< dynamics::ConstraintSolvermConstraintSolver
 Constraint solver.
 
RecordingmRecording
 
NameChangedSignal mNameChangedSignal
 
- Protected Attributes inherited from dart::common::Subject
std::set< Observer * > mObservers
 List of current Observers.
 

Detailed Description

class World

Member Function Documentation

◆ checkCollision()

bool dart::simulation::World::checkCollision ( const collision::CollisionOption option = collision::CollisionOption(false, 1u, nullptr),
collision::CollisionResult result = nullptr 
)

Perform collision checking with 'option' over all the feasible collision pairs in this World, and the result will be stored 'result'.

If no argument is passed in then it will return just whether there is collision or not without the contact information such as contact point, normal, and penetration depth.

◆ clone()

WorldPtr dart::simulation::World::clone ( ) const

Create a clone of this World.

All Skeletons and SimpleFrames that are held by this World will be copied over.

◆ getLastCollisionResult()

const collision::CollisionResult & dart::simulation::World::getLastCollisionResult ( ) const

Return the collision checking result of the last simulation step.

If this world hasn't stepped forward yet, then the result would be empty. Note that this function does not return the collision checking result of World::checkCollision().

◆ getSimFrames()

int dart::simulation::World::getSimFrames ( ) const

Get the number of simulated frames.

TODO(MXG): I think the name of this function is much too similar to getSimpleFrame()

◆ getSkeleton()

dynamics::SkeletonPtr dart::simulation::World::getSkeleton ( const std::string &  _name) const

Find a Skeleton by name.

Parameters
[in]_nameThe name of the Skeleton you are looking for.
Returns
If the skeleton does not exist then return nullptr.

◆ setConstraintSolver()

void dart::simulation::World::setConstraintSolver ( dynamics::UniqueConstraintSolverPtr  solver)

Sets the constraint solver.

Note that the internal properties of solver will be overwritten by this World.

◆ step()

void dart::simulation::World::step ( bool  _resetCommand = true)

Calculate the dynamics and integrate the world for one step.

Parameters
[in]_resetCommandTrue if you want to reset to zero the joint command after simulation step.

Member Data Documentation

◆ mIndices

std::vector<int> dart::simulation::World::mIndices
protected

The first indeices of each skeleton's dof in mDofs.

For example, if this world has three skeletons and their dof are 6, 1 and 2 then the mIndices goes like this: [0 6 7].


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