[VisualAngle]优化自车到终止线距离算法;道路事件场景切换逻辑
This commit is contained in:
@@ -58,7 +58,6 @@ public class V2XScenarioManager implements IV2XScenarioManager {
|
||||
ThreadUtils.runOnUiThread(() -> {
|
||||
// 提取之前存储的场景
|
||||
if (v2XMessageEntity != null) {
|
||||
sceneChange();
|
||||
// 广播给应用内部其它模块
|
||||
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_ACTION);
|
||||
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity);
|
||||
@@ -69,9 +68,11 @@ public class V2XScenarioManager implements IV2XScenarioManager {
|
||||
mV2XScenario = new V2XRoadEventScenario();
|
||||
break;
|
||||
case V2XMessageEntity.V2XTypeEnum.ALERT_PUSH_VR_SHOW:
|
||||
sceneChange();
|
||||
mV2XScenario = new V2XOptimalRouteVREventScenario();
|
||||
break;
|
||||
case V2XMessageEntity.V2XTypeEnum.ALERT_THE_FRONT_WEAKNESS:
|
||||
sceneChange();
|
||||
boolean isVrMode1 = false;
|
||||
IMogoStatusManager statusManager1 = BridgeApi.INSTANCE.statusManager();
|
||||
if (statusManager1 != null) {
|
||||
@@ -101,6 +102,7 @@ public class V2XScenarioManager implements IV2XScenarioManager {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* http://wiki.zhidaohulian.com/pages/viewpage.action?pageId=52833468
|
||||
* 道路事件触发后,切换到中景
|
||||
|
||||
@@ -59,13 +59,7 @@ object CallerVisualAngleManager {
|
||||
|
||||
private var roadId = ""
|
||||
|
||||
override fun onRoadIdInfo(roadId: String) {}
|
||||
|
||||
override fun onStopLineInfo(info: StopLine) {
|
||||
if (!hasCrossRoad && info.distanceOfCarToStopLine <= 30.0) {
|
||||
hasCrossRoad = true
|
||||
changeVisualAngle(CrossRoad)
|
||||
}
|
||||
override fun onRoadIdInfo(roadId: String) {
|
||||
val oldRoadId = this.roadId
|
||||
if (oldRoadId != roadId) {
|
||||
if (hasCrossRoad) {
|
||||
@@ -73,7 +67,14 @@ object CallerVisualAngleManager {
|
||||
changeVisualAngle(Default())
|
||||
}
|
||||
}
|
||||
this.roadId = info.roadId
|
||||
this.roadId = roadId
|
||||
}
|
||||
|
||||
override fun onStopLineInfo(info: StopLine) {
|
||||
if (!hasCrossRoad && info.distanceOfCarToStopLine <= 30.0) {
|
||||
hasCrossRoad = true
|
||||
changeVisualAngle(CrossRoad)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -177,10 +178,12 @@ object CallerVisualAngleManager {
|
||||
|
||||
@OptIn(InternalCoroutinesApi::class)
|
||||
fun changeVisualAngle(scene: Scene) {
|
||||
val triggerTime = TimeUnit.MILLISECONDS.toSeconds(SystemClock.elapsedRealtime())
|
||||
val triggerTime = SystemClock.elapsedRealtime()
|
||||
scope.launch {
|
||||
Log.d("XXX", "--- 1 -----")
|
||||
val displayed = getDisplayed()
|
||||
if (displayed == null) {
|
||||
Log.d("XXX", "--- 2 -----")
|
||||
val top = getTop() //堆顶
|
||||
if (top != null && top.target.priority > scene.priority) {
|
||||
doChangeAngle(top)
|
||||
@@ -190,27 +193,36 @@ object CallerVisualAngleManager {
|
||||
}
|
||||
Log.d(TAG, "没有正在展示的视角,当前要展示的视角: $scene")
|
||||
} else {
|
||||
if (scene.javaClass == displayed.javaClass) {
|
||||
Log.d("XXX", "--- 3 -----")
|
||||
if (scene.javaClass == displayed.target.javaClass) {
|
||||
Log.d("XXX", "--- 4 -----")
|
||||
Log.d(TAG, "同一种场景不需要重复展示")
|
||||
defaultDelayJob?.safeCancel()
|
||||
return@launch
|
||||
}
|
||||
if (scene is Default) {
|
||||
Log.d("XXX", "--- 5 -----")
|
||||
Log.d(TAG, "恢复到默认视图,之前展示的视图:$displayed")
|
||||
heap -= displayed
|
||||
defaultDelayJob?.safeCancel()
|
||||
launch {
|
||||
val delay = scene.unit.toMillis(scene.delay)
|
||||
Log.d(TAG, "默认视图开启延时倒计时, 倒计时时间:${delay} ms.")
|
||||
delay(delay)
|
||||
Log.d(TAG, "默认视图结束倒计时,开始展示...")
|
||||
doChangeAngle(Record(scene, triggerTime = triggerTime))
|
||||
heap -= displayed
|
||||
}.also { defaultDelayJob = it }
|
||||
} else {
|
||||
Log.d("XXX", "--- 6 -----")
|
||||
defaultDelayJob?.safeCancel()
|
||||
val delta = triggerTime - displayed.triggerTime
|
||||
if (delta >= MaxDisplayThreshold) {
|
||||
Log.d("XXX", "--- 6-1 -----")
|
||||
Log.d(TAG, "场景: $scene 触发展示,满足条件开始展示...")
|
||||
doChangeAngle(Record(scene, triggerTime = triggerTime))
|
||||
} else {
|
||||
Log.d(TAG, "场景: $scene 触发展示,但是在20s内,丢弃...")
|
||||
Log.d("XXX", "--- 6-2 -----")
|
||||
Log.d(TAG, "场景: $scene 触发展示,但是在30s内,丢弃...")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -220,14 +232,13 @@ object CallerVisualAngleManager {
|
||||
@OptIn(InternalCoroutinesApi::class)
|
||||
private fun doChangeAngle(record: Record) {
|
||||
CallerMapUIServiceManager.getMapUIController()?.also {
|
||||
record.isDisplay = true
|
||||
synchronized(heap) {
|
||||
heap += record
|
||||
if (record.target !is Default) {
|
||||
record.isDisplay = true
|
||||
synchronized(heap) {
|
||||
heap += record
|
||||
}
|
||||
}
|
||||
val target = record.target
|
||||
if (target !is Default) {
|
||||
defaultDelayJob?.safeCancel()
|
||||
}
|
||||
if (target is LowSpeed) {
|
||||
it.changeMapVisualAngle(record.target.angle, MogoLatLng(target.lat, target.lon))
|
||||
} else {
|
||||
|
||||
@@ -82,7 +82,7 @@ MOGO_LOCATION_VERSION=1.3.32
|
||||
MOGO_TELEMATIC_VERSION=1.3.32
|
||||
######## MogoAiCloudSDK Version ########
|
||||
# 自研地图
|
||||
MAP_SDK_VERSION=2.0.9.1
|
||||
MAP_SDK_VERSION=2.0.9.2
|
||||
MAP_SDK_OPERATION_VERSION=1.0.12
|
||||
# websocket
|
||||
WEBSOCKET_VERSION=1.1.7
|
||||
|
||||
@@ -174,10 +174,10 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRoadIdInfo(@androidx.annotation.Nullable String s) {
|
||||
Log.d(TAG, "-- onRoadIdInfo --RoadId:" + s);
|
||||
if (s != null) {
|
||||
CallerMapRoadListenerManager.INSTANCE.invokeListenersOnRoadIdGet(s);
|
||||
public void onRoadIdInfo(@androidx.annotation.Nullable String roadId) {
|
||||
if (!TextUtils.isEmpty(roadId)) {
|
||||
Log.d(TAG, "-- onRoadIdInfo --RoadId:" + roadId);
|
||||
CallerMapRoadListenerManager.INSTANCE.invokeListenersOnRoadIdGet(roadId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,27 +185,24 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
public void onStopLineInfo(@androidx.annotation.Nullable StopLine stopLine) {
|
||||
Log.d(TAG, "-- onStopLineInfo -- 1 --:" + (stopLine != null ? stopLine.toString() : null) + "-> road_id:" + mRoadId);
|
||||
MogoLocation carLoc = CallerMapLocationListenerManager.INSTANCE.getCurrentLocation();
|
||||
if (stopLine != null) {
|
||||
if (stopLine != null && !TextUtils.isEmpty(stopLine.road_id) && stopLine.points != null && stopLine.points.size() > 0) {
|
||||
ArrayList<LonLatPoint> points = stopLine.points;
|
||||
if (points != null && carLoc != null) {
|
||||
if (carLoc != null) {
|
||||
MapRoadInfo.StopLine stopInfo = convert(stopLine);
|
||||
LonLatPoint match = new LonLatPoint();
|
||||
double ret = MapDataApi.INSTANCE.GetDisFromPointToLine(convert(carLoc), points, match, 1);
|
||||
Log.d(TAG, "-- onStopLineInfo --- ret: "+ ret);
|
||||
double distanceOfCarToStopLine = 0.0;
|
||||
double distanceOfCarToStopLine = -1.0;
|
||||
if (Double.compare(ret, -1.0) != 0) {
|
||||
distanceOfCarToStopLine = MapTools.INSTANCE.distance(carLoc.getLatitude(), carLoc.getLongitude(), match.getLatitude(), match.getLongitude());
|
||||
stopInfo.setDistanceOfCarToStopLine(distanceOfCarToStopLine);
|
||||
} else {
|
||||
LonLatPoint p1 = points.isEmpty() ? null : points.get(0);
|
||||
LonLatPoint p2 = points.isEmpty() ? null : points.get(points.size() - 1);
|
||||
LonLatPoint aim = p1 != null && p2 != null ? new LonLatPoint((p1.longitude + p2.longitude) / 2, (p1.altitude + p2.altitude) / 2, (p1.angle + p2.angle) / 2) : (p1 != null ? p1 : p2);
|
||||
if (aim != null) {
|
||||
distanceOfCarToStopLine = MapTools.INSTANCE.distance(carLoc.getAltitude(), carLoc.getLongitude(), aim.getLatitude(), aim.getLongitude());
|
||||
}
|
||||
LonLatPoint p1 = points.get(0);
|
||||
LonLatPoint p2 = points.get(points.size() - 1);
|
||||
distanceOfCarToStopLine = MapDataApi.INSTANCE.getNearstFromPointToSegment(carLoc.getLongitude(), carLoc.getLatitude(), p1.longitude, p1.latitude, p2.longitude, p2.latitude);
|
||||
stopInfo.setDistanceOfCarToStopLine(distanceOfCarToStopLine);
|
||||
}
|
||||
Log.d(TAG, "-- onStopLineInfo --- distance: "+ distanceOfCarToStopLine);
|
||||
stopInfo.setDistanceOfCarToStopLine(distanceOfCarToStopLine);
|
||||
Log.d(TAG, "-- :");
|
||||
CallerMapRoadListenerManager.INSTANCE.invokeListenersOnStopLineGet(stopInfo);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user