[dev_arch_opt_3.0]

[Change]
[
1、完成工控机数据和高德GPS地图数据的数据中心,以及工控机数据超时后的自动切换为高德地图GPS数据
定位监听已重构,CallerChassisLocationGCJ20ListenerManager---高的坐标系,CallerChassisLocationWGS84ListenerManager--高精坐标系,之前代码已修改,大家后续项目中根据需要进行订阅,如需控制频率可在订阅时
// 设置数据回调频率,单位HZ,1HZ的周期是1秒;50HZ的周期是1/50=0.02秒;10HZ的周期是1/10=0.1秒。
CallerChassisLocationWGS84ListenerManager.setListenerHz(Companion.functionName, 20)
CallerChassisLocationGCJ20ListenerManagersetListenerHz(Companion.functionName, 20)
]

Signed-off-by: donghongyu <donghongyu@zhidaoauto.com>
This commit is contained in:
donghongyu
2023-02-02 19:24:38 +08:00
parent 0a4b0be72a
commit 111940123f
107 changed files with 963 additions and 724 deletions

View File

@@ -57,6 +57,7 @@ dependencies {
implementation rootProject.ext.dependencies.mogoaicloudtelematic
implementation rootProject.ext.dependencies.mogoobu
implementation rootProject.ext.dependencies.amapnavi3dmap
if (Boolean.valueOf(USE_MAVEN_PACKAGE)) {
implementation rootProject.ext.dependencies.mogo_core_data

View File

@@ -4,6 +4,7 @@ import android.content.Context
import com.alibaba.android.arouter.facade.annotation.Route
import com.mogo.eagle.core.data.constants.MogoServicePaths
import com.mogo.eagle.core.function.api.datacenter.IDataCenterProvider
import com.mogo.eagle.core.function.datacenter.location.MoGoLocationDispatcher
@Route(path = MogoServicePaths.PATH_DATA_CENTER_MODULE)
class DataCenterProvider: IDataCenterProvider {
@@ -12,7 +13,7 @@ class DataCenterProvider: IDataCenterProvider {
get() = "DataCenterProvider"
override fun init(context: Context?) {
MoGoLocationDispatcher.initListener()
}
override fun onDestroy() {

View File

@@ -21,7 +21,7 @@ import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_LINK_LO
import com.mogo.eagle.core.data.trafficlight.TrafficLightResult
import com.mogo.eagle.core.data.trafficlight.toTrafficLightDetail
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotCarConfigListener
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotProvider
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotControlProvider
import com.mogo.eagle.core.function.api.map.collect.IMoGoMapDataCollectProvider
import com.mogo.eagle.core.function.datacenter.autopilot.adapter.MoGoAdasListenerImpl
import com.mogo.eagle.core.function.datacenter.autopilot.adapter.MoGoAdasMsgConnectStatusListenerImpl
@@ -67,8 +67,9 @@ import java.util.concurrent.TimeUnit
* @date 2021/9/22 8:43 下午
*/
@Route(path = MogoServicePaths.PATH_AUTO_PILOT)
class MoGoAutopilotProvider :
IMoGoAutopilotProvider, IMoGoMapDataCollectProvider.OnMapCollectCmdListener,
class MoGoAutopilotControlProvider :
IMoGoAutopilotControlProvider,
IMoGoMapDataCollectProvider.OnMapCollectCmdListener,
IMoGoAutopilotCarConfigListener {
private val TAG = "MoGoAutoPilotProvider"
private var mContext: Context? = null

View File

@@ -45,8 +45,6 @@ import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListen
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotRecordListenerManager.invokeAutopilotRecordConfig
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotRecordListenerManager.invokeAutopilotRecordResult
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotStatisticsListenerManager.invokeAutopilotStatistics
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ20ListenerManager.invokeChassisLocationGCJ02
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager.invokeChassisLocationWGS84
import com.mogo.eagle.core.function.call.autopilot.CallerPlanningActionsListenerManager.invokePNCActions
import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListenerManager.invokeAutopilotRotting
import com.mogo.eagle.core.function.call.autopilot.CallerPlanningTrajectoryListenerManager.invokeAutopilotTrajectory
@@ -135,10 +133,8 @@ class MoGoAdasListenerImpl : OnAdasListener {
clientPkFileName = "sn"
)
override fun onGnssInfo(header: MessagePad.Header, gnssInfo: MessagePad.GnssInfo) {
// WGS84坐标系高精度位置信息
invokeChassisLocationWGS84(gnssInfo)
// GCJ02高德坐标系位置信息
invokeChassisLocationGCJ02(gnssInfo)
CallerChassisGnssListenerManager.invokeChassisGnssListener(gnssInfo)
if (gnssInfo != null) {
if (1 == FunctionBuildConfig.gpsProvider) {
// 同步给MAP地图

View File

@@ -5,7 +5,7 @@ import com.mogo.commons.debug.DebugConfig.*
import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
import com.mogo.eagle.core.function.api.cloud.IMoGoCloudListener
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager
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.cloud.CallerCloudListenerManager
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
@@ -52,13 +52,13 @@ class MoGoAdasMsgConnectStatusListenerImpl :
// 同步SN给工控机
syncBasicInfoToAutopilot()
//每次工控机连接成功后,需同步当前设置的美化模式状态
CallerAutoPilotManager.setDemoMode(FunctionBuildConfig.isDemoMode)
CallerAutoPilotControlManager.setDemoMode(FunctionBuildConfig.isDemoMode)
//当连接状态是关闭美化模式时,同步给工控机
if (!FunctionBuildConfig.isDemoMode) {
CallerAutoPilotManager.setIPCDemoMode(FunctionBuildConfig.isDemoMode)
CallerAutoPilotControlManager.setIPCDemoMode(FunctionBuildConfig.isDemoMode)
}
//每次工控机连接成功后,需同步当前设置的雨天模式状态
CallerAutoPilotManager.setRainMode(FunctionBuildConfig.isRainMode)
CallerAutoPilotControlManager.setRainMode(FunctionBuildConfig.isRainMode)
} else if (ipcConnectionStatus == Constants.IPC_CONNECTION_STATUS.DISCONNECTED) {
CallerLogger.d("$M_ADAS_IMPL$TAG", "webSocket 连接失败 reason:$reason")
if (connectStatus) {

View File

@@ -2,7 +2,7 @@ package com.mogo.eagle.core.function.datacenter.autopilot.server
import com.mogo.eagle.core.data.trafficlight.TrafficLightResult
import com.mogo.eagle.core.function.api.trafficlight.IMoGoTrafficLightListener
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager
import com.mogo.eagle.core.function.call.trafficlight.CallerTrafficLightListenerManager
/**
@@ -26,6 +26,6 @@ class AsyncDataToAutopilotServer private constructor() : IMoGoTrafficLightListen
}
override fun onTrafficLightStatus(trafficLightResult: TrafficLightResult) {
CallerAutoPilotManager.sendTrafficLightData(trafficLightResult)
CallerAutoPilotControlManager.sendTrafficLightData(trafficLightResult)
}
}

View File

@@ -8,9 +8,9 @@ import com.mogo.eagle.core.data.app.AppConfigInfo
import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.data.deva.chain.ChainConstant
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_LINK_LOG_CONNECT_STATUS
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager.setDemoMode
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager.setIgnoreConditionDraw
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager.setDemoMode
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager.setIgnoreConditionDraw
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager
import com.mogo.eagle.core.utilcode.mogo.logger.*
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
@@ -174,7 +174,7 @@ class TeleMsgHandler : IMsgHandler {
private fun queryCarConfig() {
invokeNettyConnResult("乘客屏请求司机屏向工控机查询配置信息")
CallerAutoPilotManager.getCarConfig()
CallerAutoPilotControlManager.getCarConfig()
}
override fun handleClientConn2Server(channel: Channel?) {

View File

@@ -1,16 +0,0 @@
package com.mogo.eagle.core.function.datacenter.location
import com.mogo.eagle.core.data.enums.DataSourceType
import mogo.telematics.pad.MessagePad
/**
* 位置回调监听
*/
interface IMoGoLocationListener {
/**
* 位置改变回调用
* @param gnssInfo 位置信息
* @param sourceType 数据来源
*/
fun onLocationChanged(gnssInfo: MessagePad.GnssInfo, sourceType: DataSourceType)
}

View File

@@ -0,0 +1,176 @@
package com.mogo.eagle.core.function.datacenter.location
import com.amap.api.location.AMapLocation
import com.amap.api.location.AMapLocationClient
import com.amap.api.location.AMapLocationClientOption
import com.amap.api.location.AMapLocationListener
import com.mogo.commons.AbsMogoApplication
import com.mogo.commons.constants.SharedPrefsConstants
import com.mogo.eagle.core.data.enums.DataSourceType
import com.mogo.eagle.core.data.map.MogoLocation
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisGnssListener
import com.mogo.eagle.core.function.call.autopilot.CallerChassisGnssListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ20ListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr
import com.mogo.eagle.core.utilcode.util.CoordinateTransform
import com.mogo.eagle.core.utilcode.util.TimeUtils
import com.mogo.eagle.core.utilcode.util.Utils
import mogo.telematics.pad.MessagePad
/**
* 融合定位服务,这里同时监听多来源的位置信息,并支持修改频率
*
* @author donghongyu
*/
object MoGoLocationDispatcher :
IMoGoChassisGnssListener,
AMapLocationListener {
private val TAG = "MoGoLocationManager"
private var mCityCode: String? = null
private var mapLocation: AMapLocation? = null
/**
* 最后一次工控机GNSS返回更新的位置
*/
private var lastGnssLocation: MogoLocation = MogoLocation()
/**
* 最后一次高德定位返回的位置信息
*/
private var lastGaoDeLocation: MogoLocation = MogoLocation()
fun initListener() {
// 高德SDK隐私政策
AMapLocationClient.updatePrivacyShow(Utils.getApp(), true, true)
AMapLocationClient.updatePrivacyAgree(Utils.getApp(), true)
try {
val mLocationClient = AMapLocationClient(Utils.getApp())
//初始化定位参数
//声明mLocationOption对象
val mLocationOption = AMapLocationClientOption()
//设置定位监听
mLocationClient.setLocationListener(this)
//设置定位模式为高精度模式Battery_Saving为低功耗模式Device_Sensors是仅设备模式
mLocationOption.locationMode = AMapLocationClientOption.AMapLocationMode.Hight_Accuracy
//设置定位间隔,单位毫秒,默认为2000ms
mLocationOption.interval = 1000
//设置定位参数
mLocationClient.setLocationOption(mLocationOption)
// 启动定位监听
mLocationClient.startLocation()
} catch (e: Exception) {
e.printStackTrace()
}
// 初始化监听订阅工控机位置信息
CallerChassisGnssListenerManager.addListener(TAG, this)
}
override fun onChassisGnss(gnssInfo: MessagePad.GnssInfo) {
// 更新GNSS 信息
lastGnssLocation.gnssInfo = gnssInfo
lastGnssLocation.lastReceiveTime = TimeUtils.getNowMills()
// 将高德中的一些用于业务的数据进行融合例如CityCode、address等
mapLocation?.let {
lastGnssLocation.cityName = it.city
lastGnssLocation.cityCode = it.cityCode
lastGnssLocation.provider = it.provider
lastGnssLocation.address = it.address
lastGnssLocation.district = it.district
lastGnssLocation.province = it.province
lastGnssLocation.adCode = it.adCode
lastGnssLocation.locationDetail = it.locationDetail
lastGnssLocation.poiName = it.poiName
lastGnssLocation.aoiName = it.aoiName
lastGnssLocation.street = it.street
lastGnssLocation.streetNum = it.streetNum
lastGnssLocation.description = it.description
lastGnssLocation.buildingId = it.buildingId
lastGnssLocation.floor = it.floor
lastGnssLocation.errorCode = it.errorCode
lastGnssLocation.errorInfo = it.errorInfo
}
// WGS84坐标系高精度位置信息
CallerChassisLocationWGS84ListenerManager.invokeChassisLocationWGS84(
lastGnssLocation,
DataSourceType.TELEMATIC
)
// GCJ02高德坐标系位置信息
CallerChassisLocationGCJ20ListenerManager.invokeChassisLocationGCJ02(
lastGnssLocation,
DataSourceType.TELEMATIC
)
}
/**
* 高德地图位置改变回调
* @param aMapLocation 位置信息
*/
override fun onLocationChanged(aMapLocation: AMapLocation) {
mapLocation = aMapLocation
// 更新GNSS 信息
// 将高德中的一些用于业务的数据进行融合例如CityCode、address等
mapLocation?.let {
// 转换 GCJ02-->WGS84 坐标
val wgs84Location =
CoordinateTransform.GCJ02ToWGS84(it.longitude, it.latitude)
lastGaoDeLocation.longitude = wgs84Location[0]
lastGaoDeLocation.latitude = wgs84Location[1]
lastGaoDeLocation.heading = it.bearing.toDouble()
lastGaoDeLocation.gnssSpeed = it.speed
lastGaoDeLocation.altitude = it.altitude
lastGaoDeLocation.satelliteTime = it.time
lastGaoDeLocation.lastReceiveTime = TimeUtils.getNowMills()
lastGaoDeLocation.cityName = it.city
lastGaoDeLocation.cityCode = it.cityCode
lastGaoDeLocation.provider = it.provider
lastGaoDeLocation.address = it.address
lastGaoDeLocation.district = it.district
lastGaoDeLocation.province = it.province
lastGaoDeLocation.adCode = it.adCode
lastGaoDeLocation.locationDetail = it.locationDetail
lastGaoDeLocation.poiName = it.poiName
lastGaoDeLocation.aoiName = it.aoiName
lastGaoDeLocation.street = it.street
lastGaoDeLocation.streetNum = it.streetNum
lastGaoDeLocation.description = it.description
lastGaoDeLocation.buildingId = it.buildingId
lastGaoDeLocation.floor = it.floor
lastGaoDeLocation.errorCode = it.errorCode
lastGaoDeLocation.errorInfo = it.errorInfo
}
// 计算最后一次工控机同步的定位是否超时,如果超时则切换为高德地图定位,暂定超过30秒需要切换
if (TimeUtils.getNowMills() - lastGnssLocation.lastReceiveTime > 30000) {
// WGS84坐标系高精度位置信息
CallerChassisLocationWGS84ListenerManager.invokeChassisLocationWGS84(
lastGaoDeLocation,
DataSourceType.MAP
)
// GCJ02高德坐标系位置信息
CallerChassisLocationGCJ20ListenerManager.invokeChassisLocationGCJ02(
lastGaoDeLocation,
DataSourceType.MAP
)
}
// 本地SP缓存城市Code
val cityCode = aMapLocation.cityCode
if (cityCode != null && cityCode.isNotEmpty()) {
mCityCode = aMapLocation.cityCode
SharedPrefsMgr.getInstance(AbsMogoApplication.getApp())
.putString(SharedPrefsConstants.LOCATION_CITY_CODE, cityCode)
}
}
}

View File

@@ -1,71 +0,0 @@
package com.mogo.eagle.core.function.datacenter.location
import com.mogo.eagle.core.data.enums.DataSourceType
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationWGS84Listener
import com.mogo.eagle.core.function.api.obu.IMoGoObuLocationWGS84Listener
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager
import com.mogo.eagle.core.function.call.base.CallerBase
import com.mogo.eagle.core.utilcode.util.TimeUtils
import com.mogo.support.obu.model.MogoObuHvBasicsData
import mogo.telematics.pad.MessagePad
/**
* 融合定位服务,这里同时监听多来源的位置信息,并支持修改频率
*
* @author donghongyu
*/
object MoGoLocationManager :
CallerBase<IMoGoLocationListener>(),
IMoGoChassisLocationWGS84Listener,
IMoGoObuLocationWGS84Listener {
private val TAG = "MoGoLocationManager"
init {
CallerChassisLocationWGS84ListenerManager.addListener(TAG, this)
}
override fun onChassisLocationWGS84(gnssInfo: MessagePad.GnssInfo) {
M_LISTENERS.forEach {
val tag = it.key
// 获取数据监听需要的HZ
val hz = M_LISTENERS_HZ[tag]
if (hz != null && hz > 0) {
val hzTime = (1.0 / hz.toDouble()) * 1000
// 获取最后一次回调的时间
val hzLastSendTime = M_LISTENERS_HZ_LAST_SEND_TIME[tag]
if (hzLastSendTime != null && hzLastSendTime > 0) {
// 计算是否进入下一次回调周期
val nowTime = TimeUtils.getNowMills()
if (nowTime - hzLastSendTime > hzTime) {
syncLocationCallback(tag, it, gnssInfo, DataSourceType.TELEMATIC)
}
} else {
syncLocationCallback(tag, it, gnssInfo, DataSourceType.TELEMATIC)
}
} else {
syncLocationCallback(tag, it, gnssInfo, DataSourceType.TELEMATIC)
}
}
}
/**
* 向订阅位置信息的发出定位信息
*/
private fun syncLocationCallback(
tag: String,
it: Map.Entry<String, IMoGoLocationListener>,
gnssInfo: MessagePad.GnssInfo,
sourceType: DataSourceType
) {
// 记录最后一次回调时间
M_LISTENERS_HZ_LAST_SEND_TIME[tag] = TimeUtils.getNowMills()
val listener = it.value
listener.onLocationChanged(gnssInfo, sourceType)
}
override fun onObuLocationWGS84(data: MogoObuHvBasicsData) {
}
}

View File

@@ -3,8 +3,8 @@
##### 位置回调融合工控机、OBU、高德地图
```kotlin
// 注册监听位置变换
MoGoLocationManager.addListener(Companion.functionName, object : IMoGoLocationListener {
// 注册监听位置变换,唯一标记要接受数据的HZ回掉监听
MoGoLocationManager.addListener(Companion.functionName, 20, object : IMoGoLocationListener {
override fun onLocationChanged(
gnssInfo: MessagePad.GnssInfo,
sourceType: DataSourceType