From 98c85d9ee5e84bc882aba71ba016e56cd68a841e Mon Sep 17 00:00:00 2001 From: zhongchao Date: Tue, 10 Jan 2023 16:35:00 +0800 Subject: [PATCH] [2.13.2] add func of identify aicloud data --- .../src/main/AndroidManifest.xml | 9 ++ .../business/ai/AiCloudIdentifyDataManager.kt | 77 ++++++++----- .../ai/AiCloudRangeBroadcastReceiver.kt | 30 ++++++ .../ai/net/IAiCloudIdentifyApiService.kt | 2 + .../function/business/identify/Identify.kt | 25 ++++- .../identify/IdentifyAiCloudDataDrawer.kt | 102 ++++++++++++++++++ .../business/identify/IdentifyFactory.kt | 38 ++++++- .../identify/MapIdentifySubscriber.kt | 25 ++++- .../core/function/smp/SmallMapFragment.java | 6 +- .../api/map/marker/IMoGoIdentifyListener.kt | 2 + libraries/mogo-map-api/build.gradle | 1 + .../src/main/java/com/mogo/map/IMogoMap.java | 8 ++ .../mogo/map/marker/IMogoMarkerManager.java | 8 ++ .../main/java/com/mogo/map/AMapWrapper.java | 19 ++++ .../java/com/mogo/map/MogoMarkerManager.java | 10 ++ .../java/com/mogo/map/utils/ObjectUtils.java | 21 ++++ 16 files changed, 346 insertions(+), 37 deletions(-) create mode 100644 core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/ai/AiCloudRangeBroadcastReceiver.kt create mode 100644 core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/IdentifyAiCloudDataDrawer.kt diff --git a/core/function-impl/mogo-core-function-map/src/main/AndroidManifest.xml b/core/function-impl/mogo-core-function-map/src/main/AndroidManifest.xml index fb2b0d007d..c1429480b7 100644 --- a/core/function-impl/mogo-core-function-map/src/main/AndroidManifest.xml +++ b/core/function-impl/mogo-core-function-map/src/main/AndroidManifest.xml @@ -2,4 +2,13 @@ + + + + + + + + + \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/ai/AiCloudIdentifyDataManager.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/ai/AiCloudIdentifyDataManager.kt index f00ba5b09c..631568fccc 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/ai/AiCloudIdentifyDataManager.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/ai/AiCloudIdentifyDataManager.kt @@ -1,54 +1,83 @@ package com.mogo.eagle.core.function.business.ai import android.content.Context -import com.mogo.cloud.socket.entity.SocketDownData +import com.mogo.cloud.socket.IMogoCloudSocketOnMessageListener +import com.mogo.cloud.socket.SocketManager +import com.mogo.cloud.socket.entity.SocketDownData.SocketDownDataProto import com.mogo.eagle.core.function.business.ai.net.AiCloudIdentifyNetWorkModel import com.mogo.eagle.core.function.business.identify.MapIdentifySubscriber -import com.mogo.eagle.core.function.call.map.CallerMapIdentifyManager import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_MAP -import com.mogo.realtime.api.MoGoAiCloudRealTime -import com.mogo.realtime.socket.IMogoCloudOnMsgListener +import com.mogo.map.listener.IMogoMapListener +import com.mogo.map.uicontroller.VisualAngleMode +import com.mogo.module.common.MogoApisHandler +import com.mogo.realtime.constant.RealTimeConstant -class AiCloudIdentifyDataManager { +class AiCloudIdentifyDataManager : IMogoMapListener { companion object { private const val TAG = "AiCloudIdentifyData" + var START_METRE = 140 + var END_METRE = 2000 + @JvmStatic val aiCloudIdentifyDataManager by lazy(LazyThreadSafetyMode.SYNCHRONIZED) { AiCloudIdentifyDataManager() } - - const val START_METRE = 140 - const val END_METRE = 2000 } private val aiCloudIdentifyNetWorkModel = AiCloudIdentifyNetWorkModel() + private var showAiCloud = false fun init(mContext: Context) { - MoGoAiCloudRealTime.registerOnMsgListener(object : IMogoCloudOnMsgListener { - override fun onMsgSend(id: Long) { - } + MogoApisHandler.getInstance().apis.registerCenterApi.registerMogoMapListener(TAG, this) + SocketManager.getInstance() + .registerOnMessageListener( + RealTimeConstant.LOW_FREQUENCY_CHANNEL_ID, + object : IMogoCloudSocketOnMessageListener { + override fun target(msgType: Int): Class { + return SocketDownDataProto::class.java + } - override fun onMsgReceived(mogoSnapshotSetData: SocketDownData.LauncherSnapshotProto?) { - mogoSnapshotSetData?.let { - CallerLogger.d(TAG, "mogoSnapshotSetData : $it") - //todo 感知数据转换 -// MapIdentifySubscriber.instance.onAutopilotIdentifyDataUpdate() - } - } - }) - changeRangeOfIdentify() + override fun onMsgReceived(msgType: Int, obj: SocketDownDataProto?) { + CallerLogger.d("$M_MAP$TAG", "SocketDownDataProto obj : $obj") + obj?.let { + obj.data?.let { + if (showAiCloud) { + if (it.allListList == null || it.allListList.size == 0) { + MapIdentifySubscriber.instance.clearAiCloudRoma() + return + } + MapIdentifySubscriber.instance.renderAiCloudResult(it.allListList) + } + } + } + } + }) + requestRangeOfIdentify() } - //todo 加调试广播 - private fun changeRangeOfIdentify() { + fun requestRangeOfIdentify() { aiCloudIdentifyNetWorkModel.requestIdentifyRange({ - CallerLogger.d(M_MAP + TAG, "requestIdentifyRange ok") + CallerLogger.d( + M_MAP + TAG, + "requestIdentifyRange ok startRange:$START_METRE, endRange:$END_METRE" + ) }, { - CallerLogger.d(M_MAP + TAG, "requestIdentifyRange error : $it") + CallerLogger.d( + M_MAP + TAG, + "requestIdentifyRange error : $it , startRange:$START_METRE, endRange:$END_METRE" + ) }) } + override fun onMapVisualAngleChanged(visualAngleMode: VisualAngleMode) { + super.onMapVisualAngleChanged(visualAngleMode) + showAiCloud = when { + visualAngleMode.isLongSight -> true + else -> 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/business/ai/AiCloudRangeBroadcastReceiver.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/ai/AiCloudRangeBroadcastReceiver.kt new file mode 100644 index 0000000000..a45ec2a068 --- /dev/null +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/ai/AiCloudRangeBroadcastReceiver.kt @@ -0,0 +1,30 @@ +package com.mogo.eagle.core.function.business.ai + +import android.content.BroadcastReceiver +import android.content.Context +import android.content.Intent +import com.mogo.eagle.core.function.business.ai.AiCloudIdentifyDataManager.Companion.END_METRE +import com.mogo.eagle.core.function.business.ai.AiCloudIdentifyDataManager.Companion.START_METRE +import com.mogo.eagle.core.function.business.ai.AiCloudIdentifyDataManager.Companion.aiCloudIdentifyDataManager +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_MAP + +class AiCloudRangeBroadcastReceiver : BroadcastReceiver() { + + companion object { + private const val TAG = "AiCloudRangeBroadcastReceiver" + private const val START_RANGE = "startRange" + private const val END_RANGE = "endRange" + + // adb shell am broadcast -a com.map.aiCloud.notification --ei startRange 140 --ei endRange 2000 + } + + override fun onReceive(context: Context, intent: Intent) { + val startRange = intent.getIntExtra(START_RANGE, START_METRE) + val endRange = intent.getIntExtra(END_RANGE, END_METRE) + START_METRE = startRange + END_METRE = endRange + CallerLogger.d("$M_MAP$TAG", "startRange:$startRange, endRange:$endRange") + aiCloudIdentifyDataManager.requestRangeOfIdentify() + } +} \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/ai/net/IAiCloudIdentifyApiService.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/ai/net/IAiCloudIdentifyApiService.kt index a8050196a8..3ddaac5e43 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/ai/net/IAiCloudIdentifyApiService.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/ai/net/IAiCloudIdentifyApiService.kt @@ -2,10 +2,12 @@ package com.mogo.eagle.core.function.business.ai.net import com.mogo.eagle.core.data.BaseResponse import retrofit2.http.Body +import retrofit2.http.Headers import retrofit2.http.POST interface IAiCloudIdentifyApiService { + @Headers("Content-type:application/json;charset=UTF-8") @POST("yycp-c-v2x-service/dataFusion/remoteDrivingSet") suspend fun identifyRange(@Body map: MutableMap): BaseResponse } \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/Identify.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/Identify.kt index 5f8f399ab5..a631806987 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/Identify.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/Identify.kt @@ -1,20 +1,37 @@ package com.mogo.eagle.core.function.business.identify +import com.mogo.cloud.socket.entity.SocketDownData import com.mogo.eagle.core.data.traffic.TrafficData import mogo.telematics.pad.MessagePad import mogo.telematics.pad.MessagePad.TrackedObject interface Identify { - fun renderAdasRecognizedResult(resultList: List?) + fun renderAdasRecognizedResult(resultList: List?){ - fun renderPlanningWarningObj(planningObjects: List?) + } + + fun renderAiCloudResult(resultList: List){ + + } + + fun renderPlanningWarningObj(planningObjects: List?){ + + } fun renderOBUWarningObj(exist: Boolean, obuTrafficData: TrafficData) { } - fun clearOldMarker() + fun clearOldMarker(){ - fun getIdentifyObj(uuid: String):TrackedObject? + } + + fun clearAiMarker(){ + + } + + fun getIdentifyObj(uuid: String):TrackedObject?{ + return null + } } \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/IdentifyAiCloudDataDrawer.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/IdentifyAiCloudDataDrawer.kt new file mode 100644 index 0000000000..b1ecd75e59 --- /dev/null +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/IdentifyAiCloudDataDrawer.kt @@ -0,0 +1,102 @@ +package com.mogo.eagle.core.function.business.identify + +import android.annotation.SuppressLint +import androidx.collection.ArraySet +import com.mogo.cloud.socket.entity.SocketDownData +import com.mogo.commons.AbsMogoApplication +import com.mogo.commons.module.status.MogoStatusManager +import com.mogo.eagle.core.data.traffic.TrafficData +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.w +import com.mogo.map.MogoMarkerManager +import mogo.telematics.pad.MessagePad.PlanningObject +import mogo.telematics.pad.MessagePad.TrackedObject +import java.util.concurrent.ConcurrentHashMap + +class IdentifyAiCloudDataDrawer : Identify { + + companion object { + private const val TAG = "IdentifyDataDrawer" + } + + /** + * 上一帧数据的缓存 + */ + private val mMarkersCaches = ConcurrentHashMap() + + /** + * 记录每次实际绘制的交通元素UUID + */ + @SuppressLint("NewApi") + private val trafficDataUuidList = ArraySet() + + /** + * 过滤后的数据集合 + */ + @SuppressLint("NewApi") + private val mFilterTrafficData = HashMap() + + @SuppressLint("NewApi") + override fun renderAiCloudResult(resultList: List) { + if (resultList.isEmpty()) { + clearOldMarker() + w(TAG, "感知数据为空无需渲染……") + return + } + if (!MogoStatusManager.getInstance().isVrMode) { + clearOldMarker() + w(TAG, "渲染 adas 识别的数据 当前不是VR模式") + return + } + + //清除缓存 + for (data in resultList) { + if (trafficDataUuidList.size > 0 && trafficDataUuidList.contains("" + data.uuid)) { + trafficDataUuidList.remove("" + data.uuid) + } + } + + //清除缓存,删除marker + val it: MutableIterator<*> = trafficDataUuidList.iterator() + while (it.hasNext()) { + val key = it.next() as String + it.remove() + mMarkersCaches.remove(key) + MogoMarkerManager.getInstance(AbsMogoApplication.getApp()) + .removeMarker(key) + } + + val filterList = filterTrafficData(resultList) + if (filterList.size > 0) { + // 绘制新数据 + MogoMarkerManager.getInstance(AbsMogoApplication.getApp()) + .updateBatchAiMarkerPosition(filterList) + } + } + + /** + * 数据过滤器 + * + * @return 过滤后的数据集合 + */ + @SuppressLint("NewApi") + private fun filterTrafficData(trafficData: List): HashMap { + mFilterTrafficData.clear() + trafficDataUuidList.clear() + for (data in trafficData) { + val uuid = "" + data.uuid + mMarkersCaches[uuid] = data + trafficDataUuidList.add(uuid) + } + return mFilterTrafficData + } + + @SuppressLint("NewApi") + override fun clearAiMarker() { + for (uuid in trafficDataUuidList) { + MogoMarkerManager.getInstance(AbsMogoApplication.getApp()) + .removeMarker(uuid) + } + trafficDataUuidList.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/business/identify/IdentifyFactory.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/IdentifyFactory.kt index fc72dba29c..de05ae1663 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/IdentifyFactory.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/IdentifyFactory.kt @@ -2,6 +2,7 @@ package com.mogo.eagle.core.function.business.identify import android.os.Handler import android.os.Message +import com.mogo.cloud.socket.entity.SocketDownData import com.mogo.eagle.core.data.config.FunctionBuildConfig import com.mogo.eagle.core.data.traffic.TrafficData import com.mogo.eagle.core.function.api.obu.IMoGoObuStatusListener @@ -22,7 +23,12 @@ object IdentifyFactory : Identify, IMoGoObuStatusListener { internal val beautifyDataDrawer = IdentifyBeautifyDataDrawer() } + object AiIdentify { + internal val aiCloudDataDrawer = IdentifyAiCloudDataDrawer() + } + private var identify: Identify? = null + private var aiCloudIdentify: Identify? = null init { identify = if (FunctionBuildConfig.isBeautyMode) { @@ -30,14 +36,17 @@ object IdentifyFactory : Identify, IMoGoObuStatusListener { } else { DriverIdentify.originDataDrawer } + aiCloudIdentify = AiIdentify.aiCloudDataDrawer CallerObuListenerManager.addListener(TAG, this) } private const val MSG_DATA_TRACK = 0 - private const val MSG_DATA_WARNING = 1 - private const val MSG_DATA_OBU_WARNING_UPDATE = 2 - private const val MSG_DATA_OBU_WARNING_REMOVE = 3 - private const val MSG_DATA_CLEAR = 4 + private const val MSG_DATA_AI_TRACK = 1 + private const val MSG_DATA_WARNING = 2 + private const val MSG_DATA_OBU_WARNING_UPDATE = 3 + private const val MSG_DATA_OBU_WARNING_REMOVE = 4 + private const val MSG_DATA_CLEAR = 5 + private const val MSG_DATA_AI_CLEAR = 6 // 维护一个线程定时轮询数据进行地图绘制 private val mDrawerHandler: Handler = @@ -63,6 +72,11 @@ object IdentifyFactory : Identify, IMoGoObuStatusListener { identify!!.renderAdasRecognizedResult(msg.obj as List?) } } + MSG_DATA_AI_TRACK -> { + if (msg.obj is List<*>) { + aiCloudIdentify!!.renderAiCloudResult(msg.obj as List) + } + } MSG_DATA_WARNING -> { if (msg.obj is List<*>) { identify!!.renderPlanningWarningObj(msg.obj as List?) @@ -81,6 +95,9 @@ object IdentifyFactory : Identify, IMoGoObuStatusListener { MSG_DATA_CLEAR -> { identify!!.clearOldMarker() } + MSG_DATA_AI_CLEAR -> { + aiCloudIdentify!!.clearAiMarker() + } } } } @@ -92,6 +109,13 @@ object IdentifyFactory : Identify, IMoGoObuStatusListener { mDrawerHandler.sendMessage(message) } + override fun renderAiCloudResult(resultList: List) { + val message = Message.obtain() + message.what = MSG_DATA_AI_TRACK + message.obj = resultList + mDrawerHandler.sendMessage(message) + } + override fun renderPlanningWarningObj(planningObjects: List?) { val message = Message.obtain() message.what = MSG_DATA_WARNING @@ -105,6 +129,12 @@ object IdentifyFactory : Identify, IMoGoObuStatusListener { mDrawerHandler.sendMessage(message) } + override fun clearAiMarker() { + val message = Message.obtain() + message.what = MSG_DATA_AI_CLEAR + mDrawerHandler.sendMessage(message) + } + override fun getIdentifyObj(uuid: String): TrackedObject? { return identify?.getIdentifyObj(uuid) } diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/MapIdentifySubscriber.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/MapIdentifySubscriber.kt index da726f6703..6c3b8cd627 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/MapIdentifySubscriber.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/MapIdentifySubscriber.kt @@ -2,11 +2,13 @@ package com.mogo.eagle.core.function.business.identify import android.content.Context import com.alibaba.android.arouter.facade.annotation.Route +import com.mogo.cloud.socket.entity.SocketDownData import com.mogo.eagle.core.data.config.FunctionBuildConfig import com.mogo.eagle.core.data.constants.MogoServicePaths.PATH_IDENTIFY import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotIdentifyListener import com.mogo.eagle.core.function.api.base.IMoGoSubscriber import com.mogo.eagle.core.function.api.map.marker.IMoGoIdentifyListener +import com.mogo.eagle.core.function.business.identify.IdentifyFactory.AiIdentify.aiCloudDataDrawer import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListenerManager import com.mogo.eagle.core.utilcode.util.ThreadUtils import mogo.telematics.pad.MessagePad @@ -19,7 +21,7 @@ import mogo.telematics.pad.MessagePad.TrackedObject * @author donghongyu */ @Route(path = PATH_IDENTIFY) -class MapIdentifySubscriber private constructor() :IMoGoIdentifyListener, IMoGoSubscriber, +class MapIdentifySubscriber private constructor() : IMoGoIdentifyListener, IMoGoSubscriber, IMoGoAutopilotIdentifyListener { private val TAG = "MapIdentifySubscriber" @@ -41,7 +43,6 @@ class MapIdentifySubscriber private constructor() :IMoGoIdentifyListener, IMoGoS override fun onDestroy() { CallerAutopilotIdentifyListenerManager.removeListener(TAG) - } override fun onAutopilotIdentifyDataUpdate(trafficData: List?) { @@ -58,6 +59,26 @@ class MapIdentifySubscriber private constructor() :IMoGoIdentifyListener, IMoGoS } } + fun renderAiCloudResult(cloudData: List) { + try { + if (FunctionBuildConfig.isDrawIdentifyData) { + ThreadUtils.getSinglePool().execute { + aiCloudDataDrawer.renderAiCloudResult(cloudData) +// IdentifyFactory.renderAiCloudResult(cloudData) + } + } else { + clearAiCloudRoma() + } + } catch (e: Exception) { + e.printStackTrace() + } + } + + override fun clearAiCloudRoma() { + aiCloudDataDrawer.clearAiMarker() +// IdentifyFactory.clearAiMarker() + } + override fun onAutopilotIdentifyPlanningObj(planningObjects: List?) { try { if (FunctionBuildConfig.isDrawIdentifyData && FunctionBuildConfig.debugTrackerProvider == 0) { diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/SmallMapFragment.java b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/SmallMapFragment.java index 129bf728c3..c8b5804dd4 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/SmallMapFragment.java +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/SmallMapFragment.java @@ -141,12 +141,12 @@ public class SmallMapFragment extends BaseFragment @Override public void onAutopilotStatusResponse(@NotNull AutopilotStatusInfo autoPilotStatusInfo) { int tempStatus = autoPilotStatusInfo.getPilotmode(); - CallerLogger.INSTANCE.i(M_MAP + TAG, "onAutopilotStatusResponse:"+tempStatus+" autoPilotStatus:"+autoPilotStatus); +// CallerLogger.INSTANCE.i(M_MAP + TAG, "onAutopilotStatusResponse:"+tempStatus+" autoPilotStatus:"+autoPilotStatus); if (tempStatus != 1) { - CallerLogger.INSTANCE.i(M_MAP + TAG, "onAutopilotStatusResponse:"+tempStatus+" clearPolyline"); +// CallerLogger.INSTANCE.i(M_MAP + TAG, "onAutopilotStatusResponse:"+tempStatus+" clearPolyline"); clearPolyline(); }else if (tempStatus == 1 && autoPilotStatus == 0){ - CallerLogger.INSTANCE.i(M_MAP + TAG, "onAutopilotStatusResponse:getGlobalPath"); +// CallerLogger.INSTANCE.i(M_MAP + TAG, "onAutopilotStatusResponse:getGlobalPath"); CallerAutoPilotManager.INSTANCE.getGlobalPath(); } autoPilotStatus = tempStatus; diff --git a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/map/marker/IMoGoIdentifyListener.kt b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/map/marker/IMoGoIdentifyListener.kt index 168b5071b9..4a2569711f 100644 --- a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/map/marker/IMoGoIdentifyListener.kt +++ b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/map/marker/IMoGoIdentifyListener.kt @@ -6,4 +6,6 @@ import mogo.telematics.pad.MessagePad interface IMoGoIdentifyListener :IProvider{ fun getIdentifyObj(uuid: String): MessagePad.TrackedObject? + + fun clearAiCloudRoma() } \ No newline at end of file diff --git a/libraries/mogo-map-api/build.gradle b/libraries/mogo-map-api/build.gradle index 526a5fcf82..9c31207e62 100644 --- a/libraries/mogo-map-api/build.gradle +++ b/libraries/mogo-map-api/build.gradle @@ -55,6 +55,7 @@ dependencies { implementation project(':core:mogo-core-utils') implementation project(':core:mogo-core-data') } + implementation rootProject.ext.dependencies.mogoaicloudsocket } apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString() diff --git a/libraries/mogo-map-api/src/main/java/com/mogo/map/IMogoMap.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/IMogoMap.java index 267f3f18c8..f8947dcd4c 100644 --- a/libraries/mogo-map-api/src/main/java/com/mogo/map/IMogoMap.java +++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/IMogoMap.java @@ -1,5 +1,6 @@ package com.mogo.map; +import com.mogo.cloud.socket.entity.SocketDownData; import com.mogo.eagle.core.data.map.MogoLatLng; import com.mogo.map.center.CenterLine; import com.mogo.map.marker.IMogoMarker; @@ -53,6 +54,13 @@ public interface IMogoMap { */ void updateBatchMarkerPosition(HashMap optionsArrayList); + /** + * 批量更新锚点位置 + * + * @param optionsArrayList 锚点集合 + */ + void updateBatchAiMarkerPosition(HashMap optionsArrayList); + /** * 添加感知使用到的3d模型 * diff --git a/libraries/mogo-map-api/src/main/java/com/mogo/map/marker/IMogoMarkerManager.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/marker/IMogoMarkerManager.java index 626bfd6b4f..114864bcf3 100644 --- a/libraries/mogo-map-api/src/main/java/com/mogo/map/marker/IMogoMarkerManager.java +++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/marker/IMogoMarkerManager.java @@ -2,6 +2,7 @@ package com.mogo.map.marker; import android.content.Context; +import com.mogo.cloud.socket.entity.SocketDownData; import com.mogo.eagle.core.data.map.MogoLatLng; import java.util.ArrayList; @@ -44,6 +45,13 @@ public interface IMogoMarkerManager { */ void updateBatchMarkerPosition(HashMap optionsArrayList); + /** + * 批量更新锚点位置 + * + * @param optionsArrayList 锚点集合 + */ + void updateBatchAiMarkerPosition(HashMap optionsArrayList); + /** * 添加感知使用到的3d模型 * diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/AMapWrapper.java b/libraries/mogo-map/src/main/java/com/mogo/map/AMapWrapper.java index 721feaaeb7..0736b84625 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/AMapWrapper.java +++ b/libraries/mogo-map/src/main/java/com/mogo/map/AMapWrapper.java @@ -5,6 +5,7 @@ import android.content.Context; import android.graphics.Point; import android.util.Pair; +import com.mogo.cloud.socket.entity.SocketDownData; import com.mogo.eagle.core.data.config.FunctionBuildConfig; import com.mogo.eagle.core.data.map.MogoLatLng; import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; @@ -124,6 +125,24 @@ public class AMapWrapper implements IMogoMap { MarkerHelper.INSTANCE.updateBatchMarkerPositon(markerOptionsArrayList, false, FunctionBuildConfig.isBeautyMode ? 8.0f : 0f, 1, time, 1); } + @SuppressLint("NewApi") + @Override + public void updateBatchAiMarkerPosition(HashMap optionsArrayList) { + if (!checkAMap()) { + return; + } + ArrayList markerOptionsArrayList = new ArrayList<>(); + optionsArrayList.forEach((s, trackedObject) -> { + MarkerSimpleData markerOptions = ObjectUtils.fromAiData(trackedObject); + if (markerOptions != null) { + markerOptionsArrayList.add(markerOptions); + } + }); + long time = markerOptionsArrayList.get(0).getTime(); + MarkerHelper.INSTANCE.updateBatchMarkerPositon(markerOptionsArrayList, false, FunctionBuildConfig.isBeautyMode ? 8.0f : 0f, 1, time, 1); + + } + @Override public String addPreVehicleModel(int type, int modelRes) { try { diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/MogoMarkerManager.java b/libraries/mogo-map/src/main/java/com/mogo/map/MogoMarkerManager.java index 184dabddf4..4fa17ca67d 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/MogoMarkerManager.java +++ b/libraries/mogo-map/src/main/java/com/mogo/map/MogoMarkerManager.java @@ -2,6 +2,7 @@ package com.mogo.map; import android.content.Context; +import com.mogo.cloud.socket.entity.SocketDownData; import com.mogo.eagle.core.data.map.MogoLatLng; import com.mogo.eagle.core.function.call.v2x.CallMarkersClearManager; import com.mogo.map.marker.IMogoMarker; @@ -79,6 +80,15 @@ public class MogoMarkerManager implements IMogoMarkerManager { } } + @Override + public void updateBatchAiMarkerPosition(HashMap optionsArrayList) { + try { + MogoMap.getInstance().getMogoMap().updateBatchAiMarkerPosition(optionsArrayList); + } catch (Exception e) { + e.printStackTrace(); + } + } + @Override public String addPreVehicleModel(int type, int modelRes) { try { diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/utils/ObjectUtils.java b/libraries/mogo-map/src/main/java/com/mogo/map/utils/ObjectUtils.java index a681ad9254..4749f60061 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/utils/ObjectUtils.java +++ b/libraries/mogo-map/src/main/java/com/mogo/map/utils/ObjectUtils.java @@ -5,6 +5,7 @@ import android.graphics.Color; import android.text.TextUtils; import android.view.View; +import com.mogo.cloud.socket.entity.SocketDownData; import com.mogo.eagle.core.data.map.CenterLine; import com.mogo.eagle.core.data.map.MogoLatLng; import com.mogo.eagle.core.data.map.MogoLocation; @@ -142,6 +143,26 @@ public class ObjectUtils { return markerOptions; } + public static MarkerSimpleData fromAiData(SocketDownData.CloudRoadDataProto aiData) { + if (aiData == null) { + return null; + } + MarkerSimpleData markerOptions = null; + try { + markerOptions = new MarkerSimpleData(); + markerOptions.setId(aiData.getUuid().hashCode()); + markerOptions.setMarkerType(aiData.getType()); + markerOptions.setRotateAngle((float) aiData.getHeading()); + markerOptions.setLat(aiData.getWgslat()); + markerOptions.setLon(aiData.getWgslon()); + markerOptions.setTime(Double.valueOf(aiData.getSatelliteTime()).longValue()); + markerOptions.setColor("#00000000"); + } catch (Exception e) { + e.printStackTrace(); + } + return markerOptions; + } + private static BitmapDescriptor getBitmapDescriptorFromMogo(MogoMarkerOptions options) { if (options == null) { return null;