Follow this link to skip to the main content

me_joint.h

Go to the documentation of this file.
00001 // -*-c++-*-
00002 //---------------------------< /-/ CLARAty /-/ >------------------------------
00003 /**
00004  * @file me_joint.h
00005  *
00006  * The ME_Joint object corresponds to the joint in a mechanism.
00007  * ME_Joint attaches a ME_Body to its parent.
00008  * 
00009  * <br>@b Designer(s):   Antonio Diaz-Calderon,
00010  *                       Won S. Kim,
00011  *                       Hari Das Nayar,
00012  *                       Issa Nesnas
00013  * <br>@b Author(s):     Hari Das Nayar
00014  * <br>@b Date:          March 24, 2004 
00015  *
00016  * <b>Software License:</b><br>
00017  * <code> http://claraty.jpl.nasa.gov/license/open_src/  or 
00018  *        file: license/open_src.txt </code>
00019  *
00020  * &copy; 2006, Jet Propulsion Laboratory, California Institute of Technology<br>
00021  *
00022  * $Revision: 1.7 $
00023  */
00024 //---------------------------------------------------------------------------
00025 
00026 #ifndef ME_JOINT_H
00027 #define ME_JOINT_H
00028 
00029 #include "claraty/share.h"
00030 #include "claraty/frame.h"
00031 
00032 
00033 namespace claraty {
00034 
00035 //----------------------------------------------------------------------
00036 //-----------------------<< Joint_Limits class >>-----------------------
00037 //----------------------------------------------------------------------
00038 /**
00039  * Joint_Limits class
00040  * This class maintains joint limit attributes.
00041  *
00042  * @ingroup mech_model_pkg
00043  */
00044 class Joint_Limits {
00045 public:
00046   Joint_Limits()
00047     : _min (0.0), _max(0.0), _vmax(0.0), _torque_min(0.0), _torque_max(0.0) {}
00048   Joint_Limits(const Joint_Limits & jm)
00049   {
00050     _min = jm._min; _max = jm._max; _vmax = jm._vmax;
00051     _torque_min = jm._torque_min; _torque_max = jm._torque_max;
00052   }
00053   void set_parameters(double joint_min, double joint_max,
00054                       double joint_vmax,
00055                       double joint_tmin, double joint_tmax)
00056   {
00057     _min = joint_min;
00058     _max = joint_max;
00059     _vmax = joint_vmax;
00060     _torque_min = joint_tmin;
00061     _torque_max = joint_tmax;
00062   }
00063   void get_parameters(double & joint_min, double & joint_max,
00064                                   double & joint_vmax,
00065                                   double & joint_tmin, double & joint_tmax)
00066   {
00067     joint_min  = _min;
00068     joint_max  = _max;
00069     joint_vmax = _vmax;
00070     joint_tmin = _torque_min;
00071     joint_tmax = _torque_max;
00072   }
00073   
00074   double _min;
00075   double _max;
00076   double _vmax;
00077   double _torque_min;
00078   double _torque_max;
00079 };
00080 
00081 //-------------------------------------------------------------------------
00082 //---------------------<< Joint_Stiffness Struct >>------------------------
00083 //-------------------------------------------------------------------------
00084 /**
00085  * Joint_Stiffness class
00086  * This class maintains joint stiffness attributes.
00087  *
00088  * @ingroup mech_model_pkg
00089  */
00090 class Joint_Stiffness {
00091 public:
00092   Joint_Stiffness() : _kx(0.0), _ky(0.0), _kz(0.0) {}
00093   Joint_Stiffness(const Joint_Stiffness & js)
00094   { _kx = js._kx; _ky = js._ky; _kz = js._kz; }
00095   void set_parameters(double joint_kx, double joint_ky, double joint_kz)
00096   {
00097     _kx = joint_kx;
00098     _ky = joint_ky;
00099     _kz = joint_kz;
00100   }
00101   void get_parameters(double & joint_kx, double & joint_ky, double & joint_kz)
00102   {
00103     joint_kx = _kx;
00104     joint_ky = _ky;
00105     joint_kz = _kz;
00106   }
00107 private:
00108   double _kx;
00109   double _ky;
00110   double _kz;
00111 };
00112 
00113 //-------------------------------------------------------------------------
00114 //---------------------<< Joint_Constraint Struct >>-----------------------
00115 //-------------------------------------------------------------------------
00116 /**
00117  * Joint_Constraint class
00118  * This class maintains joint constraint attributes.
00119  *
00120  * @ingroup mech_model_pkg
00121  */
00122 class Joint_Constraint {
00123 public:
00124   Joint_Constraint(): _offset(0), _slope(0), s_expr_attribute("") {}
00125   Joint_Constraint(const Joint_Constraint & jc)
00126     : _offset(0), _slope(0), s_expr_attribute(jc.s_expr_attribute){}
00127   void set_parameters(std::string joint_constr_expr)
00128   {
00129     s_expr_attribute = joint_constr_expr;
00130   }
00131   std::string get_parameters()
00132   {
00133     return s_expr_attribute;
00134   }
00135   bool evaluate_constraint_expression();
00136   double get_slope() { return _slope;};
00137   double get_offset() { return _offset;};
00138   int get_dependent_joint_index() { return _dependent_body_joint_value_index;};
00139   std::string get_dependent_body_name() { return _dependent_body_name;}
00140 
00141 private:
00142   double _offset;
00143   double _slope;
00144   std::string s_expr_attribute;
00145   std::string _dependent_body_name;
00146   long _dependent_body_joint_value_index;
00147   
00148 };
00149 
00150 
00151 //-------------------------------------------------------------------------
00152 //---------------------------<< ME_Joint Class >>--------------------------
00153 //-------------------------------------------------------------------------
00154 /**
00155  * ME_Joint class
00156  * The ME_Joint class implements a generic model of joints in a kinematic
00157  * system.
00158  *
00159  * @ingroup mech_model_pkg
00160  */
00161 
00162 class ME_Body;
00163 
00164 class ME_Joint {
00165   friend std::ostream& operator<< (std::ostream& os,
00166                                    ME_Joint & me_joint);
00167   
00168   /** Enumeration to indicate joint type. */
00169   enum JOINT_TYPE {      // All other types can be modeled using types below 
00170     UNDEFINED = -1,
00171     PIN = 1,        // Models a 1-dof revolute joint
00172     SLIDER = 2,     // Models a 1-dof prismatic joint
00173     FULL6DOF = 3,       // Models a vehicle body relative to a
00174     // base reference frame
00175     STATIC = 10     // Models a rigid joint
00176   };
00177   
00178   /** @{ @name ME_Joint constructor/destructor */
00179 public:
00180   ME_Joint();
00181   ME_Joint(ME_Joint & me_joint);
00182   virtual ~ME_Joint(){}
00183   /** @} */
00184   
00185   /** @{ @name ME_Joint model querying */
00186 private:
00187   int _resolve_type(std::string joint_type_str);
00188   std::string _unresolve_type(int joint_type);
00189   /** @} */
00190   
00191   /** @{ @name ME_Joint model setting */
00192 public:
00193   void set_name(std::string name);
00194   std::string get_name();
00195   void set_body(ME_Body * me_body) {_me_body = me_body;};
00196   ME_Body * get_body() { return _me_body;};
00197   void set_type(std::string type);
00198   void set_type(short type);
00199   std::string get_type();
00200   void set_actuated(bool actuated);
00201   bool is_actuated();
00202   bool has_limits() {return _limited;}
00203   void set_offset(double offset);
00204   double & get_offset();
00205   void set_home(double home);
00206   double & get_home();
00207   void set_value(double value, int dof_index=0);
00208   double get_value(int dof_index=0);
00209   void set_limits(double joint_min, double joint_max,
00210                         double joint_vmax,
00211                         double joint_tmin, double joint_tmax);
00212   void get_limits(double & joint_min, double & joint_max,
00213                         double & joint_vmax,
00214                         double & joint_tmin, double & joint_tmax);
00215   void set_stiffness(double kx, double ky, double kz);
00216   void get_stiffness(double & kx, double & ky, double & kz);
00217   void set_constraint_expression(std::string expr);
00218   std::vector<double> & get_values_vector();
00219   std::string get_constraint_expression();
00220    bool is_constrained() {return _constrained;};
00221   int get_number_dofs();
00222   void rotate_joint_axes(const Quaternion<double> & rotation);
00223   void rotate_joint_axes(const RMatrix<double> & rotation);
00224   void set_joint_axes(Vector<double> joint_axis);
00225   void get_joint_axes(Vector<double> & joint_axis);
00226   Vector<double> & get_joint_axis();
00227 
00228   /** @} */
00229   
00230   /** @{ @name ME_Joint joint algorithms */
00231 public:
00232   Transform get_transform();
00233   /** @} */
00234   
00235  private:
00236   unsigned int _index;         /**< Index in Mechanism_Model.*/
00237   bool _limited;               /**< To indicate if joint has limits in
00238                                           range of motion */
00239   bool _actuated;              /**< True if actuated, false if
00240                                           passive */
00241   short _type;                 /**< Joint type. Only PIN or SLIDER are
00242                                           allowed for DH and Homogenous
00243                                           transform input format types */
00244   double _offset;              /**< Joint offset */
00245   double _home;                /**< Joint home position */
00246   unsigned int _number_of_dofs;/**< Number of joint degrees of freedom. */
00247   Frame * _parent_frame;       /**< Frame on the parent body associated
00248                                           with this joint. */
00249   std::vector<double> _values;
00250   bool _constrained;
00251   
00252   std::string        _name;          /**< Joint name */
00253   Joint_Limits       _limits;        /**< Joint limits parameters */
00254   Joint_Stiffness  * _stiffness;     /**< Joint stiffness parameters */
00255   Joint_Constraint * _constraint;    /**< Joint constraint description */
00256   ME_Body          * _me_body;       /**< Body that this joint is on */ 
00257   Vector<double>     _joint_axis;    /**< Joint axes components */
00258 };
00259 
00260 
00261 //-------------------------------------------------------------------------
00262 
00263 } // namespace claraty
00264 
00265 #endif // ME_JOINT_H
00266