Merge branch 'dev_robotaxi-d_230711_3.4.0' of gitlab.zhidaoauto.com:SCA/L4HA/AndroidApp/MoGoEagleEye into dev_robotaxi-d_230711_3.4.0

This commit is contained in:
xinfengkun
2023-07-12 16:02:51 +08:00
11 changed files with 60 additions and 161 deletions

View File

@@ -81,7 +81,7 @@ internal object V2NIdentifyDrawer {
CallerHmiManager.warningV2X(poiType, alertContent, ttsContent, object : IMoGoWarningStatusListener {
override fun onShow() {
super.onShow()
CallerVisualAngleManager.changeAngle(RoadEvent)
CallerVisualAngleManager.changeAngle(RoadEvent(itx.longitude, itx.latitude, itx.angle))
}
override fun onDismiss() {
@@ -136,7 +136,7 @@ internal object V2NIdentifyDrawer {
CallerHmiManager.warningV2X(poiType, alertContent, ttsContent, object : IMoGoWarningStatusListener {
override fun onShow() {
super.onShow()
CallerVisualAngleManager.changeAngle(RoadEvent)
CallerVisualAngleManager.changeAngle(RoadEvent(lon, lat, car.heading))
}
override fun onDismiss() {

View File

@@ -153,13 +153,16 @@ public class V2XRoadEventScenario extends AbsV2XScenario<V2XRoadEventEntity> imp
@Override
public void onShow() {
if (isNeedChangeAngle()) {
CallerVisualAngleManager.INSTANCE.changeAngle(RoadEvent.INSTANCE);
}
V2XMessageEntity<V2XRoadEventEntity> entity = getV2XMessageEntity();
if (entity != null) {
V2XRoadEventEntity content = entity.getContent();
if (content != null) {
if (isNeedChangeAngle()) {
MarkerLocation location = content.getLocation();
if (location != null) {
CallerVisualAngleManager.INSTANCE.changeAngle(new RoadEvent(content.getLocation().getLon(), content.getLocation().getLat(), content.getLocation().getAngle()));
}
}
if (entity.isNeedAddLine() && !EventTypeEnumNew.TYPE_SOCKET_ROAD_CONGESTION.getPoiType().equals(content.getPoiType())) {
drawPOI();
}

View File

@@ -7,8 +7,6 @@ import com.mogo.eagle.core.data.config.HmiBuildConfig
import com.mogo.eagle.core.data.enums.*
import com.mogo.eagle.core.data.obu.MogoObuConst
import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener
import com.mogo.eagle.core.function.api.map.angle.Default
import com.mogo.eagle.core.function.api.map.angle.TooClose
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager
@@ -949,20 +947,7 @@ class MogoPrivateObuNewManager private constructor() : OnUpgradeListener {
CallerHmiManager.warningV2X(v2xType,
alertContent,
ttsContent,// 只有第一次才tts防止更新的时候不断的提醒
object : IMoGoWarningStatusListener {
override fun onShow() {
super.onShow()
if (changeVisualAngle) {
CallerVisualAngleManager.changeAngle(TooClose)
}
}
override fun onDismiss() {
if (changeVisualAngle) {
CallerVisualAngleManager.changeAngle(Default())
}
}
},
null,
direction,
isFromObu = true
)

View File

@@ -10,12 +10,10 @@ import com.alibaba.android.arouter.facade.annotation.Route
import com.mogo.eagle.core.data.config.*
import com.mogo.eagle.core.data.constants.MogoServicePaths
import com.mogo.eagle.core.data.map.*
import com.mogo.eagle.core.data.map.MapRoadInfo.StopLine
import com.mogo.eagle.core.function.api.map.angle.*
import com.mogo.eagle.core.function.api.map.angle.Scene
import com.mogo.eagle.core.function.call.autopilot.*
import com.mogo.eagle.core.function.call.map.*
import com.mogo.eagle.core.function.call.map.CallerMapRoadListenerManager.OnRoadListener
import com.mogo.eagle.core.utilcode.kotlin.*
import com.mogo.eagle.core.utilcode.mogo.*
import com.mogo.eagle.core.utilcode.mogo.logger.*
@@ -32,11 +30,8 @@ class MoGoVisualAngleChangeProvider: IMoGoVisualAngleChangeProvider {
private const val TAG = "VisualAngleChange"
}
private val triggerLocation = AtomicReference<MogoLocation>()
private val distanceOfCarToStopLine = AtomicReference(0.0)
private val travelled by lazy { AtomicReference(0.0) }
@Volatile
private var roadEventFlag: Boolean = false
/**
* 业务实体,不对外暴露
@@ -55,52 +50,6 @@ class MoGoVisualAngleChangeProvider: IMoGoVisualAngleChangeProvider {
PriorityQueue<Record>()
}
private val listener = object : OnRoadListener {
private val roadId = AtomicReference<String>()
private val triggerRoadId = AtomicReference<String>()
override fun onRoadIdInfo(roadId: String) {
this.roadId.set(roadId)
Log.d(TAG, "-- onRoadIdInfo --: prev: ${this.triggerRoadId.get()} -> curr: $roadId")
val loc = CallerChassisLocationGCJ02ListenerManager.getChassisLocationGCJ02()
var triggerClose = false
val distance = distanceOfCarToStopLine.get() + 5
if (hasCrossRoad && distance > 0) {
val prev = triggerLocation.get()
if (prev != null) {
travelled.set(MapTools.distance(loc.longitude, loc.latitude, prev.longitude, prev.latitude) + travelled.get())
triggerLocation.set(loc)
}
val oldRoadId = triggerRoadId.get()
Log.d(TAG, "-- onRoadIdInfo --: travelled --: ${travelled.get()}")
if ((travelled.get() > distance) && oldRoadId != roadId) {
distanceOfCarToStopLine.set(0.0)
hasCrossRoad = false
triggerRoadId.set(null)
travelled.set(0.0)
triggerLocation.set(null)
Log.d(TAG, "-- onRoadIdInfo --: trigger close --")
triggerClose = true
}
}
if (triggerClose) {
changeAngle(CrossRoad(false))
}
}
override fun onStopLineInfo(info: StopLine) {
Log.d(TAG, "-- onStopLineInfo --: ${info.distanceOfCarToStopLine}")
if (!hasCrossRoad && info.distanceOfCarToStopLine <= 30.0) {
hasCrossRoad = true
triggerRoadId.set(this.roadId.get())
distanceOfCarToStopLine.set(info.distanceOfCarToStopLine)
triggerLocation.set(CallerChassisLocationGCJ02ListenerManager.getChassisLocationGCJ02())
changeAngle(CrossRoad(true))
}
}
}
override fun init(context: Context?) {
if (Thread.currentThread() != Looper.getMainLooper().thread) {
scope.launch {
@@ -120,13 +69,8 @@ class MoGoVisualAngleChangeProvider: IMoGoVisualAngleChangeProvider {
}
}
})
CallerMapRoadListenerManager.registerRoadListener("VisualAngleChange", listener)
}
@Volatile
private var hasCrossRoad = false
private var scope: CoroutineScope = acquireScope()
@Synchronized
get() {
@@ -161,12 +105,6 @@ class MoGoVisualAngleChangeProvider: IMoGoVisualAngleChangeProvider {
val displayed = getDisplayed()
if (displayed == null) {
Log.d(TAG, "--- 2 ---")
if (scene is Turning) {
if (!scene.open) {
changeAngle(Default())
return@launch
}
}
if (scene is CrossRoad) {
if (!scene.open) {
changeAngle(Default())
@@ -178,7 +116,7 @@ class MoGoVisualAngleChangeProvider: IMoGoVisualAngleChangeProvider {
val prev = displayed.target
Log.d(TAG, "--- 3 --- old: $prev -> cur: $scene")
val prevTriggerTime = displayed.triggerTime
if (scene !is Default && prev.priority > scene.priority && (prev is RoadEvent || prev is TooClose)) {
if (scene !is Default && prev.priority > scene.priority && (prev is RoadEvent)) {
val displayDuration = triggerTime - prevTriggerTime
Log.d(TAG, "--- 4 ---:场景[$prev], 已展示时长: duration: $displayDuration")
if (displayDuration < prev.displayThreshold) {
@@ -191,15 +129,6 @@ class MoGoVisualAngleChangeProvider: IMoGoVisualAngleChangeProvider {
return@launch
}
}
if (prev is Turning && scene is Turning) {
val isOpen = scene.open
if (!isOpen) {
Log.d(TAG, "--- 7 --- 场景[$scene], 收到关闭通知")
queue -= displayed
changeAngle(Default())
return@launch
}
}
if (prev is CrossRoad && scene is CrossRoad) {
val isOpen = scene.open
if (!isOpen) {
@@ -251,13 +180,6 @@ class MoGoVisualAngleChangeProvider: IMoGoVisualAngleChangeProvider {
displayed?.also {
queue -= it
}
if (target is Turning) {
if (!target.open) {
Log.d(TAG, "--- doRealVisualAngleChange --- 7 ---")
changeAngle(Default())
return
}
}
if (target is CrossRoad) {
if (!target.open) {
Log.d(TAG, "--- doRealVisualAngleChange --- 8 ---")
@@ -282,7 +204,21 @@ class MoGoVisualAngleChangeProvider: IMoGoVisualAngleChangeProvider {
queue += record
}
}
it.changeMapVisualAngle(angle, null)
if (record.target is Default && roadEventFlag) {
roadEventFlag = false
it.setLockMode(true)
}
if (record.target is RoadEvent) {
it.setLockMode(false)
roadEventFlag = true
it.animateTo(record.target.poi_lon, record.target.poi_lon, 0f, 1000, true)
scope.launch {
delay(500)
it.changeMapVisualAngle(angle, null)
}
} else {
it.changeMapVisualAngle(angle, null)
}
}
}

View File

@@ -94,15 +94,12 @@ class MapBizView(context: Context?, attrs: AttributeSet?) : MogoMapView(context,
lightSwitch?.let {
when (it.number) {
Chassis.LightSwitch.LIGHT_LEFT_VALUE -> { //左转灯
CallerVisualAngleManager.showTurning(true)
turn(1)
}
Chassis.LightSwitch.LIGHT_RIGHT_VALUE -> { //右转灯
CallerVisualAngleManager.showTurning(true)
turn(2)
}
Chassis.LightSwitch.LIGHT_NONE_VALUE -> {
CallerVisualAngleManager.showTurning(false)
turn(0)
}
}

View File

@@ -34,53 +34,17 @@ class Default(val delay: Long = 2, val unit: TimeUnit = SECONDS): Scene() {
}
/**
* 变道-接收到转向灯信息号
*/
class Turning(var open: Boolean = false): Scene() {
override val angle: VisualAngleMode = VisualAngleMode.MAP_STYLE_VR_ANGLE_TOP
override val priority: Int = 3
override val displayThreshold: Long
get() = -1
override fun toString(): String {
return "Turning(open: ${open}, priority=$priority, displayThreshold: $displayThreshold, priority=$priority)"
}
}
/**
* 后方车辆离自车过近
*/
object TooClose: Scene() {
override val angle: VisualAngleMode = VisualAngleMode.MAP_STYLE_VR_ANGLE_300
override val priority: Int = 2
override val displayThreshold: Long
get() = SECONDS.toMillis(8)
override fun toString(): String {
return "TooClose(priority=$priority, displayThreshold: $displayThreshold, priority=$priority)"
}
}
/**
* 道路事件
*/
object RoadEvent: Scene() {
class RoadEvent(val poi_lon: Double, val poi_lat: Double, val poi_angle: Double): Scene() {
override val angle: VisualAngleMode = VisualAngleMode.MODE_LONG_SIGHT
override val priority: Int = 5
override val displayThreshold: Long
get() = SECONDS.toMillis(8)
get() = SECONDS.toMillis(5)
override fun toString(): String {
return "RoadEvent(priority=${priority}, displayThreshold: ${displayThreshold}, priority=${priority})"

View File

@@ -15,9 +15,6 @@ object CallerVisualAngleManager {
.navigation() as? IMoGoVisualAngleChangeProvider
}
@Volatile
private var isVisualAngleChanged = false
fun init() {
provider?.let {
Log.d("CallerVisualAngle", "--- init ---")
@@ -32,18 +29,4 @@ object CallerVisualAngleManager {
fun updateLongSightLevel(level: Boolean) {
provider?.updateLongSightLevel(level)
}
fun showTurning(open: Boolean) {
if (open) {
if (!isVisualAngleChanged) {
isVisualAngleChanged = true
changeAngle(Turning(true))
}
} else {
if (isVisualAngleChanged) {
isVisualAngleChanged = false
changeAngle(Turning(false))
}
}
}
}

View File

@@ -378,4 +378,15 @@ public interface IMogoMapUIController {
void cancelDownloadCacheData();
String getCityCode();
/**
* 自动切换视角到指定点包含过渡动画并持续指定duration毫秒
*
* @param lon 经度
* @param lat 纬度
* @param rotateAngle 旋转角度
* @param duration 持续时间
* @param isGps 是否是高精坐标
*/
void animateTo(double lon, double lat, float rotateAngle, int duration, boolean isGps);
}

View File

@@ -1154,4 +1154,10 @@ public class AMapViewWrapper implements IMogoMapView,
return GDLocationClient.getInstance(getContext()).getLastCityCode();
}
@Override
public void animateTo(double lon, double lat, float rotateAngle, int duration, boolean isGps) {
if (mMapView.getMapAutoViewHelper() != null) {
mMapView.getMapAutoViewHelper().animateTo(lon, lat, rotateAngle, duration, isGps);
}
}
}

View File

@@ -505,4 +505,11 @@ public class MogoMapUIController implements IMogoMapUIController {
}
return null;
}
@Override
public void animateTo(double lon, double lat, float rotateAngle, int duration, boolean isGps) {
if (mDelegate != null) {
mDelegate.animateTo(lon, lat, rotateAngle, duration, isGps);
}
}
}

View File

@@ -442,4 +442,11 @@ public class AMapUIController implements IMogoMapUIController {
}
return null;
}
@Override
public void animateTo(double lon, double lat, float rotateAngle, int duration, boolean isGps) {
if (mClient != null) {
mClient.animateTo(lon, lat, rotateAngle, duration, isGps);
}
}
}