diff --git a/.gitignore b/.gitignore index 5b28756..fd1febf 100644 --- a/.gitignore +++ b/.gitignore @@ -43,3 +43,5 @@ pyvenv.cfg # Test generated files Testing/ + +assistant_snippet* \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 93cb088..b7e18e8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,23 +2,21 @@ cmake_minimum_required(VERSION 3.14...3.27) # 设置 CMake 策略 cmake_policy(SET CMP0074 NEW) # 使用 _ROOT 变量 -cmake_policy(SET CMP0167 NEW) # 使用新的 Boost 查找模块 -cmake_policy(SET CMP0135 NEW) # 设置解压时间戳行为 project(airport_collision_avoidance) -set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) # 检查编译器版本 if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10.0) - message(FATAL_ERROR "GCC 版本需要 >= 10.0 以支持 C++20") + if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0) + message(FATAL_ERROR "GCC 版本需要 >= 7.0 以支持 C++17") endif() elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13.0) - message(FATAL_ERROR "Clang 版本需要 >= 13.0 以支持 C++20") + if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) + message(FATAL_ERROR "Clang 版本需要 >= 5.0 以支持 C++17") endif() endif() @@ -27,11 +25,11 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) # 设置 Boost +set(Boost_NO_WARN_NEW_VERSIONS 1) set(Boost_USE_STATIC_LIBS OFF) set(Boost_USE_MULTITHREADED ON) set(Boost_USE_STATIC_RUNTIME OFF) -set(Boost_ROOT /opt/homebrew/Cellar/boost/1.86.0_2) -find_package(Boost REQUIRED COMPONENTS system) +find_package(Boost REQUIRED COMPONENTS system filesystem thread) # 添加 libcurl find_package(CURL REQUIRED) diff --git a/assistant_snippet_Wd4Hs2Iqxj.txt b/assistant_snippet_Wd4Hs2Iqxj.txt index 676fc5e..181a742 100644 --- a/assistant_snippet_Wd4Hs2Iqxj.txt +++ b/assistant_snippet_Wd4Hs2Iqxj.txt @@ -4,4 +4,13 @@ 4|- boost-thread 5|- openssl-libs 6|- python3 -7|- python3-libs \ No newline at end of file +7|- python3-libs +8| +9|# 安装 SCL 仓库 +10|sudo yum install -y centos-release-scl +11| +12|# 安装 GCC 7 +13|sudo yum install -y devtoolset-7-gcc devtoolset-7-gcc-c++ +14| +15|# 启用 GCC 7 +16|scl enable devtoolset-7 bash \ No newline at end of file diff --git a/scripts/prepare_deploy.sh b/scripts/prepare_deploy.sh index 62e00ca..bc20c22 100644 --- a/scripts/prepare_deploy.sh +++ b/scripts/prepare_deploy.sh @@ -50,6 +50,15 @@ sudo yum groupinstall -y "Development Tools" sudo yum install -y epel-release sudo yum install -y cmake3 boost-devel openssl-devel nlohmann-json-devel python3-devel +# Install GCC 7 +log_info "Installing GCC 7..." +sudo yum install -y centos-release-scl +sudo yum install -y devtoolset-7-gcc devtoolset-7-gcc-c++ + +# Enable GCC 7 +log_info "Enabling GCC 7..." +source /opt/rh/devtoolset-7/enable + # Download Python3 and dependencies repotrack python3 python3-pip python3-devel diff --git a/src/core/System.cpp b/src/core/System.cpp index 84324cc..7c0f989 100644 --- a/src/core/System.cpp +++ b/src/core/System.cpp @@ -344,7 +344,7 @@ void System::processLoop() { // processCollisions(collisions); // } else if (!lastVehiclesWithRisk_.empty()) { - // // 当前没有任何风险,��上次有风险车辆,需要处理恢复指令 + // // 当前没有任何风险����上次有风险车辆,需要处理恢复指令 // Logger::debug("当前无碰撞风险,检查是否需要发送恢复指令"); // for (const auto& vehicleId : lastVehiclesWithRisk_) { // Logger::debug("车辆 ", vehicleId, " 当前没有风险,准备发送恢复指令"); @@ -720,7 +720,7 @@ void System::broadcastVehicleCommand(const VehicleCommand& cmd) { j["intersectionId"] = cmd.intersectionId; } - // 添���目标位置(对于所有非 RESUME 类型的指令) + // 添����目标位置(对于所有非 RESUME 类型的指令) if (cmd.type != CommandType::RESUME) { j["targetLatitude"] = cmd.latitude; j["targetLongitude"] = cmd.longitude; @@ -792,7 +792,7 @@ void System::checkSafetyZoneIntrusion(const MovingObject& obj) { ", type=", obj.isAircraft() ? "飞机" : (obj.isSpecialVehicle() ? "特勤车" : "其他"), ", position=(", position.x, ",", position.y, ")"); - // 检查每个安全区 + // 检查每���安全�� for (auto& [id, zone] : safetyZones_) { // 检查是否在安全区内,同时会尝试设置安全区类型 if (zone->isObjectInZone(obj)) { @@ -926,7 +926,7 @@ bool System::handleSafetyZoneRisk(const Vehicle& vehicle, risk.level = cmdType == CommandType::ALERT ? RiskLevel::CRITICAL : RiskLevel::WARNING; risk.distance = distance; risk.relativeSpeed = cmd.relativeSpeed; - risk.relativeMotion = Vector2D(cmd.relativeMotionX, cmd.relativeMotionY); + risk.relativeMotion = {cmd.relativeMotionX, cmd.relativeMotionY}; risk.zoneType = WarningZoneType::WARNING; broadcastCollisionWarning(risk); diff --git a/src/types/BasicTypes.h b/src/types/BasicTypes.h index 6251125..fc2105f 100644 --- a/src/types/BasicTypes.h +++ b/src/types/BasicTypes.h @@ -16,6 +16,9 @@ struct Vector2D { double x; double y; + Vector2D() : x(0), y(0) {} + Vector2D(double x_, double y_) : x(x_), y(y_) {} + double magnitude() const; double direction() const; };