[6.5.0][道路事件] 移除道路影响区域占道策略判断逻辑,统一文案和tts语音提示

This commit is contained in:
renwj
2024-07-25 11:54:57 +08:00
parent eccdbfbd79
commit da2a9a9add

View File

@@ -3,7 +3,6 @@ package com.mogo.eagle.function.biz.v2x.v2n.pnc
import android.os.Handler
import android.os.HandlerThread
import android.os.Message
import android.util.Log
import androidx.core.util.Pair
import com.mogo.commons.voice.AIAssist
import com.mogo.eagle.core.data.config.FunctionBuildConfig
@@ -28,7 +27,6 @@ import com.mogo.eagle.core.function.call.autopilot.CallerV2XListenerManager.V2NC
import com.mogo.eagle.core.function.call.autopilot.CallerV2nNioEventListenerManager
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
import com.mogo.eagle.core.function.call.hmi.CallerRoadV2NEventWindowListenerManager
import com.mogo.eagle.core.function.call.map.CallerMapRoadListenerManager
import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager.saveMsgBox
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
@@ -46,7 +44,6 @@ import com.mogo.eagle.function.biz.v2x.v2n.scenario.scene.airoad.AiRoadMarker.Ma
import com.mogo.eagle.function.biz.v2x.v2n.utils.EventDismissBean
import com.mogo.eagle.function.biz.v2x.v2n.utils.EventDismissManager
import com.mogo.eagle.function.biz.v2x.v2n.utils.IEventDismissListener
import com.mogo.eagle.function.biz.v2x.v2n.utils.V2NUtils
import com.mogo.eagle.function.biz.v2x.v2n.utils.V2XEventAnalyticsManager
import com.mogo.map.entities.Lane
import kotlinx.coroutines.CoroutineScope
@@ -104,11 +101,11 @@ internal object V2NIdentifyDrawer: IEventDismissListener {
AiRoadMarker.aiMakers.getOrPut(id) {
AiRoadMarker().apply {
scope.launch {
Log.d("V2NIdentifyDrawer", "--- 判断是否在路口 ---")
while (CallerMapRoadListenerManager.isInRoadCross()) {
delay(2000)
}
Log.d("V2NIdentifyDrawer", "--- 不在路口了 ---")
// Log.d("V2NIdentifyDrawer", "--- 判断是否在路口 ---")
// while (CallerMapRoadListenerManager.isInRoadCross()) {
// delay(2000)
// }
// Log.d("V2NIdentifyDrawer", "--- 不在路口了 ---")
val poiType = getPoiType(itx.type).poiType
val polygon = itx.polygonList.map { Pair.create(it.longitude, it.latitude) }
marker(Marker(id,
@@ -143,69 +140,82 @@ internal object V2NIdentifyDrawer: IEventDismissListener {
car.longitude,
car.latitude
)
val alertContent = getAlertContent(poiType, distance.toDouble())
val ttsContent = getTtsContent(poiType, distance.toDouble())
// if (polygon.isNotEmpty()) {
// val decision = V2NUtils.computeOccupyLanesInfo(Triple(car.longitude, car.latitude, car.heading.toFloat()), Triple(itx.longitude, itx.latitude, itx.heading.toFloat()), polygon.map { kotlin.Pair(it.first, it.second) })
// if (decision != null) {
// val isDriver = AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)
// val total = decision.total
// val occupy = decision.occupy
// val laneId = decision.laneId
// val sb = StringBuilder()
// V2XBizTrace.onAck(decision, "计算出道路事件占道决策数据1")
// if (laneId != null) {
// val isOccupy = occupy.find { it.id == laneId } != null
// if (isOccupy) {
// if (isDriver) {
// val bestLane = V2NUtils.computeBestLane(laneId, occupy, total)
// V2XBizTrace.onAck(bestLane, "计算出最优车道")
// sb.append("发现前方${distance.toInt()}米${ if (poiType == EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.poiType) "车道施工" else "车道事故" }@@, 蘑菇建议您尽快${bestLane.second}")
// } else {
// sb.append("发现前方${distance.toInt()}米${ if (poiType == EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.poiType) "车道施工" else "车道事故" }@@, 蘑菇时刻为您守护")
// }
// } else {
// if (isDriver) {
// sb.append("发现前方${distance.toInt()}米${ if (poiType == EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.poiType) "车道施工" else "车道事故" }@@, 蘑菇提醒您小心${ if (computeDirection(laneId, occupy) > 0) "右侧" else "左侧" }行人及来车")
// } else {
// sb.append("发现前方${distance.toInt()}米${ if (poiType == EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.poiType) "车道施工" else "车道事故" }@@, 蘑菇时刻为您守护")
// }
// }
// } else {
// sb.append("发现前方${distance.toInt()}米${ if (poiType == EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.poiType) "车道施工" else "车道事故" }@@, 蘑菇时刻为您守护")
// }
// if (AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)) {
// runCatching {
// CallerHmiManager.notifyXiaoZhiStatusChanged(V2N(EventTypeEnumNew.getEnumType(poiType)), START)
// }
// scope.launch {
// delay(5000)
// runCatching {
// CallerHmiManager.notifyXiaoZhiStatusChanged(V2N(EventTypeEnumNew.getEnumType(poiType)), STOP)
// }
// }
// }
// val ss = sb.toString()
// val content = ss.substring(0, ss.indexOf("@@"))
// val tts = ss.replace("@@", "")
// CallerRoadV2NEventWindowListenerManager.showLiveVideo(id, itx.detectStartTime.takeIf { it > 0 } ?: System.currentTimeMillis(), EventTypeEnumNew.getUpdateIconRes(poiType), content, isDriver, tts, itx.cameraIp, itx.longitude, itx.latitude)
// }
// }
val isDriver = AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)
if (!isDriver) {
runCatching {
CallerHmiManager.notifyXiaoZhiStatusChanged(V2N(EventTypeEnumNew.getEnumType(poiType)), START)
}
scope.launch {
delay(5000)
runCatching {
CallerHmiManager.notifyXiaoZhiStatusChanged(V2N(EventTypeEnumNew.getEnumType(poiType)), STOP)
}
}
}
val content = "发现前方${distance.toInt()}${ if (poiType == EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.poiType) "车道施工" else "车道事故" }"
val tts = "$content, 蘑菇提醒您小心行人及来车"
V2XBizTrace.onAck(TAG, "绘制poi事件:$poiType")
saveMsgBox(
MsgBoxBean(
V2X,
V2XMsg(
poiType,
alertContent,
ttsContent,
content,
tts,
CommunicationType.V2N.name
)
)
)
if (polygon.isNotEmpty()) {
val decision = V2NUtils.computeOccupyLanesInfo(Triple(car.longitude, car.latitude, car.heading.toFloat()), Triple(itx.longitude, itx.latitude, itx.heading.toFloat()), polygon.map { kotlin.Pair(it.first, it.second) })
if (decision != null) {
val isDriver = AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)
val total = decision.total
val occupy = decision.occupy
val laneId = decision.laneId
val sb = StringBuilder()
V2XBizTrace.onAck(decision, "计算出道路事件占道决策数据1")
if (laneId != null) {
val isOccupy = occupy.find { it.id == laneId } != null
if (isOccupy) {
if (isDriver) {
val bestLane = V2NUtils.computeBestLane(laneId, occupy, total)
V2XBizTrace.onAck(bestLane, "计算出最优车道")
sb.append("发现前方${distance.toInt()}${ if (poiType == EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.poiType) "车道施工" else "车道事故" }@@, 蘑菇建议您尽快${bestLane.second}")
} else {
sb.append("发现前方${distance.toInt()}${ if (poiType == EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.poiType) "车道施工" else "车道事故" }@@, 蘑菇时刻为您守护")
}
} else {
if (isDriver) {
sb.append("发现前方${distance.toInt()}${ if (poiType == EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.poiType) "车道施工" else "车道事故" }@@, 蘑菇提醒您小心${ if (computeDirection(laneId, occupy) > 0) "右侧" else "左侧" }行人及来车")
} else {
sb.append("发现前方${distance.toInt()}${ if (poiType == EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.poiType) "车道施工" else "车道事故" }@@, 蘑菇时刻为您守护")
}
}
} else {
sb.append("发现前方${distance.toInt()}${ if (poiType == EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.poiType) "车道施工" else "车道事故" }@@, 蘑菇时刻为您守护")
}
if (AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)) {
runCatching {
CallerHmiManager.notifyXiaoZhiStatusChanged(V2N(EventTypeEnumNew.getEnumType(poiType)), START)
}
scope.launch {
delay(5000)
runCatching {
CallerHmiManager.notifyXiaoZhiStatusChanged(V2N(EventTypeEnumNew.getEnumType(poiType)), STOP)
}
}
}
val ss = sb.toString()
val content = ss.substring(0, ss.indexOf("@@"))
val tts = ss.replace("@@", "")
CallerRoadV2NEventWindowListenerManager.showLiveVideo(id, itx.detectStartTime.takeIf { it > 0 } ?: System.currentTimeMillis(), EventTypeEnumNew.getUpdateIconRes(poiType), content, isDriver, tts, itx.cameraIp, itx.longitude, itx.latitude)
}
}
CallerRoadV2NEventWindowListenerManager.showLiveVideo(id, itx.detectStartTime.takeIf { it > 0 } ?: System.currentTimeMillis(), EventTypeEnumNew.getUpdateIconRes(poiType), content, isDriver, tts, itx.cameraIp, itx.longitude, itx.latitude)
//消息埋点
V2XEventAnalyticsManager.triggerV2XEvent(
poiType, alertContent, ttsContent,
poiType, content, tts,
DataSourceType.AICLOUD, CommunicationType.V2N
)
}
@@ -416,31 +426,31 @@ internal object V2NIdentifyDrawer: IEventDismissListener {
true
}
private fun computeDirection(laneId: Int, occupy: List<Lane>): Int {
val left = occupy.first()
return if (laneId <= left.id) {
1
} else {
-1
}
}
// private fun computeDirection(laneId: Int, occupy: List<Lane>): Int {
// val left = occupy.first()
// return if (laneId <= left.id) {
// 1
// } else {
// -1
// }
// }
private fun getTtsContent(poiType: String, distance: Double): String {
return when (poiType) {
EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.poiType -> {
"前方${distance.toInt()}米道路施工"
}
EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGU.poiType -> {
"前方${distance.toInt()}米交通事故"
}
EventTypeEnumNew.TYPE_SOCKET_ROAD_CONGESTION.poiType -> {
"前方${distance.toInt()}米交通拥堵"
}
else -> {
throw AssertionError("error!!!")
}
}
}
// private fun getTtsContent(poiType: String, distance: Double): String {
// return when (poiType) {
// EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.poiType -> {
// "前方${distance.toInt()}米道路施工"
// }
// EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGU.poiType -> {
// "前方${distance.toInt()}米交通事故"
// }
// EventTypeEnumNew.TYPE_SOCKET_ROAD_CONGESTION.poiType -> {
// "前方${distance.toInt()}米交通拥堵"
// }
// else -> {
// throw AssertionError("error!!!")
// }
// }
// }
private fun computeCrossCountBetween(start: Triple<Double, Double, Double>, end: kotlin.Pair<Double, Double>): Int {
// val points = V2NUtils.generateIntermediatePoints(kotlin.Pair(start.first, start.second), end, 50.0 * 1e-7)
@@ -458,22 +468,22 @@ internal object V2NIdentifyDrawer: IEventDismissListener {
return 1
}
private fun getAlertContent(poiType: String, distance: Double): String {
return when (poiType) {
EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.poiType -> {
"前方${distance.toInt()}米道路施工"
}
EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGU.poiType -> {
"前方${distance.toInt()}米交通事故"
}
EventTypeEnumNew.TYPE_SOCKET_ROAD_CONGESTION.poiType -> {
"前方${distance.toInt()}米交通拥堵"
}
else -> {
throw AssertionError("error!!!")
}
}
}
// private fun getAlertContent(poiType: String, distance: Double): String {
// return when (poiType) {
// EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.poiType -> {
// "前方${distance.toInt()}米道路施工"
// }
// EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGU.poiType -> {
// "前方${distance.toInt()}米交通事故"
// }
// EventTypeEnumNew.TYPE_SOCKET_ROAD_CONGESTION.poiType -> {
// "前方${distance.toInt()}米交通拥堵"
// }
// else -> {
// throw AssertionError("error!!!")
// }
// }
// }
private fun isDrawRoadLine(poiType: String): Boolean {
// return EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.poiType == poiType