1
- cmake_minimum_required (VERSION 2.8.3)
1
+ # Copyright (c) 2020
2
+ # Commonwealth Scientific and Industrial Research Organisation (CSIRO)
3
+ # ABN 41 687 119 230
4
+ #
5
+ # Author: Fletcher Talbot
6
+
7
+ cmake_minimum_required (VERSION 3.5)
2
8
project (syropod_highlevel_controller)
3
9
4
- ## Find catkin macros and libraries
5
- ## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
6
- ## is used, also find other catkin packages
10
+ set (PACKAGE_VERSION 0.5.11)
11
+ if (EXISTS "${CMAKE_CURRENT_LIST_DIR} /package.xml" )
12
+ file (READ package.xml PACKAGE_XML)
13
+ string (REGEX REPLACE ".*<version>[\\ t ]*(.*)[\\ t ]*<\\ /version>.*" "\\ 1" PACKAGE_VERSION "${PACKAGE_XML} " )
14
+ endif (EXISTS "${CMAKE_CURRENT_LIST_DIR} /package.xml" )
15
+ set (syropod_highlevel_controller_VERSION "${PACKAGE_VERSION} " )
16
+
17
+ # C++ standards setup.
18
+ set (CMAKE_CXX_STANDARD 17)
19
+ set (CMAKE_CXX_STANDARD_REQUIRED TRUE )
20
+ # Ensure -fPIC is added.
21
+ set (CMAKE_POSITION_INDEPENDENT_CODE ON )
22
+ set (CMAKE_EXPORT_COMPILE_COMMANDS ON )
23
+
24
+ # Additional CMake modules
25
+ list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR} /cmake" )
26
+
27
+ set (CLANG_TIDY_PROJECT_PREFIX SHC) # clang-tidy option prefix
28
+ include (compilerSetup) # Setup compiler warnings.
29
+ include (clang-tidy) # clang-tidy support
30
+
31
+ # Find external depedencies.
32
+ # Generally, we should specify either CONFIG to use config style scripts, or MODULE for FindPackage scripts.
33
+ find_package (Eigen3 REQUIRED)
34
+
35
+ # Alias eigen include dirs for catkin/version interopability
36
+ set (Eigen3_INCLUDE_DIRS ${EIGEN3_INCLUDE_DIR} )
37
+
38
+ # Need message generation commands.
7
39
find_package (catkin REQUIRED COMPONENTS
8
40
roscpp
9
41
rospy
@@ -16,41 +48,9 @@ find_package(catkin REQUIRED COMPONENTS
16
48
tf2_ros
17
49
)
18
50
51
+ ## Generate dynamic reconfigure parameters in the 'cfg' folder
19
52
generate_dynamic_reconfigure_options(config/Dynamic.cfg)
20
53
21
- ## System dependencies are found with CMake's conventions
22
- # find_package(Boost REQUIRED COMPONENTS system)
23
-
24
-
25
- ## Uncomment this if the package has a setup.py. This macro ensures
26
- ## modules and global scripts declared therein get installed
27
- ## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html
28
- # catkin_python_setup()
29
-
30
- ################################################
31
- ## Declare ROS messages, services and actions ##
32
- ################################################
33
-
34
- ## To declare and build messages, services or actions from within this
35
- ## package, follow these steps:
36
- ## * Let MSG_DEP_SET be the set of packages whose message types you use in
37
- ## your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...).
38
- ## * In the file package.xml:
39
- ## * add a build_depend and a run_depend tag for each package in MSG_DEP_SET
40
- ## * If MSG_DEP_SET isn't empty the following dependencies might have been
41
- ## pulled in transitively but can be declared for certainty nonetheless:
42
- ## * add a build_depend tag for "message_generation"
43
- ## * add a run_depend tag for "message_runtime"
44
- ## * In this file (CMakeLists.txt):
45
- ## * add "message_generation" and every package in MSG_DEP_SET to
46
- ## find_package(catkin REQUIRED COMPONENTS ...)
47
- ## * add "message_runtime" and every package in MSG_DEP_SET to
48
- ## catkin_package(CATKIN_DEPENDS ...)
49
- ## * uncomment the add_*_files sections below as needed
50
- ## and list every .msg/.srv/.action file to be processed
51
- ## * uncomment the generate_messages entry below
52
- ## * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...)
53
-
54
54
#Generate messages in the 'msg' folder
55
55
add_message_files(
56
56
FILES
@@ -59,20 +59,6 @@ generate_dynamic_reconfigure_options(config/Dynamic.cfg)
59
59
TargetTipPose.msg
60
60
)
61
61
62
- ## Generate services in the 'srv' folder
63
- # add_service_files(
64
- # FILES
65
- # Service1.srv
66
- # Service2.srv
67
- # )
68
-
69
- ## Generate actions in the 'action' folder
70
- # add_action_files(
71
- # FILES
72
- # Action1.action
73
- # Action2.action
74
- # )
75
-
76
62
# Generate added messages and services with any dependencies listed here
77
63
generate_messages(
78
64
DEPENDENCIES
@@ -92,85 +78,123 @@ generate_dynamic_reconfigure_options(config/Dynamic.cfg)
92
78
## DEPENDS: system dependencies of this project that dependent projects also need
93
79
catkin_package(
94
80
INCLUDE_DIRS include
95
- # LIBRARIES syropod_highlevel_controller
96
- CATKIN_DEPENDS roscpp rospy message_runtime std_msgs sensor_msgs geometry_msgs dynamic_reconfigure
97
- # DEPENDS system_lib
81
+ CATKIN_DEPENDS
82
+ roscpp
83
+ message_runtime
84
+ std_msgs
85
+ sensor_msgs
86
+ geometry_msgs
87
+ dynamic_reconfigure
88
+ DEPENDS
89
+ Eigen3
98
90
)
99
- add_definitions (-DEIGEN3_SUPPORT -DDEBUG -std=c++11 -Wall -g -ggdb -O0 -fopenmp -fPIC)
100
91
101
- ###########
102
- ## Build ##
103
- ###########
104
- #FILE(GLOB syropod_highlevel_controller_sources "src/*.cpp")
92
+ ##################################
93
+ # Build setup
94
+ ##################################
95
+
96
+ # Configure the project config header.
97
+ configure_file (shc_config.in.h "${CMAKE_CURRENT_BINARY_DIR} /shc_config.h" )
98
+
105
99
## Specify additional locations of header files
106
100
## Your package locations should be listed before other locations
107
- # include_directories(include)
108
101
include_directories (
109
102
include
110
103
${catkin_INCLUDE_DIRS}
111
- /usr/include /eigen3
104
+ SYSTEM
105
+ ${Eigen3_INCLUDE_DIRS}
112
106
)
113
107
114
- ## Declare a cpp library
115
- # add_library(syropod_highlevel_controller
116
- # src/${PROJECT_NAME}/syropod_highlevel_controller.cpp
117
- # )
108
+ # Project source files. There are two options here:
109
+ # 1. Populate the following varibles inline here:
110
+ # - SOURCES for source files to be built and header files associated with built sources.
111
+ # - PUBLIC_HEADERS for all headers to be marshalled as part of the public API.
112
+ # May double up with SOURCES
113
+ # 2. Create a file alongside CMakeLists.txt called "sourcelist.cmake" and populate
114
+ # the same varaibles in that file instead, then use "incldue(sourcelist.cmake)" here.
115
+ #include(sourcelist.cmake)
116
+ # For executables we don't need to concern outselves with PUBLIC_HEADERS as we can assume noone will link to the
117
+ # executable. Cases where linking to the executable is requried (e.g., plugins) are beyond the scope of this exercise.
118
+ set (SOURCES
119
+ src/admittance_controller.cpp
120
+ src/debug_visualiser.cpp
121
+ src/main.cpp
122
+ src/model.cpp
123
+ src/pose_controller.cpp
124
+ src/state_controller.cpp
125
+ src/walk_controller.cpp
126
+ # include/${PROJECT_NAME}/admittance_controller.h
127
+ # include/${PROJECT_NAME}/debug_visualiser.h
128
+ # include/${PROJECT_NAME}/model.h
129
+ # include/${PROJECT_NAME}/parameters_and_states.h
130
+ # include/${PROJECT_NAME}/pose.h
131
+ # include/${PROJECT_NAME}/pose_controller.h
132
+ # include/${PROJECT_NAME}/standard_includes.h
133
+ # include/${PROJECT_NAME}/state_controller.h
134
+ # include/${PROJECT_NAME}/walk_controller.h
135
+ shc_config.in.h
136
+ )
137
+
138
+
118
139
119
- ## Declare a cpp executable
120
- add_executable (syropod_highlevel_controller_node src/main.cpp src/model.cpp src/walk_controller.cpp src/pose_controller.cpp src/debug_visualiser.cpp src/admittance_controller.cpp src/state_controller.cpp)
140
+ # Build generated header list.
141
+ set (GENERATED_FILES
142
+ "${CMAKE_CURRENT_BINARY_DIR} /shc_config.h"
143
+ )
144
+
145
+ # Generate the executable.
146
+ add_executable (${PROJECT_NAME} _node include ${SOURCES} ${GENERATED_FILES} )
147
+ # CMake does not automatically propagate CMAKE_DEBUG_POSTFIX to executables. We do so to avoid confusing link issues
148
+ # which can would when building release and debug exectuables to the same path.
149
+ # set_target_properties(waypoint_gui_node PROPERTIES DEBUG_POSTFIX "${CMAKE_DEBUG_POSTFIX}")
121
150
122
- ## Add cmake target dependencies of the executable/library
123
- ## as an example, message headers may need to be generated before nodes
151
+ # Add dependencies for catkin exports and exports from this project.
152
+ # Variables may be empty, so these lines may need to be disabled. For example, in this case
153
+ # ${PROJECT_NAME}_EXPORTED_TARGETS is only availabe because we have generated messages for this package.
154
+ add_dependencies (${PROJECT_NAME} _node ${catkin_EXPORTED_TARGETS} ${PROJECT_NAME} _generate_messages_cpp ${PROJECT_NAME} _gencfg)
124
155
125
- ## Specify libraries to link a library or executable target against
126
- target_link_libraries (syropod_highlevel_controller_node ${catkin_LIBRARIES} -fopenmp)
127
156
128
- add_dependencies (syropod_highlevel_controller_node syropod_highlevel_controller_generate_messages_cpp syropod_highlevel_controller_gencfg)
129
-
130
- #############
131
- ## Install ##
132
- #############
133
-
134
- # all install targets should use catkin DESTINATION variables
135
- # See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html
136
-
137
- ## Mark executable scripts (Python etc.) for installation
138
- ## in contrast to setup.py, you can choose the destination
139
- # install(PROGRAMS
140
- # scripts/my_python_script
141
- # DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
142
- # )
143
-
144
- ## Mark executables and/or libraries for installation
145
- # install(TARGETS syropod_highlevel_controller syropod_highlevel_controller_node
146
- # ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
147
- # LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
148
- # RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
149
- # )
150
-
151
- ## Mark cpp header files for installation
152
- # install(DIRECTORY include/${PROJECT_NAME}/
153
- # DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
154
- # FILES_MATCHING PATTERN "*.h"
155
- # PATTERN ".svn" EXCLUDE
156
- # )
157
-
158
- ## Mark other files for installation (e.g. launch and bag files, etc.)
159
- # install(FILES
160
- # # myfile1
161
- # # myfile2
162
- # DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
163
- # )
164
-
165
- #############
166
- ## Testing ##
167
- #############
168
-
169
- ## Add gtest based cpp test target and link libraries
170
- # catkin_add_gtest(${PROJECT_NAME}-test test/test_syropod_highlevel_controller.cpp)
171
- # if(TARGET ${PROJECT_NAME}-test)
172
- # target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME})
173
- # endif()
174
-
175
- ## Add folders to be run by python nosetests
176
- # catkin_add_nosetests(test)
157
+ # Add include directories to the target
158
+ # For executables, all includes can be private (see set(SOURCES ...) above).
159
+ target_include_directories (${PROJECT_NAME} _node
160
+ PRIVATE
161
+ # Include path for generated files during build.
162
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR} >
163
+ # Add parent directory to support include pattern: #include <project_dir/header.h>
164
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR} /..>
165
+ )
166
+
167
+ # Add catkin include directories and system include directories.
168
+ # Always add ${catkin_INCLUDE_DIRS} with the SYSTEM argument
169
+ # These dependenties should be private as much as possible.
170
+ target_include_directories (${PROJECT_NAME} _node SYSTEM
171
+ PRIVATE
172
+ "${catkin_INCLUDE_DIRS} "
173
+ )
174
+
175
+ # Link dependencies.
176
+ # Properly defined targets will also have their include directories and those of dependencies added by this command.
177
+ target_link_libraries (${PROJECT_NAME} _node ${catkin_LIBRARIES} )
178
+
179
+ # Enable clang-tidy
180
+ clang_tidy_target(${PROJECT_NAME} EXCLUDE_MATCHES ".*\\ .in($|\\ ..*)" )
181
+
182
+ # Setup folder display with the target for Visual Studio. This should always be done to match
183
+ # the on disk layout of the source files.
184
+ source_group ("generated" FILES ${GENERATED_FILES} )
185
+ source_group ("source" REGULAR_EXPRESSION ".*$" )
186
+ # With CMake 3.8+ you can do the following:
187
+ # source_group(TREE "${CMAKE_CURRENT_LIST_DIR}" PREFIX source FILES ${SOURCES})
188
+
189
+ # Setup installation.
190
+ # Binary installation.
191
+ install (TARGETS ${PROJECT_NAME} _node
192
+ LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
193
+ ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
194
+ RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
195
+ INCLUDES DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
196
+ )
197
+
198
+ install (DIRECTORY config launch rviz_cfg
199
+ DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
200
+ )
0 commit comments