[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:
@@ -10,7 +10,7 @@ import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_ALIAS_C
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_LINK_ADAS
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_LINK_LOG_WEB_SOCKET_AUTOPILOT
|
||||
import com.mogo.eagle.core.data.trafficlight.TrafficLightResult
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotProvider
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotControlProvider
|
||||
import com.mogo.eagle.core.function.call.base.CallerBase
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
|
||||
import com.zhjt.service.chain.ChainLog
|
||||
@@ -23,12 +23,12 @@ import kotlin.random.Random
|
||||
*@date 2021/10/14 2:15 下午
|
||||
* 域控制器管理
|
||||
*/
|
||||
object CallerAutoPilotManager {
|
||||
object CallerAutoPilotControlManager {
|
||||
private val TAG = "CallerAutoPilotManager"
|
||||
|
||||
private val providerApi: IMoGoAutopilotProvider?
|
||||
private val providerApi: IMoGoAutopilotControlProvider?
|
||||
get() = CallerBase.getApiInstance(
|
||||
IMoGoAutopilotProvider::class.java,
|
||||
IMoGoAutopilotControlProvider::class.java,
|
||||
MogoServicePaths.PATH_AUTO_PILOT
|
||||
)
|
||||
|
||||
@@ -6,9 +6,9 @@ import mogo.telematics.pad.MessagePad
|
||||
import perception.TrafficLightOuterClass
|
||||
|
||||
/**
|
||||
* 域控制器感知数据
|
||||
* @author xiaoyuzhou
|
||||
* @date 2021/9/30 5:48 下午
|
||||
* 域控制器感知数据
|
||||
*/
|
||||
object CallerAutopilotIdentifyListenerManager : CallerBase<IMoGoAutopilotIdentifyListener>() {
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.mogo.eagle.core.function.call.autopilot
|
||||
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisGnssListener
|
||||
import com.mogo.eagle.core.function.call.base.CallerBase
|
||||
import mogo.telematics.pad.MessagePad
|
||||
|
||||
/**
|
||||
* 车辆定位 WGS84 坐标系-高精度坐标系 数据 回调监听
|
||||
* @author xiaoyuzhou
|
||||
* @date 2021/9/30 5:48 下午
|
||||
*/
|
||||
object CallerChassisGnssListenerManager : CallerBase<IMoGoChassisGnssListener>() {
|
||||
|
||||
/**
|
||||
* 车辆定位 WGS84 坐标系-高精度坐标系 数据
|
||||
* @param gnssInfo
|
||||
*/
|
||||
@Synchronized
|
||||
fun invokeChassisGnssListener(gnssInfo: MessagePad.GnssInfo) {
|
||||
M_LISTENERS.forEach {
|
||||
val tag = it.key
|
||||
val listener = it.value
|
||||
listener.onChassisGnss(gnssInfo)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,10 +1,12 @@
|
||||
package com.mogo.eagle.core.function.call.autopilot
|
||||
|
||||
import com.mogo.eagle.core.data.enums.DataSourceType
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener
|
||||
import com.mogo.eagle.core.function.call.base.CallerBase
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import com.mogo.eagle.core.utilcode.util.CoordinateTransform
|
||||
import mogo.telematics.pad.MessagePad
|
||||
import com.mogo.eagle.core.utilcode.util.TimeUtils
|
||||
|
||||
/**
|
||||
* @author xiaoyuzhou
|
||||
@@ -16,9 +18,21 @@ object CallerChassisLocationGCJ20ListenerManager : CallerBase<IMoGoChassisLocati
|
||||
val TAG = "CallerChassisLocationGCJ20ListenerManager"
|
||||
|
||||
@Volatile
|
||||
private var mGnssInfo: MessagePad.GnssInfo? = null
|
||||
private var mGnssInfo: MogoLocation? = null
|
||||
|
||||
fun getChassisLocationGCJ02(): MessagePad.GnssInfo? {
|
||||
/**
|
||||
* 添加监听并指定回掉频率
|
||||
*/
|
||||
fun addListener(
|
||||
tag: String,
|
||||
callBackHz: Int,
|
||||
listener: IMoGoChassisLocationGCJ02Listener
|
||||
) {
|
||||
addListener(tag, listener)
|
||||
setListenerHz(tag, callBackHz)
|
||||
}
|
||||
|
||||
fun getChassisLocationGCJ02(): MogoLocation? {
|
||||
return mGnssInfo
|
||||
}
|
||||
|
||||
@@ -27,25 +41,62 @@ object CallerChassisLocationGCJ20ListenerManager : CallerBase<IMoGoChassisLocati
|
||||
* @param gnssInfo
|
||||
*/
|
||||
@Synchronized
|
||||
fun invokeChassisLocationGCJ02(gnssInfo: MessagePad.GnssInfo?) {
|
||||
fun invokeChassisLocationGCJ02(gnssInfo: MogoLocation?,sourceType: DataSourceType) {
|
||||
gnssInfo?.let {
|
||||
// 转换 WGS84-->GCJ02 坐标
|
||||
val gcj20Location = CoordinateTransform.WGS84ToGCJ02(gnssInfo.longitude, gnssInfo.latitude)
|
||||
val gcj20Location =
|
||||
CoordinateTransform.WGS84ToGCJ02(gnssInfo.longitude, gnssInfo.latitude)
|
||||
|
||||
val gnssBuilder = gnssInfo.toBuilder()
|
||||
gnssBuilder.longitude = gcj20Location[0]
|
||||
gnssBuilder.latitude = gcj20Location[1]
|
||||
gnssInfo.longitude = gcj20Location[0]
|
||||
gnssInfo.latitude = gcj20Location[1]
|
||||
|
||||
this.mGnssInfo = gnssBuilder.build()
|
||||
this.mGnssInfo = gnssInfo
|
||||
|
||||
M_LISTENERS.forEach {
|
||||
val tag = it.key
|
||||
val listener = it.value
|
||||
listener.onChassisLocationGCJ02(this.mGnssInfo)
|
||||
// 获取数据监听需要的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, sourceType)
|
||||
}
|
||||
} else {
|
||||
syncLocationCallback(tag, it, gnssInfo, sourceType)
|
||||
}
|
||||
} else {
|
||||
syncLocationCallback(tag, it, gnssInfo, sourceType)
|
||||
}
|
||||
}
|
||||
} ?: let {
|
||||
Logger.e(TAG, "定位数据为Null")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 向订阅位置信息的发出定位信息
|
||||
* @param tag
|
||||
* @param it
|
||||
* @param gnssInfo
|
||||
* @param sourceType 数据来源
|
||||
*/
|
||||
private fun syncLocationCallback(
|
||||
tag: String,
|
||||
it: Map.Entry<String, IMoGoChassisLocationGCJ02Listener>,
|
||||
mogoLocation: MogoLocation,
|
||||
sourceType: DataSourceType
|
||||
) {
|
||||
// 记录最后一次回调时间
|
||||
M_LISTENERS_HZ_LAST_SEND_TIME[tag] = TimeUtils.getNowMills()
|
||||
val listener = it.value
|
||||
listener.onChassisLocationGCJ02(mogoLocation)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.mogo.eagle.core.function.call.autopilot
|
||||
|
||||
import com.mogo.eagle.core.data.enums.DataSourceType
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationWGS84Listener
|
||||
import com.mogo.eagle.core.function.call.base.CallerBase
|
||||
import mogo.telematics.pad.MessagePad
|
||||
import com.mogo.eagle.core.utilcode.util.TimeUtils
|
||||
|
||||
/**
|
||||
* @author xiaoyuzhou
|
||||
@@ -12,24 +14,74 @@ import mogo.telematics.pad.MessagePad
|
||||
object CallerChassisLocationWGS84ListenerManager : CallerBase<IMoGoChassisLocationWGS84Listener>() {
|
||||
|
||||
@Volatile
|
||||
private var gnssInfo: MessagePad.GnssInfo? = null
|
||||
private var gnssInfo: MogoLocation? = null
|
||||
|
||||
fun getChassisLocationWGS84(): MessagePad.GnssInfo? {
|
||||
fun getChassisLocationWGS84(): MogoLocation? {
|
||||
return gnssInfo
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加监听并指定回掉频率
|
||||
*/
|
||||
fun addListener(
|
||||
tag: String,
|
||||
callBackHz: Int,
|
||||
listener: IMoGoChassisLocationWGS84Listener
|
||||
) {
|
||||
addListener(tag, listener)
|
||||
setListenerHz(tag, callBackHz)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 车辆定位 WGS84 坐标系-高精度坐标系 数据
|
||||
* @param gnssInfo
|
||||
*/
|
||||
@Synchronized
|
||||
fun invokeChassisLocationWGS84(gnssInfo: MessagePad.GnssInfo) {
|
||||
fun invokeChassisLocationWGS84(gnssInfo: MogoLocation,sourceType: DataSourceType) {
|
||||
this.gnssInfo = gnssInfo
|
||||
M_LISTENERS.forEach {
|
||||
val tag = it.key
|
||||
val listener = it.value
|
||||
listener.onChassisLocationWGS84(gnssInfo)
|
||||
// 获取数据监听需要的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, sourceType)
|
||||
}
|
||||
} else {
|
||||
syncLocationCallback(tag, it, gnssInfo, sourceType)
|
||||
}
|
||||
} else {
|
||||
syncLocationCallback(tag, it, gnssInfo, sourceType)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 向订阅位置信息的发出定位信息
|
||||
* @param tag
|
||||
* @param it
|
||||
* @param gnssInfo
|
||||
* @param sourceType 数据来源
|
||||
*/
|
||||
private fun syncLocationCallback(
|
||||
tag: String,
|
||||
it: Map.Entry<String, IMoGoChassisLocationWGS84Listener>,
|
||||
mogoLocation: MogoLocation,
|
||||
sourceType: DataSourceType
|
||||
) {
|
||||
// 记录最后一次回调时间
|
||||
M_LISTENERS_HZ_LAST_SEND_TIME[tag] = TimeUtils.getNowMills()
|
||||
val listener = it.value
|
||||
listener.onChassisLocationWGS84(mogoLocation)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -30,12 +30,14 @@ open class CallerBase<T : Any> {
|
||||
|
||||
/**
|
||||
* 设置对应监听,指定Hz频率
|
||||
* @param tag 订阅者标记
|
||||
* @param callBackHz 订阅者想要接受的回调的hz频率
|
||||
*/
|
||||
fun setListenerHz(tag: String, hz: Int) {
|
||||
fun setListenerHz(tag: String, callBackHz: Int) {
|
||||
if (M_LISTENERS_HZ.containsKey(tag)) {
|
||||
return
|
||||
}
|
||||
M_LISTENERS_HZ[tag] = hz
|
||||
M_LISTENERS_HZ[tag] = callBackHz
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,7 +24,6 @@ import com.zhidaoauto.map.sdk.open.tools.MapTools
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.android.asCoroutineDispatcher
|
||||
import kotlinx.coroutines.internal.synchronized
|
||||
import mogo.telematics.pad.MessagePad.GnssInfo
|
||||
import java.util.*
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.util.concurrent.TimeUnit.SECONDS
|
||||
@@ -65,7 +64,7 @@ object CallerVisualAngleManager {
|
||||
val displayThreshold: Long //最大展示时长 > 0; 表示最长展示多长时间, -1 表示,一直展示,直到触发默认视角, 0: 默认视角专用值,
|
||||
}
|
||||
|
||||
private val triggerLocation = AtomicReference<GnssInfo>()
|
||||
private val triggerLocation = AtomicReference<MogoLocation>()
|
||||
|
||||
private val distanceOfCarToStopLine = AtomicReference(0.0)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user