Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting Drake to work with ROS using find_package() #12773

Closed
JeffR1992 opened this issue Feb 26, 2020 · 5 comments
Closed

Getting Drake to work with ROS using find_package() #12773

JeffR1992 opened this issue Feb 26, 2020 · 5 comments
Labels
component: distribution Nightly binaries, monthly releases, docker, installation unused team: kitware unused type: user assistance

Comments

@JeffR1992
Copy link

I've had a look at the official Drake website and on this Github too, but unfortunately haven't been able to find a direct answer to the following question (although there have been a few questions regarding find_package()).

I downloaded the drake binaries from https://drake.mit.edu/from_binary.html and am trying to use some of drake's functionality in a ROS project (in particular, drake's implementation to efficiently solve the discrete algebraic Riccati equation (DARE)).

I'm on Ubuntu 16.04 using ROS Kinetic. As such, in my ROS project's CMakeLists.txt I have,

find_package(catkin REQUIRED COMPONENTS
  roscpp
  std_msgs
  mav_msgs
  drake
)

and in the package.xml I've added,

  <build_depend>drake</build_depend>
  <build_export_depend>drake</build_export_depend>
  <exec_depend>drake</exec_depend>

However, when calling catkin build in my workspace I get the following error,

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

    drakeConfig.cmake
    drake-config.cmake

  Add the installation prefix of "drake" to CMAKE_PREFIX_PATH or set
  "drake_DIR" to a directory containing one of the above files.  If "drake"
  provides a separate development package or SDK, be sure it has been
  installed.
Call Stack (most recent call first):
  CMakeLists.txt:10 (find_package)

Is there a way to allow find_package() to work when trying to find the drake package?

@jamiesnape jamiesnape self-assigned this Feb 26, 2020
@jamiesnape
Copy link
Contributor

jamiesnape commented Feb 26, 2020

Ubuntu 16.04 using ROS Kinetic

Note that we have not supported 16.04 since 105877e (October 24, 2019). Assuming you are using a version from before then, you are going to need to do exactly what the error message says (set CMAKE_PREFIX_PATH to /path/to/drake or set drake_DIR to /path/to/drake/lib/cmake/drake). Even then, you may run into issues since #9500 is unresolved.

@JeffR1992
Copy link
Author

JeffR1992 commented Feb 26, 2020

Thanks @jamiesnape, I'm using the drake binaries from drake-latest-xenial.tar.gz (for some reason permission is denied when trying to download drake-20191026-xenial.tar.gz). I tried adding the explicit path to drake using set(CMAKE_PREFIX_PATH "/home/jeff/dev/drake") above the call to find_package() in CMakeLists.txt, but that still doesn't seem to work when calling catkin build.

I feel like I must be doing something incorrectly, the first few lines of my CMakeLists.txt now looks as follows,

cmake_minimum_required(VERSION 2.8.3)
project(quadrotor_controller)

set(CMAKE_PREFIX_PATH "/home/jeff/dev/drake")

find_package(catkin REQUIRED COMPONENTS
  roscpp
  std_msgs
  mav_msgs
  drake
)

@jamiesnape
Copy link
Contributor

You would need literally find_package(drake REQUIRED) and then use target_link_libraries(.... drake::drake), etc. If that is not sufficient, let me know.

@JeffR1992
Copy link
Author

JeffR1992 commented Feb 26, 2020

Hmm, catkin build complains about being unable to find roscpp with the above changes, which makes we think I did it incorrectly. This is the error I'm getting:

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

    roscppConfig.cmake
    roscpp-config.cmake

  Add the installation prefix of "roscpp" to CMAKE_PREFIX_PATH or set
  "roscpp_DIR" to a directory containing one of the above files.  If "roscpp"
  provides a separate development package or SDK, be sure it has been
  installed.
Call Stack (most recent call first):
  CMakeLists.txt:6 (find_package)

And this is my current CMakeLists.txt in its entirety:

cmake_minimum_required(VERSION 2.8.3)
project(quadrotor_controller)

set(CMAKE_PREFIX_PATH "/home/jeff/dev/drake")

find_package(catkin REQUIRED COMPONENTS
  roscpp
  std_msgs
  mav_msgs
)

find_package(drake REQUIRED)

catkin_package(
#  INCLUDE_DIRS include
#  LIBRARIES quadrotor_controller
  CATKIN_DEPENDS mav_msgs
#  DEPENDS system_lib
)

include_directories(
  include
  ${catkin_INCLUDE_DIRS}
)

add_library(simple_controller STATIC
  src/simple_controller.cpp
)

add_executable(${PROJECT_NAME}_node
  src/quadrotor_controller_node.cpp
)

target_link_libraries(${PROJECT_NAME}_node
  simple_controller
  drake::drake
  ${catkin_LIBRARIES}
)

set(CMAKE_CXX_COMPILER "/usr/bin/clang++")

@jwnimmer-tri
Copy link
Collaborator

In the past couple of months, we've moved to using Stack Overflow as our desired forum for support (see https://drake.mit.edu/getting_help.html#asking-your-question).

I'm sorry for closing an issue without a clear resolution, but if you are still having trouble please open a new SO post tagged with drake, and provide the latest version of the failing example.

Note that current development is focused on Bionic and Focal; we haven't supported Xenial since last October at https://github.com/RobotLocomotion/drake/releases/tag/v0.11.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: distribution Nightly binaries, monthly releases, docker, installation unused team: kitware unused type: user assistance
Projects
None yet
Development

No branches or pull requests

3 participants