Files
lzwc-terminal-unitreeGo2/CMakeLists.txt
Sucan126 6c8a4a3b38 refactor(controller): Update TrajectoryFollow method signature and improve path handling
- Changed the signature of TrajectoryFollow to accept a vector of unitree::robot::go2::PathPoint instead of std::array<float, 6>.
- Updated the implementation of TrajectoryFollow in controller.cpp to utilize the new path type.
- Removed unnecessary status message in CMakeLists.txt related to unitree_sdk2 detection.
- Added a new function in custom_robot.cpp to create example trajectories for different path types (line, square, circle) and integrated it into the command processing for TrajectoryFollow.
2025-09-23 18:40:42 +08:00

64 lines
1.4 KiB
CMake

cmake_minimum_required(VERSION 3.16)
project(main)
# Set C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Find required packages
find_package(PkgConfig REQUIRED)
find_package(Threads REQUIRED)
# Try to find PahoMqttC, fallback to manual linking if not found
find_package(PahoMqttC QUIET)
if(NOT PahoMqttC_FOUND)
message(STATUS "PahoMqttC package not found, using manual library linking")
find_library(PAHO_MQTT_C_LIBRARY NAMES paho-mqtt3c REQUIRED)
find_path(PAHO_MQTT_C_INCLUDE_DIR NAMES MQTTClient.h REQUIRED)
endif()
find_package(unitree_sdk2 REQUIRED)
# Include directories
include_directories(
include
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/include/nlohmann
$<$<NOT:$<BOOL:${PahoMqttC_FOUND}>>:${PAHO_MQTT_C_INCLUDE_DIR}>
)
# Source files
set(SOURCES
src/main.cpp
src/controller.cpp
src/custom_robot.cpp
src/config.cpp
src/logger.cpp
src/mqtt.cpp
src/navigation.cpp
src/low_controller.cpp
src/recharge.cpp
)
add_executable(main ${SOURCES})
# Link libraries
target_link_libraries(main
PRIVATE
unitree_sdk2
Threads::Threads
$<$<BOOL:${PahoMqttC_FOUND}>:PahoMqttC::PahoMqttC>
$<$<NOT:$<BOOL:${PahoMqttC_FOUND}>>:${PAHO_MQTT_C_LIBRARY}>
)
# Set output directory
set_target_properties(main PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
)
# Install target
install(TARGETS main
RUNTIME DESTINATION bin
)