diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiFragment.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiFragment.kt index 7760451e81..bcc57eb412 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiFragment.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiFragment.kt @@ -1374,6 +1374,7 @@ class MoGoHmiFragment : MvpFragment(), HmiBuildConfig.isShowSnBindingView = isOpen } + private var takeOver = false /** * 工控机监控节点上报 @@ -1381,31 +1382,6 @@ class MoGoHmiFragment : MvpFragment(), override fun onAutopilotGuardian(guardianInfo: MogoReportMsg.MogoReportMessage?) { ThreadUtils.runOnUiThread { guardianInfo?.let { - when (it.code) { - EXIT_AUTOPILOT_FOR_PLANNING, - EXIT_AUTOPILOT_FOR_LOCATION, - EXIT_AUTOPILOT_FOR_CHASSIS, - EXIT_AUTOPILOT_FOR_DISTANCE -> { - showWarningV2X( - EventTypeEnum.TAKE_OVER_EVENT.poiType, - EventTypeEnum.TAKE_OVER_EVENT.content, - EventTypeEnum.TAKE_OVER_EVENT.tts, - EventTypeEnum.TAKE_OVER_EVENT.poiType, - object : IMoGoWarningStatusListener { - override fun onShow() { - clTakeOverView.visibility = View.VISIBLE - } - - override fun onDismiss() { - clTakeOverView.visibility = View.GONE - } - }, - true, - 6000L - ) - } - } - if (reportList.size > 49) { reportList.removeLast() } @@ -1418,6 +1394,38 @@ class MoGoHmiFragment : MvpFragment(), ) reportListFloatWindow?.refreshData(reportList) + if(FunctionBuildConfig.isDemoMode){ + return@let + } + if(takeOver){ + return@let + } + when (it.code) { + EXIT_AUTOPILOT_FOR_PLANNING, + EXIT_AUTOPILOT_FOR_LOCATION, + EXIT_AUTOPILOT_FOR_CHASSIS, + EXIT_AUTOPILOT_FOR_DISTANCE -> { + showWarningV2X( + EventTypeEnum.TAKE_OVER_EVENT.poiType, + EventTypeEnum.TAKE_OVER_EVENT.content, + EventTypeEnum.TAKE_OVER_EVENT.tts, + EventTypeEnum.TAKE_OVER_EVENT.poiType, + object : IMoGoWarningStatusListener { + override fun onShow() { + takeOver = true + clTakeOverView.visibility = View.VISIBLE + } + + override fun onDismiss() { + takeOver = false + clTakeOverView.visibility = View.GONE + } + }, + true, + 6000L + ) + } + } } } } diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt index 384af51e4f..adc7747c96 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt @@ -9,6 +9,7 @@ import android.graphics.Color import android.os.Build import android.text.Html import android.util.AttributeSet +import android.util.Log import android.view.LayoutInflater import android.view.View import android.widget.* @@ -21,7 +22,6 @@ import androidx.recyclerview.widget.LinearLayoutManager import chassis.Chassis import com.mogo.cloud.passport.MoGoAiCloudClient import com.mogo.cloud.passport.MoGoAiCloudClientConfig -import com.mogo.commons.AbsMogoApplication import com.mogo.commons.debug.DebugConfig import com.mogo.eagle.core.data.app.AppConfigInfo import com.mogo.eagle.core.data.autopilot.* @@ -57,7 +57,6 @@ import com.mogo.eagle.core.function.call.map.CallerSmpManager import com.mogo.eagle.core.function.call.obu.CallerOBUManager import com.mogo.eagle.core.function.call.obu.CallerObuListenerManager import com.mogo.eagle.core.function.call.setting.CallerMoGoUiSettingManager -import com.mogo.eagle.core.function.call.telematic.CallerTelematicManager import com.mogo.eagle.core.function.hmi.R import com.mogo.eagle.core.function.hmi.ui.logcatch.ILogViewListener import com.mogo.eagle.core.function.hmi.ui.logcatch.LogInfoView @@ -633,33 +632,20 @@ class DebugSettingView @JvmOverloads constructor( } - // 初始化 GSP数据源 数据 rgGpsProvider.check( when (FunctionBuildConfig.gpsProvider) { - 0 -> { - R.id.rbGpsProviderAndroid - } - 1 -> { - R.id.rbGpsProviderRTK - } - 2 -> { - R.id.rbGpsProviderOBU - } + 0 -> R.id.rbGpsProviderAndroid + 1 -> R.id.rbGpsProviderRTK + 2 -> R.id.rbGpsProviderOBU else -> R.id.rbGpsProviderAndroid } ) rgGpsProvider.setOnCheckedChangeListener { _, checkedId -> when (checkedId) { - R.id.rbGpsProviderAndroid -> { - FunctionBuildConfig.gpsProvider = 0 - } - R.id.rbGpsProviderRTK -> { - FunctionBuildConfig.gpsProvider = 1 - } - R.id.rbGpsProviderOBU -> { - FunctionBuildConfig.gpsProvider = 2 - } + R.id.rbGpsProviderAndroid -> FunctionBuildConfig.gpsProvider = 0 + R.id.rbGpsProviderRTK -> FunctionBuildConfig.gpsProvider = 1 + R.id.rbGpsProviderOBU -> FunctionBuildConfig.gpsProvider = 2 } } @@ -690,22 +676,18 @@ class DebugSettingView @JvmOverloads constructor( trackerIPCProvider.check( when (FunctionBuildConfig.trackerIPCProvider) { 0 -> R.id.trackerIPCUnion - 1 -> R.id.trackerIPCObu - 2 -> R.id.trackerIPCV2N + 1 -> R.id.trackerIPC + 2 -> R.id.trackerIPCObu + 3 -> R.id.trackerIPCV2I else -> R.id.trackerIPCUnion } ) - trackerProvider.setOnCheckedChangeListener{ _, checkedId -> - when(checkedId){ - R.id.trackerIPCUnion -> { - FunctionBuildConfig.trackerIPCProvider = 0 - } - R.id.trackerIPCObu -> { - FunctionBuildConfig.trackerIPCProvider = 1 - } - R.id.trackerIPCV2N -> { - FunctionBuildConfig.trackerIPCProvider = 2 - } + trackerIPCProvider.setOnCheckedChangeListener { _, checkedId -> + when (checkedId) { + R.id.trackerIPCUnion -> FunctionBuildConfig.trackerIPCProvider = 0 + R.id.trackerIPC -> FunctionBuildConfig.trackerIPCProvider = 1 + R.id.trackerIPCObu -> FunctionBuildConfig.trackerIPCProvider = 2 + R.id.trackerIPCV2I -> FunctionBuildConfig.trackerIPCProvider = 3 } } diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_debug_setting.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_debug_setting.xml index 13f392ed35..063ec5f432 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_debug_setting.xml +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_debug_setting.xml @@ -1796,6 +1796,16 @@ android:layout_height="wrap_content" android:layout_weight="1" android:padding="@dimen/dp_10" + android:text="融合全部感知数据" + android:textColor="#000" + android:textSize="@dimen/dp_24" /> + + @@ -1811,12 +1821,12 @@ android:textSize="@dimen/dp_24" /> diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/map/identify/IdentifyOriginDataDrawer.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/map/identify/IdentifyOriginDataDrawer.kt index 343bbd8449..d4c3e3d62b 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/map/identify/IdentifyOriginDataDrawer.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/map/identify/IdentifyOriginDataDrawer.kt @@ -1,21 +1,14 @@ package com.mogo.eagle.core.function.map.identify import android.annotation.SuppressLint -import android.text.TextUtils import androidx.collection.ArraySet import com.mogo.commons.AbsMogoApplication -import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo -import com.mogo.eagle.core.data.config.FunctionBuildConfig -import com.mogo.eagle.core.data.enums.TrafficTypeEnum import com.mogo.eagle.core.data.traffic.TrafficData -import com.mogo.eagle.core.data.traffic.threatLevelColor -import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener -import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.w import com.mogo.map.MogoMarkerManager import com.mogo.module.common.MogoApisHandler -import mogo.telematics.pad.MessagePad -import mogo.telematics.pad.MessagePad.* +import mogo.telematics.pad.MessagePad.PlanningObject +import mogo.telematics.pad.MessagePad.TrackedObject import java.util.concurrent.ConcurrentHashMap /** @@ -23,20 +16,12 @@ import java.util.concurrent.ConcurrentHashMap * @date 2021/10/19 10:45 上午 * 域控制器识别信息绘制 */ -class IdentifyOriginDataDrawer : Identify, IMoGoAutopilotStatusListener { +class IdentifyOriginDataDrawer : Identify { companion object { private const val TAG = "IdentifyDataDrawer" } - init { - // 添加 ADAS状态 监听 - CallerAutoPilotStatusListenerManager.addListener(TAG, this) - } - - @Volatile - private var mAutopilotStatus: Int = 0 //自动驾驶状态 - /** * 上一帧数据的缓存 */ @@ -54,58 +39,13 @@ class IdentifyOriginDataDrawer : Identify, IMoGoAutopilotStatusListener { @SuppressLint("NewApi") private val mFilterTrafficData = HashMap() - /** - * planning 感知物预警缓存,用于重置color状态 - */ - private val pncWarningTrafficData = ConcurrentHashMap() - - /** - * obu 感知物预警缓存,用于重置color状态 - */ - private val obuWarningTrafficData = ConcurrentHashMap() - @SuppressLint("NewApi") - override fun renderPlanningWarningObj(planningObjects: List?) { - pncWarningTrafficData.clear() - if (FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData || mAutopilotStatus == 2) { - if (planningObjects == null) { - return - } - planningObjects.forEach { planningObj -> - val trackId = planningObj.uuid.toString() - if (mMarkersCaches.containsKey(trackId)) { - val trackObj = mMarkersCaches[trackId] - if (planningObj.type == 0) { - //0是leading障碍物,障碍物车身红色提示 - trackObj?.let { - pncWarningTrafficData[trackId] = PlanningTrack( - "#D65D5AFF", - CallerAutoPilotStatusListenerManager.getCurWgs84SatelliteTime() - ) - } - } else if (planningObj.type == 1) { - //1是避障和择机的障碍物,障碍物车身黄色提示 - trackObj?.let { - pncWarningTrafficData[trackId] = PlanningTrack( - "#E4DD94FF", - CallerAutoPilotStatusListenerManager.getCurWgs84SatelliteTime() - ) - } - } - } - } - } + override fun renderPlanningWarningObj(planningObjects: List?) { + WarningHelper.renderPlanningOriginWarningObj(planningObjects, mMarkersCaches) } override fun renderOBUWarningObj(exist: Boolean, obuTrafficData: TrafficData) { - if (obuTrafficData.uuid.isNullOrEmpty()) { - return - } - if (exist) { - obuWarningTrafficData[obuTrafficData.uuid!!] = obuTrafficData - } else { - obuWarningTrafficData.remove(obuTrafficData.uuid!!) - } + WarningHelper.renderOBUWarningObj(exist, obuTrafficData) } /** @@ -129,7 +69,7 @@ class IdentifyOriginDataDrawer : Identify, IMoGoAutopilotStatusListener { //清除缓存 for (data in resultList) { if (trafficDataUuidList.size > 0 && trafficDataUuidList.contains("" + data.uuid)) { - if (!FunctionBuildConfig.isDrawUnknownIdentifyData && data.type == TrafficTypeEnum.TYPE_TRAFFIC_ID_WEI_ZHI.type) { + if (TrackerSourceHelper.filterData(data)) { continue } trafficDataUuidList.remove("" + data.uuid) @@ -165,7 +105,7 @@ class IdentifyOriginDataDrawer : Identify, IMoGoAutopilotStatusListener { trafficDataUuidList.clear() for (data in trafficData) { // 过滤掉未知感知数据 - if (!FunctionBuildConfig.isDrawUnknownIdentifyData && data.type == TrafficTypeEnum.TYPE_TRAFFIC_ID_WEI_ZHI.type) { + if (TrackerSourceHelper.filterData(data)) { continue } var temp: TrackedObject = data @@ -173,38 +113,8 @@ class IdentifyOriginDataDrawer : Identify, IMoGoAutopilotStatusListener { //首次过来的数据不添加,首次未添加的感知物在调用完绘制方法后再塞入cache map val cacheData = mMarkersCaches[uuid] if (cacheData != null) { - - //OBU数据颜色标记 - val first = data.trackedSourceList.stream() - .filter { trackedSource: TrackedSource -> trackedSource.source == 4 } - .findFirst() - if (first.isPresent) { - val subFirst = first.get().subSourceList.stream() - .filter { subSource: SubSource -> subSource.source == 1 } - .findFirst() - if (subFirst.isPresent) { - val subID = subFirst.get().id - if (!TextUtils.isEmpty(subID)) { - temp = data.toBuilder().setColor("#36D3FE").build() - if (obuWarningTrafficData.containsKey(subID)) { - temp = data.toBuilder() - .setColor(obuWarningTrafficData[subID]!!.threatLevelColor()) - .build() - } - } - } - } - - //预警颜色变化 - if (pncWarningTrafficData.containsKey(uuid)) { - val planningTrack = pncWarningTrafficData[uuid] - if (!timeOut(planningTrack!!.time)) { - temp = data.toBuilder().setColor(planningTrack.color).build() - } else { - pncWarningTrafficData.remove(uuid) - } - } - + val color = TrackerSourceHelper.getDefaultColor(data) + temp = data.toBuilder().setColor(color).build() mFilterTrafficData[uuid] = temp } mMarkersCaches[uuid] = temp @@ -223,17 +133,7 @@ class IdentifyOriginDataDrawer : Identify, IMoGoAutopilotStatusListener { .removeMarker(uuid) } trafficDataUuidList.clear() - pncWarningTrafficData.clear() - } - - override fun onAutopilotStatusResponse(autoPilotStatusInfo: AutopilotStatusInfo) { - mAutopilotStatus = autoPilotStatusInfo.state - } - - private fun timeOut(time: Double): Boolean { - val duration = - (CallerAutoPilotStatusListenerManager.getCurWgs84SatelliteTime() * 1000).toLong() - (time * 1000).toLong() - return duration >= 500 + WarningHelper.clear() } } \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/map/identify/TrackManager.java b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/map/identify/TrackManager.java index dfccf31eb5..c5b5a301f3 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/map/identify/TrackManager.java +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/map/identify/TrackManager.java @@ -9,8 +9,6 @@ import androidx.annotation.RequiresApi; import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; import com.mogo.commons.AbsMogoApplication; -import com.mogo.eagle.core.data.config.FunctionBuildConfig; -import com.mogo.eagle.core.data.enums.TrafficTypeEnum; import com.mogo.eagle.core.data.traffic.TrafficData; import com.mogo.eagle.core.data.traffic.TrafficDataKt; import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager; @@ -22,7 +20,6 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.Optional; import java.util.concurrent.ConcurrentHashMap; import mogo.telematics.pad.MessagePad; @@ -64,57 +61,13 @@ public class TrackManager { @SuppressLint("NewApi") private final HashMap mFilterTrafficData = new HashMap<>(); - //感知物预警各自先以帧数更新保持,不做同一个集合的融合处理(以卫星时间做判断先后,可能会出现不同ip节点间的回溯问题) - /** - * planning 感知物预警缓存,用于重置color状态 - */ - private final ConcurrentHashMap pncWarningTrafficData = new ConcurrentHashMap<>(); - - /** - * obu 感知物预警缓存,用于重置color状态 - */ - private final ConcurrentHashMap obuWarningTrafficData = new ConcurrentHashMap<>(); - @SuppressLint("NewApi") public synchronized void renderPlanningWarningObj(List planningObjects) { - pncWarningTrafficData.clear(); - //处于美化模式或者自动驾驶状态下展示 - if (FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData || CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState() == 2) { - if (planningObjects == null) { - return; - } - planningObjects.forEach(planningObj -> { - String trackId = "" + planningObj.getUuid(); - if (mMarkersCaches.containsKey(trackId)) { - TrackObj trackObj = mMarkersCaches.get(trackId); - if (trackObj == null) { - return; - } - if (planningObj.getType() == 0) { - pncWarningTrafficData.put(trackId, new PlanningTrack( - "#D65D5AFF", - CallerAutoPilotStatusListenerManager.INSTANCE.getCurWgs84SatelliteTime() - )); - } else if (planningObj.getType() == 1) { - pncWarningTrafficData.put(trackId, new PlanningTrack( - "#E4DD94FF", - CallerAutoPilotStatusListenerManager.INSTANCE.getCurWgs84SatelliteTime() - )); - } - } - }); - } + WarningHelper.INSTANCE.renderPlanningWarningObj(planningObjects, mMarkersCaches); } public synchronized void renderOBUWarningObj(boolean exist, TrafficData obuTrafficData) { - if (obuTrafficData.getUuid() == null || obuTrafficData.getUuid().isEmpty()) { - return; - } - if (exist) { - obuWarningTrafficData.put(obuTrafficData.getUuid(), obuTrafficData); - } else { - obuWarningTrafficData.remove(obuTrafficData.getUuid()); - } + WarningHelper.INSTANCE.renderOBUWarningObj(exist, obuTrafficData); } /** @@ -126,39 +79,14 @@ public class TrackManager { mFilterTrafficData.clear(); //进入过滤机制的感知物体,首先从缓存队列中进行查找 uuid for (MessagePad.TrackedObject data : trafficData) { - if (!FunctionBuildConfig.isDrawUnknownIdentifyData && data.getType() == TrafficTypeEnum.TYPE_TRAFFIC_ID_WEI_ZHI.getType()) { + if (TrackerSourceHelper.INSTANCE.filterData(data)) { continue; } String uuid = "" + data.getUuid(); TrackObj trackObj = mMarkersCaches.get(uuid); - //OBU数据颜色标记 - Optional first = data.getTrackedSourceList().stream() - .filter(trackedSource -> trackedSource.getSource() == 4).findFirst(); - if (first.isPresent()) { - Optional subFirst = first.get().getSubSourceList().stream().filter(subSource -> subSource.getSource() == 1).findFirst(); - if (subFirst.isPresent()) { - String subID = subFirst.get().getId(); - if (!TextUtils.isEmpty(subID)) { - data = data.toBuilder().setColor("#36D3FE").build(); - if (obuWarningTrafficData.containsKey(subID)) { - data = data.toBuilder() - .setColor(TrafficDataKt.threatLevelColor(obuWarningTrafficData.get(subID))) - .build(); - } - } - } - } - - // 判断物体是否与预警信息 - if (pncWarningTrafficData.containsKey(uuid)) { - PlanningTrack planningTrack = pncWarningTrafficData.get(uuid); - if (planningTrack != null && !timeOut(planningTrack.getTime())) { - data = data.toBuilder().setColor(planningTrack.getColor()).build(); - } else { - pncWarningTrafficData.remove(uuid); - } - } + String color = TrackerSourceHelper.INSTANCE.getDefaultColor(data); + data = data.toBuilder().setColor(color).build(); if (trackObj != null) { trackObj.updateObj(data); @@ -178,7 +106,7 @@ public class TrackManager { if (cache != null) { //相对静止物体并且非obu数据,则不改变,为感知融合同位置物体,使用缓存数据做覆盖 if (cacheTrack.relativeStatic()) { - if(data.getColor()!= null && !data.getColor().isEmpty()){ + if (data.getColor() != null && !data.getColor().isEmpty()) { cache = cache.toBuilder().setColor(data.getColor()).build(); } data = cache; @@ -206,7 +134,7 @@ public class TrackManager { //过滤现有元素 for (MessagePad.TrackedObject data : resultList) { String uuid = "" + data.getUuid(); - if (!FunctionBuildConfig.isDrawUnknownIdentifyData && data.getType() == TrafficTypeEnum.TYPE_TRAFFIC_ID_WEI_ZHI.getType()) { + if (TrackerSourceHelper.INSTANCE.filterData(data)) { continue; } if (trafficDataUuid.size() > 0) { @@ -234,13 +162,8 @@ public class TrackManager { @SuppressLint("NewApi") public void clearAll() { trafficDataUuid.clear(); - pncWarningTrafficData.clear(); + WarningHelper.INSTANCE.clear(); mMarkersCaches.forEach((uuid, trackObj) -> removeKey(uuid)); } - private Boolean timeOut(Double time) { - long duration = (long) (CallerAutoPilotStatusListenerManager.INSTANCE.getCurWgs84SatelliteTime() * 1000) - (long) (time * 1000); - return duration >= 500; - } - } diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/map/identify/TrackerSourceHelper.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/map/identify/TrackerSourceHelper.kt new file mode 100644 index 0000000000..470b3068b6 --- /dev/null +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/map/identify/TrackerSourceHelper.kt @@ -0,0 +1,135 @@ +package com.mogo.eagle.core.function.map.identify + +import android.annotation.SuppressLint +import com.mogo.eagle.core.data.config.FunctionBuildConfig +import com.mogo.eagle.core.data.enums.TrafficTypeEnum +import mogo.telematics.pad.MessagePad.* + +object TrackerSourceHelper { + + @SuppressLint("NewApi") + fun filterData(data: TrackedObject): Boolean { + if (!FunctionBuildConfig.isDrawUnknownIdentifyData + && data.type == TrafficTypeEnum.TYPE_TRAFFIC_ID_WEI_ZHI.type + ) { + return true + } + var trackIPCFilter = true + when (FunctionBuildConfig.trackerIPCProvider) { + 0 -> trackIPCFilter = false + 1 -> if (isIPC(data)) { + trackIPCFilter = false + } + 2 -> { + if (isObu(data).second) { + trackIPCFilter = false + } + } + 3 -> { + if (isV2I(data).second) { + trackIPCFilter = false + } + } + } + return trackIPCFilter + } + + fun getDefaultColor(data: TrackedObject): String { + var color = "" + if (!FunctionBuildConfig.isDrawUnknownIdentifyData + && data.type == TrafficTypeEnum.TYPE_TRAFFIC_ID_WEI_ZHI.type + ) { + return "" + } + + if (isV2I(data).second) { + color = "#00AEFF" + } + + //等级最高 + if (isObu(data).second) { + color = "#36D3FE" + // obu预警 + isObu(data).first?.let { + val obuColor = WarningHelper.getObuColor(it.id) + if (obuColor.isNotBlank()) { + color = obuColor + } + } + } + + // pnc预警 + val pncColor = WarningHelper.getPncColor(data.uuid.toString()) + if (pncColor.isNotBlank()) { + color = pncColor + } + return color + } + + /** + * 过滤所有 工控感知数据 all match + */ + @SuppressLint("NewApi") + fun isIPC(data: TrackedObject): Boolean { + val source = data.trackedSourceList.stream().allMatch { + it.source != 4 + } + return source + } + + /** + * any match 任何一个匹配到OBU,则认为是存在obu数据 + */ + @SuppressLint("NewApi") + fun isObu(data: TrackedObject): Pair { + val source = data.trackedSourceList.stream().anyMatch { + it.source == 4 + } + if (source) { + val first = data.trackedSourceList.stream() + .filter { trackedSource: TrackedSource -> trackedSource.source == 4 }.findFirst() + if (first.isPresent) { + val subObu = first.get().subSourceList.stream().anyMatch { + it.source == 1 + } + if (subObu) { + val subFirst = first.get().subSourceList.stream() + .filter { subSource: SubSource -> subSource.source == 1 } + .findFirst() + if (subFirst.isPresent) { + return Pair(subFirst.get(), true) + } + } + } + } + return Pair(null, false) + } + + /** + * 过滤所有 v2i 感知数据 all match + */ + @SuppressLint("NewApi") + fun isV2I(data: TrackedObject): Pair { + val source = data.trackedSourceList.stream().allMatch { + it.source == 4 + } + if (source) { + val first = data.trackedSourceList.stream() + .filter { trackedSource: TrackedSource -> trackedSource.source == 4 }.findFirst() + if (first.isPresent) { + val subV2I = first.get().subSourceList.stream().allMatch { + it.source == 6 + } + if (subV2I) { + val subFirst = first.get().subSourceList.stream() + .filter { subSource: SubSource -> subSource.source == 6 } + .findFirst() + if (subFirst.isPresent) { + return Pair(subFirst.get(), true) + } + } + } + } + return Pair(null, false) + } +} \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/map/identify/WarningHelper.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/map/identify/WarningHelper.kt new file mode 100644 index 0000000000..f7f70ccb05 --- /dev/null +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/map/identify/WarningHelper.kt @@ -0,0 +1,148 @@ +package com.mogo.eagle.core.function.map.identify + +import android.annotation.SuppressLint +import com.mogo.eagle.core.data.config.FunctionBuildConfig +import com.mogo.eagle.core.data.traffic.TrafficData +import com.mogo.eagle.core.data.traffic.threatLevelColor +import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo +import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager.getCurWgs84SatelliteTime +import mogo.telematics.pad.MessagePad +import mogo.telematics.pad.MessagePad.PlanningObject +import java.util.concurrent.ConcurrentHashMap +import java.util.function.Consumer + +object WarningHelper { + + //感知物预警各自先以帧数更新保持,不做同一个集合的融合处理(以卫星时间做判断先后,可能会出现不同ip节点间的回溯问题) + /** + * planning 感知物预警缓存,用于重置color状态 + */ + private val pncWarningBeautyTrafficData = ConcurrentHashMap() + + /** + * planning 感知物预警缓存,用于重置color状态 + */ + private val pncWarningOriginTrafficData = ConcurrentHashMap() + + /** + * obu 感知物预警缓存,用于重置color状态 + */ + private val obuWarningTrafficData = ConcurrentHashMap() + + @SuppressLint("NewApi") + fun renderPlanningWarningObj( + planningObjects: List?, + mMarkersCaches: ConcurrentHashMap + ) { + pncWarningBeautyTrafficData.clear() + //处于美化模式或者自动驾驶状态下展示 + if (FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData || getAutoPilotStatusInfo().state == 2) { + if (planningObjects == null) { + return + } + planningObjects.forEach(Consumer { planningObj: PlanningObject -> + val trackId = "" + planningObj.uuid + if (mMarkersCaches.containsKey(trackId)) { + mMarkersCaches[trackId] ?: return@Consumer + if (planningObj.type == 0) { //0是leading障碍物,障碍物车身红色提示 + pncWarningBeautyTrafficData[trackId] = PlanningTrack( + "#D65D5AFF", + getCurWgs84SatelliteTime() + ) + } else if (planningObj.type == 1) { //1是避障和择机的障碍物,障碍物车身黄色提示 + pncWarningBeautyTrafficData[trackId] = PlanningTrack( + "#E4DD94FF", + getCurWgs84SatelliteTime() + ) + } + } + }) + } + } + + @SuppressLint("NewApi") + fun renderPlanningOriginWarningObj( + planningObjects: List?, + mMarkersCaches: ConcurrentHashMap + ) { + pncWarningOriginTrafficData.clear() + //处于美化模式或者自动驾驶状态下展示 + if (FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData || getAutoPilotStatusInfo().state == 2) { + if (planningObjects == null) { + return + } + planningObjects.forEach(Consumer { planningObj: PlanningObject -> + val trackId = "" + planningObj.uuid + if (mMarkersCaches.containsKey(trackId)) { + mMarkersCaches[trackId] ?: return@Consumer + if (planningObj.type == 0) { //0是leading障碍物,障碍物车身红色提示 + pncWarningOriginTrafficData[trackId] = PlanningTrack( + "#D65D5AFF", + getCurWgs84SatelliteTime() + ) + } else if (planningObj.type == 1) { //1是避障和择机的障碍物,障碍物车身黄色提示 + pncWarningOriginTrafficData[trackId] = PlanningTrack( + "#E4DD94FF", + getCurWgs84SatelliteTime() + ) + } + } + }) + } + } + + fun renderOBUWarningObj(exist: Boolean, obuTrafficData: TrafficData) { + if (obuTrafficData.uuid == null || obuTrafficData.uuid!!.isEmpty()) { + return + } + if (exist) { + obuWarningTrafficData[obuTrafficData.uuid!!] = obuTrafficData + } else { + obuWarningTrafficData.remove(obuTrafficData.uuid) + } + } + + fun getObuColor(uuid: String): String { + if (obuWarningTrafficData.containsKey(uuid)) { + return obuWarningTrafficData[uuid]!!.threatLevelColor() + } + return "" + } + + fun getPncColor(uuid: String): String { + if (FunctionBuildConfig.isBeautyMode) { + // 判断物体是否有预警信息 + if (pncWarningBeautyTrafficData.containsKey(uuid)) { + val planningTrack = pncWarningBeautyTrafficData[uuid] + if (planningTrack != null && !timeOut(planningTrack.time)) { + return planningTrack.color + } else { + pncWarningBeautyTrafficData.remove(uuid) + } + } + return "" + } else { + // 判断物体是否有预警信息 + if (pncWarningOriginTrafficData.containsKey(uuid)) { + val planningTrack = pncWarningOriginTrafficData[uuid] + if (planningTrack != null && !timeOut(planningTrack.time)) { + return planningTrack.color + } else { + pncWarningOriginTrafficData.remove(uuid) + } + } + return "" + } + } + + fun clear() { + pncWarningBeautyTrafficData.clear() + pncWarningOriginTrafficData.clear() + obuWarningTrafficData.clear() + } + + private fun timeOut(time: Double): Boolean { + val duration = (getCurWgs84SatelliteTime() * 1000).toLong() - (time * 1000).toLong() + return duration >= 500 + } +} \ No newline at end of file diff --git a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/config/FunctionBuildConfig.kt b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/config/FunctionBuildConfig.kt index 4f12272c8f..ed2b6943ae 100644 --- a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/config/FunctionBuildConfig.kt +++ b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/config/FunctionBuildConfig.kt @@ -80,7 +80,7 @@ object FunctionBuildConfig { var debugTrackerProvider = 0 /** - * 感知物识别使用的数据来源 0 = 默认输出 1 = 只显示工控硬件数据感知来源 2 = 只显示V2V数据来源 3 = 只显示V2N数据来源 + * 感知物识别使用的数据来源 0 = 默认输出 1 = 只显示工控硬件数据感知来源 2 = 只显示V2V数据来源 3 = 只显示V2I数据来源 */ @Volatile @JvmField diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/enums/EventTypeEnum.kt b/modules/mogo-module-common/src/main/java/com/mogo/module/common/enums/EventTypeEnum.kt index 7521d0ac83..2f9a527d69 100644 --- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/enums/EventTypeEnum.kt +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/enums/EventTypeEnum.kt @@ -363,8 +363,8 @@ enum class EventTypeEnum( tts = "" ), - TYPE_VIP_IDENTIFICATION("10022", "", "", R.drawable.icon_warning_v2x_vip_turn_light, "VIP车辆优先通行", "已为您变灯请优先通行"), - TYPE_VIP_ERROR_IDENTIFICATION("10023", "", "", R.drawable.icon_warning_v2x_vip_turn_light, "请求失败,", "请求失败请稍后重试"), + TYPE_VIP_IDENTIFICATION("10022", "", "", R.drawable.icon_warning_v2x_vip_turn_light, "VIP车辆优先通行", "已为您变灯,请优先通行"), + TYPE_VIP_ERROR_IDENTIFICATION("10023", "", "", R.drawable.icon_warning_v2x_vip_turn_light, "请求失败,", "请求失败,请稍后重试"), TYPE_OPTIMAL_ROUTE_RECOMMEND("2000", "", "", R.drawable.icon_warning_v2x_optimal_route, "为您推荐最优路线", "已为您选择最优路线");