ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Use IKFast in separate package

asked 2018-05-02 16:39:27 -0500

maxgitt gravatar image

I am attempting to use some of the definitions and functions found in the IKFast plugin package (more on this below) but am running into trouble adding the necessary dependencies in my CMakeLists.txt

The file structure of the files relevant to me look like this:

myrobot_ikfast_plugin/
    include/
        ikfast.h
    src/
        myrobot_group_ikfast_solver.cpp
    CMakeLists.txt
    package.xml
my_package/
    src/
        my_iksolver.cpp
    CMakeLists.txt
    package.xml

Within my_iksolver.cpp I require the use of

  • IkSolutionList
  • IkSolutionBase
  • IkReal
  • ComputeIk()

The above definitions and functions come from both ikfast.h and myrobot_group_ikfast_solver.cpp, so I suppose I only really need to include the cpp file as it already has a #include ikfast.h. Where I'm stuck is editing the CMakeLists.txts to include the few things I need from IKFast.

As noted here by, my lord and savior, gvdhoorn https://answers.ros.org/question/2172... , the "elegant" way to do this is to consider using libraries so naturally I tried the following:

Added to myrobot_ikfast_plugin/CMakeLists.txt:

add_library(ik_solver src/kuka_arm_ikfast_solver.cpp)
target_link_libraries(ik_solver ${catkin_LIBRARIES})

And added the ik_solver to the install:

install(TARGETS ${IKFAST_LIBRARY_NAME} ik_solver LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION})

Then I added to my_package/CMakeLists.txt:

  • kuka_ikfast_plugin to find_package()
  • add_executable(my_iksolver src/my_iksolver.cpp)
  • target_link_libraries(my_iksolver ik_solver) (see above created library)

But when attempting to #include <kuka_arm_ikfast_solver.cpp> I get a build error "No such file or directory`.

So the questions that I would like to be answered are summarized as follows:

  1. How should I edit IKFast's CMakeLists.txt so that I can use components of both the cpp and header files.
  2. How should I edit my_package CMakeLists.txt and my_package/package.xml to use those components.
  3. How should I #include the cpp file (marked as a library) to be used by my_package/src/my_iksolver.cpp.

Thanks for the help ahead of time!

edit retag flag offensive close merge delete

Comments

I suppose I only really need to include the cpp file as it already has a #include ikfast.h

I would not recommend including a cpp file. I know the (MoveIt) IKFast plugin infrastructure does that, but it's not really nice.

Treat the IKFast lib as library, include the ikfast.h and ..

gvdhoorn gravatar image gvdhoorn  ( 2018-05-03 05:16:26 -0500 )edit

.. it should work.

gvdhoorn gravatar image gvdhoorn  ( 2018-05-03 05:16:35 -0500 )edit

so I removed everything from both CMakeLists.txts except for find_package(myrobot_ikfast_plugin), I can't seem to #include ikfash.h, maybe I'm missing something. what commands do I have to give in both CMakeLists to "treat IKfast lib as library"?

maxgitt gravatar image maxgitt  ( 2018-05-03 09:20:59 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-05-03 16:23:53 -0500

maxgitt gravatar image

Solved, the docs for catkin helped me do this properly. First in the CMakeLists.txt catkin_package

catkin_package(
  # Other pkgs can use ikfast.h
  INCLUDE_DIRS
    include
)

Now other packages can use ikfast.h but a good number of definitions and functions have been excluded by #ifdef. So you must

#define IKFAST_HAS_LIBRARY

in ikfast.h. And then a a link to the definition of computerIK() must be created to <myrobot>_<group>_ikfast_solver.cpp by making the additional changes to the CMakeLists.txt

catkin_package(
  # Other pkgs can use ikfast.h
  INCLUDE_DIRS
    include
  LIBRARIES
    ik_solver_lib
)

add_library(ik_solver_lib src/kuka_arm_ikfast_solver.cpp)
target_link_libraries(ik_solver_lib ${catkin_LIBRARIES})

# And include in installs
install(TARGETS ${IKFAST_LIBRARY_NAME} ik_solver_lib LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION})

Now all that's needed is to add to the package that you would like to use IKFast's functionality by adding

find_package(catkin REQUIRED COMPONENTS 
    ...
    kuka_ikfast_plugin
)

Simply #include <ikfast.h> in any cpp in your package.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-05-02 16:39:27 -0500

Seen: 234 times

Last updated: May 03 '18