00001 // Copyright (C) 2013 Stephen Roderick <kiwi dot net at mac dot com> 00002 00003 // This library is free software; you can redistribute it and/or 00004 // modify it under the terms of the GNU Lesser General Public 00005 // License as published by the Free Software Foundation; either 00006 // version 2.1 of the License, or (at your option) any later version. 00007 00008 // This library is distributed in the hope that it will be useful, 00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 // Lesser General Public License for more details. 00012 00013 // You should have received a copy of the GNU Lesser General Public 00014 // License along with this library; if not, write to the Free Software 00015 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00016 00017 #ifndef __SOLVERI_HPP 00018 #define __SOLVERI_HPP 00019 00020 namespace KDL { 00021 00084 class SolverI 00085 { 00086 public: 00087 enum { 00089 E_DEGRADED = +1, 00091 E_NOERROR = 0, 00093 E_NO_CONVERGE = -1, 00095 E_UNDEFINED = -2, 00097 E_NOT_UP_TO_DATE = -3, 00099 E_SIZE_MISMATCH = -4, 00101 E_MAX_ITERATIONS_EXCEEDED = -5, 00103 E_OUT_OF_RANGE = -6, 00105 E_NOT_IMPLEMENTED = -7, 00107 E_SVD_FAILED = -8 00108 }; 00109 00111 SolverI() : 00112 error(E_NOERROR) 00113 {} 00114 00115 virtual ~SolverI() 00116 {} 00117 00119 virtual int getError() const { return error; } 00120 00125 virtual const char* strError(const int error) const 00126 { 00127 if (E_NOERROR == error) return "No error"; 00128 else if (E_NO_CONVERGE == error) return "Failed to converge"; 00129 else if (E_UNDEFINED == error) return "Undefined value"; 00130 else if (E_DEGRADED == error) return "Converged but degraded solution"; 00131 else if (E_NOT_UP_TO_DATE == error) return "Internal data structures not up to date with Chain"; 00132 else if (E_SIZE_MISMATCH == error) return "The size of the input does not match the internal state"; 00133 else if (E_MAX_ITERATIONS_EXCEEDED == error) return "The maximum number of iterations is exceeded"; 00134 else if (E_OUT_OF_RANGE == error) return "The requested index is out of range"; 00135 else if (E_NOT_IMPLEMENTED == error) return "The requested function is not yet implemented"; 00136 else if (E_SVD_FAILED == error) return "SVD failed"; 00137 else return "UNKNOWN ERROR"; 00138 } 00139 00145 virtual void updateInternalDataStructures() = 0; 00146 00147 protected: 00149 int error; 00150 }; 00151 00152 } // namespaces 00153 00154 #endif