将 C++版本 改为 17
This commit is contained in:
parent
906a761e34
commit
b49cfe7853
2
.gitignore
vendored
2
.gitignore
vendored
@ -43,3 +43,5 @@ pyvenv.cfg
|
||||
|
||||
# Test generated files
|
||||
Testing/
|
||||
|
||||
assistant_snippet*
|
||||
@ -2,23 +2,21 @@ cmake_minimum_required(VERSION 3.14...3.27)
|
||||
|
||||
# 设置 CMake 策略
|
||||
cmake_policy(SET CMP0074 NEW) # 使用 <PackageName>_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)
|
||||
|
||||
@ -4,4 +4,13 @@
|
||||
4|- boost-thread
|
||||
5|- openssl-libs
|
||||
6|- python3
|
||||
7|- python3-libs
|
||||
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
|
||||
@ -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
|
||||
|
||||
|
||||
@ -344,7 +344,7 @@ void System::processLoop() {
|
||||
// processCollisions(collisions);
|
||||
|
||||
// } else if (!lastVehiclesWithRisk_.empty()) {
|
||||
// // 当前没有任何风险,<EFBFBD><EFBFBD>上次有风险车辆,需要处理恢复指令
|
||||
// // 当前没有任何风险<EFBFBD><EFBFBD><EFBFBD><EFBFBD>上次有风险车辆,需要处理恢复指令
|
||||
// Logger::debug("当前无碰撞风险,检查是否需要发送恢复指令");
|
||||
// for (const auto& vehicleId : lastVehiclesWithRisk_) {
|
||||
// Logger::debug("车辆 ", vehicleId, " 当前没有风险,准备发送恢复指令");
|
||||
@ -720,7 +720,7 @@ void System::broadcastVehicleCommand(const VehicleCommand& cmd) {
|
||||
j["intersectionId"] = cmd.intersectionId;
|
||||
}
|
||||
|
||||
// 添<><E6B7BB><EFBFBD>目标位置(对于所有非 RESUME 类型的指令)
|
||||
// 添<><E6B7BB><EFBFBD><EFBFBD>目标位置(对于所有非 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, ")");
|
||||
|
||||
// 检查每个安全区
|
||||
// 检查每<EFBFBD><EFBFBD><EFBFBD>安全<EFBFBD><EFBFBD>
|
||||
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);
|
||||
|
||||
@ -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;
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user