-
Notifications
You must be signed in to change notification settings - Fork 5
/
CMakeLists.txt
353 lines (279 loc) · 11.6 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
# Copyright: (C) 2014 Walkman Consortium
# Authors: Enrico Mingo Hoffman, Alessio Rocchi
# CopyPolicy: Released under the terms of the GNU GPL v2.0.
cmake_minimum_required(VERSION 3.0)
include(ExternalProject)
project(open_sot VERSION 4.0.0)
set(CMAKE_CXX_STANDARD 20)
option(SET_SSE4_FLAG "set -msse4 flag to gcc" OFF)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/")
# Set a default build type for single-configuration
# CMake generators if no build type is set.
if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RelWithDebInfo)
endif(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
set(${CMAKE_PROJECT_NAME}_CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE})
add_subdirectory(doc)
find_package(Boost COMPONENTS system REQUIRED)
find_package(Eigen3 REQUIRED)
find_package(orocos_kdl REQUIRED)
find_package(urdf REQUIRED)
find_package(kdl_parser REQUIRED)
find_package(moveit_core QUIET)
find_package(PCL 1.7 QUIET COMPONENTS common
filters
surface)
#search
#io)
find_package(eigen_conversions REQUIRED)
find_package(xbot2_interface REQUIRED)
find_package(PkgConfig REQUIRED)
find_package(matlogger2 REQUIRED)
# compilation flags
option(OPENSOT_COMPILE_EXAMPLES "Compile OpenSoT examples" FALSE)
option(OPENSOT_COMPILE_TESTS "Compile OpenSoT tests" FALSE)
option(OPENSOT_VERBOSE "Some additional prints" FALSE)
option(OPENSOT_VERBOSE_MATLOG "Log all aggregated tasks/constraints to MAT-file" FALSE)
option(OPENSOT_DISABLE_VECTORIZATION "Disable Eigen3 vectorization" FALSE)
option(OPENSOT_COMPILE_COLLISION "Compile OpenSoT collision avoidance" TRUE)
if(${OPENSOT_DISABLE_VECTORIZATION})
add_definitions(-DEIGEN_DONT_VECTORIZE)
add_definitions(-DEIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT)
endif()
if(${OPENSOT_VERBOSE_MATLOG})
add_definitions(-DOPENSOT_VERBOSE_MATLOG)
endif()
if(${OPENSOT_VERBOSE})
add_definitions(-DOPENSOT_VERBOSE)
endif()
# add include directories
INCLUDE_DIRECTORIES(include ${EIGEN3_INCLUDE_DIR}
${PCL_INCLUDE_DIRS} ${XBotInterface_INCLUDE_DIRS} ${eigen_conversions_INCLUDE_DIRS}
)
ADD_DEFINITIONS(${PCL_DEFINITIONS})
add_definitions(-DBOOST_BIND_GLOBAL_PLACEHOLDERS)
# for every file in sot_INCLUDES CMake already sets the property HEADER_FILE_ONLY
file(GLOB_RECURSE sot_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/include" *.h)
##CONSTRAINTS
set(OPENSOT_CONSTRAINTS_SOURCES src/constraints/Aggregated.cpp
src/constraints/SubConstraint.cpp
src/constraints/BilateralConstraint.cpp
src/constraints/TaskToConstraint.cpp
src/constraints/acceleration/VelocityLimits.cpp
src/constraints/acceleration/TorqueLimits.cpp
src/constraints/velocity/CartesianPositionConstraint.cpp
src/constraints/velocity/CartesianVelocity.cpp
src/constraints/velocity/JointLimits.cpp
src/constraints/velocity/JointLimitsInvariance.cpp
src/constraints/velocity/VelocityLimits.cpp
src/constraints/velocity/OmniWheels4X.cpp
src/constraints/force/FrictionCone.cpp
src/constraints/force/WrenchLimits.cpp
src/constraints/force/CoP.cpp
src/constraints/force/StaticConstraint.cpp
src/constraints/force/NormalTorque.cpp
src/constraints/GenericConstraint.cpp
src/constraints/acceleration/JointLimits.cpp
src/constraints/acceleration/JointLimitsViability.cpp
src/constraints/acceleration/JointLimitsECBF.cpp
)
if(${PCL_FOUND} AND ${moveit_core_FOUND})
message("Adding src/constraints/velocity/ConvexHull.cpp to compilation")
set(OPENSOT_CONSTRAINTS_SOURCES ${OPENSOT_CONSTRAINTS_SOURCES}
src/constraints/velocity/ConvexHull.cpp)
endif()
if(${OPENSOT_COMPILE_COLLISION})
message("Adding src/constraints/velocity/SelfCollisionAvoidance.cpp to compilation")
set(OPENSOT_CONSTRAINTS_SOURCES ${OPENSOT_CONSTRAINTS_SOURCES}
src/constraints/velocity/CollisionAvoidance.cpp
src/tasks/velocity/CollisionAvoidance.cpp)
endif()
##TASKS
set(OPENSOT_TASKS_SOURCES src/tasks/Aggregated.cpp
src/tasks/SubTask.cpp
src/tasks/MinimizeVariable.cpp
src/tasks/GenericTask.cpp
src/tasks/GenericLPTask.cpp
src/tasks/acceleration/Postural.cpp
src/tasks/acceleration/Cartesian.cpp
src/tasks/acceleration/Contact.cpp
src/tasks/acceleration/CoM.cpp
src/tasks/acceleration/DynamicFeasibility.cpp
src/tasks/acceleration/MinJointVel.cpp
src/tasks/acceleration/AngularMomentum.cpp
src/tasks/velocity/Cartesian.cpp
src/tasks/velocity/CartesianAdmittance.cpp #TODO: refactor to better implementation of admittance, not using filters
src/tasks/velocity/PureRolling.cpp
src/tasks/velocity/Gaze.cpp
src/tasks/velocity/Contact.cpp
src/tasks/velocity/CoM.cpp
src/tasks/velocity/AngularMomentum.cpp
src/tasks/velocity/LinearMomentum.cpp
src/tasks/velocity/Manipulability.cpp
src/tasks/velocity/MinimumEffort.cpp
src/tasks/velocity/Postural.cpp
src/tasks/velocity/JointAdmittance.cpp #TODO: refactor to better implementation of admittance, not using filters
src/tasks/force/CoM.cpp
src/tasks/force/FloatingBase.cpp
src/tasks/force/Force.cpp
src/tasks/force/Cartesian.cpp
src/tasks/floating_base/Contact.cpp
src/tasks/floating_base/IMU.cpp
)
##SOLVERS
set(OPENSOT_SOLVERS_SOURCES src/solvers/BackEnd.cpp
src/solvers/BackEndFactory.cpp
src/solvers/iHQP.cpp
src/solvers/nHQP.cpp
src/solvers/eHQP.cpp
src/solvers/l1HQP.cpp)
option(OPENSOT_SOTH_FRONT_END "Add to compilation soth and HCOD front-end" OFF)
if(${OPENSOT_SOTH_FRONT_END})
message("Internal soth will be used!")
add_subdirectory(external/soth-ext/)
include_directories(external/soth-ext/include)
message("Adding src/solvers/HCOD.cpp to compilation")
set(OPENSOT_SOLVERS_SOURCES ${OPENSOT_SOLVERS_SOURCES} src/solvers/HCOD.cpp)
set(PRIVATE_TLL hcod_wrapper soth)
endif()
##UTILS
set(OPENSOT_UTILS_SOURCES src/utils/AutoStack.cpp
src/utils/Affine.cpp
src/utils/AffineUtils.cpp
src/utils/Indices.cpp
src/utils/cartesian_utils.cpp
src/utils/InverseDynamics.cpp)
if(${PCL_FOUND})
message("Adding src/utils/convex_hull_utils.cpp to compilation")
set(OPENSOT_UTILS_SOURCES ${OPENSOT_UTILS_SOURCES}
src/utils/convex_hull_utils.cpp)
endif()
##VARIABLES
set(OPENSOT_VARIABLES_SOURCES src/variables/Torque.cpp)
ADD_LIBRARY(OpenSoT SHARED
${OPENSOT_CONSTRAINTS_SOURCES}
${OPENSOT_TASKS_SOURCES}
${OPENSOT_SOLVERS_SOURCES}
${OPENSOT_UTILS_SOURCES}
${OPENSOT_VARIABLES_SOURCES}
${sot_INCLUDES})
set(PRIVATE_TLL ${PRIVATE_TLL} ${eigen_conversions_LIBRARIES})
if(${OPENSOT_COMPILE_COLLISION})
target_link_libraries(OpenSoT PUBLIC xbot2_interface::collision)
endif()
if(${PCL_FOUND})
set(PRIVATE_TLL ${PRIVATE_TLL} ${QHULL_LIBRARIES} ${PCL_LIBRARIES})
endif()
configure_file(version.h.in include/OpenSoT/version.h)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/include)
install(FILES ${CMAKE_BINARY_DIR}/include/OpenSoT/version.h
DESTINATION include/OpenSoT)
TARGET_LINK_LIBRARIES(OpenSoT
PUBLIC
xbot2_interface::xbot2_interface
matlogger2::matlogger2
PRIVATE
${PRIVATE_TLL})
if(${OPENSOT_SOTH_FRONT_END})
target_compile_definitions(OpenSoT
PUBLIC
-DOPENSOT_HAS_SOTH_FRONT_END)
endif()
########################################################################
# Compile and install back ends #
########################################################################
# Find package qpOASES or build it using ExternalProject
find_package(qpOASES QUIET)
if(NOT qpOASES_FOUND)
message("Internal qpOASES will be used!")
set(qpOASES_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external/qpOASES-ext/")
set(qpOASES_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/external/src/qpOASES-ext-build/")
ExternalProject_Add(qpOASES-ext SOURCE_DIR "${qpOASES_SOURCE_DIR}"
PREFIX "${CMAKE_CURRENT_BINARY_DIR}/external"
INSTALL_COMMAND ""
CMAKE_ARGS -DCMAKE_CXX_FLAGS:STRING="-fPIC" -DCMAKE_BUILD_TYPE=${${CMAKE_PROJECT_NAME}_CMAKE_BUILD_TYPE})
link_directories("${qpOASES_BINARY_DIR}/libs/")
set(qpOASES_INCLUDE_DIRS "${qpOASES_SOURCE_DIR}/include")
set(qpOASES_LIBRARIES qpOASES)
set(qpOASES_FOUND TRUE)
endif()
include_directories("${qpOASES_INCLUDE_DIRS}")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
include(MacroInstallLib)
if(${qpOASES_FOUND})
message("Adding src/solvers/QPOasesBackEnd.cpp to compilation")
add_library(OpenSotBackEndQPOases SHARED src/solvers/QPOasesBackEnd.cpp)
if(TARGET qpOASES-ext)
add_dependencies(OpenSotBackEndQPOases qpOASES-ext)
endif()
target_link_libraries(OpenSotBackEndQPOases OpenSoT qpOASES)
library_install(OpenSotBackEndQPOases 1 0 0)
endif()
find_package(osqp QUIET)
if(${osqp_FOUND})
message("Adding src/solvers/OSQPBackEnd.cpp to compilation")
add_library(OpenSotBackEndOSQP SHARED src/solvers/OSQPBackEnd.cpp)
target_link_libraries(OpenSotBackEndOSQP OpenSoT osqp::osqpstatic)
library_install(OpenSotBackEndOSQP 1 0 0)
endif()
find_package(qpSWIFT QUIET)
if(${qpSWIFT_FOUND})
message("Adding src/solvers/qpSWIFTBackEnd.cpp to compilation")
add_library(OpenSotBackEndqpSWIFT SHARED src/solvers/qpSWIFTBackEnd.cpp)
target_link_libraries(OpenSotBackEndqpSWIFT OpenSoT qpSWIFT::qpSWIFT-static)
library_install(OpenSotBackEndqpSWIFT 1 0 0)
endif()
find_package(proxsuite QUIET)
if(${proxsuite_FOUND})
message("Adding src/solvers/proxQPBackEnd.cpp to compilation")
add_library(OpenSotBackEndproxQP SHARED src/solvers/proxQPBackEnd.cpp)
target_link_libraries(OpenSotBackEndproxQP OpenSoT proxsuite::proxsuite)
library_install(OpenSotBackEndproxQP 1 0 0)
endif()
find_package(GLPK QUIET)
if(${GLPK_FOUND})
message("Adding src/solvers/GLPKBackEnd.cpp to compilation")
add_library(OpenSotBackEndGLPK SHARED src/solvers/GLPKBackEnd.cpp)
target_link_libraries(OpenSotBackEndGLPK OpenSoT ${GLPK_LIBRARY})
library_install(OpenSotBackEndGLPK 1 0 0)
endif()
add_subdirectory(external/eiQuadProg-ext/)
include_directories(external/eiQuadProg-ext/include)
message("Adding src/solvers/eiQuadProgBackEnd.cpp to compilation")
add_library(OpenSotBackEndeiQuadProg SHARED src/solvers/eiQuadProgBackEnd.cpp)
target_link_libraries(OpenSotBackEndeiQuadProg OpenSoT eiQuadProg)
library_install(OpenSotBackEndeiQuadProg 1 0 0)
#############################################################
# Export OpenSoT so that it can be found using find_package #
#############################################################
install(DIRECTORY include/
DESTINATION include
FILES_MATCHING PATTERN "*.h")
include(AddUninstallTarget)
include(MacroInstallLib)
library_install(OpenSoT
${PROJECT_VERSION_MAJOR}
${PROJECT_VERSION_MINOR}
${PROJECT_VERSION_PATCH})
include(GenerateDeb)
configure_file(version.h.in include/OpenSoT/version.h)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/include)
install(FILES ${CMAKE_BINARY_DIR}/include/OpenSoT/version.h
DESTINATION include/OpenSoT)
#######################
# Add Testing and Examples target #
#######################
if(OPENSOT_COMPILE_TESTS)
add_subdirectory(tests)
endif()
if(OPENSOT_COMPILE_EXAMPLES)
add_subdirectory(examples)
endif()
##############
## Bindings ##
##############
add_subdirectory(bindings/python)
if(OPENSOT_COMPILE_TESTS OR OPENSOT_COMPILE_EXAMPLES)
add_custom_target(copy_robot_model_files ALL
${CMAKE_COMMAND} -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/tests/robots" "${CMAKE_CURRENT_BINARY_DIR}/tests/robots")
endif()