Moby
ArticulatedBody.h
1 /****************************************************************************
2  * Copyright 2005 Evan Drumwright
3  * This library is distributed under the terms of the Apache V2.0
4  * License (obtainable from http://www.apache.org/licenses/LICENSE-2.0).
5  ****************************************************************************/
6 
7 #ifndef _ARTICULATED_BODY_H
8 #define _ARTICULATED_BODY_H
9 
10 #include <vector>
11 #include <boost/shared_ptr.hpp>
12 #include <Ravelin/Vector3d.h>
13 #include <Ravelin/Matrix3d.h>
14 #include <Ravelin/SMomentumd.h>
15 #include <Ravelin/sorted_pair>
16 #include <Moby/UnilateralConstraint.h>
17 #include <Moby/ControlledBody.h>
18 #include <Moby/Joint.h>
19 #include <Ravelin/ArticulatedBodyd.h>
20 
21 namespace Moby {
22 
23 class RigidBody;
24 
26 class ArticulatedBody : public virtual Ravelin::ArticulatedBodyd, public virtual ControlledBody
27 {
28  public:
30  virtual ~ArticulatedBody() {}
31  virtual void update_visualization();
32  virtual void load_from_xml(boost::shared_ptr<const XMLTree> node, std::map<std::string, BasePtr>& id_map);
33  virtual void save_to_xml(XMLTreePtr node, std::list<boost::shared_ptr<const Base> >& shared_objects) const;
35  bool is_joint_constraint_violated() const;
36  virtual void prepare_to_calc_ode(Ravelin::SharedConstVectorNd& x, double t, double dt, void* data);
37  virtual void prepare_to_calc_ode_sustained_constraints(Ravelin::SharedConstVectorNd& x, double t, double dt, void* data);
38  virtual void ode(double t, double dt, void* data, Ravelin::SharedVectorNd& dx);
39 // virtual unsigned num_generalized_coordinates(Ravelin::DynamicBodyd::GeneralizedCoordinateType gctype) const;
40 
42  template <class OutputIterator>
43  OutputIterator find_limit_constraints(OutputIterator begin) const;
44 
46  ArticulatedBodyPtr get_this() { return boost::dynamic_pointer_cast<ArticulatedBody>(Ravelin::ArticulatedBodyd::shared_from_this()); }
47 
49  boost::shared_ptr<const ArticulatedBody> get_this() const { return boost::dynamic_pointer_cast<const ArticulatedBody>(Ravelin::ArticulatedBodyd::shared_from_this()); }
50 
51  private:
52  ArticulatedBody(const ArticulatedBody& ab) {}
53 
54  // joint constraint violation
55  std::vector<double> _cvio;
56 
57  // joint velocity tolerances (for joints at constraints)
58  std::vector<double> _cvel_vio;
59 
60  // temporary variables
61  Ravelin::VectorNd _dq;
62 
63 }; // end class
64 
65 #include "ArticulatedBody.inl"
66 
67 } // end namespace Moby
68 
69 #endif
Abstract class for articulated bodies.
Definition: ArticulatedBody.h:26
Represents a single rigid body.
Definition: RigidBody.h:43
virtual void update_visualization()
Updates visualization for the body.
Definition: ArticulatedBody.cpp:227
boost::shared_ptr< XMLTree > XMLTreePtr
XML tree smart pointer.
Definition: Types.h:104
virtual void prepare_to_calc_ode_sustained_constraints(Ravelin::SharedConstVectorNd &x, double t, double dt, void *data)
Integrates a dynamic body.
Definition: ArticulatedBody.cpp:75
bool is_joint_constraint_violated() const
Checks for a joint constraint violation.
Definition: ArticulatedBody.cpp:203
ArticulatedBodyPtr get_this()
Gets shared pointer to this object as type ArticulatedBody.
Definition: ArticulatedBody.h:46
virtual void save_to_xml(XMLTreePtr node, std::list< boost::shared_ptr< const Base > > &shared_objects) const
Saves this object to a XML tree.
Definition: ArticulatedBody.cpp:344
boost::shared_ptr< const ArticulatedBody > get_this() const
Gets shared pointer to this object as type const ArticulateBody.
Definition: ArticulatedBody.h:49
void update_joint_constraint_violations()
Updates joint constraint violation (after integration)
Definition: ArticulatedBody.cpp:181
boost::shared_ptr< ArticulatedBody > ArticulatedBodyPtr
Articulated body smart pointer.
Definition: Types.h:65
virtual void load_from_xml(boost::shared_ptr< const XMLTree > node, std::map< std::string, BasePtr > &id_map)
Loads a MCArticulatedBody object from an XML node.
Definition: ArticulatedBody.cpp:236
Superclass for controlled bodies.
Definition: ControlledBody.h:21
virtual void prepare_to_calc_ode(Ravelin::SharedConstVectorNd &x, double t, double dt, void *data)
Prepares to compute the ODE.
Definition: ArticulatedBody.cpp:119
virtual void ode(double t, double dt, void *data, Ravelin::SharedVectorNd &dx)
Returns the ODE's for position and velocity (concatenated into x)
Definition: ArticulatedBody.cpp:163
OutputIterator find_limit_constraints(OutputIterator begin) const
Finds (joint) limit constraints.
Definition: ArticulatedBody.h:10