Skip to content

Commit

Permalink
Add initial python binding utilized by Chimera and Boost.Python (#1237)
Browse files Browse the repository at this point in the history
  • Loading branch information
jslee02 authored Feb 21, 2019
1 parent 0a1996e commit 1b2e228
Show file tree
Hide file tree
Showing 54 changed files with 3,585 additions and 27 deletions.
30 changes: 22 additions & 8 deletions .azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Ref: https://docs.microsoft.com/en-us/azure/devops/pipelines

jobs:
- job: ubuntu_xenial_gcc_debug
- job: xenial_gcc_debug
pool:
vmImage: 'Ubuntu 16.04'
variables:
Expand All @@ -14,7 +14,7 @@ jobs:
steps:
- template: .ci/azure-pipelines/native.yml

- job: ubuntu_xenial_gcc_release
- job: xenial_gcc_release
pool:
vmImage: 'Ubuntu 16.04'
variables:
Expand All @@ -26,7 +26,7 @@ jobs:
steps:
- template: .ci/azure-pipelines/native.yml

- job: ubuntu_xenial_32bit_gcc_release
- job: xenial_32bit_gcc_release
pool:
vmImage: 'Ubuntu 16.04'
variables:
Expand All @@ -38,7 +38,7 @@ jobs:
steps:
- template: .ci/azure-pipelines/docker.yml

- job: ubuntu_bionic_gcc_release
- job: bionic_gcc_release
pool:
vmImage: 'Ubuntu 16.04'
variables:
Expand All @@ -50,7 +50,21 @@ jobs:
steps:
- template: .ci/azure-pipelines/docker.yml

- job: ubuntu_cosmic_gcc_release
- job: bionic_gcc_dartpy_release
pool:
vmImage: 'Ubuntu 16.04'
variables:
OS_NAME: linux
COMPILER: gcc
BUILD_TYPE: Release
BUILD_DARTPY: ON
BUILD_DIR: $(Build.SourcesDirectory)
DOCKERFILE: Dockerfile.ubuntu-bionic
steps:
- template: .ci/azure-pipelines/docker.yml
timeoutInMinutes: 0

- job: cosmic_gcc_release
pool:
vmImage: 'Ubuntu 16.04'
variables:
Expand All @@ -62,7 +76,7 @@ jobs:
steps:
- template: .ci/azure-pipelines/docker.yml

- job: ubuntu_disco_gcc_release
- job: disco_gcc_release
pool:
vmImage: 'Ubuntu 16.04'
variables:
Expand All @@ -74,7 +88,7 @@ jobs:
steps:
- template: .ci/azure-pipelines/docker.yml

- job: macos_high_seirra_clang_debug
- job: high_seirra_clang_debug
pool:
vmImage: 'macOS 10.13'
variables:
Expand All @@ -89,7 +103,7 @@ jobs:
'.ci/script.sh'
displayName: 'Script'
- job: macos_high_seirra_clang_release
- job: high_seirra_clang_release
pool:
vmImage: 'macOS 10.13'
variables:
Expand Down
2 changes: 2 additions & 0 deletions .ci/docker/env.list
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ BUILD_DIR
COMPILER
BUILD_NAME
BUILD_TYPE
BUILD_DARTPY
BUILD_DOCS
CODECOV
SUDO
13 changes: 12 additions & 1 deletion .ci/install_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ $SUDO apt-get -y install \
libxi-dev \
libxmu-dev \
libbullet-dev \
liblz4-dev \
libflann-dev \
coinor-libipopt-dev \
libtinyxml2-dev \
Expand All @@ -58,8 +59,18 @@ else
exit 1
fi

if [ "$BUILD_DARTPY" = "ON" ]; then
sudo apt-add-repository -y ppa:personalrobotics
sudo apt-get -qq update
sudo apt-get -y install libboost-dev libboost-thread-dev libboost-python-dev
sudo apt-get -y install python3-dev python3-numpy
sudo apt-get -y install chimera python3-boost-numpy-eigen
sudo apt-get -y install python3-pip -y
sudo pip3 install pytest -U
fi

$SUDO apt-get -y install lcov

if [ $BUILD_NAME = DOCS ]; then
if [ $BUILD_DOCS = "ON" ]; then
$SUDO apt-get -qq -y install doxygen
fi
51 changes: 45 additions & 6 deletions .ci/script.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,35 @@
#!/usr/bin/env bash
set -ex

num_threads=4
# Sanity checks for required environment variables.
if [ -z "$BUILD_TYPE" ]; then
echo "Error: Environment variable BUILD_TYPE is unset."
exit 1
fi

if [ -z "$BUILD_DARTPY" ]; then
echo "Info: Environment variable BUILD_DARTPY is unset. Using OFF by default."
BUILD_DARTPY=OFF
fi

if [ -z "$BUILD_DOCS" ]; then
echo "Info: Environment variable BUILD_DOCS is unset. Using OFF by default."
BUILD_DOCS=OFF
fi

if [ -z "$CODECOV" ]; then
echo "Info: Environment variable CODECOV is unset. Using OFF by default."
CODECOV=OFF
fi

# https://unix.stackexchange.com/a/129401
if [ -z "$OS_NAME" ]; then
echo "Error: Environment variable OS_NAME is unset."
exit 1
fi

# Set number of threads for parallel build
# Ref: https://unix.stackexchange.com/a/129401
num_threads=4
while getopts ":j:" opt; do
case $opt in
j) num_threads="$OPTARG"
Expand All @@ -13,12 +39,15 @@ while getopts ":j:" opt; do
esac
done

# Set compilers
if [ "$COMPILER" = "gcc" ]; then
export CC=gcc
export CXX=g++
elif [ "$COMPILER" = "clang" ]; then
export CC=clang
export CXX=clang++
else
echo "Info: Compiler isn't specified. Using the system default."
fi

# Skip Xenial and Bionic in push builds
Expand All @@ -35,10 +64,20 @@ fi

mkdir build && cd build

if [ "$BUILD_NAME" = "BIONIC_DEBUG" ]; then
cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DDART_VERBOSE=ON -DDART_TREAT_WARNINGS_AS_ERRORS=ON -DDART_BUILD_EXTRAS=ON -DDART_CODECOV=ON ..
else
cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DDART_VERBOSE=ON -DDART_TREAT_WARNINGS_AS_ERRORS=ON -DDART_BUILD_EXTRAS=ON -DDART_CODECOV=OFF ..
cmake .. \
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
-DDART_BUILD_DARTPY=$BUILD_DARTPY \
-DDART_VERBOSE=ON \
-DDART_TREAT_WARNINGS_AS_ERRORS=ON \
-DDART_BUILD_EXTRAS=ON \
-DDART_CODECOV=$CODECOV

if [ "$BUILD_DARTPY" = "ON" ]; then
make -j$num_threads binding
make -j$num_threads dartpy

# Disabled for now
# make pytest
fi

if [ "$OS_NAME" = "linux" ]; then
Expand Down
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ matrix:
- BUILD_NAME=BIONIC_DEBUG
- DOCKERFILE="Dockerfile.ubuntu-bionic"
- BUILD_TYPE=Debug
- CODECOV: ON
- COMPILER=GCC
services: docker
- os: linux
Expand Down Expand Up @@ -60,7 +61,7 @@ matrix:
# - COMPILER=CLANG
- os: linux
env:
- BUILD_NAME=DOCS
- BUILD_DOCS=ON
- DOCKERFILE="Dockerfile.ubuntu-bionic"
- BUILD_TYPE=Release
- COMPILER=GCC
Expand Down Expand Up @@ -95,4 +96,4 @@ deploy:
verbose: true
on:
branch: master
condition: $BUILD_NAME == DOCS && $TRAVIS_EVENT_TYPE != cron
condition: $BUILD_DOCS == ON && $TRAVIS_EVENT_TYPE != cron
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

* Fixed linking error of FLANN by explicitly linking to lz4: [#1221](https://github.com/dartsim/dart/pull/1221)

* Build system
* Build System

* Changed to use GNUInstallDirs for install paths: [#1241](https://github.com/dartsim/dart/pull/1241)
* Fixed not failing for missing required dependencies: [#1250](https://github.com/dartsim/dart/pull/1250)
Expand All @@ -29,6 +29,10 @@

* Fixed Skeleton::setState(): [#1245](https://github.com/dartsim/dart/pull/1245)

* Python

* Added (experimental) Python binding: [#1237](https://github.com/dartsim/dart/pull/1237)

#### Compilers Tested

* Linux
Expand Down
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ option(DART_BUILD_EXTRAS "Build extra projects" OFF)
option(DART_CODECOV "Turn on codecov support" OFF)
option(DART_TREAT_WARNINGS_AS_ERRORS "Treat warnings as errors" OFF)
option(DART_FAST_DEBUG "Add -O1 option for DEBUG mode build" OFF)
option(DART_BUILD_DARTPY "Build dartpy (the python binding)" OFF)

#===============================================================================
# Print intro
Expand Down Expand Up @@ -311,6 +312,10 @@ if(TARGET dart)

endif()

if (DART_BUILD_DARTPY)
add_subdirectory(python)
endif()

if(DART_BUILD_EXTRAS)
add_subdirectory(extras)
endif()
Expand Down
4 changes: 2 additions & 2 deletions cmake/DARTFindDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ if(ASSIMP_FOUND)
include(CheckCXXSourceCompiles)
set(CMAKE_REQUIRED_DEFINITIONS "")
if (NOT ASSIMP_VERSION VERSION_LESS 3.3.0 AND NOT MSVC)
set(CMAKE_REQUIRED_FLAGS "-std=c++11")
set(CMAKE_REQUIRED_FLAGS "-std=c++11 -w")
else()
set(CMAKE_REQUIRED_FLAGS "")
set(CMAKE_REQUIRED_FLAGS "-w")
endif()
set(CMAKE_REQUIRED_INCLUDES ${ASSIMP_INCLUDE_DIRS})
set(CMAKE_REQUIRED_LIBRARIES ${ASSIMP_LIBRARIES})
Expand Down
2 changes: 1 addition & 1 deletion dart/collision/bullet/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ if(BULLET_FOUND)
# any Bullet headers. This is a workaround for the fact that Bullet does not
# add the definition to BULLET_DEFINITIONS or generate a #cmakedefine header.
include(CheckCXXSourceCompiles)
set(CMAKE_REQUIRED_FLAGS "")
set(CMAKE_REQUIRED_FLAGS "-w")
set(CMAKE_REQUIRED_DEFINITIONS "-DBT_USE_DOUBLE_PRECISION")
set(CMAKE_REQUIRED_INCLUDES "${BULLET_INCLUDE_DIRS}")
set(CMAKE_REQUIRED_LIBRARIES "${BULLET_LIBRARIES}")
Expand Down
8 changes: 4 additions & 4 deletions dart/math/detail/Random-impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ struct functor_has_linear_access<
namespace dart {
namespace math {

namespace {
namespace detail {

//==============================================================================
template <template <typename...> class C, typename... Ts>
Expand Down Expand Up @@ -406,13 +406,13 @@ struct NormalImpl<
}
};

} // namespace
} // detail namespace

//==============================================================================
template <typename S>
S Random::uniform(S min, S max)
{
return UniformImpl<S>::run(min, max);
return detail::UniformImpl<S>::run(min, max);
}

//==============================================================================
Expand Down Expand Up @@ -453,7 +453,7 @@ DynamicSizeMatrixT Random::uniform(
template <typename S>
S Random::normal(S min, S max)
{
return NormalImpl<S>::run(min, max);
return detail::NormalImpl<S>::run(min, max);
}

} // namespace math
Expand Down
5 changes: 3 additions & 2 deletions dart/optimizer/pagmo/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Dependency checks
dart_find_package(NLOPT)
dart_find_package(pagmo)
dart_check_optional_package(pagmo "dart-optimizer-pagmo" "pagmo" "2.8")
if(pagmo_FOUND)
Expand All @@ -20,7 +21,7 @@ set(component_name optimizer-pagmo)

# Add target
dart_add_library(${target_name} ${hdrs} ${srcs})
target_link_libraries(${target_name} PUBLIC dart Pagmo::pagmo)
target_link_libraries(${target_name} PUBLIC dart Pagmo::pagmo NLOPT::nlopt)

# Thread
if(THREADS_HAVE_PTHREAD_ARG)
Expand All @@ -34,7 +35,7 @@ endif()
add_component(${PROJECT_NAME} ${component_name})
add_component_targets(${PROJECT_NAME} ${component_name} ${target_name})
add_component_dependencies(${PROJECT_NAME} ${component_name} dart)
add_component_dependency_packages(${PROJECT_NAME} ${component_name} pagmo)
add_component_dependency_packages(${PROJECT_NAME} ${component_name} pagmo NLOPT)

# Generate header for this namespace
dart_get_filename_components(header_names "optimizer_pagmo headers" ${hdrs})
Expand Down
Loading

0 comments on commit 1b2e228

Please sign in to comment.