$search
00001 /* 00002 * Katana Native Interface - A C++ interface to the robot arm Katana. 00003 * Copyright (C) 2005 Neuronics AG 00004 * Check out the AUTHORS file for detailed contact information. 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 */ 00020 00021 /********************************************************************************/ 00022 #ifndef _LMBASE_H_ 00023 #define _LMBASE_H_ 00024 /********************************************************************************/ 00025 #include "common/dllexport.h" 00026 #include "common/Timer.h" 00027 #include "KNI_InvKin/ikBase.h" 00028 #include "common/exception.h" 00029 #include <vector> 00030 #include <cmath> 00031 00032 #include "boost/numeric/ublas/matrix.hpp" 00033 #include "boost/numeric/ublas/vector.hpp" 00034 #include "boost/numeric/ublas/vector_proxy.hpp" 00035 #include "boost/numeric/ublas/triangular.hpp" 00036 #include "boost/numeric/ublas/lu.hpp" 00037 #include "boost/numeric/ublas/io.hpp" 00038 00039 /********************************************************************************/ 00040 00041 00042 //---------------------------------------------------------------------------// 00043 00048 00049 00052 class JointSpeedException : public Exception { 00053 public: 00054 JointSpeedException() throw(): 00055 Exception("Joint speed too high", -70) {} 00056 }; 00057 00060 class WaitParameterException : public Exception { 00061 public: 00062 WaitParameterException() throw(): 00063 Exception("Wait parameter set to false", -71) {} 00064 }; 00065 00066 00067 //---------------------------------------------------------------------------// 00068 00073 class DLLDIR_LM CLMBase : public CikBase { 00074 00075 private: 00076 double _maximumVelocity; 00077 bool _activatePositionController; 00078 00079 00090 double totalTime(double distance, double acc, double dec, double vmax); 00091 00103 double relPosition(double reltime, double distance, double acc, double dec, 00104 double vmax); 00105 00122 void splineCoefficients(int steps, double *timearray, double *encoderarray, 00123 double *arr_p1, double *arr_p2, double *arr_p3, double *arr_p4); 00124 00136 bool checkJointSpeed(std::vector<int> lastsolution, 00137 std::vector<int> solution, double time); 00138 00148 int getSpeed(int distance, int acceleration, int time); 00149 00150 00151 public: 00152 00153 CLMBase() : _maximumVelocity(20), _activatePositionController(true) {} 00154 00156 void movLM(double X, double Y, double Z, 00157 double Al, double Be, double Ga, 00158 bool exactflag, double vmax, bool wait=true, int tolerance = 100, long timeout = TM_ENDLESS); 00159 00178 void movLM2P(double X1, double Y1, double Z1, double Al1, double Be1, 00179 double Ga1, double X2, double Y2, double Z2, double Al2, double Be2, 00180 double Ga2, bool exactflag, double vmax, bool wait=true, 00181 int tolerance = 100, long timeout = TM_ENDLESS); 00182 00201 void movP2P(double X1, double Y1, double Z1, double Ph1, double Th1, 00202 double Ps1, double X2, double Y2, double Z2, double Ph2, double Th2, 00203 double Ps2, bool exactflag, double vmax, bool wait=true, 00204 long timeout = TM_ENDLESS); 00205 00206 void setMaximumLinearVelocity(double maximumVelocity); 00207 double getMaximumLinearVelocity() const; 00208 00212 void setActivatePositionController(bool activate); 00213 00216 bool getActivatePositionController(); 00217 00219 void moveRobotLinearTo( 00220 double x, double y, double z, 00221 double phi, double theta, double psi, 00222 bool waitUntilReached = true, 00223 int waitTimeout = TM_ENDLESS); 00224 00229 void moveRobotLinearTo( 00230 std::vector<double> coordinates, 00231 bool waitUntilReached = true, 00232 int waitTimeout = TM_ENDLESS); 00233 00236 void moveRobotTo(double x, double y, double z, 00237 double phi, double theta, double psi, 00238 bool waitUntilReached = true, int waitTimeout = TM_ENDLESS); 00239 00244 void moveRobotTo(std::vector<double> coordinates, bool waitUntilReached = true, int waitTimeout = TM_ENDLESS); 00245 00246 }; 00247 /********************************************************************************/ 00248 #endif //_IKBASE_H_ 00249 /********************************************************************************/