From 48fbf28761cb9ac8763308a8ea5b5b949052c6f5 Mon Sep 17 00:00:00 2001 From: Tian jianyong <11429339@qq.com> Date: Thu, 23 Jan 2025 10:57:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E6=97=A0=E4=BA=BA?= =?UTF-8?q?=E8=BD=A6=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E5=92=8C=20API=20?= =?UTF-8?q?=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 3 +- config/system_config.json | 9 +- ...le_control.json => unmanned_vehicles.json} | 0 docs/official_api.md | 103 ++++++++++++++++++ src/vehicle/ControllableVehicles.cpp | 2 +- 5 files changed, 110 insertions(+), 7 deletions(-) rename config/{vehicle_control.json => unmanned_vehicles.json} (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 32b80b2..c408735 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -145,9 +145,8 @@ message(STATUS "CMAKE_EXE_LINKER_FLAGS: ${CMAKE_EXE_LINKER_FLAGS}") # 复制配置文件到构建目录 configure_file(${CMAKE_SOURCE_DIR}/config/system_config.json ${CMAKE_BINARY_DIR}/config/system_config.json COPYONLY) configure_file(${CMAKE_SOURCE_DIR}/config/intersections.json ${CMAKE_BINARY_DIR}/config/intersections.json COPYONLY) -configure_file(${CMAKE_SOURCE_DIR}/config/vehicle_control.json ${CMAKE_BINARY_DIR}/config/vehicle_control.json COPYONLY) configure_file(${CMAKE_SOURCE_DIR}/config/airport_bounds.json ${CMAKE_BINARY_DIR}/config/airport_bounds.json COPYONLY) - +configure_file(${CMAKE_SOURCE_DIR}/config/unmanned_vehicles.json ${CMAKE_BINARY_DIR}/config/unmanned_vehicles.json COPYONLY) if(NOT APPLE) target_link_libraries(collision_avoidance PRIVATE diff --git a/config/system_config.json b/config/system_config.json index 367e35f..8da32bc 100644 --- a/config/system_config.json +++ b/config/system_config.json @@ -42,13 +42,14 @@ "unmanned_vehicle": { "host": "localhost", "port": 8081, - "status_path": "/openApi/getVehicleStatus", - "command_path": "/openApi/sendVehicleCommand", + "location_path": "/api/VehicleLocationInfo", + "status_path": "/api/VehicleStateInfo", + "command_path": "/api/VehicleCommandInfo", "refresh_interval_ms": 1000, "auth": { "username": "dianxin", "password": "dianxin@123", - "auth_path": "/login", + "auth_path": "/api/login", "auth_required": false }, "timeout_ms": 5000, @@ -62,7 +63,7 @@ "auth": { "username": "dianxin", "password": "dianxin@123", - "auth_path": "/login", + "auth_path": "/api/login", "auth_required": false }, "timeout_ms": 5000, diff --git a/config/vehicle_control.json b/config/unmanned_vehicles.json similarity index 100% rename from config/vehicle_control.json rename to config/unmanned_vehicles.json diff --git a/docs/official_api.md b/docs/official_api.md index f5d7612..645c87f 100644 --- a/docs/official_api.md +++ b/docs/official_api.md @@ -120,3 +120,106 @@ responseData: "transId": "68f79d1a-e27f-11ed-b28c-2cf05d9c2649", "timestamp": 1736175610 } + +### 2.2 无人车位置上报 + +1. 接口地址: + +2. 请求方法:GET + +3. 返回值(以 List 数据返回,一次请求返回集合对象): + +| 字段名称 | 类型 | 是否必填 | 说明 | +|---------|------|----------|------| +| transId | string | 是 | 消息唯一 id,消息的唯一标识符 | +| timestamp | long | 是 | 时间戳(UTC 时间,单位:毫秒) | +| vehicleID | string | 是 | 车辆 ID | +| latitude | double | 是 | 纬度 | +| longitude | double | 是 | 经度 | +| speed | double | 是 | 速度(单位:m/s) | +| direction | double | 是 | 车头航向角,正东为 0 度(弧度) | + +示例: + +requestData: +[ +{ + "transId": "68f79d1a-e27f-11ed-b28c-2cf05d9c2649", + "timestamp": 1736175610000, + "vehicleID": "AT001", + "latitude": 123.112, + "longitude": 78.331, + "speed": 3.2, + "direction": 1.57 +} +] + +### 2.3 无人车状态上报 + +1. 接口地址: + +2. 请求方法:POST + +3. 请求参数: + +| 字段名称 | 类型 | 是否必填 | 说明 | +|---------|------|----------|------| +| transId | string | 是 | 消息唯一 id,消息的唯一标识符 | +| timestamp | long | 是 | 时间戳(UTC 时间,单位:毫秒) | +| vehicleID | string | 是 | 车辆 ID | +| isSingle | boolean | 是 | True:单个车辆,False:所有车辆 | + +示例: + + requestData: + { + "transId": "68f79d1a-e27f-11ed-b28c-2cf05d9c2649", + "timestamp": 1736175610000, + "vehicleID": "AT001", + "isSingle": true + } + +4. 返回值(以 List 数据返回,一次请求返回集合对象): + +| 字段名称 | 类型 | 是否必填 | 说明 | +|---------|------|----------|------| +| transId | string | 是 | 消息唯一 id,消息的唯一标识符 | +| timestamp | long | 是 | 时间戳(UTC 时间,单位:毫秒) | +| vehicleID | string | 是 | 车辆 ID | +| loginState | boolean | 是 | 登录状态:True:登录,False:未登录 | +| faultInfo | list | 是 | 故障信息,以列表返回,可能存在多个 | +| activeSafety | boolean | 是 | 车辆最小风险策略触发(主动安全):True:触发,False:未触发 | +| RC | boolean | 是 | 被接管或干预相关信息,是否被远控RemoteControl,True:车辆在遥控器远控模式,False:车辆处于自动驾驶模式 | +| Command | int | 是 | 接收的远程指令信息,0:恢复,1:急停,2:缓停 | +| airportInfo | list | 否 | 机场特殊要求的其他信息 | +| vehicleMode | int | 是 | 无人设备控制模式(底盘控制模式),1:手动(司机驾驶),2:自动,3:遥控器,4:远程,5:故障等待 | +| gearState | int | 是 | 车辆当前档位,1:N,2:D,3:P,4:R, 5: 未知 | +| chassisReady | boolean | 是 | 底盘是否准备就绪,True:车辆发控制指令就可以走,false: 其他 | +| collisionStatus | boolean | 否 | 防撞梁是否触发,true:触发,false:未触发 | +| clearance | int | 是 | 0:关闭,1:开启(示廓灯) | +| turnSignalStstus | int | 是 | 转向灯状态,0:off , 1 : trun left , 2 : trun right, 3: 双闪 | +| pointCloud | list | 否 | 点云数据字节流,每个点的长度,现在是12,每个坐标为float,长度4| + +示例: + +responseData: +[ + { + "transId": "68f79d1a-e27f-11ed-b28c-2cf05d9c2649", + "timestamp": 1736175610000, + "vehicleID": "AT001", + "loginStatus":true, + "faultInfo":[], + "activeSafety":false, + "RC":false, + "Command":0, + "airportInfo":[], + "vehicleMode": 2, + "gearState": 2, + "chassisRaedy":true, + "collisionStatus":false, + "clearance":0, + "turnSignalStstus":0, + "pointCloud":[] + } +] diff --git a/src/vehicle/ControllableVehicles.cpp b/src/vehicle/ControllableVehicles.cpp index 8a3fe34..fe49fa9 100644 --- a/src/vehicle/ControllableVehicles.cpp +++ b/src/vehicle/ControllableVehicles.cpp @@ -9,7 +9,7 @@ ControllableVehicles* ControllableVehicles::instance_ = nullptr; ControllableVehicles& ControllableVehicles::getInstance() { if (instance_ == nullptr) { - instance_ = new ControllableVehicles("config/vehicle_control.json"); + instance_ = new ControllableVehicles("config/unmanned_vehicles.json"); } return *instance_; }