Merge branch 'dev_minibus-d_230425_3.2.0' into code_opt_3.3.0

This commit is contained in:
zhongchao
2023-06-01 19:57:23 +08:00
211 changed files with 321 additions and 17329 deletions

View File

@@ -281,6 +281,7 @@ class MoGoAutopilotControlProvider :
SharedPrefsMgr.getInstance(it).putString(MoGoConfig.AUTOPILOT_IP, autoPilotIp)
}
// 设置IP地址
AdasManager.getInstance().adasOptions.isClient = false
AdasManager.getInstance().adasOptions.ipcConnectionMode =
AdasOptions.IPC_CONNECTION_MODE.ASSIGN
AdasManager.getInstance().adasOptions.ipcAssignIP = autoPilotIp

View File

@@ -288,9 +288,6 @@ class MoGoAdasListenerImpl : OnAdasListener {
autopilotStatusInfo.state = autopilotState.state
autopilotStatusInfo.pilotmode = autopilotState.autopilotMode
autopilotStatusInfo.reason = autopilotState.reason
autopilotStatusInfo.camera = autopilotState.camera
autopilotStatusInfo.rtk = autopilotState.rtk
autopilotStatusInfo.radar = autopilotState.radar
autopilotStatusInfo.version = AdasManager.getInstance().adasVersion
if (autopilotStatusInfo.connectIP == null) {
autopilotStatusInfo.connectIP = AdasManager.getInstance().ipcConnectedIp

View File

@@ -1,10 +1,24 @@
package com.mogo.eagle.core.function.datacenter.autopilot.server
import android.annotation.SuppressLint
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo
import com.mogo.eagle.core.data.biz.trafficlight.TrafficLightResult
import com.mogo.eagle.core.data.deva.chain.ChainConstant
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
import com.mogo.eagle.core.function.api.datacenter.union.IMoGoTrafficLightListener
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
import com.mogo.eagle.core.function.call.v2x.CallerTrafficLightListenerManager
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
import com.zhidao.support.adas.high.AdasManager
import com.zhjt.service.chain.ChainLog
import com.zhjt.service.chain.TracingConstants.Endpoint.Companion.PAD
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable
import java.util.concurrent.TimeUnit
import java.util.concurrent.atomic.AtomicInteger
/**
* @author xiaoyuzhou
@@ -14,7 +28,8 @@ import com.zhidao.support.adas.high.AdasManager
* 异步同步数据给 Autopilot 控制器
* 数据源不限于OBU、网络等
*/
class AsyncDataToAutopilotServer private constructor() : IMoGoTrafficLightListener {
class AsyncDataToAutopilotServer private constructor() : IMoGoTrafficLightListener,
IMoGoAutopilotStatusListener {
companion object {
const val TAG = "AsyncDataToAutopilotServer"
val INSTANCE: AsyncDataToAutopilotServer by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
@@ -22,10 +37,41 @@ class AsyncDataToAutopilotServer private constructor() : IMoGoTrafficLightListen
}
}
private var mPreAutoStatus = AtomicInteger(-1)
private var createSubscribe: Disposable? = null
fun initServer() {
CallerAutoPilotStatusListenerManager.addListener(TAG, this)
CallerTrafficLightListenerManager.addListener(TAG, this)
}
@SuppressLint("CheckResult")
override fun onAutopilotStatusResponse(autoPilotStatusInfo: AutopilotStatusInfo) {
super.onAutopilotStatusResponse(autoPilotStatusInfo)
val state = autoPilotStatusInfo.state
if (mPreAutoStatus.get() != state) {
mPreAutoStatus.set(state)
createSubscribe?.let {
if (!it.isDisposed) {
bizLog(SceneConstant.M_ADAS_IMPL + TAG, "自动驾驶状态变化取消前置轨迹请求间隔2s重新请求底盘轨迹")
createSubscribe?.dispose()
}
}
when (state) {
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING -> {
createSubscribe = Observable.timer(2000L, TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread())
.subscribe {
bizLog(SceneConstant.M_ADAS_IMPL + TAG, "请求底盘轨迹")
CallerAutoPilotControlManager.getGlobalPath()
}
}
else -> {}
}
}
}
override fun onTrafficLightStatus(trafficLightResult: TrafficLightResult) {
var version = -1
if (AdasManager.getInstance().carConfig != null) {
@@ -34,4 +80,16 @@ class AsyncDataToAutopilotServer private constructor() : IMoGoTrafficLightListen
if (version > -1 && version < 290)
CallerAutoPilotControlManager.sendTrafficLightData(trafficLightResult)
}
@ChainLog(
linkChainLog = ChainConstant.CHAIN_LINK_LOG_WEB_SOCKET_AUTOPILOT,
linkCode = ChainConstant.CHAIN_LINK_ADAS,
endpoint = PAD,
nodeAliasCode = ChainConstant.CHAIN_ALIAS_CODE_ADAS_MESSAGE_AUTOPILOT_BIZ,
paramIndexes = [0, 1],
clientPkFileName = "sn"
)
private fun bizLog(tag: String, msg: String) {
CallerLogger.d(tag, msg)
}
}

View File

@@ -1,6 +1,7 @@
package com.mogo.eagle.core.function.datacenter.v2x
import android.content.Context
import android.os.CountDownTimer
import android.os.Handler
import com.mogo.eagle.core.data.biz.trafficlight.*
import com.mogo.eagle.core.data.config.FunctionBuildConfig
@@ -63,6 +64,9 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLight
@Volatile
private var hasObuLightStatus: Boolean = false
private var lightCountDownTimer: CountDownTimer?= null
private var lastLightTime: Long = System.currentTimeMillis()
fun initServer(context: Context) {
mContext = context
//注册监听AI云.OBU路侧获取红绿灯状态
@@ -79,6 +83,28 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLight
CallerLogger.d("${SceneConstant.M_OBU}${TAG}", "onAutopilotPerceptionTrafficLight ---- hasObuLightStatus = $hasObuLightStatus ----hasAiLightStatus = $hasAiLightStatus ")
if (!hasObuLightStatus) {
if (!hasAiLightStatus) {
lastLightTime = System.currentTimeMillis()
if(lightCountDownTimer==null){
lightCountDownTimer = object: CountDownTimer(300000,1000){
override fun onTick(millisUntilFinished: Long) {
if((System.currentTimeMillis() - lastLightTime)>1000){
//隐藏红绿灯显示
CallerTrafficLightListenerManager.disableTrafficLight()
lightCountDownTimer?.cancel()
lightCountDownTimer = null
}
}
override fun onFinish() {
lightCountDownTimer?.cancel()
lightCountDownTimer = null
}
}
lightCountDownTimer?.start()
}
trafficLights?.let { it ->
var light: TrafficLight? = null
if (it.hasStraight()) {
@@ -205,7 +231,7 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLight
CallerTrafficLightListenerManager.changeCountdownYellow(remain)
}
TrafficLightEnum.BLACK -> {
CallerTrafficLightListenerManager.disableTrafficLightCountDown()
CallerTrafficLightListenerManager.disableTrafficLight()
}
else -> {
hide()

View File

@@ -11,7 +11,6 @@ import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
import com.mogo.eagle.core.function.api.autopilot.IMoGoPlanningRottingListener
import com.mogo.eagle.core.function.business.ai.net.AiCloudIdentifyNetWorkModel.Companion.aiCloudIdentifyNetWorkModel
import com.mogo.eagle.core.function.business.identify.MapIdentifySubscriber
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListenerManager
@@ -50,7 +49,6 @@ class AiCloudIdentifyDataManager : IMogoMapListener,
MogoMapListenerHandler.mogoMapListenerHandler.registerHostMapListener(TAG, this)
CallerAutoPilotStatusListenerManager.addListener(TAG, this)
CallerPlanningRottingListenerManager.addListener(TAG,this)
CallerAutoPilotControlManager.getGlobalPath()
MogoAiCloudSocketManager.getInstance(mContext)
.registerOnMessageListener(
0x040003, //低频数据
@@ -163,8 +161,6 @@ class AiCloudIdentifyDataManager : IMogoMapListener,
super.onAutopilotRouteLineId(lineId)
if (lineId == 0L) {
updateRomaStyle(true)
}else{
CallerAutoPilotControlManager.getGlobalPath()
}
}

View File

@@ -0,0 +1,58 @@
package com.mogo.eagle.core.function.business.cachemap
import android.util.Log
import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.data.map.MogoLocation
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationWGS84Listener
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
import com.mogo.eagle.core.utilcode.util.ThreadUtils
import com.mogo.map.hdcache.IHdCacheListener
object CacheHDMapManager: IMoGoChassisLocationWGS84Listener {
private const val TAG = "CacheHDMapManager"
@Volatile
private var location: MogoLocation? = null
fun scheduleGetLocation() {
if (!AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) {
CallerChassisLocationWGS84ListenerManager.addListener(TAG, this)
ThreadUtils.getIoPool().execute {
if (!CallerMapUIServiceManager.isCityDataCached()) {
while (true) {
if (location != null) {
Log.d(TAG, "开始下载")
CallerMapUIServiceManager.cacheHDDataByCityByLonLat(object : IHdCacheListener {
override fun onMapHdCacheProgress(cityId: Int, progress: Double) {
Log.d(TAG, "下载进度:${progress.toInt()}")
}
override fun onMapHdCacheResult(cityId: Int, state: Int) {
if (state == 0) {
Log.d(TAG, "下载失败")
}
}
}, location!!)
Log.d(TAG, "移除监听并关闭循环")
CallerChassisLocationWGS84ListenerManager.removeListener(TAG)
return@execute
}
try {
Log.d(TAG, "开始休眠...")
Thread.sleep(1500)
} catch (e: Exception) {}
}
} else {
Log.d(TAG, "高精地图缓存已下载!")
}
}
}
}
override fun onChassisLocationWGS84(gnssInfo: MogoLocation) {
location = gnssInfo
}
}

View File

@@ -12,6 +12,7 @@ import com.mogo.eagle.core.data.map.MogoLocation
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotRecordListener
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener
import com.mogo.eagle.core.function.api.map.collect.IMoGoMapDataCollectProvider
import com.mogo.eagle.core.function.business.cachemap.CacheHDMapManager
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotRecordListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
@@ -73,6 +74,7 @@ class MoGoMapDataCollectProvider : IMoGoMapDataCollectProvider, OnTaskListener,
MoGoAiCloudClient.getInstance().addTokenCallbacks(this)
CallerLogger.d("$M_MAP$TAG", "--------- init --------")
CallerLogger.d("$M_MAP$TAG", "executor: ${executor.get()?.hashCode() ?: 0}")
CacheHDMapManager.scheduleGetLocation()
}
override fun onDestroy() {

View File

@@ -130,16 +130,16 @@ object MarkerDrawerManager {
heading
) >= 90
) {
currentIndex = if (i < lastArrivedIndex) {
lastArrivedIndex
} else {
lastArrivedIndex = i
i
}
Log.d("MarkerDrawerManager", "已走过的点的索引为:$currentIndex")
currentIndex = i
}
}
}
Log.d("MarkerDrawerManager", "当次计算已走过的点的索引为:$currentIndex,存储的上次索引为:$lastArrivedIndex")
if (currentIndex < lastArrivedIndex) {
currentIndex = lastArrivedIndex
} else {
lastArrivedIndex = currentIndex
}
newPoints.addAll(routePoints)
newPoints.add(currentIndex + 1, LatLng(realLat, realLon))
return currentIndex + 1

View File

@@ -17,7 +17,6 @@ import com.mogo.eagle.core.data.map.MogoLocation
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener
import com.mogo.eagle.core.function.api.autopilot.IMoGoPlanningRottingListener
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager.getGlobalPath
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListenerManager
@@ -296,10 +295,10 @@ class SmallMapView @JvmOverloads constructor(
endLatLng.latitude, endLatLng.longitude,
currentLatLng.latitude, currentLatLng.longitude
)
CallerLogger.d(
SceneConstant.M_MAP + TAG,
"calculateDistance=$calculateDistance"
)
// CallerLogger.d(
// SceneConstant.M_MAP + TAG,
// "calculateDistance=$calculateDistance"
// )
if (calculateDistance <= 5) {
CallerLogger.d(
SceneConstant.M_MAP + TAG, "onChassisLocationGCJ02 -----> calculateDistance <= 5 ")
@@ -325,8 +324,6 @@ class SmallMapView @JvmOverloads constructor(
UiThreadHandler.post {
clearPolyline()
}
} else if (tempStatus == 1 && autoPilotStatus == 0) {
getGlobalPath()
}
autoPilotStatus = tempStatus
}

View File

@@ -20,7 +20,6 @@ import com.amap.api.maps.CameraUpdate
import com.amap.api.maps.CameraUpdateFactory
import com.amap.api.maps.TextureMapView
import com.amap.api.maps.model.*
import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.data.map.Infrastructure
import com.mogo.eagle.core.data.map.MogoLocation
import com.mogo.eagle.core.data.v2x.Center
@@ -29,7 +28,6 @@ import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Liste
import com.mogo.eagle.core.function.api.autopilot.IMoGoPlanningRottingListener
import com.mogo.eagle.core.function.api.autopilot.IMoGoV2XListener
import com.mogo.eagle.core.function.api.biz.IFuncBizProvider
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager.getGlobalPath
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerV2XListenerManager
@@ -49,9 +47,12 @@ import com.mogo.eagle.core.function.smp.V2XMarkerView
import com.mogo.eagle.core.utilcode.mogo.MapAssetStyleUtils
import com.mogo.eagle.core.utilcode.util.ThreadUtils
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
import com.zhidaoauto.map.sdk.open.tools.ThreadPoolUtils
import me.jessyan.autosize.utils.AutoSizeUtils
import mogo.telematics.pad.MessagePad
import mogo.v2x.MogoV2X
import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
import kotlin.math.pow
/**
@@ -126,6 +127,10 @@ class OverMapView @JvmOverloads constructor(
@Volatile
private var isInit = false
private val singlePool by lazy {
Executors.newSingleThreadExecutor()
}
companion object {
const val TAG = "OverMapView"
}
@@ -408,8 +413,6 @@ class OverMapView @JvmOverloads constructor(
}
})
CallerV2XListenerManager.addListener(TAG, this)
// 主动查一次全局路径规划的数据
getGlobalPath()
}
private fun setUpMap() {
@@ -468,38 +471,36 @@ class OverMapView @JvmOverloads constructor(
return
}
val list: List<MessagePad.Location> = locationList
ThreadUtils.getSinglePool().submit {
lastArrivedIndex = -1
// 转成高德坐标系并存储
updateRoutePoints(list, mContext!!)
val planningPointList: List<LatLng> = planningPoints
UiThreadHandler.post {
displayCustomOverView()
drawStartAndEndMarker(planningPointList)
if (geoHashInfMap.isNullOrEmpty()) {
UiThreadHandler.postDelayed({
drawInfrastructureMarkers(locationList)
}, 1000)
} else {
drawInfrastructureMarkers(locationList)
}
}
}
// 转成高德坐标系并存储
updateRoutePoints(list, mContext!!)
val planningPointList: List<LatLng> = planningPoints
UiThreadHandler.post ({
displayCustomOverView()
drawStartAndEndMarker(planningPointList)
}, UiThreadHandler.MODE.QUEUE)
if (!isInit) {
callback = object : MarkerDrawerManager.Callback {
override fun onLocationChanged(planningPoints: List<LatLng>, locIndex: Int) {
// 每1s刷新一下轨迹线
UiThreadHandler.post {
UiThreadHandler.post ({
if (planningPoints.isNotEmpty()) {
drawPolyline(planningPoints, locIndex)
}
}
}, UiThreadHandler.MODE.QUEUE)
}
}
startLoopCalCarLocation()
isInit = true
}
UiThreadHandler.post({
if (geoHashInfMap.isNullOrEmpty()) {
UiThreadHandler.postDelayed({
drawInfrastructureMarkers(locationList)
}, 1000, UiThreadHandler.MODE.QUEUE)
} else {
drawInfrastructureMarkers(locationList)
}
}, UiThreadHandler.MODE.QUEUE)
}
/**
@@ -884,7 +885,9 @@ class OverMapView @JvmOverloads constructor(
*/
override fun onAutopilotRotting(globalPathResp: MessagePad.GlobalPathResp?) {
globalPathResp?.let {
handlePlanningData(it.wayPointsList)
singlePool.execute {
handlePlanningData(it.wayPointsList)
}
}
}
@@ -948,8 +951,8 @@ class OverMapView @JvmOverloads constructor(
)
}
}
UiThreadHandler.post {
UiThreadHandler.post({
showV2XEventMarkers(list)
}
}, UiThreadHandler.MODE.QUEUE)
}
}