-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
170 lines (131 loc) · 8.15 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
cmake_minimum_required(VERSION 3.12)
# PicoSDK Include
if (DEFINED ENV{PICO_SDK_PATH} AND (NOT PICO_SDK_PATH))
set(PICO_SDK_PATH $ENV{PICO_SDK_PATH})
message("Using PICO_SDK_PATH from environment ('${PICO_SDK_PATH}')")
endif ()
set(PICO_SDK_PATH "${PICO_SDK_PATH}" CACHE PATH "Path to the Raspberry Pi Pico SDK")
get_filename_component(PICO_SDK_PATH "${PICO_SDK_PATH}" REALPATH BASE_DIR "${CMAKE_BINARY_DIR}")
if (NOT EXISTS ${PICO_SDK_PATH})
message(FATAL_ERROR "Directory '${PICO_SDK_PATH}' not found")
endif ()
set(PICO_SDK_INIT_CMAKE_FILE ${PICO_SDK_PATH}/pico_sdk_init.cmake)
if (NOT EXISTS ${PICO_SDK_INIT_CMAKE_FILE})
message(FATAL_ERROR "Directory '${PICO_SDK_PATH}' does not appear to contain the Raspberry Pi Pico SDK")
endif ()
set(PICO_SDK_PATH ${PICO_SDK_PATH} CACHE PATH "Path to the Raspberry Pi Pico SDK" FORCE)
include(${PICO_SDK_INIT_CMAKE_FILE})
# End PicoSDK
project(ll C CXX ASM)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 20)
# Initialize the SDK
pico_sdk_init()
# Include dirs
include_directories(include/)
add_compile_options(-Wall
-Wno-format # int != int32_t as far as the compiler is concerned because gcc has int32_t as long int
-Wno-unused-function # we have some for the docs that aren't called
)
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
add_compile_options(-Wno-maybe-uninitialized)
endif()
# Shared library to all pico FW
add_library(ll_common INTERFACE)
pico_generate_pio_header(ll_common ${CMAKE_CURRENT_LIST_DIR}/pio/ws2812.pio)
target_sources(ll_common INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/src/shared/comm.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/shared/neopixel_connect.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/shared/led_provider.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/shared/ws281x_provider.cpp")
# Linked libs
target_link_libraries(ll_common INTERFACE pico_i2c_slave pico_stdlib pico_rand pico_multicore pico_sync hardware_i2c hardware_pio)
# Shared library to all pico asserv FW
add_library(ll_common_asserv INTERFACE)
target_sources(ll_common_asserv INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/src/asserv/comm_asserv.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/asserv/encoder.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/asserv/control_loop.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/asserv/pid.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/asserv/odometry.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/asserv/controller.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/asserv/pll.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/asserv/accel_limiter.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/asserv/speed_profile.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/asserv/effects.cpp")
# Linked Libs
target_link_libraries(ll_common_asserv INTERFACE ll_common hardware_pwm hardware_pio)
# PIO header gen.
pico_generate_pio_header(ll_common_asserv ${CMAKE_CURRENT_LIST_DIR}/pio/quadrature_encoder.pio)
# Shared library to all pico asserv FW
add_library(dynamixel_sdk INTERFACE)
target_sources(dynamixel_sdk INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/src/dynamixel_sdk/group_bulk_read.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/dynamixel_sdk/group_bulk_write.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/dynamixel_sdk/group_fast_bulk_read.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/dynamixel_sdk/group_fast_sync_read.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/dynamixel_sdk/group_handler.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/dynamixel_sdk/group_sync_read.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/dynamixel_sdk/group_sync_write.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/dynamixel_sdk/packet_handler.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/dynamixel_sdk/port_handler.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/dynamixel_sdk/port_handler_pico.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/dynamixel_sdk/protocol1_packet_handler.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/dynamixel_sdk/protocol2_packet_handler.cpp")
target_compile_definitions(dynamixel_sdk INTERFACE)
# Linked Libs
target_link_libraries(dynamixel_sdk INTERFACE pico_stdlib hardware_uart)
# Define Final interface libraries from which to make executables
# Asserv
# Paminable
add_library(ll_asserv_paminable INTERFACE)
target_sources(ll_asserv_paminable INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/src/asserv/driver.cpp")
target_compile_definitions(ll_asserv_paminable INTERFACE ASSERV ROBOT_PAMI PAMINABLE)
target_link_libraries(ll_asserv_paminable INTERFACE ll_common_asserv)
# Pamini
add_library(ll_asserv_pamini INTERFACE)
target_sources(ll_asserv_pamini INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/src/asserv/driver.cpp")
target_compile_definitions(ll_asserv_pamini INTERFACE ASSERV ROBOT_PAMI)
target_link_libraries(ll_asserv_pamini INTERFACE ll_common_asserv)
# Main robot
add_library(ll_asserv_main INTERFACE)
target_sources(ll_asserv_main INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/src/asserv/comm_bg.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/asserv/driver_bg.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/asserv/comm_odrive.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/asserv/driver_odrive.cpp")
target_compile_definitions(ll_asserv_main INTERFACE ASSERV ROBOT_MAIN)
target_link_libraries(ll_asserv_main INTERFACE ll_common_asserv)
# Actuators
# Main robot
add_library(ll_action_main INTERFACE)
target_sources(ll_action_main INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/src/action/comm_action.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/action/dynamixel_manager.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/action/dynamixel_motor.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/action/dynamixel_xl430.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/action/stepper_driver.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/action/endstop.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/action/elevator.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/action/pump.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/action/arm.cpp")
target_compile_definitions(ll_action_main INTERFACE ROBOT_MAIN)
target_link_libraries(ll_action_main INTERFACE ll_common dynamixel_sdk)
# Pamigami
add_library(ll_pamigami INTERFACE)
target_sources(ll_pamigami INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/src/action/dynamixel_manager.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/action/dynamixel_motor.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/action/dynamixel_xl430.cpp")
target_compile_definitions(ll_pamigami INTERFACE ROBOT_PAMI PAMIGAMI)
target_link_libraries(ll_pamigami INTERFACE ll_common dynamixel_sdk)
# Create executables from interface libs
add_executable(paminable "${CMAKE_CURRENT_SOURCE_DIR}/src/asserv/main.cpp")
target_link_libraries(paminable PUBLIC ll_asserv_paminable)
# Common to all projects
pico_enable_stdio_usb(paminable 1)
pico_enable_stdio_uart(paminable 0)
# create map/bin/hex file etc.
pico_add_extra_outputs(paminable)
add_executable(pamini "${CMAKE_CURRENT_SOURCE_DIR}/src/asserv/main.cpp")
target_link_libraries(pamini PUBLIC ll_asserv_pamini)
# Common to all projects
pico_enable_stdio_usb(pamini 1)
pico_enable_stdio_uart(pamini 0)
# create map/bin/hex file etc.
pico_add_extra_outputs(pamini)
add_executable(main_asserv "${CMAKE_CURRENT_SOURCE_DIR}/src/asserv/main.cpp")
target_link_libraries(main_asserv PUBLIC ll_asserv_main)
# Common to all projects
pico_enable_stdio_usb(main_asserv 1)
pico_enable_stdio_uart(main_asserv 0)
# create map/bin/hex file etc.
pico_add_extra_outputs(main_asserv)
add_executable(main_action "${CMAKE_CURRENT_SOURCE_DIR}/src/action/main.cpp")
target_link_libraries(main_action PUBLIC ll_action_main)
# Common to all projects
pico_enable_stdio_usb(main_action 1)
pico_enable_stdio_uart(main_action 0)
# create map/bin/hex file etc.
pico_add_extra_outputs(main_action)
add_executable(pamigami "${CMAKE_CURRENT_SOURCE_DIR}/src/action/pamigami.cpp" "src/action/hcsr04.cpp")
target_link_libraries(pamigami PUBLIC ll_pamigami)
# Common to all projects
pico_enable_stdio_usb(pamigami 1)
pico_enable_stdio_uart(pamigami 0)
# create map/bin/hex file etc.
pico_add_extra_outputs(pamigami)