行人逆行、盲区、交叉路口碰撞预警

Signed-off-by: chenfufeng <chenfufeng@zhidaoauto.com>
This commit is contained in:
chenfufeng
2021-09-28 18:09:51 +08:00
committed by liujing
parent c01cab3647
commit a7d9040e4e
4 changed files with 135 additions and 36 deletions

View File

@@ -57,6 +57,12 @@ enum class TrafficTypeEnum(
R.raw.daba,
R.raw.daba
),
TYPE_TRAFFIC_ID_CAMERA(
9,
"摄像头",
R.raw.shexiangtou,
R.raw.shexiangtou
),
TYPE_TRAFFIC_ID_SPECIAL_VEHICLE(
11,
"特殊车辆",

View File

@@ -7,20 +7,22 @@ import androidx.annotation.Keep
*/
@Keep
data class AdvanceWarningBean(
var objectId: String,
var status: Int,
var typeId: Int,
var objectId: String,// 物体唯一标识
var objectType: Int,// 物体类型 1-人 2-自行车 3-小轿车 4-摩托车 5-红绿灯 6-bus 8-truck 9-路边摄像头
var status: Int,// 1.add 2.update 3.delete
var typeId: Int,// 首位大类标识 1预警 2规划 3拥堵 4事故
var time: Long,
var level: Int,
var level: Int,// 预警等级
var threatLevel: Int,// 危险等级0保留1模型原始颜色2通知--黄3警告--红
var position: Position,
var heading: Int,
var heading: Double,
var speed: Double,
var distance: Double,
var roadId: String,
var laneId: String,
var laneNum: Int,
var gdLocusList: List<Position>,
var locusList: List<Position>
var roadId: String,// 道路id
var laneId: String,// 车道id
var laneNum: Int,// 车道号中心线编号为0 中心线右侧编号为负数3车道通行Road的车道编号0,-1,-2,-3
var gdLocusList: List<Position>,// 线性经纬度轨迹列表(高德)
var locusList: List<Position>// 轨迹列表(Wgs84坐标系)
)
@Keep

View File

@@ -1,26 +0,0 @@
package com.mogo.module.v2x.listener;
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
import com.mogo.eagle.core.data.v2x.AdvanceWarningBean;
import com.mogo.service.cloud.socket.IMogoOnMessageListener;
import com.mogo.utils.logger.Logger;
import com.mogo.utils.network.utils.GsonUtil;
/**
* @author chenfufeng
* @description 路口碰撞预警、盲区预警等
* @since: 2021/9/23
*/
public class V2XMessageListener_404000 implements IMogoOnMessageListener<AdvanceWarningBean> {
@Override
public Class target() {
return AdvanceWarningBean.class;
}
@Override
public void onMsgReceived(AdvanceWarningBean message) {
// 将接收到的数据转换成最优车道推荐的场景数据
Logger.i(MODULE_NAME, "V2XMessageListener_404000" + GsonUtil.jsonFromObject(message));
}
}

View File

@@ -0,0 +1,117 @@
package com.mogo.module.v2x.listener
import com.mogo.eagle.core.data.enums.TrafficTypeEnum
import com.mogo.eagle.core.data.traffic.TrafficData
import com.mogo.service.cloud.socket.IMogoOnMessageListener
import com.mogo.eagle.core.data.v2x.AdvanceWarningBean
import com.mogo.module.v2x.V2XConst
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
import com.mogo.eagle.core.function.api.hmi.warning.WarningStatusListener
import com.mogo.module.common.drawer.TrafficMarkerDrawer
import com.mogo.module.common.enums.EventTypeEnum
import com.mogo.module.v2x.utils.V2XUtils
import com.mogo.utils.logger.Logger
/**
* @author chenfufeng
* @description 路口碰撞预警、盲区预警等
* @since: 2021/9/23
*/
class V2XMessageListener_404000 : IMogoOnMessageListener<AdvanceWarningBean> {
override fun target(): Class<AdvanceWarningBean> {
return AdvanceWarningBean::class.java
}
override fun onMsgReceived(message: AdvanceWarningBean?) {
if (message == null) {
Logger.i(V2XConst.MODULE_NAME, "V2XMessageListener_404000message is null!")
return
}
Logger.i(
V2XConst.MODULE_NAME,
"V2XMessageListener_404000" + com.mogo.utils.network.utils.GsonUtil.jsonFromObject(
message
)
)
V2XUtils.runOnUiThread {
var trafficData = buildTrafficData(message)
when (message.status) {
1 -> {
var tts = ""
var content = ""
var appId = 0
when (message.typeId) {
// 弱势交通碰撞预警
1001 -> {
appId = EventTypeEnum.TYPE_USECASE_ID_VRUCW_PERSON.poiType.toInt()
tts = EventTypeEnum.TYPE_USECASE_ID_VRUCW_PERSON.tts
content = EventTypeEnum.TYPE_USECASE_ID_VRUCW_PERSON.content
}
// 弱势交通逆行预警
1002 -> {
appId = EventTypeEnum.TYPE_USECASE_ID_VRUCW_PERSON.poiType.toInt()
tts = "行人逆行预警"
content = "行人逆行预警"
}
// 交叉路口碰撞预警
1003 -> {
appId = EventTypeEnum.TYPE_USECASE_ID_ICW.poiType.toInt()
tts = EventTypeEnum.TYPE_USECASE_ID_ICW.tts
content = EventTypeEnum.TYPE_USECASE_ID_ICW.content
}
// 盲区预警
1004 -> {
appId = EventTypeEnum.TYPE_USECASE_ID_BSW.poiType.toInt()
tts = String.format(EventTypeEnum.TYPE_USECASE_ID_BSW.tts, getWarningDirection())
content = EventTypeEnum.TYPE_USECASE_ID_BSW.content
}
// 逆向超车预警
1005 -> {
appId = EventTypeEnum.TYPE_USECASE_ID_DNPW.poiType.toInt()
tts = EventTypeEnum.TYPE_USECASE_ID_DNPW.tts
content = EventTypeEnum.TYPE_USECASE_ID_DNPW.content
}
}
// 显示弹框,语音提示
CallerHmiManager.showWarningV2X(appId, content, tts,
"$appId", object : WarningStatusListener {
override fun onShow() {}
override fun onDismiss() {
}
})
TrafficMarkerDrawer.updateITrafficInfo(trafficData)
}
2 -> {
TrafficMarkerDrawer.updateITrafficInfo(trafficData)
}
3 -> {
TrafficMarkerDrawer.removeCvxRvInfoIndInfo(trafficData.uuid)
}
}
}
}
private fun buildTrafficData(message: AdvanceWarningBean): TrafficData {
return TrafficData().apply {
type = when (message.objectType) {
1 -> TrafficTypeEnum.TYPE_TRAFFIC_ID_PEOPLE
2 -> TrafficTypeEnum.TYPE_TRAFFIC_ID_BICYCLE
3 -> TrafficTypeEnum.TYPE_TRAFFIC_ID_TA_CHE
4 -> TrafficTypeEnum.TYPE_TRAFFIC_ID_MOTO
6 -> TrafficTypeEnum.TYPE_TRAFFIC_ID_BUS
8 -> TrafficTypeEnum.TYPE_TRAFFIC_ID_TRUCK
9 -> TrafficTypeEnum.TYPE_TRAFFIC_ID_CAMERA
else -> TrafficTypeEnum.TYPE_TRAFFIC_ID_WEI_ZHI
}
uuid = message.objectId
lat = message.position.lat
lon = message.position.lon
heading = message.heading
threatLevel = message.threatLevel
}
}
private fun getWarningDirection(): String {
return ""
}
}