Moby
Joint.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 _MOBY_JOINT_H
8 #define _MOBY_JOINT_H
9 
10 #include <boost/weak_ptr.hpp>
11 #include <boost/shared_ptr.hpp>
12 #include <Ravelin/Pose3d.h>
13 #include <Ravelin/MatrixNd.h>
14 #include <Ravelin/SAcceld.h>
15 #include <Ravelin/LinAlgd.h>
16 #include <Ravelin/Jointd.h>
17 #include <Moby/Base.h>
18 #include <Moby/ControlledBody.h>
19 #include <Moby/RigidBody.h>
20 #include <Moby/Visualizable.h>
21 
22 namespace Moby {
23 
24 class VisualizationData;
25 
27 
30 class Joint : public Visualizable, public virtual Ravelin::Jointd
31 {
32  friend class ArticulatedBody;
33 
34  public:
39  enum ConstraintType { eUnknown, eExplicit, eImplicit };
40  enum DOFs { DOF_1=0, DOF_2=1, DOF_3=2, DOF_4=3, DOF_5=4, DOF_6=5 };
41 
42  Joint();
43  Joint(boost::weak_ptr<RigidBody> inboard, boost::weak_ptr<RigidBody> outboard);
44  virtual ~Joint() {}
45  void set_location(const Point3d& p, RigidBodyPtr inboard, RigidBodyPtr outboard);
46  Ravelin::VectorNd& get_scaled_force(Ravelin::VectorNd& f);
47  virtual void save_to_xml(XMLTreePtr node, std::list<boost::shared_ptr<const Base> >& shared_objects) const;
48  virtual void load_from_xml(boost::shared_ptr<const XMLTree> node, std::map<std::string, BasePtr>& id_map);
49  virtual void set_inboard_link(RigidBodyPtr link, bool update_pose);
50  virtual void set_outboard_link(RigidBodyPtr link, bool update_pose);
53 
55  RigidBodyPtr get_inboard_link() const { return (_inboard_link.expired()) ? RigidBodyPtr() : boost::dynamic_pointer_cast<RigidBody>(boost::shared_ptr<Ravelin::RigidBodyd>(_inboard_link)); }
56 
58  RigidBodyPtr get_outboard_link() const { return (_outboard_link.expired()) ? RigidBodyPtr() : boost::dynamic_pointer_cast<RigidBody>(boost::shared_ptr<Ravelin::RigidBodyd>(_outboard_link)); }
59 
61  Ravelin::VectorNd lolimit;
62 
64  Ravelin::VectorNd hilimit;
65 
68 
70  double mu_fc;
71 
73  double mu_fv;
74 
77 
78  protected:
79  void determine_q_dot();
80 
82 
90 // virtual void calc_constraint_jacobian(RigidBodyPtr body, unsigned index, double Cq[]) = 0;
91 
93 
101 // virtual void calc_constraint_jacobian_dot(RigidBodyPtr body, unsigned index, double Cq[]) = 0;
102 
104 
108  virtual void init_data();
109 
110  private:
111  boost::shared_ptr<Ravelin::Pose3d> _vtransform;
112 }; // end class
113 } // end namespace
114 
115 #endif
116 
void set_articulated_body(ArticulatedBodyPtr abody)
Sets the articulated body corresponding to this body.
Definition: Joint.cpp:207
Abstract class for articulated bodies.
Definition: ArticulatedBody.h:26
Class that allows for visualizing simulation data.
Definition: Visualizable.h:29
virtual void set_inboard_link(RigidBodyPtr link, bool update_pose)
Sets the pointer to the inboard link for this joint (and updates the spatial axes, if the outboard link has been set)
Definition: Joint.cpp:111
ArticulatedBodyPtr get_articulated_body()
Gets the articulated body corresponding to this body.
Definition: Joint.cpp:194
Represents a single rigid body.
Definition: RigidBody.h:43
virtual void set_outboard_link(RigidBodyPtr link, bool update_pose)
Sets the pointer to the outboard link for this joint.
Definition: Joint.cpp:127
RigidBodyPtr get_inboard_link() const
Gets the inboard link for this joint.
Definition: Joint.h:55
double mu_fv
The viscous friction coefficient for this joint.
Definition: Joint.h:73
boost::shared_ptr< RigidBody > RigidBodyPtr
Rigid body smart pointer.
Definition: Types.h:62
boost::shared_ptr< XMLTree > XMLTreePtr
XML tree smart pointer.
Definition: Types.h:104
double compliant_layer_depth
The depth of the compliant layer around the joint limit.
Definition: Joint.h:76
RigidBodyPtr get_outboard_link() const
Gets the outboard link for this joint.
Definition: Joint.h:58
virtual void init_data()
Computes the constraint Jacobian for this joint with respect to the given body in Rodrigues parameter...
Definition: Joint.cpp:144
Ravelin::Vector3d Point3d
Typedef to distinguish between a 3D vector and a point.
Definition: Types.h:47
double mu_fc
The coulomb friction coefficient for this joint.
Definition: Joint.h:70
Defines a joint used in articulated rigid body dynamics simulation.
Definition: Joint.h:30
boost::shared_ptr< ArticulatedBody > ArticulatedBodyPtr
Articulated body smart pointer.
Definition: Types.h:65
Ravelin::VectorNd & get_scaled_force(Ravelin::VectorNd &f)
Gets the scaled actuator forces.
Definition: Joint.cpp:181
Ravelin::VectorNd lolimit
The lower joint limit.
Definition: Joint.h:61
virtual void save_to_xml(XMLTreePtr node, std::list< boost::shared_ptr< const Base > > &shared_objects) const
Implements Base::save_to_xml()
Definition: Joint.cpp:398
ConstraintType
Definition: Joint.h:39
void set_location(const Point3d &p, RigidBodyPtr inboard, RigidBodyPtr outboard)
Sets the location of this joint with specified inboard and outboard links.
Definition: Joint.cpp:157
Ravelin::VectorNd hilimit
The upper joint limit.
Definition: Joint.h:64
void determine_q_dot()
(Relatively slow) method for determining the joint velocity from current link velocities ...
Definition: Joint.cpp:80
virtual void load_from_xml(boost::shared_ptr< const XMLTree > node, std::map< std::string, BasePtr > &id_map)
Implements Base::load_from_xml()
Definition: Joint.cpp:213
Joint()
Initializes the joint.
Definition: Joint.cpp:27
double limit_restitution
The coefficient of restitution applied when this joint reaches a limit.
Definition: Joint.h:67