fix bug of planning change color
This commit is contained in:
@@ -15,7 +15,8 @@ import mogo.telematics.pad.MessagePad.TrackedObject
|
||||
*
|
||||
* @author donghongyu
|
||||
*/
|
||||
class MapIdentifySubscriber private constructor() : IMoGoSubscriber, IMoGoAutopilotIdentifyListener {
|
||||
class MapIdentifySubscriber private constructor() : IMoGoSubscriber,
|
||||
IMoGoAutopilotIdentifyListener {
|
||||
|
||||
private val TAG = "MapIdentifySubscriber"
|
||||
|
||||
@@ -42,7 +43,9 @@ class MapIdentifySubscriber private constructor() : IMoGoSubscriber, IMoGoAutopi
|
||||
override fun onAutopilotIdentifyDataUpdate(trafficData: List<TrackedObject>?) {
|
||||
try {
|
||||
if (FunctionBuildConfig.isDrawIdentifyData) {
|
||||
ThreadUtils.getSinglePool().execute { IdentifyFactory.renderAdasRecognizedResult(trafficData) }
|
||||
ThreadUtils.getSinglePool().execute {
|
||||
IdentifyFactory.renderAdasRecognizedResult(trafficData)
|
||||
}
|
||||
} else {
|
||||
IdentifyFactory.clearOldMarker()
|
||||
}
|
||||
@@ -54,7 +57,8 @@ class MapIdentifySubscriber private constructor() : IMoGoSubscriber, IMoGoAutopi
|
||||
override fun onAutopilotIdentifyPlanningObj(planningObjects: List<MessagePad.PlanningObject>?) {
|
||||
try {
|
||||
if (FunctionBuildConfig.isDrawIdentifyData) {
|
||||
ThreadUtils.getSinglePool().execute { IdentifyFactory.renderPlanningWarningObj(planningObjects) }
|
||||
ThreadUtils.getSinglePool()
|
||||
.execute { IdentifyFactory.renderPlanningWarningObj(planningObjects) }
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package com.mogo.eagle.core.function.map.identify
|
||||
|
||||
import android.os.Handler
|
||||
import android.os.Message
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
|
||||
import com.mogo.eagle.core.utilcode.mogo.thread.WorkThreadHandler
|
||||
import mogo.telematics.pad.MessagePad
|
||||
import mogo.telematics.pad.MessagePad.TrackedObject
|
||||
|
||||
@@ -14,25 +17,61 @@ object IdentifyFactory : Identify {
|
||||
internal val beautifyDataDrawer = IdentifyBeautifyDataDrawer()
|
||||
}
|
||||
|
||||
override fun renderPlanningWarningObj(planningObjects: List<MessagePad.PlanningObject>?) {
|
||||
identify!!.renderPlanningWarningObj(planningObjects)
|
||||
}
|
||||
|
||||
override fun renderAdasRecognizedResult(resultList: List<TrackedObject>?) {
|
||||
identify!!.renderAdasRecognizedResult(resultList)
|
||||
}
|
||||
|
||||
override fun clearOldMarker() {
|
||||
identify!!.clearOldMarker()
|
||||
}
|
||||
|
||||
private var identify: Identify? = null
|
||||
|
||||
init { //todo 还得加开关做判断
|
||||
init {
|
||||
identify = if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) {
|
||||
UserIdentify.beautifyDataDrawer
|
||||
} else {
|
||||
DriverIdentify.originDataDrawer
|
||||
}
|
||||
}
|
||||
|
||||
private const val MSG_DATA_TRACK = 0
|
||||
private const val MSG_DATA_WARNING = 1
|
||||
private const val MSG_DATA_CLEAR = 2
|
||||
|
||||
// 维护一个线程定时轮询数据进行地图绘制
|
||||
private val mDrawerHandler: Handler =
|
||||
object : Handler(WorkThreadHandler.newInstance("IdentifyFactoryDrawer").looper) {
|
||||
override fun handleMessage(msg: Message) {
|
||||
super.handleMessage(msg)
|
||||
when(msg.what){
|
||||
MSG_DATA_TRACK -> {
|
||||
if(msg.obj is List<*>){
|
||||
identify!!.renderAdasRecognizedResult(msg.obj as List<TrackedObject>?)
|
||||
}
|
||||
}
|
||||
MSG_DATA_WARNING -> {
|
||||
if(msg.obj is List<*>){
|
||||
identify!!.renderPlanningWarningObj(msg.obj as List<MessagePad.PlanningObject>?)
|
||||
}
|
||||
}
|
||||
MSG_DATA_CLEAR ->{
|
||||
identify!!.clearOldMarker()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun renderAdasRecognizedResult(resultList: List<TrackedObject>?) {
|
||||
val message = Message.obtain()
|
||||
message.what = MSG_DATA_TRACK
|
||||
message.obj = resultList
|
||||
mDrawerHandler.sendMessage(message)
|
||||
}
|
||||
|
||||
override fun renderPlanningWarningObj(planningObjects: List<MessagePad.PlanningObject>?) {
|
||||
val message = Message.obtain()
|
||||
message.what = MSG_DATA_WARNING
|
||||
message.obj = planningObjects
|
||||
mDrawerHandler.sendMessage(message)
|
||||
}
|
||||
|
||||
override fun clearOldMarker() {
|
||||
val message = Message.obtain()
|
||||
message.what = MSG_DATA_CLEAR
|
||||
mDrawerHandler.sendMessage(message)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.mogo.eagle.core.function.map.identify
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.util.Log
|
||||
import androidx.collection.ArraySet
|
||||
import com.mogo.commons.AbsMogoApplication
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo
|
||||
@@ -15,7 +14,6 @@ import com.mogo.module.common.MogoApisHandler
|
||||
import mogo.telematics.pad.MessagePad
|
||||
import mogo.telematics.pad.MessagePad.TrackedObject
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import java.util.function.Consumer
|
||||
|
||||
/**
|
||||
* @author xiaoyuzhou
|
||||
@@ -33,6 +31,7 @@ class IdentifyOriginDataDrawer : Identify, IMoGoAutopilotStatusListener {
|
||||
CallerAutoPilotStatusListenerManager.addListener(TAG, this)
|
||||
}
|
||||
|
||||
@Volatile
|
||||
private var mAutopilotStatus: Int = 0 //自动驾驶状态
|
||||
|
||||
/**
|
||||
@@ -40,11 +39,6 @@ class IdentifyOriginDataDrawer : Identify, IMoGoAutopilotStatusListener {
|
||||
*/
|
||||
private val mMarkersCaches = ConcurrentHashMap<String, TrackedObject>()
|
||||
|
||||
/**
|
||||
* kalman缓存数据
|
||||
*/
|
||||
private val algoCache = ConcurrentHashMap<String, KalmanFilter>()
|
||||
|
||||
/**
|
||||
* 记录每次实际绘制的交通元素UUID
|
||||
*/
|
||||
@@ -58,53 +52,31 @@ class IdentifyOriginDataDrawer : Identify, IMoGoAutopilotStatusListener {
|
||||
/**
|
||||
* planning 感知物预警缓存,用于重置color状态
|
||||
*/
|
||||
private val colorTrafficData = ArrayList<String>()
|
||||
|
||||
private val obj = TrackedObject.newBuilder().setUuid(67025).setLongitude(112.57413261072935).setLatitude(26.821571389153718).setHeading(329.9748205834151).setSpeed(0.0).setType(3).build()
|
||||
private val obj1 = TrackedObject.newBuilder().setUuid(3124).setLongitude(112.57433521072935).setLatitude(26.821472689153718).setHeading(329.9748205834151).setSpeed(0.0).setType(3).build()
|
||||
private val obj2 = TrackedObject.newBuilder().setUuid(12).setLongitude(112.57423521072935).setLatitude(26.821372689153718).setHeading(329.9748205834151).setSpeed(0.0).setType(3).build()
|
||||
private val colorTrafficData = ConcurrentHashMap<String, String>()
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
override fun renderPlanningWarningObj(planningObjects: List<MessagePad.PlanningObject>?) {
|
||||
colorTrafficData.clear()
|
||||
//处于美化模式或者自动驾驶状态下展示
|
||||
if(FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData || mAutopilotStatus==2){
|
||||
if (FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData || mAutopilotStatus == 2) {
|
||||
if (planningObjects == null) {
|
||||
Log.d("hy","planningObjects null")
|
||||
if (colorTrafficData.size == 0) {
|
||||
return
|
||||
}
|
||||
colorTrafficData.forEach {
|
||||
val cacheData = mMarkersCaches[it] //todo 是否要直接绘制 还是等下一帧
|
||||
if (cacheData != null) {
|
||||
mMarkersCaches[it] = cacheData.toBuilder().setColor("#D8D8D8FF").build()
|
||||
}
|
||||
}
|
||||
colorTrafficData.clear()
|
||||
return
|
||||
}
|
||||
val tempTrafficData = ArrayList<TrackedObject>()
|
||||
|
||||
// //todo test code 用于模拟感知物
|
||||
// mMarkersCaches["67025"] = obj
|
||||
// mMarkersCaches["3124"] = obj1
|
||||
// mMarkersCaches["12"] = obj2
|
||||
|
||||
mMarkersCaches.forEach { (uuid, data) ->
|
||||
var temp = data
|
||||
planningObjects.forEach {
|
||||
val trackId = it.uuid.toString()
|
||||
if(uuid == trackId){
|
||||
colorTrafficData.add(trackId)
|
||||
temp = data.toBuilder().setColor("#FFBCB239").build()
|
||||
planningObjects.forEach { planningObj ->
|
||||
val trackId = planningObj.uuid.toString()
|
||||
if(mMarkersCaches.containsKey(trackId)){
|
||||
val trackObj = mMarkersCaches[trackId]
|
||||
trackObj?.let {
|
||||
colorTrafficData[trackId] = "#FFBCB239"
|
||||
val temp = it.toBuilder().setColor("#FFBCB239").build()
|
||||
tempTrafficData.add(temp)
|
||||
}
|
||||
}
|
||||
tempTrafficData.add(temp)
|
||||
}
|
||||
|
||||
MogoMarkerManager.getInstance(AbsMogoApplication.getApp())
|
||||
.updateBatchMarkerPosition(tempTrafficData)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -129,18 +101,22 @@ 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) {
|
||||
//CallerLogger.INSTANCE.w(TAG, "未知感知类型数据,丢弃,不渲染");
|
||||
continue
|
||||
}
|
||||
trafficDataUuidList.remove("" + data.uuid)
|
||||
}
|
||||
}
|
||||
trafficDataUuidList.forEach(Consumer { uuid: String ->
|
||||
mMarkersCaches.remove(uuid)
|
||||
algoCache.remove(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(uuid)
|
||||
})
|
||||
.removeMarker(key)
|
||||
}
|
||||
|
||||
val filterList = filterTrafficData(resultList)
|
||||
if (filterList.size > 0) {
|
||||
// 绘制新数据
|
||||
@@ -160,22 +136,24 @@ class IdentifyOriginDataDrawer : Identify, IMoGoAutopilotStatusListener {
|
||||
for (data in trafficData) {
|
||||
// 过滤掉未知感知数据
|
||||
if (!FunctionBuildConfig.isDrawUnknownIdentifyData && data.type == TrafficTypeEnum.TYPE_TRAFFIC_ID_WEI_ZHI.type) {
|
||||
//CallerLogger.INSTANCE.w(TAG, "未知感知类型数据,丢弃,不渲染");
|
||||
continue
|
||||
}
|
||||
var temp:TrackedObject = data
|
||||
val uuid = "" + data.uuid
|
||||
//首次过来的数据不添加,首次未添加的感知物在调用完绘制方法后再塞入cache map
|
||||
val cacheData = mMarkersCaches[uuid]
|
||||
if (cacheData != null) {
|
||||
if (data.speed < 0.5) {
|
||||
data.toBuilder().setHeading(cacheData.heading).setLongitude(cacheData.longitude)
|
||||
temp = data.toBuilder().setHeading(cacheData.heading).setLongitude(cacheData.longitude)
|
||||
.setLatitude(cacheData.latitude).build()
|
||||
}
|
||||
}
|
||||
mMarkersCaches[uuid] = data
|
||||
mMarkersCaches[uuid] = temp
|
||||
trafficDataUuidList.add(uuid)
|
||||
mFilterTrafficData.add(data)
|
||||
//更新已存在的感知物体数据
|
||||
if(colorTrafficData.containsKey(uuid)){
|
||||
continue
|
||||
}
|
||||
mFilterTrafficData.add(temp)
|
||||
}
|
||||
return mFilterTrafficData
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user