10 #include <sys/times.h>
14 #include <boost/shared_ptr.hpp>
16 #include <Moby/Base.h>
18 #include <Moby/RigidBody.h>
19 #include <Moby/Dissipation.h>
20 #include <Moby/ArticulatedBody.h>
32 class VisualizationData;
50 virtual double step(
double step_size);
55 virtual void save_to_xml(
XMLTreePtr node, std::list<boost::shared_ptr<const Base> >& shared_objects)
const;
56 virtual void load_from_xml(boost::shared_ptr<const XMLTree> node, std::map<std::string, BasePtr>& id_map);
89 void apply_impulse(boost::shared_ptr<Ravelin::DynamicBodyd> db,
const Ravelin::SharedVectorNd& gj);
90 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;
91 virtual double check_pairwise_constraint_violations(
double t) {
return 0.0; }
92 void find_islands(std::vector<std::vector<boost::shared_ptr<Ravelin::DynamicBodyd> > >& islands);
94 osg::Group* _persistent_vdata;
95 osg::Group* _transient_vdata;
105 template <
class ForwardIterator>
106 double integrate(
double step_size, ForwardIterator begin, ForwardIterator end);
112 static Ravelin::VectorNd& ode(
const Ravelin::VectorNd& x,
double t,
double dt,
void* data, Ravelin::VectorNd& dx);
116 #include "Simulator.inl"
Abstract class for articulated bodies.
Definition: ArticulatedBody.h:26
Ravelin::VectorNd _current_dx
The derivative at the current time.
Definition: Simulator.h:103
void calc_fwd_dyn(double dt)
Calculates forward dynamics for bodies (does not consider unilateral constraints) ...
Definition: Simulator.cpp:482
boost::shared_ptr< Dissipation > dissipator
The dissipation mechanism for larger time steps.
Definition: Simulator.h:62
void find_islands(std::vector< std::vector< boost::shared_ptr< Ravelin::DynamicBodyd > > > &islands)
Finds islands.
Definition: Simulator.cpp:956
double dynamics_time
User time spent by dynamics on the last step.
Definition: Simulator.h:83
Class from which all Moby classes are derived.
Definition: Base.h:20
Defines an articulated body for use with reduced-coordinate dynamics algorithms.
Definition: RCArticulatedBody.h:43
double current_time
The current simulation time.
Definition: Simulator.h:59
virtual void load_from_xml(boost::shared_ptr< const XMLTree > node, std::map< std::string, BasePtr > &id_map)
Implements Base::load_from_xml()
Definition: Simulator.cpp:817
unsigned num_generalized_coordinates(const std::vector< boost::shared_ptr< Ravelin::DynamicBodyd > > &island) const
Gets the number of generalized coordinates in an island.
Definition: Simulator.cpp:808
Represents a single rigid body.
Definition: RigidBody.h:43
Simulator()
Sets up the simulator.
Definition: Simulator.cpp:41
const std::vector< ControlledBodyPtr > & get_dynamic_bodies() const
Gets the list of dynamic bodies in the simulator.
Definition: Simulator.h:69
boost::shared_ptr< ControlledBody > ControlledBodyPtr
Dynamic body smart pointer.
Definition: Types.h:89
Defines the mechanism for handling impact constraints.
Definition: ImpactConstraintHandler.h:37
void(* post_step_callback_fn)(Simulator *s)
Callback function after a step is completed.
Definition: Simulator.h:80
osg::Node * get_transient_vdata() const
Gets the transient (one-step) visualization data.
Definition: Simulator.h:77
boost::shared_ptr< XMLTree > XMLTreePtr
XML tree smart pointer.
Definition: Types.h:104
void update_visualization()
Updates all visualization under the simulator.
Definition: Simulator.cpp:304
double integrate(double step_size)
Integrates all dynamic bodies.
Definition: Simulator.h:109
void remove_dynamic_body(ControlledBodyPtr body)
Removes a dynamic body from the simulator.
Definition: Simulator.cpp:200
double integrate(double step_size, ForwardIterator begin, ForwardIterator end)
Integrates both position and velocity of rigid _bodies.
Definition: Simulator.h:13
Simulator for both unarticulated and articulated rigid bodies without contact.
Definition: Simulator.h:40
void add_dynamic_body(ControlledBodyPtr body)
Adds a dynamic body to the simulator.
Definition: Simulator.cpp:251
Projected constraint stabilization mechanism.
Definition: ConstraintStabilization.h:21
virtual double step(double step_size)
Steps the Simulator forward in time without contact.
Definition: Simulator.cpp:148
void apply_impulse(boost::shared_ptr< Ravelin::DynamicBodyd > db, const Ravelin::SharedVectorNd &gj)
Applies a generalized impulse to a dynamic body.
Definition: Simulator.cpp:356
virtual void save_to_xml(XMLTreePtr node, std::list< boost::shared_ptr< const Base > > &shared_objects) const
Implements Base::save_to_xml()
Definition: Simulator.cpp:1048
osg::Node * get_persistent_vdata() const
Gets the persistent visualization data.
Definition: Simulator.h:74
ControlledBodyPtr find_dynamic_body(const std::string &name) const
Finds the dynamic body in the simulator, if any.
Definition: Simulator.cpp:173
std::vector< JointPtr > implicit_joints
Set of implicit joints maintained in the simulation (does not include implicit joints belonging to RC...
Definition: Simulator.h:86
std::vector< ControlledBodyPtr > _bodies
The set of bodies in the simulation.
Definition: Simulator.h:100
void add_transient_vdata(osg::Node *vdata)
Adds transient visualization data to the simulator.
Definition: Simulator.cpp:311
void precalc_fwd_dyn()
Prepares to calculate forward dynamics for bodies.
Definition: Simulator.cpp:319