Go to the documentation of this file.
   37 #ifndef IKFAST_HEADER_COMMON 
   38 #define IKFAST_HEADER_COMMON 
   41 #define IKFAST_VERSION 61 
   47 class IkSingleDOFSolutionBase
 
   74     virtual void GetSolution(T* solution, 
const T* freevalues) 
const = 0;
 
   77     virtual void GetSolution(std::vector<T>& solution, 
const std::vector<T>& freevalues)
 const {
 
   79         GetSolution(&solution.at(0), freevalues.size() > 0 ? &freevalues.at(0) : NULL);
 
   85     virtual const std::vector<int>& 
GetFree() 
const = 0;
 
   88     virtual const int GetDOF() 
const = 0;
 
   93 class IkSolutionListBase
 
  112     virtual void Clear() = 0;
 
  116 template <
typename T>
 
  117 class IkFastFunctions
 
  130     typedef int* (*GetFreeParametersFn)();
 
  136     typedef const char* (*GetIkFastVersionFn)();
 
  140     typedef const char* (*GetKinematicsHashFn)();
 
  147 template <
typename T>
 
  156     virtual void GetSolution(T* solution, 
const T* freevalues)
 const {
 
  157         for(std::size_t i = 0; i < 
_vbasesol.size(); ++i) {
 
  162                 if( solution[i] > T(3.14159265358979) ) {
 
  163                     solution[i] -= T(6.28318530717959);
 
  165                 else if( solution[i] < T(-3.14159265358979) ) {
 
  166                     solution[i] += T(6.28318530717959);
 
  172     virtual void GetSolution(std::vector<T>& solution, 
const std::vector<T>& freevalues)
 const {
 
  173         solution.resize(
GetDOF());
 
  174         GetSolution(&solution.at(0), freevalues.size() > 0 ? &freevalues.at(0) : NULL);
 
  177     virtual const std::vector<int>& 
GetFree()
 const {
 
  181         return static_cast<int>(
_vbasesol.size());
 
  185         for(
size_t i = 0; i < 
_vbasesol.size(); ++i) {
 
  186             if( 
_vbasesol[i].maxsolutions == (
unsigned char)-1) {
 
  187                 throw std::runtime_error(
"max solutions for joint not initialized");
 
  191                     throw std::runtime_error(
"index >= max solutions for joint");
 
  194                     throw std::runtime_error(
"2nd index >= max solutions for joint");
 
  203         for(
int i = (
int)
_vbasesol.size()-1; i >= 0; --i) {
 
  204             if( 
_vbasesol[i].maxsolutions != (
unsigned char)-1 && 
_vbasesol[i].maxsolutions > 1 ) {
 
  205                 for(
size_t j = 0; j < v.size(); ++j) {
 
  208                 size_t orgsize=v.size();
 
  209                 if( 
_vbasesol[i].indices[1] != (
unsigned char)-1 ) {
 
  210                     for(
size_t j = 0; j < orgsize; ++j) {
 
  211                         v.push_back(v[j]+
_vbasesol[i].indices[1]);
 
  214                 if( 
_vbasesol[i].indices[0] != (
unsigned char)-1 ) {
 
  215                     for(
size_t j = 0; j < orgsize; ++j) {
 
  223     std::vector< IkSingleDOFSolutionBase<T> > 
_vbasesol;       
 
  228 template <
typename T>
 
  229 class IkSolutionList : 
public IkSolutionListBase<T>
 
  242             throw std::runtime_error(
"GetSolution index is invalid");
 
  244         typename std::list< IkSolution<T> >::const_iterator it = 
_listsolutions.begin();
 
  245         std::advance(it,
index);
 
  263 #endif // OPENRAVE_IKFAST_HEADER 
  266 #ifdef IKFAST_HAS_LIBRARY 
  269 #ifdef IKFAST_CLIBRARY 
  271 #define IKFAST_API extern "C" __declspec(dllexport) 
  273 #define IKFAST_API extern "C" 
  279 #ifdef IKFAST_NAMESPACE 
  280 namespace IKFAST_NAMESPACE {
 
  284 typedef IKFAST_REAL IkReal;
 
  286 typedef double IkReal;
 
  301 IKFAST_API 
void ComputeFk(
const IkReal* joints, IkReal* eetrans, IkReal* eerot);
 
  324 #ifdef IKFAST_NAMESPACE 
  328 #endif // IKFAST_HAS_LIBRARY 
  
unsigned char jointtype
joint type, 0x01 is revolute, 0x11 is slider
unsigned char indices[5]
unique index of the solution used to keep track on what part it came from. sometimes a solution can b...
virtual const IkSolutionBase< T > & GetSolution(size_t index) const =0
returns the solution pointer
const typedef char *(* GetKinematicsHashFn)()
GetIkFastVersionFn _GetIkFastVersion
std::list< IkSolution< T > > _listsolutions
IkSingleDOFSolutionBase()
void(* ComputeFkFn)(const T *, T *, T *)
std::vector< IkSingleDOFSolutionBase< T > > _vbasesol
solution and their offsets if joints are mimiced
const typedef char *(* GetIkFastVersionFn)()
GetFreeParametersFn _GetFreeParameters
virtual size_t GetNumSolutions() const
returns the number of solutions stored
virtual void GetSolutionIndices(std::vector< unsigned int > &v) const
virtual void GetSolution(T *solution, const T *freevalues) const =0
gets a concrete solution
T foffset
joint value is fmul*sol[freeind]+foffset
std::vector< int > _vfree
unsigned char maxsolutions
max possible indices, 0 if controlled by free index or a free joint itself
manages all the solutions
virtual size_t AddSolution(const std::vector< IkSingleDOFSolutionBase< T > > &vinfos, const std::vector< int > &vfree)
add one solution and return its index for later retrieval
GetKinematicsHashFn _GetKinematicsHash
virtual size_t GetNumSolutions() const =0
returns the number of solutions stored
const IKFAST_API char * GetKinematicsHash()
int(* GetNumFreeParametersFn)()
holds the solution for a single dof
IKFAST_API void ComputeFk(const IkReal *j, IkReal *eetrans, IkReal *eerot)
GetNumFreeParametersFn _GetNumFreeParameters
virtual const std::vector< int > & GetFree() const
Gets the indices of the configuration space that have to be preset before a full solution can be retu...
virtual const int GetDOF() const =0
the dof of the solution
virtual ~IkSolutionBase()
virtual size_t AddSolution(const std::vector< IkSingleDOFSolutionBase< T > > &vinfos, const std::vector< int > &vfree)=0
add one solution and return its index for later retrieval
virtual void Validate() const
virtual const IkSolutionBase< T > & GetSolution(size_t index) const
returns the solution pointer
IKFAST_API int GetNumFreeParameters()
const IKFAST_API char * GetIkFastVersion()
IKFAST_API int GetIkType()
virtual void GetSolution(T *solution, const T *freevalues) const
gets a concrete solution
IKFAST_API int GetNumJoints()
GetNumJointsFn _GetNumJoints
The discrete solutions are returned in this structure.
virtual ~IkSolutionListBase()
IKFAST_API int * GetFreeParameters()
virtual void Clear()=0
clears all current solutions, note that any memory addresses returned from GetSolution will be invali...
GetIkRealSizeFn _GetIkRealSize
IKFAST_API bool ComputeIk(const IkReal *eetrans, const IkReal *eerot, const IkReal *pfree, IkSolutionListBase< IkReal > &solutions)
virtual ~IkFastFunctions()
virtual const int GetDOF() const
the dof of the solution
virtual const std::vector< int > & GetFree() const =0
Gets the indices of the configuration space that have to be preset before a full solution can be retu...
virtual void GetSolution(std::vector< T > &solution, const std::vector< T > &freevalues) const
std::vector version of GetSolution
IkSolution(const std::vector< IkSingleDOFSolutionBase< T > > &vinfos, const std::vector< int > &vfree)
IKFAST_API int GetIkRealSize()
signed char freeind
if >= 0, mimics another joint
Default implementation of IkSolutionBase.
bool(* ComputeIkFn)(const T *, const T *, const T *, IkSolutionListBase< T > &)
int *(* GetFreeParametersFn)()
virtual void GetSolution(std::vector< T > &solution, const std::vector< T > &freevalues) const
std::vector version of GetSolution
virtual void Clear()
clears all current solutions, note that any memory addresses returned from GetSolution will be invali...