from SimOneIOStruct import *
[文档]
def SoInitEvaluationService(mainVehicleId, serviceIP="127.0.0.1", port=8078, withMainVehicle=True, withObstacleNeeded=True):
"""
初始化评价服务\n
Initialize the Evaluation Service for autonomous driving algorithms.\n
默认情况下,评价服务将接收判决数据和GPS数据(类别:judge, mainvehicle)\n
By default, the evaluation service will receive judge data and GPS data (categories: judge, mainvehicle).
:param str mainVehicleId: 主车的ID\n
Id of the main vehicle.
:param str serviceIP: 评价服务的IP地址\n
IP address of the evaluation service. Default is "127.0.0.1".
:param int port: 评价服务的端口号\n
Port number for the evaluation server. Default is 8078.
:param bool withMainVehicle: 是否默认发送主车数据到评价服务器\n
Whether to send MainVehicle data to the evaluation server by default. Default is True.
:param bool withObstacleNeeded: 是否发送障碍物数据到评价服务器\n
Whether to send Obstacle data to the evaluation server. Default is True.
:return: 执行结果:成功或失败。Execution outcome: success or failure.
:rtype: bool
"""
SimoneAPI.InitEvaluationService.restype = c_bool
_mainVehicleId = create_string_buffer(mainVehicleId.encode(), 256)
_serviceIP = create_string_buffer(serviceIP.encode(), 256)
_withMainVehicle = c_bool(withMainVehicle)
_withObstacleNeeded = c_bool(withObstacleNeeded)
return SimoneAPI.InitEvaluationService(_mainVehicleId, _serviceIP, port, _withMainVehicle, _withObstacleNeeded)
[文档]
def SoInitEvaluationServiceWithLocalData(mainVehicleId, withMainVehicle=True, withObstacleNeeded=True):
"""
初始化评价服务,并使用本地存储数据\n
Initialize the Evaluation Service for autonomous driving algorithms with local data storage.\n
默认情况下,评价服务将接收判决数据和GPS数据(类别:judge, mainvehicle)\n
By default, the evaluation service will receive judge data and GPS data (categories: judge, mainvehicle).
:param str mainVehicleId: 主车的ID\n
Id of the main vehicle.
:param bool withMainVehicle: 是否默认发送主车数据到评价服务器\n
Whether to send MainVehicle data to the evaluation server by default. Default is True.
:param bool withObstacleNeeded: 是否发送障碍物数据到评价服务器\n
Whether to send Obstacle data to the evaluation server. Default is True.
:return: 执行结果:成功或失败\n
Execution outcome: success or failure.
:rtype: bool
"""
SimoneAPI.InitEvaluationServiceWithLocalData.restype = c_bool
_mainVehicleId = create_string_buffer(mainVehicleId.encode(), 256)
_withMainVehicle = c_bool(withMainVehicle)
_withObstacleNeeded = c_bool(withObstacleNeeded)
return SimoneAPI.InitEvaluationServiceWithLocalData(_mainVehicleId, _withMainVehicle, _withObstacleNeeded)
[文档]
def SoAddEvaluationRecord(mainVehicleId, jsonString):
"""
添加评价算法所需的各类信息(JSON格式)\n
Add evaluation records for the Evaluation algorithm in JSON format.\n
该记录可由json dump生成,包含属性类别、时间戳等信息,例如:{"category": "signal", "timestamp": 1648363819335, "ACC": "on", "ACCSpeed": 20}\n
The record, which can be generated by json dump, includes property category, timestamp, and other information, e.g., {"category": "signal", "timestamp": 1648363819335, "ACC": "on", "ACCSpeed": 20}.
:param str mainVehicleId: 主车的ID\n
Id of the main vehicle.
:param str jsonString: 以JSON格式表示的记录字符串\n
Record string in JSON format.
:return: 执行结果:成功或失败\n
Execution outcome: success or failure.
:rtype: bool
"""
SimoneAPI.AddEvaluationRecord.restype = c_bool
_mainVehicleId = create_string_buffer(mainVehicleId.encode(), 256)
_jsonString = create_string_buffer(jsonString.encode())
return SimoneAPI.AddEvaluationRecord(_mainVehicleId, _jsonString)
[文档]
def SoSaveEvaluationRecord():
"""
保存评价算法所需的各类信息(JSON格式)\n
Save the evaluation records for the Evaluation algorithm in JSON format.\n
此函数用于保存之前添加的评价算法记录,格式为JSON\n
This function is used to save the previously added evaluation records in JSON format.
:return: 执行结果:成功或失败\n
Execution outcome: success or failure.
:rtype: bool
"""
SimoneAPI.SaveEvaluationRecord.restype = c_bool
return SimoneAPI.SaveEvaluationRecord()
SimOne_JudgeEventCBType = CFUNCTYPE(c_void_p, c_char_p, POINTER(SimOne_Data_JudgeEvent))
G_API_JudgeEvent_CB = None
def _api_judgeEvent_cb(mainVehicleId, judgeEventDetailInfo):
global G_API_JudgeEvent_CB
if G_API_JudgeEvent_CB is None:
return
G_API_JudgeEvent_CB(mainVehicleId, judgeEventDetailInfo)
api_scenarioEvent_cb = SimOne_JudgeEventCBType(_api_judgeEvent_cb)
[文档]
def SoSetJudgeEventCB(cb):
"""
场景判定事件回调\n
Register the callback function for scenario judgment events.\n
此函数用于注册场景判定事件的回调函数,用于处理场景中的判定事件\n
This function is used to register a callback function for scenario judgment events, to handle judgment events within the scenario.
:param function cb: 场景判定事件的回调函数\n
Scenario judgment event callback function.
:param str mainVehicleId: 主车的ID\n
Id of the main vehicle.
:param str judgeEventDetailInfo: 场景判定事件的详细信息\n
Detail info for scenario judgment event.
:return: 执行结果:成功或失败\n
Execution outcome: success or failure.
:rtype: bool
"""
SimoneAPI.SetJudgeEventCB.restype = c_bool
if cb == 0:
cb = None
global G_API_JudgeEvent_CB
G_API_JudgeEvent_CB = cb
return SimoneAPI.SetJudgeEventCB(api_scenarioEvent_cb)
[文档]
def SoAddJudgeEvent(mainVehicleId, data, terminate=False):
"""
发送场景判定事件\n
Broadcast scenario judgment event information for report generation.\n
此函数用于广播场景中的判定事件信息,用于报告生成\n
This function is used to broadcast judgment event information in a scenario, intended for report generation.
:param str mainVehicleId: 主车的ID\n
ID of the main vehicle.
:param str data: 场景中的判定事件信息\n
Judge event information of the scenario.
:param bool terminate: 是否终止场景,默认为False\n
Whether to terminate the scenario, default is False.
:return: 执行结果:成功或失败\n
Execution outcome: success or failure.
:rtype: bool
"""
SimoneAPI.AddJudgeEvent.restype = c_bool
_mainVehicleId = create_string_buffer(mainVehicleId.encode(), 256)
_data = create_string_buffer(data.encode())
return SimoneAPI.AddJudgeEvent(_mainVehicleId, _data, terminate)