[2.15.0][V2N上车] 添加交通拥堵事件处理逻辑

This commit is contained in:
renwj
2023-03-30 16:41:36 +08:00
parent de979c9ede
commit c8ef1d7a52
4 changed files with 123 additions and 11 deletions

View File

@@ -18,7 +18,10 @@ import com.mogo.eagle.core.utilcode.mogo.logger.*
import com.mogo.eagle.core.utilcode.util.*
import com.mogo.eagle.function.biz.v2x.v2n.scenario.scene.airoad.*
import com.mogo.eagle.function.biz.v2x.v2n.scenario.scene.airoad.AiRoadMarker.Marker
import mogo.telematics.pad.MessagePad.Header
import mogo.telematics.pad.MessagePad.TrackedObject
import mogo.v2x.MogoV2X
import mogo.v2x.MogoV2X.RSI_PB
/**
* V2N上车相关事件绘制
@@ -28,17 +31,19 @@ internal object V2NIdentifyDrawer {
private const val TAG = "V2NIdentifyDataSubscriber"
private const val MSG_WHAT_DRAW_ALL = 0x1010
private const val MSG_WHAT_DRAW_SHIGONE = 0x1010 // 道路施工
private const val MSG_WHAT_DRAW_SHIGU = 0x1011 // 交通事故
private const val MSG_WHAT_DRAW_YONGDU = 0x1012 // 交通拥堵
private val callback = Handler.Callback { msg ->
if (msg.what == MSG_WHAT_DRAW_ALL) {
if (msg.what == MSG_WHAT_DRAW_SHIGONE || msg.what == MSG_WHAT_DRAW_SHIGU) {
val events = msg.obj as? List<*>
if (events == null || events.isEmpty()) {
return@Callback true
}
val car = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84()
val filtered = events.filterIsInstance(TrackedObject::class.java).filter { itx ->
DrivingDirectionUtils.getDegreeOfCar2Poi(car.longitude, car.latitude, itx.longitude, itx.latitude, car.heading.toInt()) <= 90
DrivingDirectionUtils.getDegreeOfCar2Poi(car.longitude, car.latitude, itx.longitude, itx.latitude, car.heading.toInt()) < 90
}
if (filtered.isEmpty()) {
return@Callback true
@@ -75,6 +80,61 @@ internal object V2NIdentifyDrawer {
CallerVisualAngleManager.changeAngle(RoadEvent)
}
override fun onDismiss() {
super.onDismiss()
CallerVisualAngleManager.changeAngle(Default())
}
}, ALERT_WARNING_TOP, 10000, false)
}
}.receive()
}
} else if (msg.what == MSG_WHAT_DRAW_YONGDU) {
val events = msg.obj as? List<*>
if (events == null || events.isEmpty()) {
return@Callback true
}
val car = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84()
val filtered = events.filterIsInstance(MogoV2X.RTEData_PB::class.java).filter { itx ->
val eventLon = itx.eventPos?.offsetLL?.positionLatLon?.lon?.let { it * 1.0 / 10_000_000 } ?: 0.0
val eventLat = itx.eventPos?.offsetLL?.positionLatLon?.lat?.let { it * 1.0 / 10_000_000 } ?: 0.0
DrivingDirectionUtils.getDegreeOfCar2Poi(car.longitude, car.latitude, eventLon, eventLat, car.heading.toInt()) < 90
}
if (filtered.isEmpty()) {
return@Callback true
}
filtered.forEach { itx ->
val id = itx.rteId.toString()
val lon = itx.eventPos?.offsetLL?.positionLatLon?.lon?.let { it * 1.0 / 10_000_000 } ?: 0.0
val lat = itx.eventPos?.offsetLL?.positionLatLon?.lat?.let { it * 1.0 / 10_000_000 } ?: 0.0
AiRoadMarker.aiMakers.getOrPut(id) {
AiRoadMarker().apply {
val poiType = getPoiType(itx.eventType).poiType
marker(Marker(id, poiType, lon, lat, car.heading, null, null,
V2XRoadEventEntity().also { e ->
e.poiType = poiType
e.location = MarkerLocation().also { l ->
val p = CoordinateTransform.WGS84ToGCJ02(lon, lat)
l.lon = p[0]
l.lat = p[1]
l.angle = car.heading
}
e.noveltyInfo = MarkerExploreWay().also {
it.poiType = poiType
it.location = e.location
it.polygon = emptyList()
}
}), true, isDrawRoadLine(poiType))
val distance = CoordinateUtils.calculateLineDistance(lon, lat, car.longitude, car.latitude)
val alertContent = getAlertContent(poiType, distance.toDouble())
val ttsContent = getTtsContent(poiType, distance.toDouble())
saveMsgBox(MsgBoxBean(V2X, V2XMsg(poiType, alertContent, ttsContent)))
CallerHmiManager.warningV2X(poiType, alertContent, ttsContent, object : IMoGoWarningStatusListener {
override fun onShow() {
super.onShow()
CallerVisualAngleManager.changeAngle(RoadEvent)
}
override fun onDismiss() {
super.onDismiss()
CallerVisualAngleManager.changeAngle(Default())
@@ -95,6 +155,9 @@ internal object V2NIdentifyDrawer {
EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGU.poiType -> {
"前方${distance.toInt()}米交通事故"
}
EventTypeEnumNew.TYPE_SOCKET_ROAD_CONGESTION.poiType -> {
"前方${distance.toInt()}米交通拥堵"
}
else -> {
throw AssertionError("error!!!")
}
@@ -109,6 +172,9 @@ internal object V2NIdentifyDrawer {
EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGU.poiType -> {
"前方${distance.toInt()}米交通事故"
}
EventTypeEnumNew.TYPE_SOCKET_ROAD_CONGESTION.poiType -> {
"前方${distance.toInt()}米交通拥堵"
}
else -> {
throw AssertionError("error!!!")
}
@@ -119,7 +185,7 @@ internal object V2NIdentifyDrawer {
return EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.poiType == poiType
}
private fun getPoiType(type: Int): EventTypeEnumNew = if (type == 501 || type == 502) EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG else if (type == 13) EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGU else throw AssertionError("error!!!")
private fun getPoiType(type: Int): EventTypeEnumNew = if (type == 501 || type == 502) EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG else if (type == 13) EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGU else if (type == 102) EventTypeEnumNew.TYPE_SOCKET_ROAD_CONGESTION else throw AssertionError("error!!!")
private val handler by lazy {
val thread = HandlerThread("v2n_identify_drawer")
@@ -131,17 +197,42 @@ internal object V2NIdentifyDrawer {
override fun onAutopilotIdentifyDataUpdate(trafficData: List<TrackedObject>?) {
super.onAutopilotIdentifyDataUpdate(trafficData)
val events = trafficData?.filter { it.type == 501 || it.type == 502 || it.type == 13 }
val shiGong = trafficData?.filter { it.type == 501 || it.type == 502 }
Logger.d(TAG, "--- onAutopilotIdentifyDataUpdate -- : trafficData: ${ trafficData?.joinToString(",") }")
if (events != null && events.isNotEmpty()) {
draw(events)
if (shiGong != null && shiGong.isNotEmpty()) {
drawShiGong(shiGong)
}
val shiGu = trafficData?.filter { it.type == 13 }
if (shiGu != null && shiGu.isNotEmpty()) {
drawShiGu(shiGu)
}
}
override fun onAutopilotV2nCongestionEvent(header: Header, rsi: RSI_PB) {
super.onAutopilotV2nCongestionEvent(header, rsi)
rsi.rsiFrame?.rtes?.rteDataList?.filter {
it.eventType == 102
}?.takeIf {
it.isNotEmpty()
}?.also {
drawYongDu(it)
}
}
}
private fun draw(events: List<TrackedObject>) {
handler.removeMessages(MSG_WHAT_DRAW_ALL)
handler.sendMessage(Message.obtain(handler, MSG_WHAT_DRAW_ALL, events))
private fun drawShiGong(events: List<TrackedObject>) {
handler.removeMessages(MSG_WHAT_DRAW_SHIGONE)
handler.sendMessage(Message.obtain(handler, MSG_WHAT_DRAW_SHIGONE, events))
}
private fun drawShiGu(events: List<TrackedObject>) {
handler.removeMessages(MSG_WHAT_DRAW_SHIGU)
handler.sendMessage(Message.obtain(handler, MSG_WHAT_DRAW_SHIGU, events))
}
private fun drawYongDu(events: List<MogoV2X.RTEData_PB>) {
handler.removeMessages(MSG_WHAT_DRAW_YONGDU)
handler.sendMessage(Message.obtain(handler, MSG_WHAT_DRAW_YONGDU, events))
}
fun init() {

View File

@@ -53,6 +53,7 @@ import com.mogo.eagle.core.function.call.obu.CallerObuMapMathListenerManager
import com.mogo.eagle.core.function.call.obu.CallerObuWarningRsiListenerManager
import com.mogo.eagle.core.function.call.obu.CallerObuWarningRsmListenerManager
import com.mogo.eagle.core.function.call.obu.CallerObuWarningSpatListenerManager
import com.mogo.eagle.core.function.call.v2x.*
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
import com.mogo.support.obu.ObuScene
@@ -640,7 +641,7 @@ class MoGoAdasListenerImpl : OnAdasListener {
* @param rsi 数据
*/
override fun onV2nCongestionEvent(header: MessagePad.Header, rsi: MogoV2X.RSI_PB) {
CallerAutopilotIdentifyListenerManager.invokeAutopilotV2nCongestionEvent(header, rsi)
}
/**