/** * AutomaticServiceDefines.h * * @brief: 自动驾驶服务相关定义 * @author: zhanke * @history: 2024-08-01, create file */ #ifndef AUTOMATICSERVICEDEFINES_H #define AUTOMATICSERVICEDEFINES_H #include #include #include #include "json.hpp" // 定义常量 pi = 3.14... #ifdef M_PI #undef M_PI #endif #define M_PI double(3.14159265358979323846) namespace automatic_service { static constexpr auto DCRK = "20100"; // 倒车入库 static constexpr auto PDQB = "20300"; // 坡道起步 static constexpr auto CFTC = "20400"; // 侧方停车 static constexpr auto QXXS = "20600"; // 曲线行驶 static constexpr auto ZJZW = "20700"; // 直角转弯 // 项目索引对应语音文件项目分类编号 static std::unordered_map itemIndex2SoundMap = { {DCRK, 2}, {PDQB, 1}, {CFTC, 4}, {QXXS, 3}, {ZJZW, 0}}; }; // namespace automatic_service namespace data { // 场地模型经纬度坐标基准点定义 struct BasePoint { std::string basegpsn; std::string basegpse; std::string basegpsnO; std::string basegpseO; }; NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(BasePoint, basegpsn, basegpse, basegpsnO, basegpseO) // 场地模型经纬度坐标点定义 struct ModelPoint { std::string Index; double GPSN; double GPSE; double High; }; NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(ModelPoint, Index, GPSN, GPSE, High) // 场地模型定义 struct FieldModel { std::string ModelName; std::string Index; std::vector Points; }; NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(FieldModel, ModelName, Index, Points) // 场地模型列表 struct FieldModelList { std::vector model; }; NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(FieldModelList, model) // 教学点信息定义 struct TeachPointInfo { int point_index = 0; std::string teachName; double velocity_max = 0.0; double velocity_std = 0.0; double steering_std = 0.0; double lamp_std = 0.0; }; NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(TeachPointInfo, point_index, teachName, velocity_max, velocity_std, steering_std, lamp_std) // 项目教学点定义 struct TeachItem { std::string item_code; std::vector teach_point; }; NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(TeachItem, item_code, teach_point) struct TeachItemList { std::vector item; }; NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(TeachItemList, item) // 教学点参数定义 struct TeachPointParam { std::string libIndex; // 库位编号(可能存在一个项目有多个可选库位的情况) double distance1; // 辅助教学模式判断距离(单位:微米) double distance2; // 语音教学模式判断距离(暂时用不到) }; NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(TeachPointParam, libIndex, distance1, distance2) struct TeachPointParamInfo { std::string name; // 教学点编号 std::vector params; }; NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(TeachPointParamInfo, name, params) struct TeachPoint { std::string itemCode; // 项目代码 std::vector teachPoint; }; NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(TeachPoint, itemCode, teachPoint) struct TeachPointList { std::vector item; }; NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(TeachPointList, item); // 车模定义 struct CarModel { double Angle; double BasePointHigh; double BasePointN; double BasePointE; std::vector Points; }; NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(CarModel, Angle, BasePointHigh, BasePointN, BasePointE, Points) struct CarModelList { std::vector Model; }; NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(CarModelList, Model) struct CrsProperty { std::string name; }; NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(CrsProperty, name) struct Crs { std::string type; CrsProperty properties; }; NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Crs, type, properties) struct FeatureProperty { int id; std::string name; int type; std::string describe; }; NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(FeatureProperty, id, name, type, describe) struct Geometry { std::string type; std::vector> coordinates; // 坐标 }; NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Geometry, type, coordinates) struct Feature { std::string type; FeatureProperty properties; Geometry geometry; }; NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Feature, type, properties, geometry) // 路径列表/库位列表定义 struct Track { // 根据id获取类型 int getTypeById(int id) { for (Feature ft : features) { if (id == ft.properties.id) { return ft.properties.type; } } return 1; // 默认1: 倒库模式 } // 根据id获取Feature Feature getFeaturesById(int id) { Feature result; for (Feature ft : features) { if (id == ft.properties.id) { result = ft; } } return result; } std::string type; std::string name; Crs crs; std::vector features; }; NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Track, type, name, crs, features) } // namespace data #endif // AUTOMATICSERVICEDEFINES_H