This commit is contained in:
zhongchao
2023-04-04 15:09:31 +08:00
parent 8d41c335d6
commit c52c3828f8
63 changed files with 875 additions and 426 deletions

View File

@@ -0,0 +1,28 @@
package com.mogo.eagle.function.biz.v2x
import com.mogo.commons.debug.DebugConfig
import com.mogo.eagle.core.data.deva.chain.ChainConstant
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_V2X
import com.zhjt.service.chain.ChainLog
import com.zhjt.service.chain.TracingConstants
class V2XBizTrace {
companion object {
@ChainLog(
linkChainLog = ChainConstant.CHAIN_LINK_LOG_CLOUD_V2N,
linkCode = ChainConstant.CHAIN_LINK_CLOUD,
endpoint = TracingConstants.Endpoint.PAD,
nodeAliasCode = ChainConstant.CHAIN_ALIAS_CODE_CLOUD_V2N,
paramIndexes = [0, 1],
clientPkFileName = "sn"
)
fun onAck(data: Any, data1: Any) {
if (DebugConfig.isDebug()) {
CallerLogger.d("$M_V2X${data.toString()}", data1)
}
}
}
}

View File

@@ -2,9 +2,11 @@ package com.mogo.eagle.function.biz.v2x.v2n
import android.content.Context
import android.content.Intent
import android.os.Build
import android.os.Handler
import android.os.Looper
import android.util.Log
import androidx.annotation.RequiresApi
import androidx.localbroadcastmanager.content.LocalBroadcastManager
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_ALIAS_CODE_CLOUD_V2N
@@ -54,6 +56,7 @@ import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_V2X
import com.mogo.eagle.core.utilcode.util.Utils
import com.mogo.eagle.function.biz.v2x.V2XBizTrace
import com.mogo.eagle.function.biz.v2x.v2n.network.callback.IV2XCallback
import com.zhjt.service.chain.ChainLog
import com.zhjt.service.chain.TracingConstants
@@ -138,6 +141,7 @@ object V2XEventManager : IMoGoChassisLocationGCJ02Listener, IV2XCallback,
v2XMessageEntity.type = V2XMessageEntity.V2XTypeEnum.ALERT_ROAD_WARNING
v2XMessageEntity.content = v2XRoadEventEntity
V2XScenarioManager.getInstance().handlerMessage(v2XMessageEntity)
V2XBizTrace.onAck("巡航处理 handlerMessage v2XMessageEntity", " $v2XMessageEntity")
}
}
}
@@ -182,6 +186,7 @@ object V2XEventManager : IMoGoChassisLocationGCJ02Listener, IV2XCallback,
}
}
@RequiresApi(Build.VERSION_CODES.N)
@ChainLog(
linkChainLog = CHAIN_LINK_LOG_CLOUD_V2N,
linkCode = CHAIN_LINK_CLOUD,
@@ -212,7 +217,7 @@ object V2XEventManager : IMoGoChassisLocationGCJ02Listener, IV2XCallback,
return
}
}
Logger.d("$M_V2X$TAG", "poiType : $poiType , 触发道路事件")
CallerLogger.d("$M_V2X$TAG", "poiType : $poiType , 触发道路事件")
CallerHmiManager.warningV2X(poiType, tts, tts, null, ALERT_WARNING_TOP, isFromObu = false)
}
}
@@ -327,13 +332,17 @@ object V2XEventManager : IMoGoChassisLocationGCJ02Listener, IV2XCallback,
)
)
)
CallerHmiManager.warningV2X(tempAppId.toString(), tempContent, tempTts, object : IMoGoWarningStatusListener {
val change = changeVisualAngle
override fun onShow() {
if (change) {
CallerVisualAngleManager.changeAngle(TooClose)
CallerHmiManager.warningV2X(
tempAppId.toString(),
tempContent,
tempTts,
object : IMoGoWarningStatusListener {
val change = changeVisualAngle
override fun onShow() {
if (change) {
CallerVisualAngleManager.changeAngle(TooClose)
}
}
}
override fun onDismiss() {
if (change) {

View File

@@ -8,20 +8,20 @@ import android.view.animation.DecelerateInterpolator
import androidx.core.util.Pair
import com.mogo.eagle.core.data.map.MogoLatLng
import com.mogo.eagle.core.data.map.entity.V2XRoadEventEntity
import com.mogo.eagle.core.function.call.autopilot.*
import com.mogo.eagle.core.function.call.map.*
import com.mogo.eagle.function.biz.v2x.v2n.scenario.scene.road.V2XAiRoadEventMarker
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager
import com.mogo.eagle.core.utilcode.util.CoordinateUtils
import com.mogo.eagle.core.utilcode.util.DrivingDirectionUtils
import com.mogo.eagle.function.biz.v2x.V2XBizTrace
import com.mogo.eagle.function.biz.v2x.v2n.remove.MarkerRemoveManager
import com.mogo.eagle.function.biz.v2x.v2n.remove.MarkerWrapper
import com.mogo.eagle.function.biz.v2x.v2n.scenario.scene.road.V2XAiRoadEventMarker
import com.mogo.map.MogoMap
import com.mogo.map.overlay.IMogoPolyline
import com.mogo.map.overlay.MogoPolylineOptions
import java.util.*
import java.util.concurrent.atomic.AtomicReference
import java.util.concurrent.ConcurrentHashMap
import com.mogo.eagle.function.biz.v2x.v2n.remove.MarkerRemoveManager
import com.mogo.eagle.function.biz.v2x.v2n.remove.MarkerWrapper
import com.mogo.eagle.core.utilcode.util.CoordinateUtils
import java.util.concurrent.atomic.AtomicReference
/**
* Ai云道路施工事件道路颜色标记类
@@ -81,29 +81,45 @@ class AiRoadMarker {
}
if (drawRoadLine) {
//施工中心点前方的自车行驶方向上300米距离
val l1 = MogoMap.getInstance().mogoMap.getCenterLineRangeInfo(marker.poi_lon, marker.poi_lat, location.heading.toFloat(), 300f)
val l1 = MogoMap.getInstance().mogoMap.getCenterLineRangeInfo(
marker.poi_lon,
marker.poi_lat,
location.heading.toFloat(),
300f
)
//施工中心点后方的自车行驶方向上300米距离
Logger.d(TAG, "--- marker --- 3 --- l1: $l1")
val l2 = MogoMap.getInstance().mogoMap.getCenterLineRangeInfo(marker.poi_lon, marker.poi_lat, location.heading.toFloat(), -300f)
V2XBizTrace.onAck("$TAG --- marker --- 3 --- l1:", l1)
val l2 = MogoMap.getInstance().mogoMap.getCenterLineRangeInfo(
marker.poi_lon,
marker.poi_lat,
location.heading.toFloat(),
-300f
)
if (l1.points.isEmpty() || l2.points.isEmpty()) {
Logger.d(TAG, "--- marker --- 3 --- return ----")
V2XBizTrace.onAck("$TAG --- marker --- 3 --- return ----", "")
return
}
Logger.d(TAG, "--- marker --- 4 --- l2: $l2")
V2XBizTrace.onAck("$TAG --- marker --- 4 --- l2:", l2)
val points = LinkedList<MogoLatLng>()
if (l2 != null && l2.points.isNotEmpty()) {
points.addAll(l2.points.reversed().map {
MogoLatLng(it.second, it.first)
})
}
val centerX= marker.poi_lon
val centerX = marker.poi_lon
val centerY = marker.poi_lat
Logger.d(TAG, "--- marker --- 5 --- marker: $marker")
V2XBizTrace.onAck("$TAG --- marker --- 5 --- marker:", marker)
val farthestPoint = marker.polygon?.let {
var find: Pair<Double, Double> = Pair(centerX, centerY)
var min = Long.MAX_VALUE
for (p in it) {
val angle = DrivingDirectionUtils.getDegreeOfCar2Poi2(centerX, centerY, p.first, p.second, location.heading)
val angle = DrivingDirectionUtils.getDegreeOfCar2Poi2(
centerX,
centerY,
p.first,
p.second,
location.heading
)
if (angle < min) {
min = angle
find = p
@@ -112,10 +128,17 @@ class AiRoadMarker {
MogoLatLng(find.second, find.first)
} ?: MogoLatLng(centerY, centerX)
marker.farthestPoint = Pair(farthestPoint.lon, farthestPoint.lat)
Logger.d(TAG, "--- marker --- 6 --- marker: $marker")
V2XBizTrace.onAck("$TAG --- marker --- 6 --- marker:", marker)
if (l1 != null && l1.points.isNotEmpty()) {
for (l in l1.points) {
if (DrivingDirectionUtils.getDegreeOfCar2Poi2(farthestPoint.lon, farthestPoint.lat, l.first, l.second, (location.heading + 180)) < 90L) {
if (DrivingDirectionUtils.getDegreeOfCar2Poi2(
farthestPoint.lon,
farthestPoint.lat,
l.first,
l.second,
(location.heading + 180)
) < 90L
) {
points.add(l.let { MogoLatLng(it.second, it.first) })
}
}
@@ -128,12 +151,16 @@ class AiRoadMarker {
val total = points.size
val colors = ArrayList<Int>()
(0..total).forEach { i ->
colors += evaluator.evaluate(interceptor.getInterpolation(i * 1f / total), START_COLOR, END_COLOR) as Int
colors += evaluator.evaluate(
interceptor.getInterpolation(i * 1f / total),
START_COLOR,
END_COLOR
) as Int
}
var line = line.get()
options.points(points)
options.colorValues(colors)
Logger.d(TAG, "--- marker --- 7 --- points: ${points.size}")
V2XBizTrace.onAck("$TAG --- marker --- 7 --- points:", "${points.size}")
if (line == null || line.isDestroyed) {
val l = overlayManager?.addPolyline(options)
this.line.set(l)
@@ -156,9 +183,9 @@ class AiRoadMarker {
private fun removeLine() {
val old = line.get()
Logger.d(TAG, "--- removeRedLine --- 1 ---")
V2XBizTrace.onAck("$TAG --- removeRedLine --- 1", "")
if (old != null) {
Logger.d(TAG, "--- removeRedLine --- 2 ---")
V2XBizTrace.onAck("$TAG --- removeRedLine --- 2", "")
line.set(null)
old.isVisible = false
old.remove()
@@ -166,7 +193,7 @@ class AiRoadMarker {
}
private fun unMarker(marker: Marker) {
Logger.d(TAG, "--- unMarker ---")
V2XBizTrace.onAck("$TAG --- unMarker ---", "")
this.marker.set(null)
removeLine()
roadMarker.removeMarkers()
@@ -175,12 +202,15 @@ class AiRoadMarker {
}
fun receive() {
Logger.d(TAG, "receive --- 1 ---")
V2XBizTrace.onAck("$TAG --- receive --- 1 ---", "")
val poi = this.marker.get()
val car = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84()
if (poi != null) {
val distance = CoordinateUtils.calculateLineDistance(car.longitude, car.latitude, poi.poi_lon, poi.poi_lat)
Logger.d(TAG, "receive --- 2 ---:car:[${car.longitude}, ${car.latitude}] -> poi:[${poi.poi_lon}, ${poi.poi_lat}] --> distance:$distance")
V2XBizTrace.onAck(
"$TAG --- receive --- 2 ---",
"car:[${car.longitude}, ${car.latitude}] -> poi:[${poi.poi_lon}, ${poi.poi_lat}] --> distance:$distance"
)
if (distance < 500) {
checkExpired()
} else {

View File

@@ -1,11 +1,14 @@
package com.mogo.eagle.function.biz.v2x.v2n.scenario.scene.road;
import android.util.Log;
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_V2X;
import androidx.core.util.Pair;
import com.mogo.eagle.core.data.enums.EventTypeEnumNew;
import com.mogo.eagle.core.data.map.entity.MarkerExploreWay;
import com.mogo.eagle.core.data.map.entity.MarkerLocation;
import com.mogo.eagle.core.data.map.entity.V2XRoadEventEntity;
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
import com.mogo.eagle.function.biz.v2x.V2XBizTrace;
import com.mogo.eagle.function.biz.v2x.v2n.bridge.BridgeApi;
import com.mogo.eagle.function.biz.v2x.v2n.manager.IMoGoV2XMarkerManager;
import com.mogo.eagle.function.biz.v2x.v2n.remove.MarkerWrapper;
@@ -33,10 +36,10 @@ public class V2XRoadEventMarker implements IV2XMarker<V2XRoadEventEntity> {
IMoGoV2XMarkerManager marker = BridgeApi.INSTANCE.v2xMarker();
if (marker != null) {
if (entity != null) {
Log.d("RWJ", "V2XRoadEventMarker:" + entity.getPoiType());
V2XBizTrace.Companion.onAck("V2XRoadEventMarker -> poiType : ", entity.getPoiType());
if (isAiRoadEvent(entity.getPoiType())) {
MarkerExploreWay noveltyInfo = entity.getNoveltyInfo();
Log.d("RWJ", "V2XRoadEventMarker -> noveltyInfo:" + noveltyInfo);
V2XBizTrace.Companion.onAck("V2XRoadEventMarker -> noveltyInfo : ",noveltyInfo.toString());
if (noveltyInfo != null) {
Pair<Double, Double> gpsLocation = noveltyInfo.getGpsLocation();
List<Pair<Double, Double>> polygons = noveltyInfo.getPolygon();
@@ -51,13 +54,13 @@ public class V2XRoadEventMarker implements IV2XMarker<V2XRoadEventEntity> {
} else {
IMogoMarker iMarker = marker.drawableAlarmPOI(BridgeApi.INSTANCE.context(), entity, null);
if (iMarker != null) {
Log.d("RWJ", "V2XRoadEventMarker:" + entity.getPoiType() + "--- add Marker");
V2XBizTrace.Companion.onAck("V2XRoadEventMarker -> --- add Marker type: ", entity.getPoiType());
ArrayList<IMogoMarker> markers = new ArrayList<>();
markers.add(iMarker);
String id = entity.getLocation().getLon() + "_" + entity.getLocation().getLat();
MarkerRemoveManager.INSTANCE.addMarker(new MarkerWrapper(id, entity.getLocation().getLon(), entity.getLocation().getLat(), 0, markers, null, null));
} else {
Log.d("RWJ", "V2XRoadEventMarker:" + entity.getPoiType() + "--- return empty marker");
CallerLogger.INSTANCE.d(M_V2X + "RWJ", "V2XRoadEventMarker:" + entity.getPoiType() + "--- return empty marker");
}
}
}

View File

@@ -29,6 +29,7 @@ import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_V2X
import com.mogo.eagle.core.utilcode.util.ToastUtils
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
import com.mogo.eagle.function.biz.v2x.V2XBizTrace
import com.mogo.eagle.function.biz.v2x.trafficlight.core.MogoTrafficLightManager
import com.mogo.eagle.function.biz.v2x.vip.network.VipNetWorkModel
import com.zhjt.service_biz.BizConfig
@@ -110,6 +111,7 @@ class VipCarManager : IMogoOnMessageListener<VipMessage>, IMoGoTrafficLightListe
if (exit) {
CallerLogger.d("$M_V2X$TAG", "驶离路口,返回 , then resetConditions")
V2XBizTrace.onAck("驶离路口","resetConditions")
resetConditions()
exit = false
return
@@ -120,7 +122,7 @@ class VipCarManager : IMogoOnMessageListener<VipMessage>, IMoGoTrafficLightListe
"$M_V2X$TAG",
"vip 获取到灯态,但没找到对应车道数据 trafficLightResult : $trafficLightResult , then resetConditions"
)
resetConditions()
result = null
return
}
@@ -155,6 +157,7 @@ class VipCarManager : IMogoOnMessageListener<VipMessage>, IMoGoTrafficLightListe
MSG_WHAT_VIP_CANCEL,
cancelDelayTime - System.currentTimeMillis()
)
V2XBizTrace.onAck("setVip","time:$cancelDelayTime")
CallVipSetListenerManager.invokeVipSetStatus(true)
CallerTrafficLightListenerManager.addListener(TAG, this)
}
@@ -164,6 +167,7 @@ class VipCarManager : IMogoOnMessageListener<VipMessage>, IMoGoTrafficLightListe
if (handler.hasMessages(MSG_WHAT_VIP_CANCEL)) {
handler.removeMessages(MSG_WHAT_VIP_CANCEL)
}
V2XBizTrace.onAck("cancelVip","resetConditions")
resetConditions()
CallVipSetListenerManager.invokeVipSetStatus(false)
CallerTrafficLightListenerManager.removeListener(TAG)
@@ -192,7 +196,7 @@ class VipCarManager : IMogoOnMessageListener<VipMessage>, IMoGoTrafficLightListe
}
}
fun turnLight(controlTime: Int) {
private fun turnLight(controlTime: Int) {
if (result == null || mContext == null) return
val mogoLocation = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84()
if (mogoLocation != null) {
@@ -202,6 +206,14 @@ class VipCarManager : IMogoOnMessageListener<VipMessage>, IMoGoTrafficLightListe
result!!.lightId, result!!.crossId, bearing, controlTime,
// 100445, "10037", 90.0, controlTime, //衡阳25号路口测试数据
{
V2XBizTrace.onAck(
TAG + "turnLight", "code:${it.code}" +
",light:${this.result ?: ""}" +
",lightId:${result?.lightId}" +
",crossId:${result?.crossId}" +
",bearing:$bearing" +
",controlTime:$controlTime"
)
// 请求变灯成功,直接提示
if (it.sn == MoGoAiCloudClientConfig.getInstance().sn && it.code == 0) {
CallerLogger.d("$M_V2X$TAG", "变灯请求成功")
@@ -222,42 +234,39 @@ class VipCarManager : IMogoOnMessageListener<VipMessage>, IMoGoTrafficLightListe
return@turnLightToGreen
}
// 请求变灯失败,根据灯态来提示。 此处灯态未获取到
if (this.result == null || this.result?.currentRoadTrafficLight() == null) {
showWarning(
EventTypeEnumNew.TYPE_VIP_ERROR_IDENTIFICATION.poiType,
EventTypeEnumNew.TYPE_VIP_ERROR_IDENTIFICATION.content + ", 稍后重试",
EventTypeEnumNew.TYPE_VIP_ERROR_IDENTIFICATION.tts
)
return@turnLightToGreen
}
// 如果当前为红灯,则提示
if (this.result!!.currentRoadTrafficLight()!!.isRed()) {
val time = if (it.countDown / 60 >= 1) {
"${it.countDown / 60}${it.countDown % 60}秒后重试"
} else {
val temp = if (it.countDown == 0) {
1
} else {
it.countDown
}
"${temp}秒后重试"
}
showWarning(
EventTypeEnumNew.TYPE_VIP_ERROR_IDENTIFICATION.poiType,
EventTypeEnumNew.TYPE_VIP_ERROR_IDENTIFICATION.content + time,
EventTypeEnumNew.TYPE_VIP_ERROR_IDENTIFICATION.tts
)
} else {
CallerLogger.d(
"$M_V2X$TAG",
"变灯请求失败,当前为非红灯不做展示 , light : ${result.toString()} , trafficLightControl : $it"
)
}
// // 如果当前为红灯,则提示
// if (this.result!!.currentRoadTrafficLight()!!.isRed()) {
// val time = if (it.countDown / 60 >= 1) {
// "${it.countDown / 60}分${it.countDown % 60}秒后重试"
// } else {
// val temp = if (it.countDown == 0) {
// 1
// } else {
// it.countDown
// }
// "${temp}秒后重试"
// }
// showWarning(
// EventTypeEnumNew.TYPE_VIP_ERROR_IDENTIFICATION.poiType,
// EventTypeEnumNew.TYPE_VIP_ERROR_IDENTIFICATION.content + time,
// EventTypeEnumNew.TYPE_VIP_ERROR_IDENTIFICATION.tts
// )
// } else {
// CallerLogger.d(
// "$M_V2X$TAG",
// "变灯请求失败,当前为非红灯不做展示 , light : ${result.toString()} , trafficLightControl : $it"
// )
// }
},
{ errorMsg ->
CallerLogger.e("$M_V2X$TAG", "变灯请求失败 msg : $errorMsg")
V2XBizTrace.onAck(
TAG + "turnLight", "变灯请求失败 msg:$errorMsg" +
",lightId:${result?.lightId}" +
",crossId:${result?.crossId}" +
",bearing:$bearing" +
",controlTime:$controlTime"
)
ToastUtils.showLong("服务异常,请稍后重试")
})
}