Physsim::ImpulseContactSimulator Class Reference

A contact handling simulator that is purely impulse based-- forces are not used to determine contacts. More...

#include <ImpulseContactSimulator.h>

Inheritance diagram for Physsim::ImpulseContactSimulator:

Physsim::Simulator Physsim::Base List of all members.

Public Member Functions

 ImpulseContactSimulator ()
 Constructs a ImpulseContactSimulator with no parameters.
virtual void determine_external_forces ()
 Explicitly computes all of the external forces applied to bodies.
CollisionGeometryPtr find_collision_geometry (const std::string &name) const
 Finds the collision geometry in the contact simulator, if any.
virtual void clone (BasePtr &cloned, bimap< BasePtr, BasePtr > *object_map=NULL) const
 Clones this object and all objects underneath.
virtual bool is_struct_identical (BaseConstPtr object) const
 Verifies that structure is identical.
virtual void load_state (BaseConstPtr object, bimap< BasePtr, BasePtr > *object_map=NULL)
 Loads object data.
virtual void save_state (BasePtr object, bimap< BasePtr, BasePtr > *object_map=NULL) const
 Saves all object data.
virtual void load_from_xml (XMLTreeConstPtr node, std::map< std::string, BasePtr > &id_map)
 Implements Base::load_from_xml().
virtual void save_to_xml (XMLTreePtr node, std::list< BaseConstPtr > &shared_objects) const
 Implements Base::save_to_xml().
virtual void output_object_state (std::ostream &out) const
 Outputs this class data to the stream.
const std::map< sorted_pair<
BasePtr >, boost::shared_ptr<
ContactData > > & 
get_contact_data () const
 Gets the map of contact data for this simulator.
const std::list< ContactPtr > & get_contacts () const
 Gets the list of contacts determined on the last step.
void clear_contact_data ()
 Clears the set of contact data.
void add_contact_data (boost::shared_ptr< ContactData > cd)
 Adds the given ContactData object to the set of contact data.
boost::shared_ptr< CollisionDetectionget_collision_detection ()
 Gets the collision detection method for the simulator.
void set_collision_detection (boost::shared_ptr< CollisionDetection > colldet)
 Gets the collision detection method for the simulator.
virtual Real step (Real step_size)
 Steps the simulation forward.
void set_callback_function (void(*fn)(ContactPtr))
 Sets the callback function for processing found contacts.
void(* get_callback_function ())(ContactPtr)
 Gets the callback function for processing found method (if any).
Real get_collision_tolerance () const
 Gets the non-negative tolerance with which the simulator tests for collision.
void set_collision_tolerance (Real collision_tolerance)
 Sets the non-negative tolerance with which the simulator tests for collision (default is zero).

Protected Member Functions

void preprocess_contact (ContactPtr contact) const
 Performs necessary preprocessing on a contact.
boost::shared_ptr< ContactDataget_contact_data (CollisionGeometryPtr g1, boost::shared_ptr< CollisionGeometry > g2) const
bool impact_contact (boost::shared_ptr< ICSMinimalStateStruct > state_t0, boost::shared_ptr< ICSMinimalStateStruct > state_tf)
 Determines whether there is an impact contact in the interval [t0, tf].
void regress_to_first_TOI (boost::shared_ptr< ICSMinimalStateStruct > state_t0, boost::shared_ptr< ICSMinimalStateStruct > state_tf, Real tolerance)
 Finds and integrates the simulation to right after the first time-of-impact (TOI) for a simulation with impacts.
boost::shared_ptr< ICSMinimalStateStructclone_minimal () const
 Clones the state of the simulator minimally.
void load_state_minimal (boost::shared_ptr< ICSMinimalStateStruct > mss)
 Loads the state of the simulator from a minimal description.
void update_contacts ()
 Calls collision detection and updates list of contacts.

Static Protected Member Functions

static void * find_contact (void *arg)

Protected Attributes

std::list< ContactPtr > _contacts
Real _collision_tolerance
std::map< sorted_pair< BasePtr >,
boost::shared_ptr< ContactData > > 
_contact_data
boost::shared_ptr< CollisionDetection_coll_det
void(* _callback_fn )(ContactPtr)

Detailed Description

A contact handling simulator that is purely impulse based-- forces are not used to determine contacts.

ImpulseContactSimulator::step(step_size) operates using the following model:

  1. apply resting contact forces (if any)
  2. step the simulation forward by step_size
  3. if impacting contact in interval [t,t+step_size]
    1. determine TOI (time-of-impact)
    2. regress simulation to TOI
    3. apply impulses to colliding bodies
Contact parameters are managed via a library of ContactData objects, each of which refers to some combination of two CollisionGeometry, RigidBody, and ArticulatedBody objects. This allows contact parameters to be specified at various granularities.

The contact handling mechanism must subclass Simulator to drive the integration; this is necessary due to the different requirements of the various contact restitution methods.

The ImpulseContactSimulator is more advanced than the ThreshContactSimulator: it is simpler, more stable, and faster.


Constructor & Destructor Documentation

ImpulseContactSimulator::ImpulseContactSimulator (  ) 

Constructs a ImpulseContactSimulator with no parameters.

The parameters default to the following values:


Member Function Documentation

void ImpulseContactSimulator::determine_external_forces (  )  [virtual]

Explicitly computes all of the external forces applied to bodies.

This method explicitly computes all external forces applied to the bodies in the simulation, including gravity. This method is called by step() automatically if needed, or the user can call this manually before step() (if the user needs to know all of the applied forces).

Reimplemented from Physsim::Simulator.

void ImpulseContactSimulator::load_state ( BaseConstPtr  object,
bimap< BasePtr, BasePtr > *  correspondence = NULL 
) [virtual]

Loads object data.

The underlying structure between this and object must be identical. In particular, the vectors of dynamic bodies and recurrent forces must be identical (same length and identical structure), the sets of contact data are identically sized, and identically one/none collision detector, collision method, resting contact, and integrator.

Reimplemented from Physsim::Simulator.

void ImpulseContactSimulator::save_state ( BasePtr  object,
bimap< BasePtr, BasePtr > *  correspondence = NULL 
) const [virtual]

Saves all object data.

The underlying structure between this and object must be identical. In particular, the vectors of dynamic bodies and recurrent forces must be identical (same length and identical structure), the sets of contact data are identically sized, and identically one/none collision detector, collision method, resting contact, and integrator.

Reimplemented from Physsim::Simulator.

void ImpulseContactSimulator::output_object_state ( std::ostream &  out  )  const [virtual]

Outputs this class data to the stream.

This method outputs all of the low-level details to the stream; if serialization is desired, use save_to_xml() instead.

See also:
save_to_xml()

Reimplemented from Physsim::Base.

Real ImpulseContactSimulator::step ( Real  step_size  )  [virtual]

Steps the simulation forward.

The simulator will take less than the step_size requested if collision impulses are applied. If the full step size is requested, call step_full().

Returns:
the step size taken (<= step_size)

Reimplemented from Physsim::Simulator.

bool ImpulseContactSimulator::impact_contact ( boost::shared_ptr< ICSMinimalStateStruct state_t0,
boost::shared_ptr< ICSMinimalStateStruct state_tf 
) [protected]

Determines whether there is an impact contact in the interval [t0, tf].

This method may be made more complex in the future, but it currently checks whether an impact exists at time tf.

Precondition:
simulator is currently at configuration state_tf

void ImpulseContactSimulator::regress_to_first_TOI ( boost::shared_ptr< ICSMinimalStateStruct state_t0,
boost::shared_ptr< ICSMinimalStateStruct state_tf,
Real  tolerance 
) [protected]

Finds and integrates the simulation to right after the first time-of-impact (TOI) for a simulation with impacts.

The simulation regresses to immediately after either the first joint-limit impact or the first contact impact, whichever occurs before the other.

Parameters:
state_t0 the simulation at the previous step
state_tf the simulation at/after time-of-impact

boost::shared_ptr< ICSMinimalStateStruct > ImpulseContactSimulator::clone_minimal (  )  const [protected]

Clones the state of the simulator minimally.

All bodies are cloned, time is saved, and contact data is saved.


The documentation for this class was generated from the following files:
Generated on Wed Oct 24 14:54:22 2007 for Physsim by  doxygen 1.5.1