Merge branch 'dev_robotaxi-d_240705_6.5.0' of gitlab.zhidaoauto.com:SCA/L4HA/AndroidApp/MoGoEagleEye into dev_robotaxi-d_240705_6.5.0

This commit is contained in:
aibingbing
2024-07-10 19:17:34 +08:00
58 changed files with 467 additions and 327 deletions

View File

@@ -6,36 +6,26 @@ import android.os.Message
import android.text.TextUtils
import android.util.Log
import androidx.core.util.Pair
import com.google.gson.JsonArray
import com.google.gson.JsonObject
import com.mogo.commons.voice.AIAssist
import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.data.enums.CommunicationType
import com.mogo.eagle.core.data.enums.DataSourceType
import com.mogo.eagle.core.data.enums.EventTypeEnumNew
import com.mogo.eagle.core.data.enums.TrafficTypeEnum
import com.mogo.eagle.core.data.enums.WarningDirectionEnum.ALERT_WARNING_TOP
import com.mogo.eagle.core.data.map.entity.MarkerExploreWay
import com.mogo.eagle.core.data.map.entity.MarkerLocation
import com.mogo.eagle.core.data.map.entity.V2XRoadEventEntity
import com.mogo.eagle.core.data.msgbox.MsgBoxBean
import com.mogo.eagle.core.data.msgbox.MsgBoxType.V2X
import com.mogo.eagle.core.data.msgbox.V2XMsg
import com.mogo.eagle.core.function.angle.scenes.Default
import com.mogo.eagle.core.function.angle.scenes.RoadEvent
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotIdentifyListener
import com.mogo.eagle.core.function.api.autopilot.IMoGoV2nNioEventListener
import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener
import com.mogo.eagle.core.function.api.hmi.xiaozhi.event.V2N
import com.mogo.eagle.core.function.api.hmi.xiaozhi.state.State
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerV2XListenerManager.V2NCarTypeCheck
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.CallerMapUIServiceManager
import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager
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,8 +36,7 @@ import com.mogo.eagle.core.utilcode.util.CoordinateUtils
import com.mogo.eagle.core.utilcode.util.DrivingDirectionUtils
import com.mogo.eagle.core.utilcode.util.GsonUtils
import com.mogo.eagle.function.biz.v2x.V2XBizTrace
import com.mogo.eagle.function.biz.v2x.v2n.consts.V2XConst
import com.mogo.eagle.function.biz.v2x.v2n.remove.MarkerWrapper
import com.mogo.eagle.function.biz.v2x.v2n.pnc.beans.Extras
import com.mogo.eagle.function.biz.v2x.v2n.scenario.scene.airoad.AiRoadMarker
import com.mogo.eagle.function.biz.v2x.v2n.scenario.scene.airoad.AiRoadMarker.Marker
import com.mogo.eagle.function.biz.v2x.v2n.utils.EventDismissBean
@@ -57,17 +46,12 @@ import com.mogo.eagle.function.biz.v2x.v2n.utils.V2NUtils
import com.mogo.eagle.function.biz.v2x.v2n.utils.V2XEventAnalyticsManager
import com.mogo.map.MapDataWrapper
import com.mogo.map.entities.Lane
import com.mogo.map.overlay.core.Level.MAP_MARKER
import com.mogo.map.overlay.point.Point
import mogo.telematics.pad.MessagePad
import mogo.telematics.pad.MessagePad.Header
import mogo.telematics.pad.MessagePad.TrackedObject
import mogo.telematics.pad.MessagePad.V2nCrossSpeed
import mogo.v2x.MogoV2X
import mogo.v2x.MogoV2X.RSI_PB
import mogo.v2x.MogoV2X.RTEData_PB
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.TimeUnit.SECONDS
import kotlin.math.abs
/**
@@ -150,7 +134,7 @@ internal object V2NIdentifyDrawer: IEventDismissListener {
it.location = e.location
it.polygon = polygon
}
}), true, isDrawRoadLine(poiType)
}, isUseGps = true), true, isDrawRoadLine(poiType)
)
val distance = CoordinateUtils.calculateLineDistance(
@@ -174,6 +158,7 @@ internal object V2NIdentifyDrawer: IEventDismissListener {
)
)
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)
@@ -323,31 +308,23 @@ internal object V2NIdentifyDrawer: IEventDismissListener {
V2XBizTrace.onAck(TAG, mapOf("other_retrograde_vehicle" to "event == null"), true)
return@Callback true
}
val body = runCatching { GsonUtils.fromJson(event.exts, Map::class.java) }.getOrNull()
val cameraIp = body?.get("cameraIp") as? String ?: ""
val array = (body?.get("eventExtUnits") as? JsonArray)
val body = runCatching { GsonUtils.fromJson(event.exts, Extras::class.java) }.getOrNull()
val cameraIp = body?.cameraIp
val array = body?.eventExtUnits
var heading = 0.0
var uuid = ""
if (array != null && array.size() > 0) {
if (!array.isNullOrEmpty()) {
for (e in array) {
if (e is JsonObject) {
if (e.has("heading")) {
heading = runCatching { e.asDouble }.getOrNull() ?: 0.0
}
if (e.has("uuid")) {
uuid = runCatching { e.asString }.getOrNull() ?: ""
}
}
heading = e.heading ?: 0.0
uuid = e.uuid ?: ""
}
}
Logger.d(TAG, "cameraIp: $cameraIp, heading:$heading, uuid: $uuid")
val newEventId = "other_retrograde_vehicle_${event.eventId}"
val isUseGps = event.gnssType != 0
val eventLocation = if (isUseGps) arrayOf(event.longitude, event.latitude) else CoordinateTransform.GCJ02ToWGS84(event.longitude, event.latitude)
val carLocation = if (isUseGps) CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84() else CallerChassisLocationGCJ02ListenerManager.getChassisLocationGCJ02()
AiRoadMarker.aiMakers.getOrPut(newEventId) {
val eventLocation = when (event.gnssType) {
0 -> CoordinateTransform.GCJ02ToWGS84(event.longitude, event.latitude)
else -> arrayOf(event.longitude, event.latitude)
}
val carLocation = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84()
val distance = CoordinateUtils.calculateLineDistance(carLocation.longitude, carLocation.latitude, eventLocation[0], eventLocation[1])
if (distance > 150) {
Logger.i(TAG, "other_retrograde_vehicle --> distance > 150")
@@ -364,11 +341,11 @@ internal object V2NIdentifyDrawer: IEventDismissListener {
isDriver,
String.format(EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_SOCKET_ROAD_OTHER_RETROGRADE_VEHICLE.poiType), distance.toInt()),
cameraIp.toString(),
event.longitude,
event.latitude)
eventLocation[0],
eventLocation[1])
AiRoadMarker()
}.also {
it.marker(Marker(newEventId, EventTypeEnumNew.TYPE_SOCKET_ROAD_OTHER_RETROGRADE_VEHICLE.poiType, event.longitude, event.latitude, 0.0), drawMarker = true, false, isHighFrequency = true)
it.marker(Marker(newEventId, EventTypeEnumNew.TYPE_SOCKET_ROAD_OTHER_RETROGRADE_VEHICLE.poiType, eventLocation[0], eventLocation[1], heading, isUseGps = isUseGps), drawMarker = true, false, isHighFrequency = true)
}.receive()
} else if (msg.what == MSG_WHAT_DRAW_GREEN_WAVE) {
val data = msg.obj as? V2nCrossSpeed ?: return@Callback true
@@ -406,35 +383,31 @@ internal object V2NIdentifyDrawer: IEventDismissListener {
} else if (msg.what == MSG_WHAT_DRAW_PEOPLE_CROSS) {
Logger.i(TAG, "people cross -- 1 --")
val data = msg.obj as? MessagePad.Event ?: return@Callback true
val body = runCatching { GsonUtils.fromJson(data.exts, Map::class.java) }.getOrNull()
val cameraIp = body?.get("cameraIp") as? String ?: ""
val array = (body?.get("eventExtUnits") as? JsonArray)
val body = runCatching { GsonUtils.fromJson(data.exts, Extras::class.java) }.getOrNull()
val cameraIp = body?.cameraIp
val array = body?.eventExtUnits
var heading = 0.0
var uuid = ""
if (array != null && array.size() > 0) {
if (!array.isNullOrEmpty()) {
for (e in array) {
if (e is JsonObject) {
if (e.has("heading")) {
heading = runCatching { e.asDouble }.getOrNull() ?: 0.0
}
if (e.has("uuid")) {
uuid = runCatching { e.asString }.getOrNull() ?: ""
}
}
heading = e.heading ?: 0.0
uuid = e.uuid ?: ""
}
}
Logger.d(TAG, "cameraIp: $cameraIp, heading:$heading, uuid: $uuid")
val isUseGps = data.gnssType != 0
val eventLocation = if (isUseGps) arrayOf(data.longitude, data.latitude) else CoordinateTransform.GCJ02ToWGS84(data.longitude, data.latitude)
val carLocation = if (isUseGps) CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84() else CallerChassisLocationGCJ02ListenerManager.getChassisLocationGCJ02()
val distance = CoordinateUtils.calculateLineDistance(carLocation.longitude, carLocation.latitude, eventLocation[0], eventLocation[1])
AiRoadMarker.aiMakers.getOrPut(data.eventId) {
Logger.i(TAG, "people cross -- 2 --")
val isDriver = AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)
val carLocation = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84()
val distance = CoordinateUtils.calculateLineDistance(carLocation.longitude, carLocation.latitude, data.longitude, data.latitude)
if (distance > 150) {
Logger.i(TAG, "people cross --> distance > 150")
V2XBizTrace.onAck(TAG, mapOf("people cross" to "distance > 150"), true)
return@Callback true
}
Logger.i(TAG, "people cross -- 3 --")
val isDriver = AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)
// 弹事件框
CallerRoadV2NEventWindowListenerManager.showLiveVideo(
data.eventId,
@@ -444,12 +417,12 @@ internal object V2NIdentifyDrawer: IEventDismissListener {
isDriver,
String.format(EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_SOCKET_ROAD_PEOPLE_CROSS.poiType), distance.toInt()),
cameraIp.toString(),
data.longitude,
data.latitude)
eventLocation[0],
eventLocation[1])
AiRoadMarker()
}.also {
Logger.i(TAG, "people cross -- 4 --")
it.marker(Marker(data.eventId, EventTypeEnumNew.TYPE_SOCKET_ROAD_PEOPLE_CROSS.poiType, data.longitude, data.latitude, heading), drawMarker = true, false, isHighFrequency = true)
it.marker(Marker(data.eventId, EventTypeEnumNew.TYPE_SOCKET_ROAD_PEOPLE_CROSS.poiType, eventLocation[0], eventLocation[1], heading, isUseGps = isUseGps), drawMarker = true, false, isHighFrequency = true)
}.receive()
}
true

View File

@@ -0,0 +1,17 @@
package com.mogo.eagle.function.biz.v2x.v2n.pnc.beans
import androidx.annotation.Keep
@Keep
data class Extras (
val cameraIp: String? = null,
val eventExtUnits: List<EventExtUnit>? = null
)
@Keep
data class EventExtUnit(
val heading: Double? = null,
val uuid: String? = null
)

View File

@@ -107,7 +107,7 @@ class AiRoadMarker {
val builder = getOrPutPointOptionBuilder(markerId, V2XConst.V2X_MARKER_OWNER, MAP_MARKER)
builder
.set3DMode(true)
.isUseGps(true)
.isUseGps(marker.isUseGps)
.icon3DRes(EventTypeEnumNew.getMarker3DRes(marker.poiType))
.anchorColor("#D65D5AFF")
.controlAngle(true)
@@ -122,7 +122,7 @@ class AiRoadMarker {
if (marker.poiType == EventTypeEnumNew.TYPE_SOCKET_ROAD_OTHER_RETROGRADE_VEHICLE.poiType) {
distance = 100
}
val wrapper = MarkerWrapper(markerId, marker.poi_lon, marker.poi_lat, 1, elapsedDistance = distance)
val wrapper = MarkerWrapper(markerId, marker.poi_lon, marker.poi_lat, if (marker.isUseGps) 1 else 0, elapsedDistance = distance)
wrapper.onRemoved = {
builders.remove(markerId)
markerIds.remove(p.id)
@@ -153,7 +153,7 @@ class AiRoadMarker {
if (marker.poiType == EventTypeEnumNew.TYPE_SOCKET_ROAD_GREE_WAVE.poiType) {
elapsedDuration = TimeUnit.SECONDS.toMillis(3)
}
val wrapper = MarkerWrapper(markerId, marker.poi_lon, marker.poi_lat, 1, elapsedDistance = elapsedDistance, elapsedDuration = elapsedDuration)
val wrapper = MarkerWrapper(markerId, marker.poi_lon, marker.poi_lat, if (marker.isUseGps) 1 else 0, elapsedDistance = elapsedDistance, elapsedDuration = elapsedDuration)
if (drawMarker) {
marker.entity?.apply { roadMarker.drawMarkers(this, wrapper) }
}
@@ -371,6 +371,7 @@ class AiRoadMarker {
val polygon: List<Pair<Double, Double>>? = null,
var farthestPoint: Pair<Double, Double>? = null,
var entity: V2XRoadEventEntity? = null,
var isUseGps: Boolean = false
) {
override fun equals(other: Any?): Boolean {

View File

@@ -47,7 +47,7 @@ public class V2XRoadEventMarker implements IV2XMarker<V2XRoadEventEntity> {
List<Pair<Double, Double>> polygons = noveltyInfo.getPolygon();
if (gpsLocation != null && polygons != null) {
MarkerLocation location = noveltyInfo.getLocation();
AiRoadMarker.Marker m = new AiRoadMarker.Marker(noveltyInfo.getInfoId(), noveltyInfo.getPoiType(), gpsLocation.second, gpsLocation.first, location.getAngle(), polygons, null, entity);
AiRoadMarker.Marker m = new AiRoadMarker.Marker(noveltyInfo.getInfoId(), noveltyInfo.getPoiType(), gpsLocation.second, gpsLocation.first, location.getAngle(), polygons, null, entity, false);
AiRoadMarker aiMarker = new AiRoadMarker();
aiMarker.marker(m, true, isDrawRoadLine(m.getPoiType()), false);
AiRoadMarker.aiMakers.put(noveltyInfo.getInfoId(), aiMarker);

View File

@@ -8,6 +8,8 @@ import com.zhidaoauto.map.data.road.CenterLine
import org.locationtech.jts.geom.Coordinate
import org.locationtech.jts.geom.GeometryFactory
import org.locationtech.jts.geom.LineString
import org.locationtech.jts.geom.LineString.MINIMUM_VALID_SIZE
import org.locationtech.jts.geom.Polygon
import org.locationtech.jts.linearref.LengthIndexedLine
import java.util.concurrent.CountDownLatch
@@ -27,8 +29,20 @@ object V2NUtils {
}
val occupy = ArrayList<Lane>()
val factory = GeometryFactory()
val polygonList = ArrayList<Coordinate>(polygon.map { Coordinate(it.first, it.second) })
var p1: Polygon? = null
while (p1 == null) {
if (polygonList.size < MINIMUM_VALID_SIZE) {
polygonList.add(polygonList[0])
continue
}
try {
p1 = factory.createPolygon(polygonList.toTypedArray())
} catch (ignore: IllegalArgumentException) {
polygonList.add(polygonList[0])
}
}
for (lane in lanes) {
val p1 = factory.createPolygon(polygon.map { Coordinate(it.first, it.second) }.toTypedArray())
val p2 = factory.createLineString(lane.points.map { Coordinate(it.first, it.second) }.toTypedArray()).buffer((lane.width.toDouble() * 0.7 * (1e-5)) / 2.0)
if (p1.intersects(p2)) {
occupy += lane