Using OMPL with Drake

380 views Asked by At

I am trying to work with ompl on drake and am having issues with using the ompl headers in drake. I installed ompl using the default installation path and made the following changes in drake:

Added the following to the workspace:

new_local_repository(
    name = "ompl",
    path = "/usr/local/include/ompl-1.5/ompl",
    build_file = "ompl.BUILD",
)

ompl.BUILD:

cc_library(
    name = "ompl",
    hdrs = glob(["**"]),
    includes = ["include"],
    visibility = ["//visibility:public"], 
    linkstatic = 1,
)

In my repository's BUILD.bazel:

drake_cc_binary(
    name = "ompl_ex",
    srcs = ["src/ompl_ex.cc"],
    data = [],
    test_rule_args = ["--target_realtime_rate=0.0"],
    deps = [
        "@gflags",
        "@ompl//:ompl",
    ],
)

ompl_ex.cc

#include <memory>

#include <limits.h>
#include <unistd.h>
#include <fstream>
#include <string>
#include <gflags/gflags.h>
#include <iostream>

#include <ompl/config.h>
#include <vector>

namespace drake {
namespace ompl {

int DoMain(){
    std::cout<<"the function is working"<<std::endl;
    return 0;
}

}  // namespace examples
}  // namespace drake

int main(int argc, char* argv[]) {
  gflags::ParseCommandLineFlags(&argc, &argv, true);
  return drake::ompl::DoMain();
}

The error I get:

infinite_horizon_ltl/src/ompl_ex.cc:10:10: fatal error: ompl/config.h: No such file or directory
 #include <ompl/config.h>

I use spot libraries similarly and they seem to be working fine. Not sure what I am getting wrong in the case of OMPL. I checked on drakes git issues and found that there was an attempt at integration but the branch is deleted now, and the solution proposed does not seem to be working on my system.

1

There are 1 answers

0
David M.S. Johnson On

I have found that it is easiest to work with drake as an external library in a cmake project. This works quite well with ompl. Here's a quick example which imports both drake and ompl as external libraries and solves a simple planning problem.

https://github.com/DexaiRobotics/drake-torch/tree/master/examples/drake-ompl

The output and video were made using the dexai2/drake-torch/cpu-nightly-ros docker which is available here: https://hub.docker.com/r/dexai2/drake-torch/tags

As an aside, depending on which version of Ubuntu you use, you may need change your gcc version - e.g. you need gcc-9 and g++-9 specified in the CMakeLists.txt for Ubuntu 20.04 and gcc-7 and g++-7 on 18.04. See notes here: https://drake.mit.edu/developers.html#id10