limbo icon indicating copy to clipboard operation
limbo copied to clipboard

Add cmake interface

Open jbmouret opened this issue 3 years ago • 3 comments

We did this in robot_dart and it makes it easier to compile with cmake projects.

jbmouret avatar Dec 16 '20 11:12 jbmouret

Hi @jbmouret

Thanks for sharing the library. It was on my radar a while ago and now I found some applications to explore its use. I've been investigating building the library with CMake, since my plan was to use catkin to build it.

So far I'm using CMake's ExternalProject to run waf and then setting up the static binary and headers using CMake. Then a package.xml file handles integration with catkin (I was pointed to the REP-136 to do this). I'm working on a separate fork, but it's still quite messy because I tried many things, including the waftools Cmake stuff mentioned in https://github.com/resibots/limbo/issues/261

By doing the this I was able to link limbo and interpolate using GPs with fixed kernels. However, now I'm struggling to get the NLOpt support to train the hyperparameters, since I get the following warning when trying to build the package that includes limbo:

warning: #warning NO NLOpt, and NO Libcmaes: the acquisition function will be optimized by a grid search algorithm (which is usually bad). Please install at least NLOpt or libcmaes to use limbo!

Do you have any suggestion on something that I'm probably missing that you internally handle with waf? I'm no CMake expert (I usually setup my files using other as a reference) so any comment on that could be helpful.

Thanks!

mmattamala avatar Jun 09 '21 19:06 mmattamala

Hi

First, most of limbo is header-only, so you could simply include the files. Honestly, this is what I would do... I should try to find some time to write some documentation about this.

Indeed, you will need to compile limbo with NLOpt and/or CMA-Es for BO. To do so, you need to:

  • install them [see here http://www.resibots.eu/limbo/tutorials/compilation.html ]
  • if you are compiling limbo with waf, it should detect NLOpt and CMA-ES automatically during the configure
  • compile limbo and your code with -DUSE_NLOPT -DUSE_LIBCMAES (this is because most of limbo is in the headers)

jbmouret avatar Jun 09 '21 20:06 jbmouret

Hi, thanks for the reply, I was missing the -DUSE_NLOPT flag in the installation config files. Now I'm just using the headers in CMake and I can easily import it with catkin in other projects. Cheers!

mmattamala avatar Jun 10 '21 21:06 mmattamala

Hi all,

I just installed limbo and I would like to use it within my catkin based ros projects.

@jbmouret is there any documentation now on this?

@mmattamala is there any example publicly available of how you interfaced limbo with your cmake/catkin-based project?

Thanks in advance

IoannisDadiotis avatar Aug 03 '23 15:08 IoannisDadiotis

Hi @IoannisDadiotis , I have a fork in my account: https://github.com/mmattamala/limbo It should compile by catkin build limbo. Let me know if you have further questions.

mmattamala avatar Aug 03 '23 15:08 mmattamala

@mmattamala this is very cool. Would you consider making a PR so that the rest of the users can profit from this one? Thanks!

costashatz avatar Aug 04 '23 06:08 costashatz

Yes, for sure. I'll do it now. Thank you!

mmattamala avatar Aug 04 '23 09:08 mmattamala

Hi @IoannisDadiotis , I have a fork in my account: https://github.com/mmattamala/limbo It should compile by catkin build limbo. Let me know if you have further questions.

Thanks @mmattamala .

Do you think just catkin build limbo is enough or I still have to do ./waf configure and ./waf build before?

I tried both, but I get the error

CMake Error at /opt/ros/noetic/share/catkin/cmake/catkinConfig.cmake:83 (find_package):
  Could not find a package configuration file provided by "limbo" with any of
  the following names:

    limboConfig.cmake
    limbo-config.cmake

  Add the installation prefix of "limbo" to CMAKE_PREFIX_PATH or set
  "limbo_DIR" to a directory containing one of the above files.  If "limbo"
  provides a separate development package or SDK, be sure it has been
  installed.

My CMAKE_PREFIX_PATH inlcudes the path PATH_TO_CATKIN_WS/devel and i can see the file limboConfig.cmake in PATH_TO_CATKIN_WS/devel/lib/limbo/cmake. I was also wondering if the limboConfig.cmake should be in the PATH_TO_CATKIN_WS/share/ folder instead.

IoannisDadiotis avatar Aug 04 '23 10:08 IoannisDadiotis

UPDATE: I fixed this by find_package(limbo REQUIRED) instead of find_package(catkin REQUIRED COMPONENTS limbo) in the CMakeLists.txt of my catkin package.

I also had to replace find_package(NLopt REQUIRED) with find_package(NLopt) in limbo/cmake/limboConfig.cmake.in (since otherwise catkin searches for a *config.cmake file for NLopt that cannot be found).

IoannisDadiotis avatar Aug 04 '23 15:08 IoannisDadiotis

Thanks for the follow up @IoannisDadiotis . I was about to ask you if this error was when building limbo itself or when including it in your own package. For the record, just catkin build limbo should suffice, without using waf.

I'll fix the Cmake dependencies I set as required, as @costashatz also pointed in the PR that I open earlier today: https://github.com/resibots/limbo/pull/330

mmattamala avatar Aug 04 '23 15:08 mmattamala

This is fixed by #330 !

costashatz avatar Oct 18 '23 22:10 costashatz