Ravelin
ArticulatedBody.h
1 /****************************************************************************
2  * Copyright 2015 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
8 #error This class is not to be included by the user directly. Use ArticulatedBodyd.h or ArticulatedBodyf.h instead.
9 #endif
10 
11 class RIGIDBODY;
12 class JOINT;
13 
15 class ARTICULATED_BODY : public virtual DYNAMIC_BODY
16 {
17  public:
19  virtual ~ARTICULATED_BODY() {}
20  virtual bool is_floating_base() const = 0;
21  virtual boost::shared_ptr<RIGIDBODY> get_base_link() const = 0;
22  unsigned num_constraint_eqns_explicit() const;
23  unsigned num_constraint_eqns_implicit() const;
24  virtual void rotate(const QUAT& q);
25  virtual void translate(const ORIGIN3& o);
26  virtual REAL calc_kinetic_energy(boost::shared_ptr<const POSE3> P = boost::shared_ptr<const POSE3>());
27  boost::shared_ptr<RIGIDBODY> find_link(const std::string& id) const;
28  boost::shared_ptr<JOINT> find_joint(const std::string& id) const;
29  void get_adjacent_links(std::list<sorted_pair<boost::shared_ptr<RIGIDBODY> > >& links) const;
30  virtual void set_links_and_joints(const std::vector<boost::shared_ptr<RIGIDBODY> >& links, const std::vector<boost::shared_ptr<JOINT> >& joints);
31  virtual unsigned num_joint_dof() const;
32  void find_loops(std::vector<unsigned>& loop_indices, std::vector<std::vector<unsigned> >& loop_links) const;
33  virtual MATRIXN& calc_jacobian(boost::shared_ptr<const POSE3> source_pose, boost::shared_ptr<const POSE3> target_pose, boost::shared_ptr<DYNAMIC_BODY> body, MATRIXN& J);
34  virtual MATRIXN& calc_jacobian_dot(boost::shared_ptr<const POSE3> source_pose, boost::shared_ptr<const POSE3> target_pose, boost::shared_ptr<DYNAMIC_BODY> body, MATRIXN& J);
35  virtual MATRIXN& calc_jacobian(boost::shared_ptr<const POSE3> target_pose, boost::shared_ptr<DYNAMIC_BODY> body, MATRIXN& J);
36  virtual MATRIXN& calc_jacobian_dot(boost::shared_ptr<const POSE3> target_pose, boost::shared_ptr<DYNAMIC_BODY> body, MATRIXN& J);
37 
39  virtual bool is_enabled() const { return true; }
40 
42  virtual unsigned num_joint_dof_explicit() const = 0;
43 
45  virtual unsigned num_joint_dof_implicit() const = 0;
46 
48  virtual const std::vector<boost::shared_ptr<RIGIDBODY> >& get_links() const { return _links; }
49 
51  virtual const std::vector<boost::shared_ptr<JOINT> >& get_joints() const { return _joints; }
52 
54  virtual const std::vector<boost::shared_ptr<JOINT> >& get_explicit_joints() const = 0;
55 
57  virtual const std::vector<boost::shared_ptr<JOINT> >& get_implicit_joints() const = 0;
58 
60  boost::shared_ptr<ARTICULATED_BODY> get_this() { return boost::dynamic_pointer_cast<ARTICULATED_BODY>(shared_from_this()); }
61 
63  boost::shared_ptr<const ARTICULATED_BODY> get_this() const { return boost::dynamic_pointer_cast<const ARTICULATED_BODY>(shared_from_this()); }
64 
66 
70  virtual void apply_impulse(const SMOMENTUM& w, boost::shared_ptr<RIGIDBODY> link) = 0;
71 
73  virtual void reset_accumulators() = 0;
74 
75  protected:
77  std::vector<unsigned> _processed;
78 
80 
85  virtual void compile();
86 
88  std::vector<boost::shared_ptr<RIGIDBODY> > _links;
89 
91  std::vector<boost::shared_ptr<JOINT> > _joints;
92 
93  private:
95 
96  // joint constraint violation
97  std::vector<REAL> _cvio;
98 
99  // joint velocity tolerances (for joints at constraints)
100  std::vector<REAL> _cvel_vio;
101 
102  // temporary variables
103  VECTORN _dq;
104 
105 }; // end class
106 
107 
std::vector< boost::shared_ptr< JOINT > > _joints
The set of joints for this articulated body.
Definition: ArticulatedBody.h:91
virtual const std::vector< boost::shared_ptr< RIGIDBODY > > & get_links() const
Gets the set of links.
Definition: ArticulatedBody.h:48
Abstract class for articulated bodies.
Definition: ArticulatedBody.h:15
virtual void rotate(const QUAT &q)
Transforms all links in the articulated body by the given transform.
Definition: ArticulatedBody.cpp:374
Quaternion class used for orientation.
Definition: Quat.h:21
virtual const std::vector< boost::shared_ptr< JOINT > > & get_joints() const
Gets the set of joints.
Definition: ArticulatedBody.h:51
virtual bool is_enabled() const
Articulated bodies are always enabled.
Definition: ArticulatedBody.h:39
virtual void apply_impulse(const SMOMENTUM &w, boost::shared_ptr< RIGIDBODY > link)=0
Abstract method for applying an impulse to this articulated body.
A spatial (six dimensional) momentum.
Definition: SMomentum.h:12
virtual const std::vector< boost::shared_ptr< JOINT > > & get_implicit_joints() const =0
Gets the set of implicit joints.
A generic, possibly non-square matrix.
Definition: MatrixN.h:18
Represents a single rigid body.
Definition: RigidBody.h:23
virtual void reset_accumulators()=0
Method for resetting the force and torque accumulators on all links.
Definition: ArticulatedBody.cpp:396
virtual REAL calc_kinetic_energy(boost::shared_ptr< const POSE3 > P=boost::shared_ptr< const POSE3 >())
Calculates the combined kinetic energy of all links in this body with respect to the base frame...
Definition: ArticulatedBody.cpp:382
virtual void translate(const ORIGIN3 &o)
Transforms all links in the articulated body by the given transform.
Definition: ArticulatedBody.cpp:363
virtual const std::vector< boost::shared_ptr< JOINT > > & get_explicit_joints() const =0
Gets the set of explicit joints.
virtual void compile()
Method for "compiling" the body.
Definition: ArticulatedBody.cpp:22
boost::shared_ptr< ARTICULATED_BODY > get_this()
Gets shared pointer to this object as type ARTICULATED_BODY.
Definition: ArticulatedBody.h:60
Superclass for deformable bodies and single and multi-rigid bodies.
Definition: DynamicBody.h:14
unsigned num_constraint_eqns_explicit() const
Gets the number of explicit joint constraint equations.
Definition: ArticulatedBody.cpp:304
virtual unsigned num_joint_dof() const
Gets the number of joint degrees of freedom permitted by both implicit and explicit joint constraints...
Definition: ArticulatedBody.cpp:326
A generic N-dimensional floating point vector.
Definition: VectorN.h:16
unsigned num_constraint_eqns_implicit() const
Gets the number of implicit joint constraint equations.
Definition: ArticulatedBody.cpp:315
std::vector< unsigned > _processed
Vector for processing links.
Definition: ArticulatedBody.h:77
Defines a bilateral constraint (a joint)
Definition: Joint.h:14
A three-dimensional floating point vector used for representing points and vectors in 3D and without ...
Definition: Origin3.h:16
virtual unsigned num_joint_dof_explicit() const =0
Gets the number of degrees-of-freedom permitted by explicit constraints.
std::vector< boost::shared_ptr< RIGIDBODY > > _links
The set of links for this articulated body.
Definition: ArticulatedBody.h:88
boost::shared_ptr< const ARTICULATED_BODY > get_this() const
Gets shared pointer to this object as type const ArticulateBody.
Definition: ArticulatedBody.h:63
virtual MATRIXN & calc_jacobian(boost::shared_ptr< const POSE3 > source_pose, boost::shared_ptr< const POSE3 > target_pose, boost::shared_ptr< DYNAMIC_BODY > body, MATRIXN &J)
The Jacobian transforms from the generalized coordinate from to the given frame.
virtual unsigned num_joint_dof_implicit() const =0
Gets the number of degrees-of-freedom permitted by implicit constraints.