[2.13.2] 优化弱势交通,v2v

This commit is contained in:
lixiaopeng
2023-01-13 17:53:23 +08:00
parent 3e3cbb4459
commit bf2fd9c678
12 changed files with 190 additions and 71 deletions

View File

@@ -56,8 +56,8 @@ class V2XLimitingVelocityBroadcastReceiver : BroadcastReceiver() {
*
* @param limitingVelocitySpeed 限速速度
*/
private fun dispatchShowWaring(limitingVelocitySpeed: Int) { // TODO liyz
CallerHmiManager.showLimitingVelocity(limitingVelocitySpeed, 3)
private fun dispatchShowWaring(limitingVelocitySpeed: Int) { // TODO
// CallerHmiManager.showLimitingVelocity(limitingVelocitySpeed, 3)
}
/**

View File

@@ -3,6 +3,7 @@ package com.mogo.eagle.core.function.hmi.receiver
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.util.Log
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
import com.mogo.eagle.core.function.hmi.WaringConst
@@ -69,6 +70,7 @@ class V2XTrafficLightBroadcastReceiver : BroadcastReceiver() {
* 关闭交通灯
*/
private fun dispatchCloseWaring() {
Log.d("liyz", "receiver dispatchCloseWaring disableWarningTrafficLight ")
CallerHmiManager.disableWarningTrafficLight()
}
}

View File

@@ -75,8 +75,8 @@ class V2XWarningBroadcastReceiver : BroadcastReceiver() {
ttsContent: String?,
tag: String?
) {
if (EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType == v2xType.toString()) {
CallerHmiManager.showLimitingVelocity(1, 4)
if (EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType == v2xType.toString()) { //TODO
// CallerHmiManager.showLimitingVelocity(1, 4)
}
if (alertContent.isNullOrEmpty() || ttsContent.isNullOrEmpty()) {
Log.d("MsgBox-V2XWarningBR", "alertContent或ttsContent为空!")

View File

@@ -33,6 +33,13 @@
</intent-filter>
</receiver>
<receiver android:name="com.mogo.eagle.core.function.obu.mogo.receiver.ObuTestNewObuRsiReceiver">
<intent-filter>
<action android:name="com.obu.test_newobu_rsi" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
</application>
</manifest>

View File

@@ -1,6 +1,7 @@
package com.mogo.eagle.core.function.obu.mogo
import android.content.Context
import android.util.Log
import com.mogo.eagle.core.data.config.HmiBuildConfig
import com.mogo.eagle.core.data.enums.EventTypeEnumNew
import com.mogo.eagle.core.data.enums.WarningDirectionEnum
@@ -509,6 +510,7 @@ class MogoObuDcCombineManager private constructor() : IMoGoObuDcCombineListener
// 删除
MogoObuConstants.STATUS.DELETE -> {
// 移除顶部弹窗,当收不到信号的时候触发一次
Log.d("liyz", "obudc handlerTrafficLight disableWarningTrafficLight() ---> ")
CallerHmiManager.disableWarningTrafficLight()
CallerHmiManager.disableWarningV2X(appId.toString())
isShowGreenWave = false

View File

@@ -691,8 +691,8 @@ class MogoPrivateObuManager private constructor() {
// 删除
ObuConstants.STATUS.DELETE -> {
// 移除顶部弹窗
Log.e("liyz", "old obu delete disableWarningTrafficLight() ------>")
CallerHmiManager.disableWarningTrafficLight()
Log.e("liyz", "old obu delete ------>")
// CallerHmiManager.disableWarningV2X(appId.toString())
}
}

View File

@@ -183,17 +183,22 @@ class MogoPrivateObuNewManager private constructor() {
CallerLogger.d("$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}", data.toString())
data.let {
//预警信息,预警类型 threat_level 2、3
var status = data.status
data.vehBasicsMsg?.let {
//预警方位
val direction = getMessageDirection(data.vehBasicsMsg.targetPosition)
//处理预警类型
var appId = ""
var level = -1
var status = -1
data.warningMsg?.let {
if (data.warningMsg.warningData != null && data.warningMsg.warningData.size > 0) {
level = data.warningMsg.warningData[0].warningLevel
appId = data.warningMsg.warningData[0].warningType.toString()
status = data.warningMsg.warningData[0].status
//拼凑数据
if (appId != null) {
handleSdkObu(appId, direction, status, level, data)
}
}
}
@@ -203,10 +208,6 @@ class MogoPrivateObuNewManager private constructor() {
getMessageDirection(data.vehBasicsMsg.targetPosition)
} --- direction = $direction --- appId = $appId ---level = $level -- status = $status"
)
//拼凑数据
if (appId != null) {
handleSdkObu(appId, direction, status, level, data)
}
}
}
}
@@ -229,6 +230,9 @@ class MogoPrivateObuNewManager private constructor() {
}
}
val rsiMap = mutableMapOf<String, Long>()
val rsmMap = mutableMapOf<String, Long>()
/**
* RSI预警信息 onMogoObuRsiWarning交通标志预警前方限速、前方学校等等交通事件预警前方拥堵、前方积水等等
*/
@@ -401,6 +405,22 @@ class MogoPrivateObuNewManager private constructor() {
}
}
//15秒内同一个事件只出现一次
if (rsiMap.containsKey(appId)) {
var oldTime = rsiMap[appId]
var timeDiff = (System.currentTimeMillis() - oldTime!!) / 1000
Log.d("lixp", "----1-- timeDiff = $timeDiff --appId = $appId")
if (timeDiff < 15) {
return
}
rsiMap.remove(appId)
rsiMap[appId] = System.currentTimeMillis()
Log.d("lixp", "---- timeDiff-----------2-----------")
} else {
rsiMap[appId] = System.currentTimeMillis()
}
Log.d("lixp", "---- timeDiff-----------3-----------")
CallerLogger.d(
"$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}",
"new onMogoObuRsiWarning appId = $appId --- ttsContent = $ttsContent --alertContent = $alertContent -- eventSerialNum = ${data.warningMsg[0].eventSerialNum} ---signSerialNum = ${data.warningMsg[0].signSerialNum} ---direction = ${direction.direction} --distance = ${
@@ -480,6 +500,10 @@ class MogoPrivateObuNewManager private constructor() {
data: MogoObuRsmWarningData?
) {
super.onMogoObuRsmWarning(data)
CallerLogger.d(
"$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}",
"onMogoObuRsmWarning ------> ${data.toString()}"
)
// if (HmiBuildConfig.isShowObuV2iView) {
if (HmiBuildConfig.isShowObuWeaknessTrafficView) {
// 交通参与者类型 0x0:未知 UNKNOWN | 1机动车 2:非机动车 NON_MOTOR | 3:行人 PEDESTRIAN 4:obu
@@ -502,16 +526,66 @@ class MogoPrivateObuNewManager private constructor() {
EventTypeEnumNew.getWarningContent(v2xType)
var level = -1
val direction = getMessageDirection(data.participant.targetPosition)
//15秒内同一个事件只出现一次
if (rsmMap.containsKey(v2xType)) {
var oldTime = rsmMap[v2xType]
var timeDiff = (System.currentTimeMillis() - oldTime!!) / 1000
Log.e("lixp", "onMogoObuRsmWarning ------ timeDiff---1----- = $timeDiff --v2xType = $v2xType")
if (timeDiff < 15) {
return
}
rsmMap.remove(v2xType)
rsmMap[v2xType] = System.currentTimeMillis()
Log.e("lixp", "onMogoObuRsmWarning ---- timeDiff---------2---------")
} else {
rsmMap[v2xType] = System.currentTimeMillis()
}
Log.e("lixp", "onMogoObuRsmWarning ---- timeDiff----------3---------")
//物体数据绘制 TODO 这里与dc通过工控机有区别
when (data.status) {
MogoObuConstants.STATUS.ADD -> { // 添加
// 更新数据
TrafficDataConvertUtilsNew.cvxPtcThreatIndInfo2TrafficData(data)
?.let {
CallerLogger.d(
"$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}",
"add cvxPtcThreatIndInfo2TrafficData ---it---> $it"
)
CallerMapUIServiceManager.getMarkerService()
?.updateITrafficThreatLevelInfo(it)
}
}
MogoObuConstants.STATUS.UPDATE -> {// 更新
}
MogoObuConstants.STATUS.DELETE -> { // 删除
// 更新数据 TODO 删除原来的改变颜色删除marker。不影响别的模型添加
TrafficDataConvertUtilsNew.cvxPtcThreatIndInfo2TrafficData(data)
?.let {
// 事件结束,还原交通参与者颜色
it.threatLevel = 0x01
CallerMapUIServiceManager.getMarkerService()
?.updateITrafficThreatLevelInfo(it)
}
//删除弱势交通元素
CallerMapUIServiceManager.getMarkerService()
?.removeCvxRvInfoIndInfo(data.participant.ptcId.toString())
}
}
//预警status
if (data.warningMsg != null && data.warningMsg.warningData != null && data.warningMsg.warningData.size > 0) {
level = data.warningMsg.warningData[0].warningLevel //默认是1个
CallerLogger.d(
"$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}",
"onMogoObuRsmWarning ---status---> ${data.status} ---data.warningMsg.warningData[0].status = ${data.warningMsg.warningData[0].status} ---v2xType = $v2xType ---alertContent = $alertContent ---ttsContent = $ttsContent "
)
when (data.warningMsg.warningData[0].status) {
MogoObuConstants.STATUS.ADD -> { // 添加
// if (level == 2 || level == 3) { //不考虑level
//显示警告红边
CallerHmiManager.showWarning(direction)
CallerMsgBoxManager.saveMsgBox(
@@ -542,39 +616,14 @@ class MogoPrivateObuNewManager private constructor() {
true,
5000L
)
// }
// 更新数据
TrafficDataConvertUtilsNew.cvxPtcThreatIndInfo2TrafficData(data)
?.let {
CallerLogger.d(
"$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}",
"add cvxPtcThreatIndInfo2TrafficData ---it---> $it"
)
CallerMapUIServiceManager.getMarkerService()
?.updateITrafficThreatLevelInfo(it)
}
}
MogoObuConstants.STATUS.UPDATE -> {// 更新
}
// 删除
MogoObuConstants.STATUS.DELETE -> {
MogoObuConstants.STATUS.DELETE -> { // 删除
// 关闭警告红边
CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
// 更新数据 TODO 删除原来的改变颜色删除marker。不影响别的模型添加
TrafficDataConvertUtilsNew.cvxPtcThreatIndInfo2TrafficData(data)
?.let {
// 事件结束,还原交通参与者颜色
it.threatLevel = 0x01
CallerMapUIServiceManager.getMarkerService()
?.updateITrafficThreatLevelInfo(it)
}
//删除弱势交通元素
CallerMapUIServiceManager.getMarkerService()
?.removeCvxRvInfoIndInfo(data.participant.ptcId.toString())
}
}
}
@@ -623,44 +672,44 @@ class MogoPrivateObuNewManager private constructor() {
}
/**
* 获取消息的方位 车辆相关
*/
private fun getMessageDirection(targetClassification: Int): WarningDirectionEnum {
// CallerLogger.d("$M_OBU${TAG_MOGO_NEW_OBU}", "预警红边:预警方向->$targetClassification")
return when (targetClassification) {
MogoObuConstants.VEH_TARGET_POSITION.AHEAD_IN_LANE,
MogoObuConstants.VEH_TARGET_POSITION.ONCOMING_IN_LANE -> WarningDirectionEnum.ALERT_WARNING_TOP //正前方
/**
* 获取消息的方位 车辆相关
*/
private fun getMessageDirection(targetClassification: Int): WarningDirectionEnum {
// CallerLogger.d("$M_OBU${TAG_MOGO_NEW_OBU}", "预警红边:预警方向->$targetClassification")
return when (targetClassification) {
MogoObuConstants.VEH_TARGET_POSITION.AHEAD_IN_LANE,
MogoObuConstants.VEH_TARGET_POSITION.ONCOMING_IN_LANE -> WarningDirectionEnum.ALERT_WARNING_TOP //正前方
MogoObuConstants.VEH_TARGET_POSITION.BEHEAD_IN_LANE -> WarningDirectionEnum.ALERT_WARNING_BOTTOM //正后方
MogoObuConstants.VEH_TARGET_POSITION.BEHEAD_IN_LANE -> WarningDirectionEnum.ALERT_WARNING_BOTTOM //正后方
MogoObuConstants.VEH_TARGET_POSITION.INTERSECTION_RIGHT -> WarningDirectionEnum.ALERT_WARNING_RIGHT //正右方
MogoObuConstants.VEH_TARGET_POSITION.INTERSECTION_RIGHT -> WarningDirectionEnum.ALERT_WARNING_RIGHT //正右方
MogoObuConstants.VEH_TARGET_POSITION.INTERSECTION_LEFT -> WarningDirectionEnum.ALERT_WARNING_LEFT //正左方
MogoObuConstants.VEH_TARGET_POSITION.INTERSECTION_LEFT -> WarningDirectionEnum.ALERT_WARNING_LEFT //正左方
MogoObuConstants.VEH_TARGET_POSITION.AHEAD_LEFT, MogoObuConstants.VEH_TARGET_POSITION.AHEAD_FAR_LEFT,
MogoObuConstants.VEH_TARGET_POSITION.ONCOMING_LEFT, MogoObuConstants.VEH_TARGET_POSITION.ONCOMING_FAR_LEFT
-> WarningDirectionEnum.ALERT_WARNING_TOP_LEFT //左前方
MogoObuConstants.VEH_TARGET_POSITION.AHEAD_LEFT, MogoObuConstants.VEH_TARGET_POSITION.AHEAD_FAR_LEFT,
MogoObuConstants.VEH_TARGET_POSITION.ONCOMING_LEFT, MogoObuConstants.VEH_TARGET_POSITION.ONCOMING_FAR_LEFT
-> WarningDirectionEnum.ALERT_WARNING_TOP_LEFT //左前方
MogoObuConstants.VEH_TARGET_POSITION.AHEAD_RIGHT, MogoObuConstants.VEH_TARGET_POSITION.AHEAD_FAR_RIGHT,
MogoObuConstants.VEH_TARGET_POSITION.ONCOMING_RIGHT, MogoObuConstants.VEH_TARGET_POSITION.ONCOMING_FAT_RIGHT
-> WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT //右前方
MogoObuConstants.VEH_TARGET_POSITION.AHEAD_RIGHT, MogoObuConstants.VEH_TARGET_POSITION.AHEAD_FAR_RIGHT,
MogoObuConstants.VEH_TARGET_POSITION.ONCOMING_RIGHT, MogoObuConstants.VEH_TARGET_POSITION.ONCOMING_FAT_RIGHT
-> WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT //右前方
MogoObuConstants.VEH_TARGET_POSITION.BEHEAD_LEFT, MogoObuConstants.VEH_TARGET_POSITION.BEHEAD_FAR_LEFT,
-> WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT //左后方
MogoObuConstants.VEH_TARGET_POSITION.BEHEAD_LEFT, MogoObuConstants.VEH_TARGET_POSITION.BEHEAD_FAR_LEFT,
-> WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT //左后方
MogoObuConstants.VEH_TARGET_POSITION.BEHEAD_RIGHT, MogoObuConstants.VEH_TARGET_POSITION.BEHEAD_FAR_RIGHT,
-> WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT //右后方
MogoObuConstants.VEH_TARGET_POSITION.BEHEAD_RIGHT, MogoObuConstants.VEH_TARGET_POSITION.BEHEAD_FAR_RIGHT,
-> WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT //右后方
MogoObuConstants.VEH_TARGET_POSITION.UNCLASSIFIED -> WarningDirectionEnum.ALERT_WARNING_NON //未知
else -> WarningDirectionEnum.ALERT_WARNING_ALL
MogoObuConstants.VEH_TARGET_POSITION.UNCLASSIFIED -> WarningDirectionEnum.ALERT_WARNING_NON //未知
else -> WarningDirectionEnum.ALERT_WARNING_ALL
}
}
}
/**
* 构造对应展示数据和场景 根据obu的场景add change delete确定是否展示
*
* @param appId 使用WarningTypeEnum获取icon、提示内容、tts内容
* @param appId 使用WarningTypeEnum获取icon、提示内容、tts内容 TODO 添加事件频繁播报拦截
*
* @see com.mogo.module.common.enums.EventTypeEnum
*/
@@ -833,6 +882,7 @@ private fun getMessageDirection(targetClassification: Int): WarningDirectionEnum
// 删除
MogoObuConstants.STATUS.DELETE -> {
// 移除顶部弹窗
Log.d("liyz","handlerTrafficLight new obu disableWarningTrafficLight() --->")
CallerHmiManager.disableWarningTrafficLight()
CallerHmiManager.disableWarningV2X(appId.toString())
isShowGreenWave = false
@@ -860,7 +910,7 @@ private fun getMessageDirection(targetClassification: Int): WarningDirectionEnum
val currentLight = lights[0]
CallerLogger.d(
"$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}",
"currentLight = $currentLight ---currentLight.phase = ${currentLight.phaseId} ---appId = $appId"
"changeTrafficLightStatus currentLight = $currentLight ----currentLight.light = ${currentLight.light} ---currentLight.phase = ${currentLight.phaseId} ---appId = $appId"
)
// 闯红灯预警,绿波通行和闯红灯是互斥的
when (appId) {
@@ -961,8 +1011,9 @@ private fun getMessageDirection(targetClassification: Int): WarningDirectionEnum
when (currentLight.light) {
// 灯光不可用
0 -> {
// CallerHmiManager.showWarningTrafficLight(0, 3)
// CallerHmiManager.showWarningTrafficLight(0, 3) //TODO
CallerObuTrafficLightListenerManager.invokeObuTrafficLight(0)
Log.e("liyz", "currentLight.light = ${currentLight.light} ----0-----")
}
// 红灯
2, 3 -> {

View File

@@ -0,0 +1,57 @@
package com.mogo.eagle.core.function.obu.mogo.receiver
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.util.Log
import com.mogo.eagle.core.function.obu.mogo.MogoPrivateObuNewManager
import com.mogo.support.obu.model.MogoObuRsiWarningData
import com.mogo.support.obu.model.MogoObuRvWarningData
import com.mogo.support.obu.model.advance.RsiWarning
import com.mogo.support.obu.model.advance.V2xWarning
import com.mogo.support.obu.model.advance.VehBasics
import com.mogo.support.obu.model.advance.WarningData
/**
* @author lixiaopeng
* @date 2023/1/13 10:50 上午
*
* 自研OBU RSI 模拟场景
*/
class ObuTestNewObuRsiReceiver : BroadcastReceiver() {
private var mContext: Context? = null
companion object {
private const val TAG = "ObuTestNewObuReceiver"
}
override fun onReceive(context: Context, intent: Intent) {
mContext = context
/**
* OBU 场景类型
*/
val obuSceneType = intent.getIntExtra("sceneType", 0)
val obuStatus = intent.getIntExtra("status", 0)
// val obuDistance = intent.getDoubleExtra("distance", 0.0)
val obuEventSeriaNum = intent.getIntExtra("seriaNum", 0)
val obuSignSerialNum = intent.getIntExtra("signSerialNum", 0)
val rsiWarning = RsiWarning(1)
rsiWarning.warningLevel = 1
rsiWarning.setDistance(1000)
rsiWarning.sceneType = obuSceneType //预警类型 0无效 1限速信息 2道路危险 3车内标牌 4前方拥堵
rsiWarning.eventSerialNum = obuEventSeriaNum //根据预警类型匹配 101 车辆故障
rsiWarning.signSerialNum = obuSignSerialNum // 2急转弯8桥梁
val rsiWarningList = listOf(rsiWarning) //TODO
val cvxObuRsiInfo = MogoObuRsiWarningData(obuStatus, 1, rsiWarningList)
MogoPrivateObuNewManager.INSTANCE
.getMogoObuListener()
.onMogoObuRsiWarning(cvxObuRsiInfo)
}
}

View File

@@ -1,5 +1,6 @@
package com.mogo.eagle.core.function.v2x.trafficlight
import android.util.Log
import com.mogo.eagle.core.data.trafficlight.*
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
@@ -60,6 +61,7 @@ class TrafficLightHMIManager {
fun hideTrafficLight() {
initView = false
Log.d("liyz", "TrafficLightHMIManager hideTrafficLight disableWarningTrafficLight ")
CallerHmiManager.disableWarningTrafficLight()
}
}

View File

@@ -57,7 +57,6 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLight
* @param trafficLights 感知红绿灯
*/
override fun onAutopilotPerceptionTrafficLight(trafficLights: TrafficLightOuterClass.TrafficLights?) {
Log.d("liyz", "onAutopilotPerceptionTrafficLight hasObuLightStatus = $hasObuLightStatus ---hasAiLightStatus = $hasAiLightStatus")
if (!hasObuLightStatus) {
if (!hasAiLightStatus) {
trafficLights?.let { it ->
@@ -73,7 +72,6 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLight
}
if (light == null) {
//隐藏红绿灯显示
Log.e("liyz", "onAutopilotPerceptionTrafficLight delete ------>")
TrafficLightHMIManager.INSTANCE.hideTrafficLight()
} else {
when (light.state) {