Skip to content

Commit b0fb67f

Browse files
authored
Merge pull request #12 from ethz-adrl/feature/cmake2
Feature/cmake
2 parents 5bdce9f + d0d5fe6 commit b0fb67f

File tree

1,232 files changed

+4150
-3134
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,232 files changed

+4150
-3134
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ CMakeCache.txt
33
*.cmake
44
!clang-cxx-dev-tools.cmake
55
!compilerSettings.cmake
6+
!FindIPOPT.cmake
7+
!Findblasfeo.cmake
8+
!Findhpipm.cmake
69
*.a
710
*.o
811
*.so
@@ -26,3 +29,6 @@ solution.mat
2629
.settings/
2730
*.aux
2831
*.doc*
32+
*.vscode
33+
34+
*/build/*

.travis.yml

Lines changed: 44 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,32 @@ env:
2121

2222
################################################################################
2323

24-
# Install system dependencies, namely a very barebones ROS setup.
2524
before_install:
26-
#install lapack
27-
- sudo apt-get update
28-
- sudo apt-get install liblapack-dev
29-
- sudo apt-get install libeigen3-dev
25+
26+
#install gtest
27+
- sudo apt-get update >/dev/null # suppress output
28+
- sudo apt-get install cmake >/dev/null # suppress output
29+
- sudo apt install libgtest-dev >/dev/null # suppress output
30+
- cd /usr/src/gtest/ >/dev/null # suppress output
31+
- sudo mkdir build && cd build >/dev/null # suppress output
32+
- sudo cmake .. -DBUILD_SHARED_LIBS=ON >/dev/null # suppress output
33+
- sudo make >/dev/null # suppress output
34+
- sudo cp *.so /usr/lib >/dev/null # suppress output
35+
- cd ~/ >/dev/null # suppress output
36+
3037
#install ros kinetic
31-
- sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu `lsb_release -sc` main" > /etc/apt/sources.list.d/ros-latest.list'
32-
- wget http://packages.ros.org/ros.key -O - | sudo apt-key add -
33-
- sudo apt-get update
34-
- sudo apt-get install python-catkin-tools
35-
- sudo sh -c "echo \"deb http://packages.ros.org/ros/ubuntu $ROS_CI_DESKTOP main\" > /etc/apt/sources.list.d/ros-latest.list"
36-
- sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116
37-
- sudo apt-get update -qq
38-
- sudo apt-get install -y ros-$ROS_DISTRO-ros-base
39-
- source /opt/ros/$ROS_DISTRO/setup.bash
38+
- 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
39+
- wget http://packages.ros.org/ros.key -O - | sudo apt-key add - >/dev/null # suppress output
40+
- sudo apt-get update >/dev/null # suppress output
41+
- sudo apt-get install python-catkin-tools >/dev/null # suppress output
42+
- 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
43+
- sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116 >/dev/null # suppress output
44+
- sudo apt-get update >/dev/null # suppress output
45+
- sudo apt-get install -y python-catkin-pkg python-rosdep ros-$ROS_DISTRO-ros-base >/dev/null # suppress output
46+
- source /opt/ros/$ROS_DISTRO/setup.bash >/dev/null # suppress output
4047
# Prepare rosdep to install dependencies.
41-
- sudo rosdep init
42-
- rosdep update
48+
- sudo rosdep init >/dev/null # suppress output
49+
- rosdep update >/dev/null # suppress output
4350

4451
# Create a catkin workspace with the package under integration.
4552
install:
@@ -49,7 +56,14 @@ install:
4956
# Add the package under integration to the workspace using a symlink.
5057
- cd ~/catkin_ws/src
5158
- ln -s $CI_SOURCE_PATH .
59+
60+
#install deb-packaged dependencies
61+
- cd ~/catkin_ws/src/control-toolbox/ct
62+
- chmod 775 install_deps.sh
63+
- ./install_deps.sh >/dev/null # suppress output
64+
5265
#install kindr
66+
- cd ~/catkin_ws/src/
5367
- git clone https://github.com/ANYbotics/kindr.git
5468

5569
# Install all dependencies, using wstool first and rosdep second.
@@ -67,7 +81,19 @@ script:
6781
- source /opt/ros/$ROS_DISTRO/setup.bash
6882
- cd ~/catkin_ws
6983
- catkin clean --all
70-
- catkin build -DCMAKE_BUILD_TYPE=Release
84+
- catkin config --blacklist ct_doc
85+
- catkin build -DBUILD_TESTS=true -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-w"
7186
# Run the tests, ensuring the path is set correctly.
87+
# we do not want to run the kindr tests
88+
- catkin config --blacklist kindr
89+
# run unit tests
7290
- source devel/setup.bash
73-
- catkin run_tests && catkin_test_results
91+
- cd ~/catkin_ws/src/control-toolbox/ct_core
92+
- catkin run_tests --this --no-deps >/dev/null # suppress output
93+
- cd ~/catkin_ws/src/control-toolbox/ct_optcon
94+
- catkin run_tests --this --no-deps >/dev/null # suppress output
95+
- cd ~/catkin_ws/src/control-toolbox/ct_rbd
96+
- catkin run_tests --this --no-deps >/dev/null # suppress output
97+
- cd ~/catkin_ws/src/control-toolbox/ct_models
98+
- catkin run_tests --this --no-deps >/dev/null # suppress output
99+
- catkin_test_results

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Control Toolbox
2-
![Travis (.org) branch](https://img.shields.io/travis/ethz-adrl/control-toolbox/3.0.0.svg?style=popout-square)
2+
![Travis (.org) branch](https://img.shields.io/travis/ethz-adrl/control-toolbox/3.0.1.svg?style=popout-square)
33
![GitHub top language](https://img.shields.io/github/languages/top/ethz-adrl/control-toolbox.svg?style=social)
44
![GitHub](https://img.shields.io/github/license/ethz-adrl/control-toolbox.svg?style=social)
55

ct/CMakeLists.txt

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
cmake_minimum_required(VERSION 2.6)
2-
project(ct)
3-
find_package(catkin REQUIRED)
4-
catkin_metapackage()
1+
cmake_minimum_required(VERSION 3.3)
2+
project(ct VERSION 3.0.1 LANGUAGES CXX)
53

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

119
add_custom_target(clang-format
1210
COMMAND ${CMAKE_COMMAND} -E echo_append "Running clang-format on CT..."
13-
VERBATIM)
14-
15-
add_custom_target(clang-tidy
16-
COMMAND ${CMAKE_COMMAND} -E echo_append "Running clang-tidy on CT..."
17-
VERBATIM)
11+
VERBATIM)

ct/build_ct.sh

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/bin/bash
2+
3+
build_module(){
4+
# if module directory exists
5+
if [ -d "../$1" ]; then
6+
7+
echo " === Starting module " $1 " === "
8+
# go to that module
9+
cd ../$1
10+
echo "Current directory is " $PWD
11+
12+
# collect array of all args, remove first arg because that is equal to the module to be built
13+
build_flags=( "$@" )
14+
unset build_flags[0]
15+
16+
# make and go to build directory
17+
mkdir -p build && cd build
18+
19+
echo "Building with the following flags ... "
20+
printf '%s\n' "${build_flags[@]}"
21+
22+
cmake .. ${build_flags[*]}
23+
make -j4
24+
sudo make install >/dev/null
25+
cd ..
26+
echo " === completed " $1 " === "
27+
else
28+
echo "ERROR: an error occurred during building or installing. Try building manually."
29+
exit 1
30+
fi
31+
}
32+
33+
## get current folder and make sure it is *ct*
34+
curr_folder=${PWD##*/}
35+
if [ $curr_folder != "ct" ]; then
36+
echo "ERROR: you need to start the installer from the control-toolbox/ct directory."
37+
exit 1
38+
fi
39+
40+
# check number of user input args
41+
# no args
42+
if [ -z "$1" ]
43+
then
44+
echo "No build flags supplied, using -DCMAKE_BUILD_TYPE=Release"
45+
BUILD_FLAGS="-DCMAKE_BUILD_TYPE=Release"
46+
else
47+
# entire user input is interpreted as build flags
48+
BUILD_FLAGS="$@"
49+
fi
50+
51+
build_module ct_core $BUILD_FLAGS
52+
build_module ct_optcon $BUILD_FLAGS
53+
build_module ct_rbd $BUILD_FLAGS
54+
build_module ct_models $BUILD_FLAGS
55+
56+
exit 0

ct/build_doc.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
3+
build_doc(){
4+
# if module directory exists
5+
if [ -d "../$1" ]; then
6+
7+
echo " === Starting doc for module " $1 " === "
8+
# go to that module
9+
cd ../$1
10+
echo "Current directory is " $PWD
11+
12+
# make and go to build directory
13+
mkdir -p build && cd build
14+
15+
cmake ..
16+
make doc
17+
cd ..
18+
echo " === completed doc for " $1 "."
19+
else
20+
echo "ERROR: an error occurred during building the doc."
21+
exit 1
22+
fi
23+
}
24+
25+
## get current folder and make sure it is *ct*
26+
curr_folder=${PWD##*/}
27+
if [ $curr_folder != "ct" ]; then
28+
echo "ERROR: you need to start the doc build from the control-toolbox/ct directory."
29+
exit 1
30+
fi
31+
32+
33+
build_doc ct_core
34+
build_doc ct_optcon
35+
build_doc ct_rbd
36+
build_doc ct_models
37+
build_doc ct_doc
38+
39+
exit 0

ct/clean_ct.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
3+
clean_module(){
4+
# if module directory exists
5+
if [ -d "../$1" ]; then
6+
7+
echo "Now cleaning module " $1 " ... "
8+
# go to that module
9+
cd ../$1
10+
11+
# make and go to build directory
12+
mkdir -p build && cd build
13+
rm -r -f *
14+
cd ..
15+
else
16+
echo "ERROR: an error occurred during cleaning. Try cleaning manually."
17+
exit 1
18+
fi
19+
}
20+
21+
## get current folder and make sure it is *ct*
22+
curr_folder=${PWD##*/}
23+
if [ $curr_folder != "ct" ]; then
24+
echo "ERROR: you need to start the cleaner from the control-toolbox/ct directory."
25+
exit 1
26+
fi
27+
28+
clean_module ct_core
29+
clean_module ct_optcon
30+
clean_module ct_rbd
31+
clean_module ct_models
32+
clean_module ct_doc
33+
34+
exit 0

ct/cmake/clang-cxx-dev-tools.cmake

Lines changed: 4 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# CLANG-TIDY AND CLANG-FORMAT
2-
##############################
3-
4-
# Additional targets to perform clang-format/clang-tidy
1+
##############
2+
# CLANG-FORMAT
3+
##############
54

5+
# Additional targets to perform clang-format
66

77
# function to exclude user-defined folders from the clang format- and tidy process
88
function(filter_ct_directories allItems excludeDir)
@@ -70,46 +70,3 @@ else()
7070
VERBATIM
7171
)
7272
endif()
73-
74-
# Adding clang-tidy target if clang-tidy executable is found
75-
function(ct_configure_clang_tidy TIDY_INC_DIRS)
76-
77-
ct_get_all_srcs(FALSE)
78-
79-
set(CURRENT_INC_DIRS "")
80-
81-
#message(FATAL_ERROR "Inc dirs: ${${TIDY_INC_DIRS}}")
82-
83-
foreach (THIS_INC_DIR ${${TIDY_INC_DIRS}})
84-
#message(WARNING "this inc dir: ${THIS_INC_DIR}")
85-
list(APPEND CURRENT_INC_DIRS "-I${THIS_INC_DIR}")
86-
endforeach()
87-
88-
#message(FATAL_ERROR "Current inc dirs: ${CURRENT_INC_DIRS}")
89-
90-
find_program(CLANG_TIDY_BIN "clang-tidy")
91-
if(NOT CLANG_TIDY_BIN)
92-
find_program(CLANG_TIDY_BIN "clang-tidy-3.9")
93-
endif()
94-
if(NOT CLANG_TIDY_BIN)
95-
find_program(CLANG_TIDY_BIN "clang_tidy")
96-
endif()
97-
message(STATUS ${CLANG_TIDY_BIN})
98-
if(NOT CLANG_TIDY_BIN)
99-
add_custom_target(clang-tidy
100-
COMMAND ${CMAKE_COMMAND} -E echo_append "clang-tidy executable not found"
101-
VERBATIM)
102-
else()
103-
message (STATUS "FOUND CLANG-TIDY")
104-
set(CLANG_TIDY_COMMAND COMMAND ${CLANG_TIDY_BIN} ${ALL_CXX_SOURCE_FILES} -config='' -header-filter=\".*\\/ct\\/.*\" -- -std=c++11 -fopenmp ${CURRENT_INC_DIRS})
105-
106-
add_custom_target(
107-
clang-tidy
108-
COMMAND ${CLANG_TIDY_COMMAND}
109-
COMMENT "Launching clang-tidy"
110-
WORKING_DIRECTORY ${CMAKE_PROJECT_DIR}
111-
112-
)
113-
endif() #CLANG_TIDY_BIN
114-
115-
endfunction()

ct/cmake/explicitTemplateHelpers.cmake

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ function(ct_configureFiles ConfigDir STATE_DIM_PRESPEC, CONTROL_DIM_PRESPEC, SCA
9292
set(outputFile "${outputFile}-${STATE_DIM_PRESPEC}-${CONTROL_DIM_PRESPEC}-${SCALAR_PRESPEC_CLEAN}-${POS_DIM_PRESPEC}-${VEL_DIM_PRESPEC}.cpp")
9393
#message(WARNING "configuring file \n ${file} to \n ${outputFile} ")
9494
set(DOUBLE_OR_FLOAT false)
95-
if(SCALAR_PRESPEC STREQUAL "double" OR SCALAR_PRESPEC STREQUAL "float")
95+
if((SCALAR_PRESPEC MATCHES "double") OR (SCALAR_PRESPEC MATCHES "float")) #STREQUAL did not work
9696
set(DOUBLE_OR_FLOAT true)
9797
endif()
9898
configure_file(${file} ${outputFile})
@@ -104,20 +104,7 @@ function(ct_configureFiles ConfigDir STATE_DIM_PRESPEC, CONTROL_DIM_PRESPEC, SCA
104104
endfunction()
105105

106106

107-
# creates a target for each explicit template lib and adds its sources to it
108-
function(ct_add_explicit_template_libs)
109-
foreach(lib_name ${PRESPEC_LIB_NAMES})
110-
#get_filename_component(raw_filename ${file} NAME_WE)
111-
#message(WARNING "sources for lib ${lib_name}: \n ${${lib_name}_SRCS}")
112-
add_library(${lib_name}
113-
${${lib_name}_SRCS}
114-
)
115-
target_link_libraries(${lib_name} ${catkin_LIBRARIES} ${PYTHON_LIBRARY})
116-
endforeach()
117-
endfunction()
118-
119-
120-
# link external library (for example to link optcon against lapack)
107+
# link external library (for example to link optcon against lapack) # todo this should go away
121108
function(ct_link_external_library extLibs)
122109
foreach(lib_name ${PRESPEC_LIB_NAMES})
123110
target_link_libraries(${lib_name} "${extLibs}")

ct/config/explicit_templates.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
STATE_DIM=2, CONTROL_DIM=1, POS_DIM=1, VEL_DIM=1, SCALAR=double
22
STATE_DIM=12, CONTROL_DIM=4, POS_DIM=6, VEL_DIM=6, SCALAR=double
3-
STATE_DIM=12, CONTROL_DIM=6, POS_DIM=6, VEL_DIM=6, SCALAR=double
3+
#STATE_DIM=12, CONTROL_DIM=6, POS_DIM=6, VEL_DIM=6, SCALAR=double
44
#STATE_DIM=2, CONTROL_DIM=2, POS_DIM=1, VEL_DIM=1, SCALAR=ct::core::ADScalar

ct/install_deps.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
sudo apt-get update
4+
5+
## get lapack
6+
sudo apt-get install liblapack-dev
7+
8+
## get eigen3
9+
sudo apt-get install libeigen3-dev
10+
11+
## get cmake
12+
sudo apt-get install cmake
13+
14+
## get IPOPT
15+
sudo apt-get install coinor-libipopt-dev
16+
17+
## get boost
18+
sudo apt-get install libboost-all-dev

ct/package.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<package>
22
<name>ct</name>
3-
<version>0.3.0</version>
3+
<version>3.0.1</version>
44
<description>
5-
ADRL Control Toolbox v3.0
5+
ADRL Control Toolbox 3.0.1
66
</description>
77
<maintainer email="markusgft@gmail.com">Markus Giftthaler</maintainer>
88
<license>BSD-2</license>

0 commit comments

Comments
 (0)