[2.13.2] add func of identify aicloud data

This commit is contained in:
zhongchao
2023-01-10 16:35:00 +08:00
parent 775ec4be60
commit 98c85d9ee5
16 changed files with 346 additions and 37 deletions

View File

@@ -2,4 +2,13 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mogo.eagle.core.function.map">
<application>
<receiver android:name="com.mogo.eagle.core.function.business.ai.AiCloudRangeBroadcastReceiver">
<intent-filter>
<action android:name="com.map.aiCloud.notification" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
</application>
</manifest>

View File

@@ -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<SocketDownDataProto> {
override fun target(msgType: Int): Class<SocketDownDataProto> {
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
}
}
}

View File

@@ -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()
}
}

View File

@@ -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<String, Any>): BaseResponse<Any>
}

View File

@@ -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<TrackedObject>?)
fun renderAdasRecognizedResult(resultList: List<TrackedObject>?){
fun renderPlanningWarningObj(planningObjects: List<MessagePad.PlanningObject>?)
}
fun renderAiCloudResult(resultList: List<SocketDownData.CloudRoadDataProto>){
}
fun renderPlanningWarningObj(planningObjects: List<MessagePad.PlanningObject>?){
}
fun renderOBUWarningObj(exist: Boolean, obuTrafficData: TrafficData) {
}
fun clearOldMarker()
fun clearOldMarker(){
fun getIdentifyObj(uuid: String):TrackedObject?
}
fun clearAiMarker(){
}
fun getIdentifyObj(uuid: String):TrackedObject?{
return null
}
}

View File

@@ -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<String, SocketDownData.CloudRoadDataProto>()
/**
* 记录每次实际绘制的交通元素UUID
*/
@SuppressLint("NewApi")
private val trafficDataUuidList = ArraySet<String>()
/**
* 过滤后的数据集合
*/
@SuppressLint("NewApi")
private val mFilterTrafficData = HashMap<String, SocketDownData.CloudRoadDataProto>()
@SuppressLint("NewApi")
override fun renderAiCloudResult(resultList: List<SocketDownData.CloudRoadDataProto>) {
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<SocketDownData.CloudRoadDataProto>): HashMap<String, SocketDownData.CloudRoadDataProto> {
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()
}
}

View File

@@ -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<TrackedObject>?)
}
}
MSG_DATA_AI_TRACK -> {
if (msg.obj is List<*>) {
aiCloudIdentify!!.renderAiCloudResult(msg.obj as List<SocketDownData.CloudRoadDataProto>)
}
}
MSG_DATA_WARNING -> {
if (msg.obj is List<*>) {
identify!!.renderPlanningWarningObj(msg.obj as List<MessagePad.PlanningObject>?)
@@ -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<SocketDownData.CloudRoadDataProto>) {
val message = Message.obtain()
message.what = MSG_DATA_AI_TRACK
message.obj = resultList
mDrawerHandler.sendMessage(message)
}
override fun renderPlanningWarningObj(planningObjects: List<MessagePad.PlanningObject>?) {
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)
}

View File

@@ -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<TrackedObject>?) {
@@ -58,6 +59,26 @@ class MapIdentifySubscriber private constructor() :IMoGoIdentifyListener, IMoGoS
}
}
fun renderAiCloudResult(cloudData: List<SocketDownData.CloudRoadDataProto>) {
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<MessagePad.PlanningObject>?) {
try {
if (FunctionBuildConfig.isDrawIdentifyData && FunctionBuildConfig.debugTrackerProvider == 0) {

View File

@@ -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;