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

use drake cmakelists #233

Merged
merged 9 commits into from
Jan 20, 2018
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 26 additions & 95 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ endif()
# Options
option(WITH_PERCEPTION "Build with perception libraries and tools." ON)
option(WITH_SNOPT "Build drake with support for the SNOPT solver." ON)
option(WITH_GUROBI "Build with support for Gurobi" OFF)
option(WITH_MOSEK "Build with support for MOSEK" OFF)

option(WITH_IIWA_DRIVER_RLG "Build drake-iiwa-driver, RLG version." ON)
option(WITH_IIWA_DRIVER_TRI "Build drake-iiwa-driver, TRI version." OFF)
option(WITH_SCHUNK_DRIVER "Build drake-schunk-driver." ON)
option(WITH_ROS "Build the catkin-workspace projects." ON)
option(WITH_REACHABILITY_ANALYZER "Build a reachability analyzer (better with snopt)" OFF)
option(WITH_TRIMESH "Build trimesh, a python utility for working with triangle meshes" OFF)
Expand Down Expand Up @@ -64,95 +65,43 @@ set(CMAKE_ARGS_FOR_EXTERNALS
"-DCMAKE_MODULE_PATH:STRING=${CMAKE_MODULE_PATH}"
)

find_program(CP cp)
find_program(BAZEL bazel)
if(NOT BAZEL)
message(FATAL_ERROR "Could NOT find bazel executable")
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(BAZEL_COMPILATION_MODE dbg)
else()
set(BAZEL_COMPILATION_MODE opt)
endif()
set(BAZEL_ENV CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER})
set(BAZEL_DRAKE_STARTUP_ARGS "--output_base=/$ENV{HOME}/.spartan-build/drake-build")
set(BAZEL_ARGS --compilation_mode=${BAZEL_COMPILATION_MODE} --config=unsupported_crosstool --cxxopt=-std=c++1y --host_cxxopt=-std=c++1y)
if(CMAKE_VERBOSE_MAKEFILE)
set(BAZEL_ARGS --subcommands ${BAZEL_ARGS})
endif()
if(WITH_SNOPT)
set(BAZEL_ARGS --config=snopt ${BAZEL_ARGS})
endif()

# Check that compiler is NOT ccache. Ccache is not compatible with bazel.
# "readlink -f" is not available on MacOS. We use a one-liner python script
# to get the result that "readlink -f" would give on Linux.
execute_process(
COMMAND python -c "import os,sys; print(os.path.realpath(os.path.expanduser(sys.argv[1])))" "${CMAKE_CXX_COMPILER}"
RESULT_VARIABLE COMPILER_RESULT
OUTPUT_VARIABLE COMPILER_OUTPUT
)
if(COMPILER_RESULT)
message(FATAL_ERROR "Error while running the compiler ${CMAKE_CXX_COMPILER}.")
endif()
get_filename_component(COMPILER_NAME ${COMPILER_OUTPUT} NAME)
string(STRIP ${COMPILER_NAME} COMPILER_NAME)
if("${COMPILER_NAME}" STREQUAL "ccache")
message(FATAL_ERROR
"Compiler is `ccache`. `ccache` is not compatible with `bazel` which is used to compile `drake`.
To use `ccache` to compile the rest of the project, use the CMake or environment variables \
CMAKE_C_COMPILER_LAUNCHER and CMAKE_CXX_COMPILER_LAUNCHER to set the path to `ccache`."
)
endif()


# Add external projects
# NOTE: For bazel < 0.5.2, two external projects that use Bazel must not build simultaneously.
# One can depend on another one, which will force the order in which they are built.
ExternalProject_Add(drake
SOURCE_DIR ${source_dir}/drake
BINARY_DIR ${build_dir}/drake
BUILD_ALWAYS 1
BUILD_IN_SOURCE 1
USES_TERMINAL_BUILD 1
CONFIGURE_COMMAND ""
BUILD_COMMAND ${BAZEL_ENV} "${BAZEL}" ${BAZEL_DRAKE_STARTUP_ARGS} build ${BAZEL_ARGS} //examples/kuka_iiwa_arm/... //:install @optitrack_driver//src:optitrack_client
INSTALL_COMMAND ${BAZEL_ENV} "${BAZEL}" ${BAZEL_DRAKE_STARTUP_ARGS} run ${BAZEL_ARGS} //:install -- "${CMAKE_INSTALL_PREFIX}"
CMAKE_CACHE_ARGS
-DWITH_SNOPT:BOOL=${WITH_SNOPT}
-DWITH_GUROBI:BOOL=${WITH_GUROBI}
-DWITH_MOSEK:BOOL=${WITH_MOSEK}
${CMAKE_ARGS_FOR_EXTERNALS}
INSTALL_COMMAND ""
)

ExternalProject_Add(libbot
SOURCE_DIR ${build_dir}/externals/libbot
BINARY_DIR ${build_dir}/libbot
GIT_REPOSITORY "https://github.com/RobotLocomotion/libbot2.git"
GIT_TAG "f260260b7d04c1d85169f985e1a2b4447a6832ef"
BUILD_ALWAYS 1
CMAKE_CACHE_ARGS
${CMAKE_ARGS_FOR_EXTERNALS}
DEPENDS drake
)

# This is based on drake's VTK/Qt dependency (see `tools/vtk.bzl` in drake).
# On MacOS, Drake uses homebrew VTK compiled with Qt5 and brew Python
# On Linux, checks distribution
# Ubuntu 14.04: Drake downloads a precompiled version of VTK compiled with Qt4
# Ubuntu 16.04: Drake downloads a precompiled version of VTK compiled with Qt5
# Otherwise, assume Qt5
set(USED_QTVERSION 5)
# On MacOS, Drake uses homebrew VTK compiled with Qt5 and brew Python
if(APPLE)
# VTK version used by drake
set(VTK_INSTALL_DIR /usr/local/opt/vtk@8.0)
# To configure `director`
set(VTK_ARGS
-DVTK_DIR:PATH=${VTK_INSTALL_DIR}/lib/cmake/vtk-8.0
-DPYTHON_CONFIG_EXECUTABLE:FILEPATH=/usr/local/bin/python2.7-config
)
set(QT_ARGS -DQt5_DIR:PATH=/usr/local/opt/qt/lib/cmake/Qt5)
# To configure `config/setup_environment.sh.in`
set(VTK_PYTHON_DIR ${VTK_INSTALL_DIR}/lib/python2.7/site-packages)
elseif(UNIX)
find_program(SED sed)
if(NOT SED)
message(FATAL_ERROR "Could NOT find sed executable")
endif()
execute_process(COMMAND "${SED}" -n "/^\\(NAME\\|VERSION_ID\\)=/{s/[^=]*=//;s/\"//g;p}" /etc/os-release
RESULT_VARIABLE SED_RESULT
OUTPUT_VARIABLE SED_OUTPUT
)
if(SED_RESULT)
message(FATAL_ERROR "Could NOT determine Linux distribution information")
endif()
string(REGEX REPLACE "\n" " " LINUX_DISTRIBUTION "${SED_OUTPUT}")
string(STRIP ${LINUX_DISTRIBUTION} LINUX_DISTRIBUTION)
if(LINUX_DISTRIBUTION STREQUAL "Ubuntu 14.04")
set(USED_QTVERSION 4)
endif()
# For signal-scope
set(QT_ARGS -DQt5_DIR:PATH=/usr/local/opt/qt/lib/cmake/Qt5)
endif()

ExternalProject_Add(director
Expand All @@ -171,12 +120,12 @@ ExternalProject_Add(director
-DUSE_SYSTEM_VTK:BOOL=ON
${VTK_ARGS}
-DUSE_PCL:BOOL=${WITH_PERCEPTION}
-DUSE_APRILTAGS:BOOL=${WITH_PERCEPTION}
-DUSE_APRILTAGS:BOOL=OFF
-DUSE_OPENNI2_LCM:BOOL=OFF # don't build OPENNI2 driver, conflicts with openni2_launch in ROS
-DUSE_PERCEPTION:BOOL=${WITH_PERCEPTION}
${CMAKE_ARGS_FOR_EXTERNALS}
INSTALL_COMMAND ""
DEPENDS drake
DEPENDS libbot drake
)

ExternalProject_Add(common_utils
Expand Down Expand Up @@ -330,24 +279,6 @@ if (WITH_IIWA_DRIVER_RLG OR WITH_IIWA_DRIVER_TRI)

endif()

if (WITH_SCHUNK_DRIVER)

ExternalProject_Add(drake-schunk-driver
SOURCE_DIR ${build_dir}/externals/drake-schunk-driver
GIT_REPOSITORY git@github.com:RobotLocomotion/drake-schunk-driver.git
GIT_TAG a28d35c
BUILD_ALWAYS 1
BUILD_IN_SOURCE 1
USES_TERMINAL_BUILD 1
CONFIGURE_COMMAND ""
BUILD_COMMAND ${BAZEL_ENV} "${BAZEL}" build //...
INSTALL_COMMAND
mkdir -p ${build_dir}/install/bin/ && "${CP}" ${build_dir}/externals/drake-schunk-driver/bazel-bin/src/schunk_driver ${CMAKE_INSTALL_PREFIX}/bin/schunk_driver &&
chmod ug+w ${CMAKE_INSTALL_PREFIX}/bin/schunk_driver
DEPENDS drake
)

endif()

if (WITH_ROS)
if ((NOT DEFINED ENV{CMAKE_PREFIX_PATH}) OR (NOT $ENV{CMAKE_PREFIX_PATH} MATCHES ".*ros.*"))
Expand Down
2 changes: 1 addition & 1 deletion drake
Submodule drake updated 354 files
13 changes: 8 additions & 5 deletions setup/docker/docker_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

parser.add_argument("-p", "--passthrough", type=str, default="", help="(optional) extra string that will be tacked onto the docker run command, allows you to pass extra options. Make sure to put this in quotes and leave a space before the first character")

parser.add_argument("-nodudp", "--no_udp", action='store_true', help="(optional) don't expose the udp ports")

args = parser.parse_args()
print("running docker container derived from image %s" %args.image)
source_dir=os.getcwd()
Expand Down Expand Up @@ -48,10 +50,11 @@
cmd += " --user %s " % user_name # login as current user

# expose UDP ports
cmd += " -p 30200:30200/udp " # expose udp ports for kuka
cmd += " -p 30201:30201/udp " # expose udp ports for kuka
cmd += " -p 1500:1500/udp " # expose udp ports for schunk
cmd += " -p 1501:1501/udp " # expose udp ports for schunk
if not args.no_udp:
cmd += " -p 30200:30200/udp " # expose udp ports for kuka
cmd += " -p 30201:30201/udp " # expose udp ports for kuka
cmd += " -p 1500:1500/udp " # expose udp ports for schunk
cmd += " -p 1501:1501/udp " # expose udp ports for schunk

cmd += " " + args.passthrough + " "

Expand All @@ -63,7 +66,7 @@
cmd += "--entrypoint=\"%(entrypoint)s\" " % {"entrypoint": args.entrypoint}
else:
cmd += "-it "
cmd += args.image
cmd += image_name
cmd_endxhost = "xhost -local:root"

print("command = \n \n", cmd, "\n", cmd_endxhost)
Expand Down
2 changes: 1 addition & 1 deletion setup/docker/run_jenkins.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ mkdir build
cd build

. /opt/ros/kinetic/setup.bash
cmake -DWITH_PERCEPTION:BOOL=ON -DWITH_TRIMESH:BOOL=ON -DWITH_SCHUNK_DRIVER:BOOL=ON -DWITH_IIWA_DRIVER_RLG:BOOL=ON -DWITH_ROS:BOOL=ON -DWITH_REACHABILITY_ANALYZER:BOOL=ON ..
cmake -DWITH_PERCEPTION:BOOL=ON -DWITH_TRIMESH:BOOL=OFF -DWITH_SCHUNK_DRIVER:BOOL=ON -DWITH_IIWA_DRIVER_RLG:BOOL=ON -DWITH_ROS:BOOL=ON -DWITH_REACHABILITY_ANALYZER:BOOL=ON ..
exit_status=$?
if [ ! $exit_status -eq 0 ]; then
echo "Error code in CMake: " $exit_status
Expand Down
10 changes: 8 additions & 2 deletions setup/docker/spartan.dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM nvidia/cuda:8.0-devel-ubuntu16.04
FROM nvidia/cuda:8.0-devel-ubuntu16.04

ARG USER_NAME
ARG USER_PASSWORD
Expand All @@ -16,6 +16,7 @@ RUN usermod -u $USER_ID $USER_NAME
RUN groupmod -g $USER_GID $USER_NAME


# working directory is /home/$USER_NAME
WORKDIR /home/$USER_NAME
# require no sudo pw in docker
# RUN echo $USER_PASSWORD | sudo -S bash -c 'echo "'$USER_NAME' ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/docker-user' && printf "\n"
Expand All @@ -42,8 +43,13 @@ RUN mkdir -p .config/terminator
COPY ./setup/docker/terminator_config .config/terminator/config
RUN chown $USER_NAME:$USER_NAME -R .config

# setup bazel bashrc
RUN echo "startup --output_base=/home/$USER_NAME/.spartan-build" >> .bazelrc

# change ownership of everything to our user
RUN cd $WORKDIR && chown $USER_NAME:$USER_NAME -R .
RUN cd /home/$USER_NAME && chown $USER_NAME:$USER_NAME -R .



ENTRYPOINT bash -c "source ~/spartan/setup/docker/entrypoint.sh && /bin/bash"

Expand Down
5 changes: 4 additions & 1 deletion setup/ubuntu/16.04/install_prereqs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ apt install --no-install-recommends \
qtmultimedia5-dev \
qtscript5-dev \
qttools5-dev \
libcgal-dev # needed for April Tag detection
libcgal-dev \
libxmu-dev \
libxi-dev


# Install ROS Kinetic
apt install -y --no-install-recommends lsb-release
Expand Down
5 changes: 4 additions & 1 deletion src/ReachabilityAnalyzer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ include_directories(${Eigen3_INCLUDE_DIR})
find_package(VTK REQUIRED)
include_directories(${VTK_INCLUDE_DIRS})

find_path(yaml-cpp REQUIRED)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

find_package ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, typo on my part. Just pushed a fix.


link_directories(${CMAKE_INSTALL_PREFIX}/lib)

add_executable(reachability_analyzer reachability_analyzer.cpp reachability_analyzer.hpp)
Expand All @@ -20,6 +22,7 @@ target_link_libraries(reachability_analyzer
${drake_LIBRARIES}
gflags_shared
${VTK_LIBRARIES}
RemoteTreeViewerWrapper)
RemoteTreeViewerWrapper
yaml-cpp)

install(TARGETS reachability_analyzer DESTINATION bin)