Moby
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Friends | List of all members
Moby::Simulator Class Reference

Simulator for both unarticulated and articulated rigid bodies without contact. More...

#include <Simulator.h>

Inheritance diagram for Moby::Simulator:
Moby::Base Moby::ConstraintSimulator Moby::TimeSteppingSimulator

Public Member Functions

 Simulator ()
 Sets up the simulator. More...
 
virtual double step (double step_size)
 Steps the Simulator forward in time without contact. More...
 
ControlledBodyPtr find_dynamic_body (const std::string &name) const
 Finds the dynamic body in the simulator, if any. More...
 
void add_dynamic_body (ControlledBodyPtr body)
 Adds a dynamic body to the simulator. More...
 
void remove_dynamic_body (ControlledBodyPtr body)
 Removes a dynamic body from the simulator.
 
void update_visualization ()
 Updates all visualization under the simulator.
 
virtual void save_to_xml (XMLTreePtr node, std::list< boost::shared_ptr< const Base > > &shared_objects) const
 Implements Base::save_to_xml()
 
virtual void load_from_xml (boost::shared_ptr< const XMLTree > node, std::map< std::string, BasePtr > &id_map)
 Implements Base::load_from_xml()
 
const std::vector
< ControlledBodyPtr > & 
get_dynamic_bodies () const
 Gets the list of dynamic bodies in the simulator. More...
 
void add_transient_vdata (osg::Node *vdata)
 Adds transient visualization data to the simulator.
 
osg::Node * get_persistent_vdata () const
 Gets the persistent visualization data.
 
osg::Node * get_transient_vdata () const
 Gets the transient (one-step) visualization data.
 
template<class ForwardIterator >
double integrate (double dt, ForwardIterator begin, ForwardIterator end)
 Integrates both position and velocity of rigid _bodies. More...
 
- Public Member Functions inherited from Moby::Base
 Base (const Base *b)
 

Public Attributes

double current_time
 The current simulation time.
 
boost::shared_ptr< Dissipationdissipator
 The dissipation mechanism for larger time steps.
 
void(* post_step_callback_fn )(Simulator *s)
 Callback function after a step is completed.
 
double dynamics_time
 User time spent by dynamics on the last step.
 
std::vector< JointPtrimplicit_joints
 Set of implicit joints maintained in the simulation (does not include implicit joints belonging to RCArticulatedBody objects)
 
- Public Attributes inherited from Moby::Base
boost::shared_ptr< void > userdata
 Any relevant userdata.
 
std::string id
 The unique ID for this object.
 

Protected Member Functions

void apply_impulse (boost::shared_ptr< Ravelin::DynamicBodyd > db, const Ravelin::SharedVectorNd &gj)
 Applies a generalized impulse to a dynamic body. More...
 
void solve (const std::vector< boost::shared_ptr< Ravelin::DynamicBodyd > > &island, const std::vector< JointPtr > &island_joints, const Ravelin::VectorNd &v, const Ravelin::VectorNd &f, double dt, Ravelin::VectorNd &a, Ravelin::VectorNd &lambda) const
 
virtual double check_pairwise_constraint_violations (double t)
 
void find_islands (std::vector< std::vector< boost::shared_ptr< Ravelin::DynamicBodyd > > > &islands)
 Finds islands.
 
unsigned num_generalized_coordinates (const std::vector< boost::shared_ptr< Ravelin::DynamicBodyd > > &island) const
 Gets the number of generalized coordinates in an island.
 
void calc_fwd_dyn (double dt)
 Calculates forward dynamics for bodies (does not consider unilateral constraints)
 
void precalc_fwd_dyn ()
 Prepares to calculate forward dynamics for bodies.
 
template<class ForwardIterator >
double integrate (double step_size, ForwardIterator begin, ForwardIterator end)
 Integrates both position and velocity of rigid _bodies. More...
 
double integrate (double step_size)
 Integrates all dynamic bodies.
 

Protected Attributes

osg::Group * _persistent_vdata
 
osg::Group * _transient_vdata
 
std::vector< ControlledBodyPtr_bodies
 The set of bodies in the simulation.
 
Ravelin::VectorNd _current_dx
 The derivative at the current time.
 

Friends

class ConstraintStabilization
 
class ImpactConstraintHandler
 
class RigidBody
 
class RCArticulatedBody
 

Additional Inherited Members

- Static Public Member Functions inherited from Moby::Base
template<class T >
static boost::shared_ptr< T > clone (boost::shared_ptr< T > x)
 Static method for cloning a shared pointer.
 

Detailed Description

Simulator for both unarticulated and articulated rigid bodies without contact.

Class used for performing dynamics simulation of rigid bodies without contact. Rigid body simulation of articulated bodies is supported using both maximal and reduced coordinate approaches.

Constructor & Destructor Documentation

Simulator::Simulator ( )

Sets up the simulator.

The simulator properties are set as follows:

  • simulator time = 0
  • no integrator

Member Function Documentation

void Simulator::add_dynamic_body ( ControlledBodyPtr  body)

Adds a dynamic body to the simulator.

Precondition
list of bodies is sorted

References Moby::Visualizable::get_visualization_data().

void Simulator::apply_impulse ( boost::shared_ptr< Ravelin::DynamicBodyd >  db,
const Ravelin::SharedVectorNd &  gj 
)
protected

Applies a generalized impulse to a dynamic body.

This function takes implicit constraints into account.

ControlledBodyPtr Simulator::find_dynamic_body ( const std::string &  name) const

Finds the dynamic body in the simulator, if any.

Searches unarticulated bodies, articulated bodies, and links of articulated bodies.

const std::vector<ControlledBodyPtr>& Moby::Simulator::get_dynamic_bodies ( ) const
inline

Gets the list of dynamic bodies in the simulator.

Note
if a dynamic body is articulated, only the articulated body is returned, not the links

References _bodies.

template<class ForwardIterator >
double Moby::Simulator::integrate ( double  dt,
ForwardIterator  begin,
ForwardIterator  end 
)

Integrates both position and velocity of rigid _bodies.

Returns
the size of step taken
template<class ForwardIterator >
double Moby::Simulator::integrate ( double  dt,
ForwardIterator  begin,
ForwardIterator  end 
)
protected

Integrates both position and velocity of rigid _bodies.

Returns
the size of step taken
double Simulator::step ( double  step_size)
virtual

Steps the Simulator forward in time without contact.

This pseudocode was inspired from [Baraff 1997] and [Mirtich 1996].

Parameters
step_sizethe step size
Returns
step_size

Reimplemented in Moby::TimeSteppingSimulator.


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