SimOneSensorAPI 源代码

from SimOneIOStruct import *

GpsCbFuncType = CFUNCTYPE(c_void_p, c_char_p, POINTER(SimOne_Data_Gps))
ImuCbFuncType = CFUNCTYPE(c_void_p, c_char_p, POINTER(SimOne_Data_IMU))
GroundTruthCbFuncType = CFUNCTYPE(c_void_p, c_char_p, POINTER(SimOne_Data_Obstacle))
SensorLaneInfoCbFuncType = CFUNCTYPE(c_void_p,c_char_p, c_char_p, POINTER(SimOne_Data_LaneInfo))
UltrasonicsCbFuncType = CFUNCTYPE(c_void_p, c_char_p, POINTER(SimOne_Data_UltrasonicRadars))
RadarDetectionCbFuncType = CFUNCTYPE(c_void_p, c_char_p, c_char_p,POINTER(SimOne_Data_RadarDetection))
SensorDetectionsCbFuncType = CFUNCTYPE(c_void_p, c_char_p, c_char_p,POINTER(SimOne_Data_SensorDetections))
SensorRoadMarkCbFuncType = CFUNCTYPE(c_void_p, c_char_p, c_char_p,POINTER(SimOne_Data_RoadMarkInfo))

SIMONEAPI_GPS_CB = None
SIMONEAPI_IMU_CB = None
SIMONEAPI_GROUNDTRUTH_CB = None
SIMONEAPI_SENSORLANEINFO_CB = None
SIMONEAPI_ULTRASONICS_CB = None
SIMONEAPI_RADARDETECTION_CB = None
SIMONEAPI_SENSOR_DETECTIONS_CB = None
SIMONEAPI_SENSOR_ROADMARK_CB = None

def _simoneapi_gps_cb(mainVehicleId, data):
	global SIMONEAPI_GPS_CB
	SIMONEAPI_GPS_CB(mainVehicleId, data)

def _simoneapi_imu_cb(mainVehicleId, data):
	global SIMONEAPI_IMU_CB
	SIMONEAPI_IMU_CB(mainVehicleId, data)

def _simoneapi_groundtruth_cb(mainVehicleId, data):
	global SIMONEAPI_GROUNDTRUTH_CB
	SIMONEAPI_GROUNDTRUTH_CB(mainVehicleId, data)

def _simoneapi_sensorlaneinfo_cb(mainVehicleId, sensorId, data):
	global SIMONEAPI_SENSORLANEINFO_CB
	SIMONEAPI_SENSORLANEINFO_CB(mainVehicleId, sensorId, data)

def _simoneapi_ultrasonics_cb(mainVehicleId, data):
	global SIMONEAPI_ULTRASONICS_CB
	SIMONEAPI_ULTRASONICS_CB(mainVehicleId, data)

def _simoneapi_radardetection_cb(mainVehicleId, sensorId, data):
	global SIMONEAPI_RADARDETECTION_CB
	SIMONEAPI_RADARDETECTION_CB(mainVehicleId, sensorId, data)

def _simoneapi_sensor_detections_cb(mainVehicleId, sensorId, data):
	global SIMONEAPI_SENSOR_DETECTIONS_CB
	SIMONEAPI_SENSOR_DETECTIONS_CB(mainVehicleId, sensorId, data)

def _simoneapi_sensor_roadmarkinfo_cb(mainVehicleId, sensorId, data):
	global SIMONEAPI_SENSOR_ROADMARK_CB
	SIMONEAPI_SENSOR_ROADMARK_CB(mainVehicleId, sensorId, data)

simoneapi_gps_cb_func = GpsCbFuncType(_simoneapi_gps_cb)
simoneapi_imu_cb_func = ImuCbFuncType(_simoneapi_imu_cb)
simoneapi_groundtruth_cb_func = GroundTruthCbFuncType(_simoneapi_groundtruth_cb)
simoneapi_sensorlaneinfo_cb_func = SensorLaneInfoCbFuncType(_simoneapi_sensorlaneinfo_cb)
simoneapi_ultrasonics_cb_func = UltrasonicsCbFuncType(_simoneapi_ultrasonics_cb)
simoneapi_radardetection_cb_func = RadarDetectionCbFuncType(_simoneapi_radardetection_cb)
simoneapi_sensor_detections_cb_func = SensorDetectionsCbFuncType(_simoneapi_sensor_detections_cb)
simoneapi_sensor_roadmarkinfo_cb_func = SensorRoadMarkCbFuncType(_simoneapi_sensor_roadmarkinfo_cb)

[文档] def SoGetGps(mainVehicleId, gpsData): """获取主车GPS信息\n Get vehicle GPS info :param mainVehicleId: vehicle id :type mainVehicleId: string :param gpsData: vehicle gps including basic chassis info :type gpsData: SimOne_Data_Gps :return: executive outcome: success/faile :rtype: bool """ SimoneAPI.GetGps.restype = c_bool _mainVehicleId = create_string_buffer(mainVehicleId.encode(), 256) return SimoneAPI.GetGps(_mainVehicleId, pointer(gpsData))
[文档] def SoApiSetGpsUpdateCB(cb): """主车GPS更新回调\n Register the callback func applying for GPS info :param cb: (cb)(mainVehicleId, Data_Gps) :type cb: GPS callback function mainVehicleId (str): vehicle id Data_Gps (SimOne_Data_Gps): gps info """ global SIMONEAPI_GPS_CB SimoneAPI.SetGpsUpdateCB(simoneapi_gps_cb_func) SIMONEAPI_GPS_CB = cb
[文档] def SoGetGroundTruth(mainVehicleId, obstacleData): """获取仿真场景中障碍物真值\n Get Ground Truth Data of Objects(Obstacles) from simulation scene :param mainVehicleId: vehicle id :type mainVehicleId: string :param obstacleData: obstacle(s) ground truth info :type obstacleData: SimOne_Data_Obstacle :return: executive outcome: success/faile :rtype: bool """ SimoneAPI.GetGroundTruth.restype = c_bool _mainVehicleId = create_string_buffer(mainVehicleId.encode(), 256) ret = SimoneAPI.GetGroundTruth(_mainVehicleId, pointer(obstacleData)) return ret
[文档] def SoApiSetGroundTruthUpdateCB(cb): """获取仿真场景中障碍物真值更新回调\n Register the callback func applying for obstacle info :param cb: cb(mainVehicleId, Data_Obstacle) :type cb: ground truth callback function mainVehicleId (str): vehicle id Data_Obstacle (SimOne_Data_Obstacle): ground true info """ global SIMONEAPI_GROUNDTRUTH_CB SimoneAPI.SetGroundTruthUpdateCB(simoneapi_groundtruth_cb_func) SIMONEAPI_GROUNDTRUTH_CB = cb
[文档] def SoGetRadarDetections(mainVehicleId, sensorId, detectionData): """获取毫米波雷达目标信息\n Get millimeter wave radar detections :param mainVehicleId: vehicle id :type mainVehicleId: string :param sensorId: sensor Id :type sensorId: string :param detectionData: radar detected obstacle(s) info :type detectionData: SimOne_Data_RadarDetection :return: executive outcome: success/faile :rtype: bool """ SimoneAPI.GetRadarDetections.restype = c_bool _mainVehicleId = create_string_buffer(mainVehicleId.encode(), 256) _sensorId = create_string_buffer(sensorId.encode(), 256) return SimoneAPI.GetRadarDetections(_mainVehicleId, _sensorId, pointer(detectionData))
[文档] def SoApiSetRadarDetectionsUpdateCB(cb): """毫米波雷达目标信息回调\n Register the callback func applying for Millimeter wave radar detections :param cb: cb(mainVehicleId, sensorId, Data_Detections) :type cb: radar detection callback function mainVehicleId (str): vehicle id sensorId(str): radar sensor id Data_Detections(SimOne_Data_RadarDetection): radar detected obstacle(s) info """ global SIMONEAPI_RADARDETECTION_CB SimoneAPI.SetRadarDetectionsUpdateCB(simoneapi_radardetection_cb_func) SIMONEAPI_RADARDETECTION_CB = cb
[文档] def SoGetUltrasonicRadar(mainVehicleId, sensorId, ultrasonic): """获取一个超声波雷达信息\n Get UltrasonicRadar imformations :param mainVehicleId: vehicle id :type mainVehicleId: string :param sensorId: ultrasonic radar sensor Id :type sensorId: string :param ultrasonic: ultrasonic radar detected obstacle(s) dist info :type ultrasonic: SimOne_Data_UltrasonicRadar :return: executive outcome: success/faile :rtype: bool """ SimoneAPI.GetUltrasonicRadar.restype = c_bool _mainVehicleId = create_string_buffer(mainVehicleId.encode(), 256) _sensorId = create_string_buffer(sensorId.encode(), 256) return SimoneAPI.GetUltrasonicRadar(_mainVehicleId, _sensorId, pointer(ultrasonic))
[文档] def SoGetUltrasonicRadars(mainVehicleId, ultrasonics): """获取所有超声波雷达信息\n Get all UltrasonicRadar(s) info :param mainVehicleId: vehicle id :type mainVehicleId: string :param ultrasonics: all ultrasonic radar(s) detected obstacle(s) dist info :type ultrasonics: SimOne_Data_UltrasonicRadars :return: executive outcome: success/faile :rtype: bool """ SimoneAPI.GetUltrasonicRadar.restype = c_bool _mainVehicleId = create_string_buffer(mainVehicleId.encode(), 256) return SimoneAPI.GetUltrasonicRadars(_mainVehicleId, pointer(ultrasonics))
[文档] def SoApiSetUltrasonicRadarsCB(cb): """超生波雷达真值信息更新回调\n Register the callback func applying for ultrasonics radar detections :param cb: cb(mainVehicleId, Data_Ultrasonics) :type cb: ultrasonic radar(s) callback function mainVehicleId (str): vehicle id Data_Detections(SimOne_Data_UltrasonicRadars): all ultrasonic radars(s) detected obstacle(s) info """ global SIMONEAPI_ULTRASONICS_CB SimoneAPI.SetUltrasonicRadarsCB(simoneapi_ultrasonics_cb_func) SIMONEAPI_ULTRASONICS_CB = cb
[文档] def SoGetSensorDetections(mainVehicleId, sensorId, sensorDetections): """获取传感器检测的障碍物真值\n Get ground truth objects info by sensor(s) camera/lidar/perfect perception sensors :param mainVehicleId: vehicle id :type mainVehicleId: string :param sensorId: sensor Id :type sensorId: string :param sensorDetections: sensor detected obstacles(s) info :type sensorDetections: SimOne_Data_SensorDetections :return: executive outcome: success/faile :rtype: bool """ _mainVehicleId = create_string_buffer(mainVehicleId.encode(), 256) _sensorId = create_string_buffer(sensorId.encode(), 256) SimoneAPI.GetSensorDetections.restype = c_bool return SimoneAPI.GetSensorDetections(_mainVehicleId, _sensorId, pointer(sensorDetections))
[文档] def SoApiSetSensorDetectionsUpdateCB(cb): """传感器真值信息更新回调\n Register the callback func applying for ground truth info by sensor(s) camera/lidar/perfect perception sensors :param cb: cb(mainVehicleId, sensorId, Data_Groundtruth) :type cb: sensor detections callback function mainVehicleId (str): vehicle id sensorId(str): sensor id Data_Groundtruth(SimOne_Data_SensorDetections): sensor detected obstacle(s) info """ global SIMONEAPI_SENSOR_DETECTIONS_CB SimoneAPI.SetSensorDetectionsUpdateCB(simoneapi_sensor_detections_cb_func) SIMONEAPI_SENSOR_DETECTIONS_CB = cb
[文档] def SoGetSensorConfigurations(mainVehicleId, sensorConfigurations): """获取所有传感器的配置信息: Id/类型/频率/位置/朝向\n Get sensor(s) config infor :param mainVehicleId: vehicle id :type mainVehicleId: string :param sensorConfigurations: all sensor(s) config info :type sensorConfigurations: SimOne_Data_SensorConfigurations :return: executive outcome: success/faile :rtype: bool """ SimoneAPI.GetSensorConfigurations.restype = c_bool _mainVehicleId = create_string_buffer(mainVehicleId.encode(), 256) return SimoneAPI.GetSensorConfigurations(_mainVehicleId, pointer(sensorConfigurations))
[文档] def SoGetEnvironment(pEnvironment): """获取当前环境相关信息: 天气/光照/地面\n Get current environment info :param pEnvironment: curent environment info :type pEnvironment: SimOne_Data_Environment :return: executive outcome: success/faile :rtype: bool """ SimoneAPI.GetEnvironment.restype = c_bool return SimoneAPI.GetEnvironment(pointer(pEnvironment))
[文档] def SoSetEnvironment(pEnvironment): """设置当前环境相关信息: 天气/光照/地面\n Set current environment info :param pEnvironment: environment info to be set :type pEnvironment: SimOne_Data_Environment :return: executive outcome: success/faile :rtype: bool """ SimoneAPI.SetEnvironment.restype = c_bool return SimoneAPI.SetEnvironment(pointer(pEnvironment))
[文档] def SoGetTrafficLights(mainVehicleId, opendriveLightId, trafficLight): """获取仿真场景中的交通灯真值\n Get traffic light(s) info from simulation scene :param mainVehicleId: vehicle id :type mainVehicleId: string :param opendriveLightId: traffic light opendrive-id :type opendriveLightId: int :param trafficLight: traffic lights(s) info :type trafficLight: SimOne_Data_TrafficLight :return: executive outcome: success/faile :rtype: bool """ SimoneAPI.GetTrafficLight.restype = c_bool _mainVehicleId = create_string_buffer(mainVehicleId.encode(), 256) return SimoneAPI.GetTrafficLight(_mainVehicleId, opendriveLightId, pointer(trafficLight))
[文档] def SoGetSensorLaneInfo(mainVehicleId, sensorId,pLaneInfo): """获取传感器探测车道数据\n Get lane info by sensor: objectbased-camera/fusion-sensor :param mainVehicleId: vehicle id :type mainVehicleId: string :param sensorId: sensor id :type sensorId: string :param pLaneInfo: lane info :type pLaneInfo: SimOne_Data_LaneInfo :return: executive outcome: success/faile :rtype: bool """ SimoneAPI.GetSensorLaneInfo.restype = c_bool _mainVehicleId = create_string_buffer(mainVehicleId.encode(), 256) _sensorId = create_string_buffer(sensorId.encode(), 256) return SimoneAPI.GetSensorLaneInfo(_mainVehicleId, _sensorId, pointer(pLaneInfo))
[文档] def SoApiSetSensorLaneInfoCB(cb): """获取传感器探测车道消息数据回调\n Register the callback func for applying lane info by sensor: objectbased-camera/fusion-sensors :param cb: cb(mainVehicleId, sensorId, Data_LaneInfo) :type cb: sensor detected lane info callback function mainVehicleId (str): vehicle id sensorId(str): sensor id Data_LaneInfo(SimOne_Data_LaneInfo): sensor detected lane info """ global SIMONEAPI_SENSORLANEINFO_CB SimoneAPI.SetSensorLaneInfoCB(simoneapi_sensorlaneinfo_cb_func) SIMONEAPI_SENSORLANEINFO_CB = cb
[文档] def SoGetSensorRoadMarkInfo(mainVehicleId, sensorId, pRoadMarkInfo): """获取传感器检测地面喷漆信息: 车道停止线/地面箭头/人行横道线\n Get road mark info by objectbased-camera sensor :param mainVehicleId: vehicle id :type mainVehicleId: string :param sensorId: sensor id :type sensorId: string :param pRoadMarkInfo: road mark info :type pRoadMarkInfo: SimOne_Data_RoadMarkInfo :return: executive outcome: success/faile :rtype: bool """ SimoneAPI.GetSensorRoadMarkInfo.restype = c_bool _mainVehicleId = create_string_buffer(mainVehicleId.encode(), 256) _sensorId = create_string_buffer(sensorId.encode(), 256) return SimoneAPI.GetSensorRoadMarkInfo(_mainVehicleId, _sensorId, pointer(pRoadMarkInfo))
[文档] def SoApiSetSensorRoadMarkInfoCB(cb): """获取传感器检测地面喷漆信息回调: 车道停止线/地面箭头/人行横道线\n Register the callback func for applying road mark by objectbased-camera sensor :param cb: cb(mainVehicleId, sensorId, Data_RoadMarkInfo) :type cb: sensor detected road mark callback function mainVehicleId (str): vehicle id sensorId(str): sensor id Data_RoadMarkInfo(SimOne_Data_RoadMarkInfo): sensor detected lane info """ global SIMONEAPI_SENSOR_ROADMARK_CB SimoneAPI.SetSensorRoadMarkInfoCB(simoneapi_sensor_roadmarkinfo_cb_func) SIMONEAPI_SENSOR_ROADMARK_CB = cb