@@ -85,18 +85,19 @@ link_libraries(frozen::frozen)
8585# Find argparse, library used for parsing command line arguments
8686find_package (argparse REQUIRED )
8787
88-
8988# Find the JSON library
9089find_package (nlohmann_json 3.2.0 REQUIRED )
9190
92- # Find the CAN library; contains packet and protocol definitions and does not
93- # actually require physical CAN to be present.
94- FetchContent_Declare (
91+ if (WORLD_INTERFACE STREQUAL "REAL" )
92+ # Find the CAN library; contains packet and protocol definitions and does not
93+ # actually require physical CAN to be present.
94+ FetchContent_Declare (
9595 HindsightCAN
9696 GIT_REPOSITORY https://github.com/huskyroboticsteam/HindsightCAN.git
9797 GIT_TAG ce04c1a2dced3eb0e5beaaf39b2fcc436655e790
98- )
99- FetchContent_MakeAvailable (HindsightCAN)
98+ )
99+ FetchContent_MakeAvailable (HindsightCAN)
100+ endif ()
100101
101102FetchContent_Declare (LoguruGitRepo
102103 GIT_REPOSITORY "https://github.com/emilk/loguru"
@@ -154,30 +155,32 @@ add_library(utils SHARED
154155 world_interface/data.cpp )
155156target_link_libraries (utils ${OpenCV_LIBS} )
156157
157- ## ====== CAN Interfaces =======
158- # Stub CAN interface is used for the tests (and for the Rover if
159- # CAN is disabled) and the real CAN interface is used for the Rover if CAN is
160- # enabled.
161-
162- # Common CAN source files
163-
164- # **DON'T MAKE THIS SHARED**
165- # Making this library shared causes some memory fuckery
166- # No clue why but CAN I/O goes to shit. Don't do it.
167- add_library (can_interface STATIC )
168- target_sources (can_interface PRIVATE
169- CAN/CANMotor.cpp
170- CAN/CANUtils.cpp
171- )
158+ if (WORLD_INTERFACE STREQUAL "REAL" )
159+ ## ====== CAN Interfaces =======
160+ # Stub CAN interface is used for the tests (and for the Rover if
161+ # CAN is disabled) and the real CAN interface is used for the Rover if CAN is
162+ # enabled.
163+
164+ # Common CAN source files
165+
166+ # **DON'T MAKE THIS SHARED**
167+ # Making this library shared causes some memory fuckery
168+ # No clue why but CAN I/O goes to shit. Don't do it.
169+ add_library (can_interface STATIC )
170+ target_sources (can_interface PRIVATE
171+ CAN/CANMotor.cpp
172+ CAN/CANUtils.cpp
173+ )
172174
173- # Hardware specific source files
174- target_sources (can_interface PRIVATE
175- CAN/CAN.cpp )
176- target_link_libraries (can_interface PUBLIC
177- HindsightCAN
178- Threads::Threads
179- utils
180- )
175+ # Hardware specific source files
176+ target_sources (can_interface PRIVATE
177+ CAN/CAN.cpp )
178+ target_link_libraries (can_interface PUBLIC
179+ HindsightCAN
180+ Threads::Threads
181+ utils
182+ )
183+ endif ()
181184
182185## GPS Implementations
183186
@@ -208,31 +211,27 @@ add_library(world_interface_core STATIC
208211target_include_directories (world_interface_core SYSTEM PUBLIC ${OpenCV_INCLUDE_DIRS} )
209212target_link_libraries (world_interface_core PUBLIC ${vision_libs} opencv_aruco ${OpenCV_LIBS} utils camera )
210213
211- # CAN library (above) requires some utilities from this
212- target_link_libraries (can_interface PUBLIC utils )
213-
214- add_library (stub_world_interface STATIC
215- world_interface/noop_world.cpp )
216-
217- add_library (real_world_interface STATIC
218- world_interface/real_world_interface.cpp
219- world_interface/motor/can_motor.cpp
220- )
221-
222- add_library (simulator_interface STATIC
223- world_interface/simulator_interface.cpp
224- world_interface/motor/sim_motor.cpp
225- )
226-
227- target_link_libraries (real_world_interface gps_interface can_interface world_interface_core )
228- target_link_libraries (simulator_interface world_interface_core )
229- target_link_libraries (stub_world_interface world_interface_core )
230-
231214if (WORLD_INTERFACE STREQUAL "REAL" )
215+ # CAN library (above) requires some utilities from this
216+ target_link_libraries (can_interface PUBLIC utils )
217+
218+ add_library (real_world_interface STATIC
219+ world_interface/real_world_interface.cpp
220+ world_interface/motor/can_motor.cpp
221+ )
222+ target_link_libraries (real_world_interface gps_interface can_interface world_interface_core )
232223 add_library (world_interface ALIAS real_world_interface )
233224elseif (WORLD_INTERFACE STREQUAL "SIMULATOR" )
225+ add_library (simulator_interface STATIC
226+ world_interface/simulator_interface.cpp
227+ world_interface/motor/sim_motor.cpp
228+ )
229+ target_link_libraries (simulator_interface world_interface_core )
234230 add_library (world_interface ALIAS simulator_interface )
235231else ()
232+ add_library (stub_world_interface STATIC
233+ world_interface/noop_world.cpp )
234+ target_link_libraries (stub_world_interface world_interface_core )
236235 add_library (world_interface ALIAS stub_world_interface )
237236endif ()
238237
@@ -273,7 +272,7 @@ add_executable(Rover Rover.cpp)
273272add_library (rover_common STATIC
274273 Globals.cpp
275274 control_interface.cpp
276- )
275+ )
277276target_link_libraries (rover_common
278277 utils
279278 websocket_utils
@@ -296,13 +295,6 @@ target_link_libraries(Rover
296295 ${vision_libs}
297296)
298297
299- add_executable (TunePID TunePID.cpp )
300- target_link_libraries (TunePID
301- ${rover_libs}
302- can_interface
303- )
304- target_link_libraries (TunePID ${vision_libs} )
305-
306298if (WITH_TESTS)
307299 add_executable (tests
308300 Tests.cpp
@@ -359,6 +351,13 @@ if (WORLD_INTERFACE STREQUAL "REAL")
359351 add_executable (LimitSwitchCalibration
360352 LimitCalib.cpp )
361353 target_link_libraries (LimitSwitchCalibration real_world_interface )
354+
355+ add_executable (TunePID TunePID.cpp )
356+ target_link_libraries (TunePID
357+ ${rover_libs}
358+ can_interface
359+ )
360+ target_link_libraries (TunePID ${vision_libs} )
362361endif ()
363362
364363add_compile_options (
0 commit comments