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

Feature/cmake #12

Merged
merged 52 commits into from
May 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
78ea719
backup, first steps work with pure cmake
markusgft Apr 27, 2019
e905096
corrected a single path
markusgft Apr 27, 2019
a0a09cc
ct_core now cmake only, except for prespec
markusgft Apr 28, 2019
fbf0867
ct_optcon now mostly cmake only, targets not yet getting exported cor…
markusgft Apr 28, 2019
71722ed
there is no reason for keeping sparsitypattern.cpp in ct_core. move a…
markusgft Apr 28, 2019
51d2fef
fixing template-prespec for ct_core - remove dangerous includes and f…
markusgft Apr 28, 2019
d1d3599
fix wrong link
markusgft Apr 28, 2019
400275f
travis now employs explicit template prespecification
markusgft Apr 28, 2019
3d8730b
adding python stuff again
markusgft Apr 28, 2019
758debf
putting doc in separate cmakelists
markusgft May 2, 2019
9b9e3fa
renaming costfunction convenience headers to avoid naming conflict on…
markusgft May 2, 2019
c35cf3a
first refactoring of ct_rbd makelist
markusgft May 2, 2019
b96abe2
interm backup
markusgft May 5, 2019
f9493df
made cmake integratin for ct_core leaner
markusgft May 5, 2019
2c96ba2
backing up developments for pure cmake version
markusgft May 6, 2019
582e813
Merge branch '3.0.0' into feature/cmake
markusgft May 6, 2019
fac6ec4
Merge branch '3.0.0' of github.com:ethz-adrl/control-toolbox into 3.0.0
markusgft May 6, 2019
bf81c6e
Merge branch '3.0.0' into feature/cmake
markusgft May 6, 2019
e6c7a9e
Merge branch 'feature/cmake' of github.com:ethz-adrl/control-toolbox …
markusgft May 6, 2019
e05cc48
next iteration pure cmake
markusgft May 7, 2019
6540b16
attempting manual installation of gtest
markusgft May 7, 2019
94a21e2
cmake fix travis file
markusgft May 7, 2019
ad5a407
another try for gtest
markusgft May 7, 2019
262bb67
adding cmake to travis install
markusgft May 7, 2019
b2c0c2a
go back to home directory
markusgft May 7, 2019
6706687
correcting prespec dims
markusgft May 7, 2019
63be3a5
tiny lib fix
markusgft May 7, 2019
5302699
few adaptions to doxyfiles
markusgft May 7, 2019
657fa63
removing prespec and examples from travis, seems to be too slow and t…
markusgft May 8, 2019
cca05b6
fixing cmakelist
markusgft May 8, 2019
c377f6a
muting more command line commands in travis
markusgft May 8, 2019
26db976
tests still don't run through
markusgft May 8, 2019
4d71b2b
unit tests should work now
markusgft May 8, 2019
73fc6ba
Update .travis.yml
markusgft May 8, 2019
f093b38
updating docu style a bit, updating to 3.0.1
markusgft May 10, 2019
79c1ec3
Merge branch 'feature/cmake' into feature/cmake2
markusgft May 10, 2019
f3aae74
changing legacy links from bitbucket to github
markusgft May 10, 2019
6326d68
getting rid of clang-tidy
markusgft May 11, 2019
723af06
ran clang-format on ct_core
markusgft May 11, 2019
5d644d6
ran clang-format on ct_optcon
markusgft May 11, 2019
340f885
ran clang-format on ct_rbd
markusgft May 11, 2019
4ae40bb
added a simple bash script to install ct
markusgft May 11, 2019
fc16577
mainpage slight change
markusgft May 11, 2019
ba88f64
adding findipopt.cmake
markusgft May 12, 2019
44690c0
adding shell script for installing dependencies
markusgft May 12, 2019
b63ef12
installing cmake earlier in travis script
markusgft May 12, 2019
fd7ea8f
making install_deps executable
markusgft May 12, 2019
6c46eb7
now exporting linked libraries from ct_optcon correctly
markusgft May 12, 2019
9e35df4
renamped ct_core shared-lib to ct_plot
markusgft May 12, 2019
64afaea
adding a script which cleans up build spaces
markusgft May 12, 2019
5ad6f61
adding optcon examples to documentation
markusgft May 15, 2019
d0d5fe6
updating installation tutorial
markusgft May 15, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ CMakeCache.txt
*.cmake
!clang-cxx-dev-tools.cmake
!compilerSettings.cmake
!FindIPOPT.cmake
!Findblasfeo.cmake
!Findhpipm.cmake
*.a
*.o
*.so
Expand All @@ -26,3 +29,6 @@ solution.mat
.settings/
*.aux
*.doc*
*.vscode

*/build/*
62 changes: 44 additions & 18 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,32 @@ env:

################################################################################

# Install system dependencies, namely a very barebones ROS setup.
before_install:
#install lapack
- sudo apt-get update
- sudo apt-get install liblapack-dev
- sudo apt-get install libeigen3-dev

#install gtest
- sudo apt-get update >/dev/null # suppress output
- sudo apt-get install cmake >/dev/null # suppress output
- sudo apt install libgtest-dev >/dev/null # suppress output
- cd /usr/src/gtest/ >/dev/null # suppress output
- sudo mkdir build && cd build >/dev/null # suppress output
- sudo cmake .. -DBUILD_SHARED_LIBS=ON >/dev/null # suppress output
- sudo make >/dev/null # suppress output
- sudo cp *.so /usr/lib >/dev/null # suppress output
- cd ~/ >/dev/null # suppress output

#install ros kinetic
- sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu `lsb_release -sc` main" > /etc/apt/sources.list.d/ros-latest.list'
- wget http://packages.ros.org/ros.key -O - | sudo apt-key add -
- sudo apt-get update
- sudo apt-get install python-catkin-tools
- sudo sh -c "echo \"deb http://packages.ros.org/ros/ubuntu $ROS_CI_DESKTOP main\" > /etc/apt/sources.list.d/ros-latest.list"
- sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116
- sudo apt-get update -qq
- sudo apt-get install -y ros-$ROS_DISTRO-ros-base
- source /opt/ros/$ROS_DISTRO/setup.bash
- sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu `lsb_release -sc` main" > /etc/apt/sources.list.d/ros-latest.list' >/dev/null # suppress output
- wget http://packages.ros.org/ros.key -O - | sudo apt-key add - >/dev/null # suppress output
- sudo apt-get update >/dev/null # suppress output
- sudo apt-get install python-catkin-tools >/dev/null # suppress output
- sudo sh -c "echo \"deb http://packages.ros.org/ros/ubuntu $ROS_CI_DESKTOP main\" > /etc/apt/sources.list.d/ros-latest.list" >/dev/null # suppress output
- sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116 >/dev/null # suppress output
- sudo apt-get update >/dev/null # suppress output
- sudo apt-get install -y python-catkin-pkg python-rosdep ros-$ROS_DISTRO-ros-base >/dev/null # suppress output
- source /opt/ros/$ROS_DISTRO/setup.bash >/dev/null # suppress output
# Prepare rosdep to install dependencies.
- sudo rosdep init
- rosdep update
- sudo rosdep init >/dev/null # suppress output
- rosdep update >/dev/null # suppress output

# Create a catkin workspace with the package under integration.
install:
Expand All @@ -49,7 +56,14 @@ install:
# Add the package under integration to the workspace using a symlink.
- cd ~/catkin_ws/src
- ln -s $CI_SOURCE_PATH .

#install deb-packaged dependencies
- cd ~/catkin_ws/src/control-toolbox/ct
- chmod 775 install_deps.sh
- ./install_deps.sh >/dev/null # suppress output

#install kindr
- cd ~/catkin_ws/src/
- git clone https://github.com/ANYbotics/kindr.git

# Install all dependencies, using wstool first and rosdep second.
Expand All @@ -67,7 +81,19 @@ script:
- source /opt/ros/$ROS_DISTRO/setup.bash
- cd ~/catkin_ws
- catkin clean --all
- catkin build -DCMAKE_BUILD_TYPE=Release
- catkin config --blacklist ct_doc
- catkin build -DBUILD_TESTS=true -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-w"
# Run the tests, ensuring the path is set correctly.
# we do not want to run the kindr tests
- catkin config --blacklist kindr
# run unit tests
- source devel/setup.bash
- catkin run_tests && catkin_test_results
- cd ~/catkin_ws/src/control-toolbox/ct_core
- catkin run_tests --this --no-deps >/dev/null # suppress output
- cd ~/catkin_ws/src/control-toolbox/ct_optcon
- catkin run_tests --this --no-deps >/dev/null # suppress output
- cd ~/catkin_ws/src/control-toolbox/ct_rbd
- catkin run_tests --this --no-deps >/dev/null # suppress output
- cd ~/catkin_ws/src/control-toolbox/ct_models
- catkin run_tests --this --no-deps >/dev/null # suppress output
- catkin_test_results
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Control Toolbox
![Travis (.org) branch](https://img.shields.io/travis/ethz-adrl/control-toolbox/3.0.0.svg?style=popout-square)
![Travis (.org) branch](https://img.shields.io/travis/ethz-adrl/control-toolbox/3.0.1.svg?style=popout-square)
![GitHub top language](https://img.shields.io/github/languages/top/ethz-adrl/control-toolbox.svg?style=social)
![GitHub](https://img.shields.io/github/license/ethz-adrl/control-toolbox.svg?style=social)

Expand Down
12 changes: 3 additions & 9 deletions ct/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
cmake_minimum_required(VERSION 2.6)
project(ct)
find_package(catkin REQUIRED)
catkin_metapackage()
cmake_minimum_required(VERSION 3.3)
project(ct VERSION 3.0.1 LANGUAGES CXX)

#Make sure metapackage does not fail when building documentation
add_custom_target(doc
Expand All @@ -10,8 +8,4 @@ add_custom_target(doc

add_custom_target(clang-format
COMMAND ${CMAKE_COMMAND} -E echo_append "Running clang-format on CT..."
VERBATIM)

add_custom_target(clang-tidy
COMMAND ${CMAKE_COMMAND} -E echo_append "Running clang-tidy on CT..."
VERBATIM)
VERBATIM)
56 changes: 56 additions & 0 deletions ct/build_ct.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash

build_module(){
# if module directory exists
if [ -d "../$1" ]; then

echo " === Starting module " $1 " === "
# go to that module
cd ../$1
echo "Current directory is " $PWD

# collect array of all args, remove first arg because that is equal to the module to be built
build_flags=( "$@" )
unset build_flags[0]

# make and go to build directory
mkdir -p build && cd build

echo "Building with the following flags ... "
printf '%s\n' "${build_flags[@]}"

cmake .. ${build_flags[*]}
make -j4
sudo make install >/dev/null
cd ..
echo " === completed " $1 " === "
else
echo "ERROR: an error occurred during building or installing. Try building manually."
exit 1
fi
}

## get current folder and make sure it is *ct*
curr_folder=${PWD##*/}
if [ $curr_folder != "ct" ]; then
echo "ERROR: you need to start the installer from the control-toolbox/ct directory."
exit 1
fi

# check number of user input args
# no args
if [ -z "$1" ]
then
echo "No build flags supplied, using -DCMAKE_BUILD_TYPE=Release"
BUILD_FLAGS="-DCMAKE_BUILD_TYPE=Release"
else
# entire user input is interpreted as build flags
BUILD_FLAGS="$@"
fi

build_module ct_core $BUILD_FLAGS
build_module ct_optcon $BUILD_FLAGS
build_module ct_rbd $BUILD_FLAGS
build_module ct_models $BUILD_FLAGS

exit 0
39 changes: 39 additions & 0 deletions ct/build_doc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash

build_doc(){
# if module directory exists
if [ -d "../$1" ]; then

echo " === Starting doc for module " $1 " === "
# go to that module
cd ../$1
echo "Current directory is " $PWD

# make and go to build directory
mkdir -p build && cd build

cmake ..
make doc
cd ..
echo " === completed doc for " $1 "."
else
echo "ERROR: an error occurred during building the doc."
exit 1
fi
}

## get current folder and make sure it is *ct*
curr_folder=${PWD##*/}
if [ $curr_folder != "ct" ]; then
echo "ERROR: you need to start the doc build from the control-toolbox/ct directory."
exit 1
fi


build_doc ct_core
build_doc ct_optcon
build_doc ct_rbd
build_doc ct_models
build_doc ct_doc

exit 0
34 changes: 34 additions & 0 deletions ct/clean_ct.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

clean_module(){
# if module directory exists
if [ -d "../$1" ]; then

echo "Now cleaning module " $1 " ... "
# go to that module
cd ../$1

# make and go to build directory
mkdir -p build && cd build
rm -r -f *
cd ..
else
echo "ERROR: an error occurred during cleaning. Try cleaning manually."
exit 1
fi
}

## get current folder and make sure it is *ct*
curr_folder=${PWD##*/}
if [ $curr_folder != "ct" ]; then
echo "ERROR: you need to start the cleaner from the control-toolbox/ct directory."
exit 1
fi

clean_module ct_core
clean_module ct_optcon
clean_module ct_rbd
clean_module ct_models
clean_module ct_doc

exit 0
51 changes: 4 additions & 47 deletions ct/cmake/clang-cxx-dev-tools.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# CLANG-TIDY AND CLANG-FORMAT
##############################

# Additional targets to perform clang-format/clang-tidy
##############
# CLANG-FORMAT
##############

# Additional targets to perform clang-format

# function to exclude user-defined folders from the clang format- and tidy process
function(filter_ct_directories allItems excludeDir)
Expand Down Expand Up @@ -70,46 +70,3 @@ else()
VERBATIM
)
endif()

# Adding clang-tidy target if clang-tidy executable is found
function(ct_configure_clang_tidy TIDY_INC_DIRS)

ct_get_all_srcs(FALSE)

set(CURRENT_INC_DIRS "")

#message(FATAL_ERROR "Inc dirs: ${${TIDY_INC_DIRS}}")

foreach (THIS_INC_DIR ${${TIDY_INC_DIRS}})
#message(WARNING "this inc dir: ${THIS_INC_DIR}")
list(APPEND CURRENT_INC_DIRS "-I${THIS_INC_DIR}")
endforeach()

#message(FATAL_ERROR "Current inc dirs: ${CURRENT_INC_DIRS}")

find_program(CLANG_TIDY_BIN "clang-tidy")
if(NOT CLANG_TIDY_BIN)
find_program(CLANG_TIDY_BIN "clang-tidy-3.9")
endif()
if(NOT CLANG_TIDY_BIN)
find_program(CLANG_TIDY_BIN "clang_tidy")
endif()
message(STATUS ${CLANG_TIDY_BIN})
if(NOT CLANG_TIDY_BIN)
add_custom_target(clang-tidy
COMMAND ${CMAKE_COMMAND} -E echo_append "clang-tidy executable not found"
VERBATIM)
else()
message (STATUS "FOUND CLANG-TIDY")
set(CLANG_TIDY_COMMAND COMMAND ${CLANG_TIDY_BIN} ${ALL_CXX_SOURCE_FILES} -config='' -header-filter=\".*\\/ct\\/.*\" -- -std=c++11 -fopenmp ${CURRENT_INC_DIRS})

add_custom_target(
clang-tidy
COMMAND ${CLANG_TIDY_COMMAND}
COMMENT "Launching clang-tidy"
WORKING_DIRECTORY ${CMAKE_PROJECT_DIR}

)
endif() #CLANG_TIDY_BIN

endfunction()
17 changes: 2 additions & 15 deletions ct/cmake/explicitTemplateHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function(ct_configureFiles ConfigDir STATE_DIM_PRESPEC, CONTROL_DIM_PRESPEC, SCA
set(outputFile "${outputFile}-${STATE_DIM_PRESPEC}-${CONTROL_DIM_PRESPEC}-${SCALAR_PRESPEC_CLEAN}-${POS_DIM_PRESPEC}-${VEL_DIM_PRESPEC}.cpp")
#message(WARNING "configuring file \n ${file} to \n ${outputFile} ")
set(DOUBLE_OR_FLOAT false)
if(SCALAR_PRESPEC STREQUAL "double" OR SCALAR_PRESPEC STREQUAL "float")
if((SCALAR_PRESPEC MATCHES "double") OR (SCALAR_PRESPEC MATCHES "float")) #STREQUAL did not work
set(DOUBLE_OR_FLOAT true)
endif()
configure_file(${file} ${outputFile})
Expand All @@ -104,20 +104,7 @@ function(ct_configureFiles ConfigDir STATE_DIM_PRESPEC, CONTROL_DIM_PRESPEC, SCA
endfunction()


# creates a target for each explicit template lib and adds its sources to it
function(ct_add_explicit_template_libs)
foreach(lib_name ${PRESPEC_LIB_NAMES})
#get_filename_component(raw_filename ${file} NAME_WE)
#message(WARNING "sources for lib ${lib_name}: \n ${${lib_name}_SRCS}")
add_library(${lib_name}
${${lib_name}_SRCS}
)
target_link_libraries(${lib_name} ${catkin_LIBRARIES} ${PYTHON_LIBRARY})
endforeach()
endfunction()


# link external library (for example to link optcon against lapack)
# link external library (for example to link optcon against lapack) # todo this should go away
function(ct_link_external_library extLibs)
foreach(lib_name ${PRESPEC_LIB_NAMES})
target_link_libraries(${lib_name} "${extLibs}")
Expand Down
2 changes: 1 addition & 1 deletion ct/config/explicit_templates.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
STATE_DIM=2, CONTROL_DIM=1, POS_DIM=1, VEL_DIM=1, SCALAR=double
STATE_DIM=12, CONTROL_DIM=4, POS_DIM=6, VEL_DIM=6, SCALAR=double
STATE_DIM=12, CONTROL_DIM=6, POS_DIM=6, VEL_DIM=6, SCALAR=double
#STATE_DIM=12, CONTROL_DIM=6, POS_DIM=6, VEL_DIM=6, SCALAR=double
#STATE_DIM=2, CONTROL_DIM=2, POS_DIM=1, VEL_DIM=1, SCALAR=ct::core::ADScalar
18 changes: 18 additions & 0 deletions ct/install_deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

sudo apt-get update

## get lapack
sudo apt-get install liblapack-dev

## get eigen3
sudo apt-get install libeigen3-dev

## get cmake
sudo apt-get install cmake

## get IPOPT
sudo apt-get install coinor-libipopt-dev

## get boost
sudo apt-get install libboost-all-dev
4 changes: 2 additions & 2 deletions ct/package.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<package>
<name>ct</name>
<version>0.3.0</version>
<version>3.0.1</version>
<description>
ADRL Control Toolbox v3.0
ADRL Control Toolbox 3.0.1
</description>
<maintainer email="markusgft@gmail.com">Markus Giftthaler</maintainer>
<license>BSD-2</license>
Expand Down
Loading