ikfast building library and C++ API

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
Report Content as Inappropriate

ikfast building library and C++ API

I have searched through the pages, but I could not find an answer to this (relatively simple question). I apologize if this is a repost.
I have generated an ikfast solver for my robot and I am trying to do the fallowing:
- generate a transform6d library from the solver,
- link to the library and use the methods such as ComputeIK, from the executable.
For that reason I have set-up a CMakeLists which looks like this (I am using catkin):

cmake_minimum_required(VERSION 2.8.3)


find_package(catkin REQUIRED COMPONENTS cmake_modules)
find_package(OpenRAVE REQUIRED)



add_library(transform6d src/transform6d.cpp)

add_executable(library_test src/library_test.cc)

The source library_test.cc looks like this:

#include <vector>
#include <ikfast.h>
#include <cstdio>

using namespace ikfast;

int main() {
  IkSolutionList<double> solutions;
  std::vector<double> vfree;
  double eerot[9],eetrans[3];

  eerot[0] = 0.331465; eerot[1] = -0.856741; eerot[2] = 0.395128; eetrans[0] = -0.52923682;
  eerot[3] = -0.817145; eerot[4] = -0.051353; eerot[5] = 0.574140; eetrans[1] = 1.27142974;
  eerot[6] = -0.471598; eerot[7] = -0.513184; eerot[8] = -0.717103; eetrans[2] = 1.46921539;

  bool bSuccess = ComputeIk(eetrans, eerot, vfree.size() > 0 ? &vfree[0] : NULL, solutions);

  if( !bSuccess ) {
      fprintf(stderr,"Failed to get ik solution\n");
      return -1;
  return 0;

When I try to build it I get:
error: ComputeIk was not declared in this scope

I have tried to encompass the main with namespace IKFAST_NAMESPACE, and I manage to build it, but then I get a segfault error. Even when I remove everything from the main (except return 0), I still get a segfault. Do you know how to fix this?

Thank you very much in advance!
Reply | Threaded
Open this post in threaded view
Report Content as Inappropriate

Re: ikfast building library and C++ API

I have managed to solve it. For future reference, the problem was that I was adding the compile flags to all targets, which caused problems for library_test. The fix is just adding:

set_target_properties(transform6d PROPERTIES COMPILE_FLAGS "-fPIC -DIKFAST_NO_MAIN -DIKFAST_CLIBRARY -shared")

in CMakeLists.txt after the add_library(...) and removing the set(CMAKE_CXX_FLAGS ...) field.

Out of curiosity, do you know a way of making the procedure c++11 friendly? When I add c++11 flags I get collisions with isnan.