Use IKFast in separate package
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
tofind_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:
- How should I edit IKFast's CMakeLists.txt so that I can use components of both the cpp and header files.
- How should I edit my_package CMakeLists.txt and my_package/package.xml to use those components.
- 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!
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 .... it should work.
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"?