A、加入针对260之前的Docker版本不做点云绘制操作的判断

Signed-off-by: donghongyu <donghongyu@zhidaoauto.com>
This commit is contained in:
donghongyu
2022-09-05 19:05:15 +08:00
parent 543c571ca8
commit d83fecfcee
3 changed files with 51 additions and 27 deletions

View File

@@ -1,13 +1,14 @@
package com.mogo.eagle.core.function.map
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo
import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotPointCloudListener
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
import com.mogo.eagle.core.function.api.base.IMoGoSubscriber
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotPointCloudListenerManager
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
import com.zhidaoauto.map.sdk.open.business.PointCloudHelper
import mogo.telematics.pad.MessagePad
import rule_segement.MogoPointCloudOuterClass
import java.math.BigDecimal
/**
@@ -16,12 +17,15 @@ import java.math.BigDecimal
*
* @author donghongyu
*/
class MapPointCloudSubscriber private constructor() : IMoGoSubscriber, IMoGoAutopilotPointCloudListener {
class MapPointCloudSubscriber private constructor()
: IMoGoSubscriber, IMoGoAutopilotPointCloudListener, IMoGoAutopilotStatusListener {
private val TAG = "MapPointCloudSubscriber"
private var isDrawPointCloud = false
private var mAutoPilotStatusInfo: AutopilotStatusInfo? = null
init {
onCrate()
}
@@ -34,16 +38,18 @@ class MapPointCloudSubscriber private constructor() : IMoGoSubscriber, IMoGoAuto
override fun onCrate() {
CallerAutopilotPointCloudListenerManager.addListener(TAG, this)
// 添加 ADAS状态 监听
CallerAutoPilotStatusListenerManager.addListener(TAG, this)
}
override fun onDestroy() {
CallerAutopilotPointCloudListenerManager.removeListener(TAG)
CallerAutoPilotStatusListenerManager.removeListener(TAG)
}
override fun onAutopilotPointCloudDataUpdate(pointCloud: ByteArray?) {
try {// 根据配置动态控制点云是否绘制
if (FunctionBuildConfig.isDrawPointCloudData) {
if (FunctionBuildConfig.isDrawPointCloudData && isDrawCloudPointDockerVersion()) {
if (!isDrawPointCloud) {
Logger.d(TAG, "====开启点云渲染====")
isDrawPointCloud = true
@@ -74,13 +80,48 @@ class MapPointCloudSubscriber private constructor() : IMoGoSubscriber, IMoGoAuto
}
}
override fun onAutopilotPointCloudDataUpdate(header: MessagePad.Header?, pointCloud: MogoPointCloudOuterClass.MogoPointCloud?) {
// Logger.d(TAG, "数据对比:"
// + "\n自车定位自车的 satelliteTime==${getPrettyNumber(CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().satelliteTime.toString())} 经纬度:${CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().locationLat},${CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().locationLon}"
// + "\n点云数据点云的 header?.timestamp==${getPrettyNumber(header?.timestamp.toString())} 经纬度:${pointCloud?.selfLatitude},${pointCloud?.selfLongitude} 点云数量addDataCount==${pointCloud?.addDataCount} delDataCount===${pointCloud?.delDataCount} "
// )
override fun onAutopilotStatusResponse(autoPilotStatusInfo: AutopilotStatusInfo) {
mAutoPilotStatusInfo = autoPilotStatusInfo
}
/**
* 判断是否是260之后但版本
*/
fun isDrawCloudPointDockerVersion(): Boolean {
// 由于Docker命名规则不统一但核心版本是统一但采用"."分割,如下
// MAP-taxi_RoboTaxi_Default_2.2.0_badcasetest_20220215_dev
val dockerVersionName = mAutoPilotStatusInfo?.dockVersion
// "." 分割,取前两位
val dockerVersionNameArray = dockerVersionName?.split(".")
var dockerVersionCode = ""
dockerVersionNameArray?.let {
if (it.size > 3) {
for (index in 0 until 3) {
dockerVersionCode +=
when (index) {
0 -> {
it[index].substring(it[index].lastIndex)
}
it.size - 1 -> {
it[index].substring(0, 1)
}
else -> {
it[index]
}
}
}
}
}
val dockerVersion = dockerVersionCode.toInt()
if (dockerVersion >= 260) {
return true
}
return false
}
fun getPrettyNumber(number: String): String {
return BigDecimal.valueOf(number.toDouble())
.stripTrailingZeros().toPlainString()