优化数据,自车正常移动

This commit is contained in:
lixiaopeng
2022-09-06 17:19:39 +08:00
parent fa019d9755
commit c5def34a1a
6 changed files with 112 additions and 56 deletions

View File

@@ -113,7 +113,7 @@ ext {
// obu sdk
obusdk : "com.zhidao.enterprise.smartv2x:smartv2x:1.0.0.3",
// mogoobu : 'com.zhidao.support.obu:mogoobu:1.0.0.33',
mogoobu : 'com.mogo.support.obu:mogo-obu:1.0.0_beta7',
mogoobu : 'com.mogo.support.obu:mogo-obu:1.0.0_beta10',
mogoami : 'com.zhidao.support.obu.ami:mogoami:1.0.0.24',
// google

View File

@@ -6,9 +6,11 @@ import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.data.constants.MogoServicePaths
import com.mogo.eagle.core.function.api.obu.IMoGoObuProvider
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
import com.mogo.eagle.core.utilcode.mogo.MapAssetStyleUtils
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_OBU
import com.mogo.eagle.core.utilcode.util.CommonUtils
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
/**
* @author xiaoyuzhou
@@ -21,7 +23,9 @@ class MoGoObuProvider : IMoGoObuProvider {
private var mContext: Context? = null
private val busObuIp = "192.168.8.199"
private val taxiObuIp = "192.168.1.199"
// private val taxiObuIp = "192.168.1.199"
private val taxiObuIp = "192.168.0.56" //TODO
override val functionName: String
get() = TAG
@@ -30,21 +34,35 @@ class MoGoObuProvider : IMoGoObuProvider {
}
override fun init(context: Context) {
CallerLogger.d("$M_OBU$TAG", "初始化蘑菇自研OBU…… localIp = " + CommonUtils.getLocalIPAddress())
//bus乘客版本obu功能去掉
if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode) && AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)) {
if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode) && AppIdentityModeUtils.isPassenger(
FunctionBuildConfig.appIdentityMode
)
) {
//不处理
} else {
mContext = context
mContext?.let {
if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) {
MogoPrivateObuNewManager.INSTANCE.connectObu(it, CommonUtils.getLocalIPAddress(), busObuIp)
} else if (AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode)) {
MogoPrivateObuNewManager.INSTANCE.connectObu(it, CommonUtils.getLocalIPAddress(), taxiObuIp)
val thread = object : Thread() {
override fun run() {
mContext?.let {
if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) {
MogoPrivateObuNewManager.INSTANCE.connectObu(
it,
busObuIp,
CommonUtils.getIpAddressString()
)
} else if (AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode)) {
MogoPrivateObuNewManager.INSTANCE.connectObu(
it,
taxiObuIp,
CommonUtils.getIpAddressString()
)
}
}
}
}
}.start()
}
}

View File

@@ -99,9 +99,9 @@ class MogoPrivateObuNewManager private constructor() {
* HV车辆基础信息 CvxHvCarIndInfo CvxHvInfoIndInfo
*/
override fun onMogoObuHvBasics(p0: MogoObuHvBasicsData?) {
Log.d(TAG, "onMogoObuHvBasics p0 = ${p0.toString()}")
Log.d(TAG, "onMogoObuHvBasics ------ p0 = ${p0.toString()}" + "-----FunctionBuildConfig.gpsProvider = " + FunctionBuildConfig.gpsProvider)
if (p0 != null && p0.vehBasicsMsg != null) {
Log.d(TAG, "lon = ${p0.vehBasicsMsg.longitude} --- lat = ${p0.vehBasicsMsg.latitude} ---speed = ${p0.vehBasicsMsg.speed} ---heading = ${p0.vehBasicsMsg.heading} --acceleration = ${p0.vehBasicsMsg.accFourAxes.accLat} --yawRate = ${p0.vehBasicsMsg.accFourAxes.accYaw}")
val data = JSONObject()
try {
data.putOpt("lon", p0.vehBasicsMsg.longitude)
@@ -129,8 +129,8 @@ class MogoPrivateObuNewManager private constructor() {
// 同步更新经纬度和系统时间至 AutoPilotStatusListener
CallerAutoPilotStatusListenerManager.updateAutoPilotLatLon(
System.currentTimeMillis() / 1000.0,
p0.vehBasicsMsg.longitude.toDouble(),
p0.vehBasicsMsg.latitude.toDouble()
p0.vehBasicsMsg.longitude,
p0.vehBasicsMsg.latitude
)
}
} catch (e: Exception) {
@@ -146,9 +146,10 @@ class MogoPrivateObuNewManager private constructor() {
super.onMogoObuRvWarning(data)
// 更新数据远车数据之前要匹配uuid TODO
// TrafficDataConvertUtilsNew.cvxRvInfoIndInfo2TrafficData(data)?.let {
// TrafficMarkerDrawer.updateITrafficLocationInfo(it)
// }
TrafficDataConvertUtilsNew.cvxRvInfoIndInfo2TrafficData(data)?.let {
TrafficMarkerDrawer.updateITrafficLocationInfo(it)
}
Log.d(TAG, data.toString())
data.let {
//预警信息,预警类型 threat_level 2、3
@@ -173,7 +174,7 @@ class MogoPrivateObuNewManager private constructor() {
} --- direction = $direction --- appId = $appId ---level = $level -- status = $status"
)
Log.d(
Log.e(
TAG,
"onMogoObuRvWarning target_classification = ${
getMessageDirection(data.vehBasicsMsg.targetPosition)
@@ -181,7 +182,9 @@ class MogoPrivateObuNewManager private constructor() {
)
//拼凑数据
handleSdkObu(appId, direction, status, level, data)
if (appId != null) {
handleSdkObu(appId, direction, status, level, data)
}
}
}
}
@@ -191,8 +194,7 @@ class MogoPrivateObuNewManager private constructor() {
*/
override fun onMogoObuSpatWarning(data: MogoObuSpatWarningData) {
super.onMogoObuSpatWarning(data)
if (data != null && data.lights != null
&& data.lights.isNotEmpty()
if (data?.lights != null && data.lights.isNotEmpty()
) {
handlerTrafficLight(
data.warningType,
@@ -235,11 +237,6 @@ class MogoPrivateObuNewManager private constructor() {
EventTypeEnum.TYPE_USECASE_ID_IVS.poiType //车内标牌
-> {
when (data.warning_Msg[0].eventSerialNum) { //TODO 没有下面分类
// //桥梁 和驼峰桥区别
// 1 -> {
// appId = EventTypeEnum.TYPE_USECASE_ID_ROAD_HUMP_BRIDGE.poiType
// }
904 -> { //车辆逆行
appId = EventTypeEnum.TYPE_USECASE_ID_ROAD_VEHICLE_RETROGRADE.poiType
}
@@ -260,7 +257,6 @@ class MogoPrivateObuNewManager private constructor() {
appId = EventTypeEnum.TYPE_USECASE_ID_ROAD_PARKING.poiType
}
}
alertContent = EventTypeEnum.getWarningContent(appId)
ttsContent = EventTypeEnum.getWarningTts(appId)
@@ -411,7 +407,7 @@ class MogoPrivateObuNewManager private constructor() {
*/
private fun getMessageDirection(targetClassification: Int): WarningDirectionEnum {
CallerLogger.d("$M_OBU${MogoObuConst.TAG_MOGO_OBU}", "预警红边:预警方向->$targetClassification")
Log.d(TAG, "getMessageDirection 预警红边:预警方向->$targetClassification")
// Log.d(TAG, "getMessageDirection 预警红边:预警方向->$targetClassification")
return when (targetClassification) {
MogoObuConstants.VEH_TARGET_POSITION.AHEAD_IN_LANE,
MogoObuConstants.VEH_TARGET_POSITION.ONCOMING_IN_LANE -> WarningDirectionEnum.ALERT_WARNING_TOP //正前方
@@ -679,7 +675,7 @@ class MogoPrivateObuNewManager private constructor() {
isGreenLight = false
CallerHmiManager.showWarningTrafficLight(1, 2)
val red = currentLight.countDown
val red = currentLight.countDown.toInt()
CallerHmiManager.changeCountdownRed(red)
CallerHmiManager.changeCountdownGreen(0)
CallerHmiManager.changeCountdownYellow(0)
@@ -692,7 +688,7 @@ class MogoPrivateObuNewManager private constructor() {
}
isRedLight = false
CallerHmiManager.showWarningTrafficLight(3, 2)
val green = currentLight.countDown
val green = currentLight.countDown.toInt()
CallerHmiManager.changeCountdownGreen(green)
//防止数据出现问题的容错
CallerHmiManager.changeCountdownRed(0)
@@ -734,7 +730,7 @@ class MogoPrivateObuNewManager private constructor() {
0x3 -> {
CallerHmiManager.disableWarningV2X(appId.toString())
CallerHmiManager.showWarningTrafficLight(2, 2)
val yellow = currentLight.countDown
val yellow = currentLight.countDown.toInt()
CallerHmiManager.changeCountdownYellow(yellow)
CallerHmiManager.changeCountdownGreen(0)
CallerHmiManager.changeCountdownRed(0)

View File

@@ -1,5 +1,6 @@
package com.mogo.eagle.core.function.obu.mogo.utils
import android.util.Log
import com.mogo.eagle.core.data.enums.TrafficTypeEnum
import com.mogo.eagle.core.data.traffic.TrafficData
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
@@ -22,6 +23,7 @@ object TrafficDataConvertUtilsNew {
*/
fun cvxRvInfoIndInfo2TrafficData(info: MogoObuRvWarningData): TrafficData? {
if (info.vehBasicsMsg == null) {
Log.e("liyz", "cvxRvInfoIndInfo2TrafficData info.vehBasicsMsg == null ")
CallerLogger.e("$M_OBU$TAG", "cvxRvInfoIndInfo2TrafficData 数据转换异常,请检查参数是否齐全")
return null
}
@@ -42,6 +44,7 @@ object TrafficDataConvertUtilsNew {
fun cvxRtiThreatIndInfo2TrafficData(info: MogoObuRsiWarningData): TrafficData? {
if (info.warning_Msg == null || info.warning_Msg.size < 1 || info.warning_Msg[0].position == null) {
CallerLogger.e("$M_OBU$TAG", "数据转换异常,请检查参数是否齐全")
Log.e("liyz", "cvxRtiThreatIndInfo2TrafficData info.warning_Msg == null ")
return null
}
val trafficData = TrafficData()
@@ -49,8 +52,10 @@ object TrafficDataConvertUtilsNew {
trafficData.uuid = info.warning_Msg[0].signSerialNum.toString() //TODO
trafficData.lat = info.warning_Msg[0].position.latitude.toDouble()
trafficData.lon = info.warning_Msg[0].position.longitude.toDouble()
trafficData.threatLevel = info.warning_Msg[0].warningLevel
//TODO 没有数据
trafficData.threatLevel = info.warning_Msg[0].warningLevel
Log.e("liyz", "cvxRtiThreatIndInfo2TrafficData trafficData -- ${trafficData.toString()}")
return trafficData
}
@@ -58,21 +63,27 @@ object TrafficDataConvertUtilsNew {
* OBU 预警事件 转换交通元素数据 他车预警
*/
fun cvxV2vThreatIndInfo2TrafficData(info: MogoObuRvWarningData): TrafficData? {
if (info == null || info.vehBasicsMsg == null || info.warningMsg == null || info.warningMsg.warningData == null) {
if (info == null || info.vehBasicsMsg == null || info.warningMsg == null) {
CallerLogger.e("$M_OBU$TAG", "数据转换异常,请检查参数是否齐全")
Log.e("liyz", "cvxV2vThreatIndInfo2TrafficData info == null ")
return null
}
val trafficData = TrafficData()
trafficData.uuid = info.vehBasicsMsg.id
trafficData.lat = info.vehBasicsMsg.latitude.toDouble()
trafficData.lon = info.vehBasicsMsg.longitude.toDouble()
trafficData.heading = info.vehBasicsMsg.heading.toDouble()
trafficData.speed = info.vehBasicsMsg.speed.toDouble()
trafficData.lat = info.vehBasicsMsg.latitude
trafficData.lon = info.vehBasicsMsg.longitude
trafficData.heading = info.vehBasicsMsg.heading
trafficData.speed = info.vehBasicsMsg.speed
// 判断车辆V2X预警级别调整车辆颜色
trafficData.threatLevel = info.warningMsg.warningData[0].warningLevel
if (info.warningMsg.warningData != null) {
trafficData.threatLevel = info.warningMsg.warningData[0].warningLevel
} else {
trafficData.threatLevel = 1
}
trafficData.type = TrafficTypeEnum.TYPE_TRAFFIC_ID_TA_CHE
Log.e("liyz", "cvxV2vThreatIndInfo2TrafficData trafficData = ${trafficData.toString()} ")
return trafficData
}
@@ -82,14 +93,15 @@ object TrafficDataConvertUtilsNew {
fun cvxPtcThreatIndInfo2TrafficData(info: MogoObuRsmWarningData): TrafficData? {
if (info.participant == null) {
CallerLogger.e("$M_OBU$TAG", "数据转换异常,请检查参数是否齐全")
Log.e("liyz", "cvxPtcThreatIndInfo2TrafficData info.participant ")
return null
}
val trafficData = TrafficData()
trafficData.uuid = info.participant.ptcId.toString()
trafficData.lat = info.participant.latitude.toDouble()
trafficData.lon = info.participant.longitude.toDouble()
trafficData.heading = info.participant.heading.toDouble()
trafficData.speed = info.participant.speed.toDouble()
trafficData.lat = info.participant.latitude
trafficData.lon = info.participant.longitude
trafficData.heading = info.participant.heading
trafficData.speed = info.participant.speed
when (info.participant.ptcType) {
// 未知
@@ -109,8 +121,10 @@ object TrafficDataConvertUtilsNew {
// 判断车辆V2X预警级别调整车辆颜色
if (info.m_warning_msg != null && info.m_warning_msg.warningData != null) {
trafficData.threatLevel = info.m_warning_msg.warningData[0].warningLevel
} else {
trafficData.threatLevel = 1
}
Log.e("liyz", "cvxPtcThreatIndInfo2TrafficData trafficData = ${trafficData.toString()} ")
return trafficData
}

View File

@@ -23,6 +23,7 @@ import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Field;
import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
@@ -397,6 +398,25 @@ public class CommonUtils {
}
public static String getIpAddressString() {
try {
for (Enumeration<NetworkInterface> enNetI = NetworkInterface
.getNetworkInterfaces(); enNetI.hasMoreElements(); ) {
NetworkInterface netI = enNetI.nextElement();
for (Enumeration<InetAddress> enumIpAddr = netI
.getInetAddresses(); enumIpAddr.hasMoreElements(); ) {
InetAddress inetAddress = enumIpAddr.nextElement();
if (inetAddress instanceof Inet4Address && !inetAddress.isLoopbackAddress()) {
return inetAddress.getHostAddress();
}
}
}
} catch (SocketException e) {
e.printStackTrace();
}
return "127.0.0.1";
}
// 获取本地IP函数
public static String getLocalIPAddress() {
try {

View File

@@ -5,6 +5,7 @@ import android.content.Context
import android.os.Handler
import android.os.Message
import android.text.TextUtils
import android.util.Log
import com.mogo.commons.AbsMogoApplication
import com.mogo.eagle.core.data.enums.TrafficTypeEnum
import com.mogo.eagle.core.data.traffic.TrafficData
@@ -46,7 +47,7 @@ object TrafficMarkerDrawer {
override fun handleMessage(msg: Message) {
super.handleMessage(msg)
// TODO 因为与自动驾驶的感知重合临时关掉OBU车辆绘制
// drawerTrafficInfo()
drawerTrafficInfo()
// 延时50毫秒重复发送自己定时轮询进行车辆绘制可以及时将已经不存在车辆删除
sendEmptyMessageDelayed(0, 50L)
}
@@ -79,17 +80,19 @@ object TrafficMarkerDrawer {
* 更新识别数据位置
*/
fun updateITrafficLocationInfo(trafficData: TrafficData) {
val tempTraffic = mTrafficMap[trafficData.uuid]
if (tempTraffic != null) {
tempTraffic.lat = trafficData.lat
tempTraffic.lon = trafficData.lon
tempTraffic.heading = trafficData.heading
if (trafficData.uuid != null) {
mTrafficMap[trafficData.uuid!!] = tempTraffic
}
} else {
if (trafficData.uuid != null) {
mTrafficMap[trafficData.uuid!!] = trafficData
if (trafficData != null && !TextUtils.isEmpty(trafficData.uuid)) {
val tempTraffic = mTrafficMap[trafficData.uuid]
if (tempTraffic != null) {
tempTraffic.lat = trafficData.lat
tempTraffic.lon = trafficData.lon
tempTraffic.heading = trafficData.heading
if (trafficData.uuid != null) {
mTrafficMap[trafficData.uuid!!] = tempTraffic
}
} else {
if (trafficData.uuid != null) {
mTrafficMap[trafficData.uuid!!] = trafficData
}
}
}
}
@@ -162,6 +165,7 @@ object TrafficMarkerDrawer {
TAG,
"trafficData.type = " + trafficData.type + "---trafficData.threatLevel = " + trafficData.threatLevel
)
Log.e("liyz", "drawObuRecognizedDataMarker trafficData.type = " + trafficData.type + "---trafficData.threatLevel = " + trafficData.threatLevel)
if (trafficData.type != null) {
val resId: Int = trafficData.type.traffic3DIconId
@@ -222,6 +226,10 @@ object TrafficMarkerDrawer {
TAG,
"trafficData.type = " + trafficData.type + "---trafficData.threatLevel = " + trafficData.threatLevel
)
Log.e("liyz",
"trafficData.type = " + trafficData.type + "---trafficData.threatLevel = " + trafficData.threatLevel
)
if (trafficData.type != TrafficTypeEnum.TYPE_TRAFFIC_ID_SPECIAL_VEHICLE) {
// 修改颜色
when (trafficData.threatLevel) {