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

An virtual class for simulation with constraints. More...

#include <ConstraintSimulator.h>

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

Public Member Functions

 ConstraintSimulator ()
 Default constructor.
 
virtual void load_from_xml (boost::shared_ptr< const XMLTree > node, std::map< std::string, BasePtr > &id_map)
 Implements Base::load_from_xml()
 
virtual void save_to_xml (XMLTreePtr node, std::list< boost::shared_ptr< const Base > > &shared_objects) const
 Implements Base::save_to_xml()
 
boost::shared_ptr
< ContactParameters
get_contact_parameters (CollisionGeometryPtr geom1, CollisionGeometryPtr geom2) const
 Gets the contact data between a pair of geometries (if any) More...
 
const std::vector
< PairwiseDistInfo > & 
get_pairwise_distances () const
 
std::vector
< UnilateralConstraint > & 
get_compliant_constraints ()
 Gets the (sorted) compliant constraint data.
 
std::vector
< UnilateralConstraint > & 
get_rigid_constraints ()
 Gets the (sorted) rigid constraint data.
 
boost::shared_ptr
< CollisionDetection
get_collision_detection () const
 Gets the collision detection mechanism.
 
- Public Member Functions inherited from Moby::Simulator
 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.
 
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

ConstraintStabilization cstab
 The constraint stabilization mechanism.
 
std::set< Ravelin::sorted_pair
< CollisionGeometryPtr > > 
unchecked_pairs
 Determines whether two geometries are not checked.
 
std::vector< std::pair
< ControlledBodyPtr,
Ravelin::VectorNd > > 
_x0
 Vectors set and passed to collision detection.
 
std::vector< std::pair
< ControlledBodyPtr,
Ravelin::VectorNd > > 
_x1
 
boost::shared_ptr
< ContactParameters >(* 
get_contact_parameters_callback_fn )(CollisionGeometryPtr g1, CollisionGeometryPtr g2)
 Callback function for getting contact parameters.
 
void(* post_mini_step_callback_fn )(ConstraintSimulator *s)
 Callback function after a mini-step is completed.
 
void(* constraint_callback_fn )(std::vector< UnilateralConstraint > &, boost::shared_ptr< void >)
 The callback function (called when constraints have been determined) More...
 
void(* constraint_post_callback_fn )(const std::vector< UnilateralConstraint > &, boost::shared_ptr< void >)
 The callback function (called after forces/impulses are applied)
 
boost::shared_ptr< void > constraint_callback_data
 Data passed to unilateral constraint callback.
 
boost::shared_ptr< void > constraint_post_callback_data
 Data passed to post-constraint callback.
 
std::map< Ravelin::sorted_pair
< BasePtr >, boost::shared_ptr
< ContactParameters > > 
contact_params
 Mapping from objects to contact parameters.
 
bool render_contact_points
 If set to 'true' simulator will process contact points for rendering.
 
- Public Attributes inherited from Moby::Simulator
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 calc_impacting_unilateral_constraint_forces (double dt)
 Handles constraints.
 
void find_unilateral_constraints ()
 Finds the set of unilateral constraints.
 
void calc_compliant_unilateral_constraint_forces ()
 Computes compliant contact forces.
 
void preprocess_constraint (UnilateralConstraint &e)
 Performs necessary preprocessing on an constraint.
 
void determine_geometries ()
 Sets up the list of collision geometries.
 
void broad_phase (double dt)
 Does broad phase collision detection, identifying which pairs of geometries may come into contact over time step of dt.
 
void calc_pairwise_distances ()
 Computes pairwise distances of geometries at their current poses, using broad phase results to determine which pairs should be checked. More...
 
void visualize_contact (UnilateralConstraint &constraint)
 Draws a ray directed from a contact point along the contact normal.
 
double calc_CA_step ()
 
double calc_next_CA_Euler_step (double contact_dist_thresh) const
 
- Protected Member Functions inherited from Moby::Simulator
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

ImpactConstraintHandler _impact_constraint_handler
 Object for handling impact constraints.
 
PenaltyConstraintHandler _penalty_constraint_handler
 Object for handling penalty constraints.
 
std::vector< UnilateralConstraint_rigid_constraints
 The vector of rigid constraints.
 
std::vector< UnilateralConstraint_compliant_constraints
 The vector of compliant constraints.
 
std::vector< PairwiseDistInfo_pairwise_distances
 Pairwise distances at bodies' current configurations.
 
Ravelin::VectorNd _workV
 Work vector.
 
boost::shared_ptr
< CollisionDetection
_coldet
 The collision detection mechanism.
 
std::vector< CollisionGeometryPtr_geometries
 The geometries in the simulator.
 
std::vector< std::pair
< CollisionGeometryPtr,
CollisionGeometryPtr > > 
_pairs_to_check
 Geometric pairs that should be checked for unilateral constraints (according to broad phase collision detection)
 
- Protected Attributes inherited from Moby::Simulator
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 CollisionDetection
 
class ConstraintStabilization
 

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

An virtual class for simulation with constraints.

Member Function Documentation

void ConstraintSimulator::calc_pairwise_distances ( )
protected

Computes pairwise distances of geometries at their current poses, using broad phase results to determine which pairs should be checked.

Parameters
pairwise_distanceson return, contains the pairwise distances
shared_ptr< ContactParameters > ConstraintSimulator::get_contact_parameters ( CollisionGeometryPtr  geom1,
CollisionGeometryPtr  geom2 
) const

Gets the contact data between a pair of geometries (if any)

This method looks for contact data not only between the pair of geometries, but also the rigid bodies that the geometries belong to, and any articulated bodies as well. The search proceeds in the following manner:

  1. two collision geometries
  2. one collision geometry, one rigid body
  3. two rigid bodies
  4. one collision geometry, one articulated body
  5. one rigid body, one articulated body
  6. two articulated bodies

The search order allows for multiple granularities; for example, a collision can easily be specified between two geometries of two of a robot's links (i.e., representing different surfaces on the links), between two links, or between two robots.

Parameters
g1the first collision geometry
g2the second collision geometry
Returns
a pointer to the contact data, if any, found

Member Data Documentation

void(* Moby::ConstraintSimulator::constraint_callback_fn)(std::vector< UnilateralConstraint > &, boost::shared_ptr< void >)

The callback function (called when constraints have been determined)

The callback function can remove constraints from the list, which will disable their processing (however, doing so may prevent the simulation from making progress, as the simulator attempts to disallow violations.


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