me_joint.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
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
00037
00038
00039
00040
00041
00042
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
00083
00084
00085
00086
00087
00088
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
00115
00116
00117
00118
00119
00120
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
00153
00154
00155
00156
00157
00158
00159
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
00169 enum JOINT_TYPE {
00170 UNDEFINED = -1,
00171 PIN = 1,
00172 SLIDER = 2,
00173 FULL6DOF = 3,
00174
00175 STATIC = 10
00176 };
00177
00178
00179 public:
00180 ME_Joint();
00181 ME_Joint(ME_Joint & me_joint);
00182 virtual ~ME_Joint(){}
00183
00184
00185
00186 private:
00187 int _resolve_type(std::string joint_type_str);
00188 std::string _unresolve_type(int joint_type);
00189
00190
00191
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
00231 public:
00232 Transform get_transform();
00233
00234
00235 private:
00236 unsigned int _index;
00237 bool _limited;
00238
00239 bool _actuated;
00240
00241 short _type;
00242
00243
00244 double _offset;
00245 double _home;
00246 unsigned int _number_of_dofs;
00247 Frame * _parent_frame;
00248
00249 std::vector<double> _values;
00250 bool _constrained;
00251
00252 std::string _name;
00253 Joint_Limits _limits;
00254 Joint_Stiffness * _stiffness;
00255 Joint_Constraint * _constraint;
00256 ME_Body * _me_body;
00257 Vector<double> _joint_axis;
00258 };
00259
00260
00261
00262
00263 }
00264
00265 #endif // ME_JOINT_H
00266