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

# Conflicts:
#	core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/v2n/pnc/V2NIdentifyDrawer.kt
This commit is contained in:
aibingbing
2024-07-10 09:57:21 +08:00
71 changed files with 1668 additions and 598 deletions

View File

@@ -6,6 +6,8 @@ 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
@@ -82,12 +84,6 @@ internal object V2NIdentifyDrawer: IEventDismissListener {
private const val MSG_WHAT_DRAW_GREEN_WAVE = 0x1014 // 绿波通行
private const val MSG_WHAT_DRAW_PEOPLE_CROSS = 0x1015 // 行人横穿
private val builder_people_cross by lazy {
Point.Options.Builder(V2XConst.V2X_MARKER_OWNER, MAP_MARKER).isUseGps(true).anchorColor("#D65D5AFF").set3DMode(true).icon3DRes(TrafficTypeEnum.TYPE_TRAFFIC_ID_PEOPLE.traffic3DIconId)
}
private val markers by lazy { ConcurrentHashMap<String, MarkerWrapper>() }
private val callback = Handler.Callback { msg ->
if (msg.what == MSG_WHAT_DRAW_SHIGONE || msg.what == MSG_WHAT_DRAW_SHIGU) {
val events = msg.obj as? List<*>
@@ -133,8 +129,8 @@ internal object V2NIdentifyDrawer: IEventDismissListener {
val polygon = itx.polygonList.map { Pair.create(it.longitude, it.latitude) }
marker(Marker(id,
poiType,
itx.latitude,
itx.longitude,
itx.latitude,
itx.heading,
polygon,
null,
@@ -203,7 +199,7 @@ internal object V2NIdentifyDrawer: IEventDismissListener {
}
}
val alert = sb.toString()
CallerRoadV2NEventWindowListenerManager.showLiveVideo("${itx.longitude}-${itx.latitude}", itx.systemTime.toLong(), EventTypeEnumNew.getUpdateIconRes(poiType), alert, isDriver, alert, itx.cameraIp, itx.longitude, itx.latitude)
CallerRoadV2NEventWindowListenerManager.showLiveVideo("${itx.longitude}-${itx.latitude}", itx.detectStartTime, EventTypeEnumNew.getUpdateIconRes(poiType), alert, isDriver, itx.cameraIp, itx.longitude, itx.latitude)
}
}
//消息埋点
@@ -216,7 +212,7 @@ internal object V2NIdentifyDrawer: IEventDismissListener {
}
} else if (msg.what == MSG_WHAT_DRAW_YONGDU) {
Log.d("V2NIdentifyDrawer", "---callback -- drawYongDu --- 1 ---")
val events = msg.obj as? List<*>
/* val events = msg.obj as? List<*>
if (events == null || events.isEmpty()) {
Log.d("V2NIdentifyDrawer", "---callback -- drawYongDu --- 1 filter is empty ---")
V2XBizTrace.onAck(TAG, mapOf("yongDu" to ""), true)
@@ -254,7 +250,7 @@ internal object V2NIdentifyDrawer: IEventDismissListener {
AiRoadMarker.aiMakers.getOrPut(id) {
AiRoadMarker().apply {
val poiType = getPoiType(itx.eventType).poiType
marker(Marker(id, poiType, lat, lon, car.heading, null, null,
marker(Marker(id, poiType, lon, lat, car.heading, null, null,
V2XRoadEventEntity().also { e ->
e.poiType = poiType
e.location = MarkerLocation().also { l ->
@@ -319,7 +315,7 @@ internal object V2NIdentifyDrawer: IEventDismissListener {
)
}
}.receive()
}
}*/
} else if (msg.what == MSG_WHAT_DRAW_OTHER_RETROGRADE_VEHICLE) {
val event = msg.obj as? MessagePad.Event
if (event == null) {
@@ -327,6 +323,24 @@ 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)
var heading = 0.0
var uuid = ""
if (array != null && array.size() > 0) {
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() ?: ""
}
}
}
}
Logger.d(TAG, "cameraIp: $cameraIp, heading:$heading, uuid: $uuid")
val newEventId = "other_retrograde_vehicle_${event.eventId}"
AiRoadMarker.aiMakers.getOrPut(newEventId) {
val eventLocation = when (event.gnssType) {
@@ -341,8 +355,6 @@ internal object V2NIdentifyDrawer: IEventDismissListener {
return@Callback true
}
val isDriver = AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)
val cameraIp = if(TextUtils.isEmpty(event.exts)) ""
else (GsonUtils.fromJson(event.exts, Map::class.java)["cameraIp"])?:""
// 弹事件框
CallerRoadV2NEventWindowListenerManager.showLiveVideo(
newEventId,
@@ -392,9 +404,29 @@ 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)
var heading = 0.0
var uuid = ""
if (array != null && array.size() > 0) {
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() ?: ""
}
}
}
}
Logger.d(TAG, "cameraIp: $cameraIp, heading:$heading, uuid: $uuid")
AiRoadMarker.aiMakers.getOrPut(data.eventId) {
val isDriver = AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)
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) {
@@ -402,8 +434,7 @@ internal object V2NIdentifyDrawer: IEventDismissListener {
V2XBizTrace.onAck(TAG, mapOf("people cross" to "distance > 150"), true)
return@Callback true
}
val cameraIp = if(TextUtils.isEmpty(data.exts)) ""
else (GsonUtils.fromJson(data.exts, Map::class.java)["cameraIp"])?:""
Logger.i(TAG, "people cross -- 3 --")
// 弹事件框
CallerRoadV2NEventWindowListenerManager.showLiveVideo(
data.eventId,
@@ -417,7 +448,8 @@ internal object V2NIdentifyDrawer: IEventDismissListener {
data.latitude)
AiRoadMarker()
}.also {
it.marker(Marker(data.eventId, EventTypeEnumNew.TYPE_SOCKET_ROAD_PEOPLE_CROSS.poiType, data.longitude, data.latitude, 0.0), drawMarker = true, false, isHighFrequency = true)
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)
}.receive()
}
true
@@ -461,7 +493,7 @@ internal object V2NIdentifyDrawer: IEventDismissListener {
var best = Int.MIN_VALUE
var delta = Int.MAX_VALUE
for (lane in freeLanes) {
val abs = kotlin.math.abs(lane.id - laneId)
val abs = abs(lane.id - laneId)
if (abs < delta && lane.id != laneId) {
best = lane.id
delta = abs
@@ -489,10 +521,10 @@ internal object V2NIdentifyDrawer: IEventDismissListener {
}
}
private fun computeCrossCountBetween(start: kotlin.Triple<Double, Double, Double>, end: kotlin.Pair<Double, Double>): Int {
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)
V2XBizTrace.onAck(points, "computeCrossCountBetween", true)
var crossId = MapDataWrapper.getCrossRoad(start.first, start.second, start.third)?.cross_id_end
var crossId = MapDataWrapper.getCrossRoad(start.first, start.second, start.third)?.cross_id
val angle = start.third
var count = 1
for (p in points) {

View File

@@ -11,8 +11,10 @@ import com.mogo.eagle.core.data.enums.EventTypeEnumNew
import com.mogo.eagle.core.data.map.MogoLatLng
import com.mogo.eagle.core.data.map.entity.V2XRoadEventEntity
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager
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.utilcode.mogo.logger.Logger
import com.mogo.eagle.core.utilcode.util.CoordinateUtils
import com.mogo.eagle.core.utilcode.util.DrivingDirectionUtils
import com.mogo.eagle.function.biz.v2x.V2XBizTrace
@@ -100,12 +102,17 @@ class AiRoadMarker {
fun marker(marker: Marker, drawMarker: Boolean, drawRoadLine: Boolean = false, isHighFrequency:Boolean = false) {
val markerId = marker.id
if (isHighFrequency && drawMarker) {
this.marker.set(marker)
Logger.d(TAG, "marker --->poiType: $marker, ${EventTypeEnumNew.getMarker3DRes(marker.poiType)}")
val builder = getOrPutPointOptionBuilder(markerId, V2XConst.V2X_MARKER_OWNER, MAP_MARKER)
builder
.set3DMode(true)
.isUseGps(true)
.icon3DRes(EventTypeEnumNew.getMarker3DRes(marker.poiType))
.anchorColor("#D65D5AFF")
.controlAngle(true)
.anchor(0.5f, 0.5f)
.rotate(marker.poi_angle.toFloat())
.longitude(marker.poi_lon)
.latitude(marker.poi_lat)
CallerMapUIServiceManager.getOverlayManager()?.showOrUpdatePoint(builder.build())?.let { p ->
@@ -117,9 +124,13 @@ class AiRoadMarker {
}
val wrapper = MarkerWrapper(markerId, marker.poi_lon, marker.poi_lat, 1, elapsedDistance = distance)
wrapper.onRemoved = {
CallerRoadV2NEventWindowListenerManager.dismiss(markerId)
builders.remove(markerId)
markerIds.remove(p.id)
if (marker.poiType == EventTypeEnumNew.TYPE_SOCKET_ROAD_GREE_WAVE.poiType) {
CallerHmiManager.dismissGreenWave()
} else {
CallerRoadV2NEventWindowListenerManager.dismiss(marker.id)
}
}
wrapper.addPoint(p)
MarkerRemoveManager.addMarker(wrapper)
@@ -219,22 +230,7 @@ class AiRoadMarker {
V2XBizTrace.onAck("$TAG -marker-4-l2:", l2)
val points = LinkedList<MogoLatLng>()
if (l2.points.isNotEmpty()) {
points.addAll(l2.points.reversed()/*.filter {
val location = V2XEventManager.getFirstLocationInCross()
Log.d(TAG, "l2: location -> $location")
if (location != null) {
val carLocation = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84()
if (DrivingDirectionUtils.getDegreeOfCar2Poi2(carLocation.longitude, carLocation.latitude, location.longitude, location.latitude, carLocation.heading) > 90) {
//处理同一个路口不同车道调头,这种极端情况
true
} else {
val angle = DrivingDirectionUtils.getDegreeOfCar2Poi2(location.longitude, location.latitude, it.longitude, it.latitude, location.heading)
angle <= 90
}
} else {
true
}
}.*/.map {
points.addAll(l2.points.reversed().map {
MogoLatLng(it.latitude, it.longitude)
})
}
@@ -327,7 +323,11 @@ class AiRoadMarker {
roadMarker.removeMarkers()
handler.removeCallbacks(checkExpiredTask)
aiMakers.remove(marker.id)
CallerRoadV2NEventWindowListenerManager.dismiss("${marker.poi_lon}-${marker.poi_lat}")
if (marker.poiType == EventTypeEnumNew.TYPE_SOCKET_ROAD_GREE_WAVE.poiType) {
CallerHmiManager.dismissGreenWave()
} else {
CallerRoadV2NEventWindowListenerManager.dismiss(marker.id)
}
}
}
@@ -365,12 +365,12 @@ class AiRoadMarker {
data class Marker(
val id: String,
val poiType: String,
val poi_lat: Double,
val poi_lon: Double,
val poi_lat: Double,
val poi_angle: Double,
val polygon: List<Pair<Double, Double>>? = null,
var farthestPoint: Pair<Double, Double>? = null,
var entity: V2XRoadEventEntity? = null
var entity: V2XRoadEventEntity? = null,
) {
override fun equals(other: Any?): Boolean {