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

This commit is contained in:
xinfengkun
2024-11-21 10:22:30 +08:00
14 changed files with 200 additions and 23 deletions

View File

@@ -11,6 +11,7 @@ import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.mogo.commons.AbsMogoApplication
import com.mogo.commons.debug.DebugConfig
import com.mogo.commons.voice.AIAssist
import com.mogo.eagle.core.data.EnvConfig
import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.data.config.HmiBuildConfig.isShowRouteStrategy
@@ -59,6 +60,7 @@ import com.zhjt.mogo_core_function_devatools.block.MoGoBlockProviderImpl
import com.zhjt.mogo_core_function_devatools.coldstart.ColdStartManager
import com.zhjt.mogo_core_function_devatools.driver.video.DriveSeatVideoProviderImpl
import com.mogo.eagle.core.function.api.driver.video.IDriveSeatVideoProvider
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
import com.zhjt.mogo_core_function_devatools.env.EnvChangeManager
import com.zhjt.mogo_core_function_devatools.exam.ExamControlManager
import com.zhjt.mogo_core_function_devatools.funcconfig.FuncConfigCenter.Companion.bizConfigCenter
@@ -76,6 +78,7 @@ import com.zhjt.mogo_core_function_devatools.report.IPCReportManager.Companion.i
import com.zhjt.mogo_core_function_devatools.scene.SceneManager.Companion.sceneManager
import com.zhjt.mogo_core_function_devatools.status.StatusManager
import com.zhjt.mogo_core_function_devatools.status.entity.RouteDownloadStatus
import com.zhjt.mogo_core_function_devatools.status.entity.SafetyStopCarStatus
import com.zhjt.mogo_core_function_devatools.status.entity.Status
import com.zhjt.mogo_core_function_devatools.status.ui.AutoPilotLaunchBeforeView
import com.zhjt.mogo_core_function_devatools.strict.StrictModeProviderImpl
@@ -87,6 +90,7 @@ import com.zhjt.mogo_core_function_devatools.weaknetwork.DetectResultImpl
import com.zhjt.mogo_core_function_devatools.weaknetwork.WeakNetworkStrategy
import com.zhjt.mogo_core_function_devatools.workorder.WorkOrderManager
import com.zhjt.service.chain.ChainLog
import fsm.Fsm2024
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import java.lang.ref.WeakReference
@@ -142,6 +146,27 @@ class DevaToolsProvider : IDevaToolsProvider, IAppStateListener {
listener.invoke(s.state.ordinal)
}
}
} else if (s is SafetyStopCarStatus) {
val state = s.data?.functionState
if (state != null) {
if (state == Fsm2024.State.SAFETY_STOP) {
if (AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) {
AppStateManager.currentActivity()?.also {
AIAssist.getInstance(it).speakTTSVoice("识别故障即将停车,请注意观察,小心接管")
}
CallerHmiManager.toggleSafetyStopCarWarning(true)
}
}
if (state == Fsm2024.State.SAFETY_STOPPED) {
if (AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) {
CallerHmiManager.toggleSafetyStopCarWarning(false)
AppStateManager.currentActivity()?.also {
AIAssist.getInstance(it).speakTTSVoice("请接管恢复停车状态")
}
}
}
}
}
}
val status = getExceptionStatusBeforeLaunchAutopilot(-2)

View File

@@ -29,6 +29,7 @@ import com.zhjt.mogo_core_function_devatools.status.flow.autopilot.SpeedImpl
import com.zhjt.mogo_core_function_devatools.status.flow.autopilot.SteerImpl
import com.zhjt.mogo_core_function_devatools.status.flow.can.CanImpl
import com.zhjt.mogo_core_function_devatools.status.flow.fsm.FSMImpl
import com.zhjt.mogo_core_function_devatools.status.flow.fsm.SafetyStopCarImpl
import com.zhjt.mogo_core_function_devatools.status.flow.gps.GpsImpl
import com.zhjt.mogo_core_function_devatools.status.flow.ipc.IpcImpl
import com.zhjt.mogo_core_function_devatools.status.flow.rtk.RTKImpl
@@ -99,6 +100,7 @@ object StatusManager {
is FSMStatus -> FSMImpl(ctx)
is RouteDownloadStatus -> RouteDownloadImpl(ctx)
is OtherErrorStatus -> OtherErrorImpl(ctx)
is SafetyStopCarStatus -> SafetyStopCarImpl(ctx)
}
}.also { flows += it }
for (f in flows) {
@@ -192,7 +194,7 @@ object StatusManager {
}
var xor = 0
model.status.value?.second?.filter {
it is IAutopilotPreLaunchStatus
it is IAutopilotBeforeLaunchStatus
}?.takeIf {
it.isNotEmpty()
}?.also { l ->

View File

@@ -18,6 +18,14 @@ import com.zhjt.mogo_core_function_devatools.status.entity.TracingStatus.Tracing
import com.zhjt.mogo_core_function_devatools.status.entity.TracingStatus.Tracing.TRACK_LOAD_FAIL
import com.zhjt.mogo_core_function_devatools.status.entity.TracingStatus.Tracing.TRACK_NOT_EXIST
import com.zhjt.mogo_core_function_devatools.status.entity.TracingStatus.Tracing.UNKNOWN
import fsm.Fsm2024
interface IAutopilotLaunchStatus
interface IAutopilotBeforeLaunchStatus: IAutopilotLaunchStatus
interface IAutopilotAfterLaunchStatus: IAutopilotLaunchStatus
sealed class Status(var rawData: Any? = null) {
@@ -143,7 +151,7 @@ enum class FSMStateCode {
/**
* FSM模块状态
*/
class FSMStatus(var state: FSMStateCode, var descList: List<String> = emptyList<String>()): Status(), IAutopilotPreLaunchStatus {
class FSMStatus(var state: FSMStateCode, var descList: List<String> = emptyList<String>()): Status(), IAutopilotBeforeLaunchStatus {
override fun equals(other: Any?): Boolean {
if (javaClass != other?.javaClass) return false
@@ -342,12 +350,11 @@ fun String.toState(msg: String?): Tracing? {
}
}
interface IAutopilotPreLaunchStatus
/**
* 速度
*/
data class SpeedStatus(val speed: Int): Status(), IAutopilotPreLaunchStatus {
data class SpeedStatus(val speed: Int): Status(), IAutopilotBeforeLaunchStatus {
override fun isException(): Boolean {
return false
@@ -368,7 +375,7 @@ data class SpeedStatus(val speed: Int): Status(), IAutopilotPreLaunchStatus {
/**
* 方向盘转角
*/
data class SteerStatus(val angle: Float, var isError: Boolean = false): Status(), IAutopilotPreLaunchStatus {
data class SteerStatus(val angle: Float, var isError: Boolean = false): Status(), IAutopilotBeforeLaunchStatus {
override fun isException(): Boolean {
@@ -394,7 +401,7 @@ data class SteerStatus(val angle: Float, var isError: Boolean = false): Status()
/**
* 油门
*/
data class AcceleratorStatus(val angle: Int, var isError: Boolean = false): Status(), IAutopilotPreLaunchStatus {
data class AcceleratorStatus(val angle: Int, var isError: Boolean = false): Status(), IAutopilotBeforeLaunchStatus {
override fun isException(): Boolean {
return isError && CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().state != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING
@@ -423,7 +430,7 @@ data class AcceleratorStatus(val angle: Int, var isError: Boolean = false): Stat
/**
* 刹车
*/
data class BrakeStatus(val angle: Int, var isError: Boolean = false): Status(), IAutopilotPreLaunchStatus {
data class BrakeStatus(val angle: Int, var isError: Boolean = false): Status(), IAutopilotBeforeLaunchStatus {
override fun isException(): Boolean {
return isError && CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().state != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING
@@ -456,7 +463,7 @@ data class BrakeStatus(val angle: Int, var isError: Boolean = false): Status(),
/**
* 双闪
*/
data class DoubleFlashStatus(val type: Int, var isError: Boolean = false): Status(), IAutopilotPreLaunchStatus {
data class DoubleFlashStatus(val type: Int, var isError: Boolean = false): Status(), IAutopilotBeforeLaunchStatus {
override fun isException(): Boolean {
return isError && CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().state != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING
@@ -487,7 +494,7 @@ data class DoubleFlashStatus(val type: Int, var isError: Boolean = false): Statu
/**
* 由于其它原因导致的启自驾异常
*/
data class OtherErrorStatus(val type: UnableType?, val reason: UnableLaunchReason?): Status(), IAutopilotPreLaunchStatus {
data class OtherErrorStatus(val type: UnableType?, val reason: UnableLaunchReason?): Status(), IAutopilotBeforeLaunchStatus {
override fun isException(): Boolean {
return type != null || reason != null
@@ -501,7 +508,7 @@ data class OtherErrorStatus(val type: UnableType?, val reason: UnableLaunchReaso
/**
* 挡位
*/
data class GearStatus(val value: Int, var isError: Boolean = false): Status(), IAutopilotPreLaunchStatus {
data class GearStatus(val value: Int, var isError: Boolean = false): Status(), IAutopilotBeforeLaunchStatus {
override fun isException(): Boolean {
return isError && CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().state != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING
@@ -543,7 +550,7 @@ enum class RouteState {
/**
* 轨迹下载状态
*/
data class RouteDownloadStatus(val lineId: Long = Long.MIN_VALUE, val state: RouteState = RouteNone): Status(), IAutopilotPreLaunchStatus {
data class RouteDownloadStatus(val lineId: Long = Long.MIN_VALUE, val state: RouteState = RouteNone): Status(), IAutopilotBeforeLaunchStatus {
override fun isException(): Boolean {
return (state == RouteStart || state == RouteFailed) && CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().state != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING
@@ -573,4 +580,27 @@ data class RouteDownloadStatus(val lineId: Long = Long.MIN_VALUE, val state: Rou
}
/***
* FSM功能异常触发安全停车
*/
data class SafetyStopCarStatus(val data: Fsm2024.FSMStateMsg? = null): Status(), IAutopilotAfterLaunchStatus {
override fun isException(): Boolean {
return data?.functionState == Fsm2024.State.SAFETY_STOP
}
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
other as SafetyStopCarStatus
return this.data?.functionState == other.data?.functionState
}
override fun hashCode(): Int {
return this.data?.functionState?.hashCode() ?: 0
}
}

View File

@@ -39,4 +39,6 @@ internal abstract class IFlow< T : Status>(val ctx: Context) : CoroutineScope {
open fun onDestroy() {
chl.safeCancel()
}
fun peek(): T? = chl.tryReceive().getOrNull()
}

View File

@@ -0,0 +1,59 @@
package com.zhjt.mogo_core_function_devatools.status.flow.fsm
import android.content.Context
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotCarConfigListener
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
import com.mogo.eagle.core.function.api.autopilot.IMoGoFsm2024Listener
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerFsm2024ListenerManager
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
import com.zhjt.mogo_core_function_devatools.status.entity.SafetyStopCarStatus
import com.zhjt.mogo_core_function_devatools.status.flow.IFlow
import fsm.Fsm2024
import fsm.Fsm2024.FSMStateMsg
internal class SafetyStopCarImpl(ctx: Context): IFlow<SafetyStopCarStatus>(ctx), IMoGoFsm2024Listener, IMoGoAutopilotStatusListener {
companion object {
private const val TAG = "SafetyStopCarImpl"
}
@Volatile
private var lastState: Int = -1
override fun onCreate() {
CallerFsm2024ListenerManager.addListener(TAG, this)
CallerAutoPilotStatusListenerManager.addListener(TAG, this)
}
override fun onFSM2024State(fsmState: FSMStateMsg) {
Logger.d(TAG, "--- onFSM2024State --- 1 ---: ${fsmState.functionState}")
if (fsmState.functionState == Fsm2024.State.SAFETY_STOP || fsmState.functionState == Fsm2024.State.SAFETY_STOPPED) {
send(SafetyStopCarStatus(fsmState))
}
}
override fun onDestroy() {
super.onDestroy()
CallerFsm2024ListenerManager.removeListener(TAG)
CallerAutoPilotStatusListenerManager.removeListener(TAG)
}
override fun onAutopilotStatusResponse(state: Int) {
super.onAutopilotStatusResponse(state)
Logger.d(TAG, "--- onAutopilotStatusResponse --- 1 ---: $state")
if (lastState == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING && lastState != state) {
//从自驾转成非自驾
Logger.d(TAG, "--- onAutopilotStatusResponse --- 2 ---: $state")
if (peek()?.data?.functionState == Fsm2024.State.SAFETY_STOP) {
Logger.d(TAG, "--- onAutopilotStatusResponse --- 3 ---: $state")
CallerHmiManager.toggleSafetyStopCarWarning(false)
}
}
if (lastState != state) {
lastState = state
}
}
}

View File

@@ -29,6 +29,7 @@ internal class StatusModel : ViewModel() {
it += OtherErrorStatus(null, null)
it += RouteDownloadStatus()
it += SpeedStatus(0)
it += SafetyStopCarStatus()
})
}

View File

@@ -22,7 +22,7 @@ import com.zhjt.mogo_core_function_devatools.status.entity.AcceleratorStatus
import com.zhjt.mogo_core_function_devatools.status.entity.BrakeStatus
import com.zhjt.mogo_core_function_devatools.status.entity.DoubleFlashStatus
import com.zhjt.mogo_core_function_devatools.status.entity.GearStatus
import com.zhjt.mogo_core_function_devatools.status.entity.IAutopilotPreLaunchStatus
import com.zhjt.mogo_core_function_devatools.status.entity.IAutopilotBeforeLaunchStatus
import com.zhjt.mogo_core_function_devatools.status.entity.SpeedStatus
import com.zhjt.mogo_core_function_devatools.status.entity.Status
import com.zhjt.mogo_core_function_devatools.status.entity.SteerStatus
@@ -66,7 +66,7 @@ class AutoPilotLaunchBeforeView: LinearLayout, IStatusListener {
@SuppressLint("SetTextI18n")
override fun onStatusChanged(changed: List<Status>, all: List<Status>) {
changed.filter { it is IAutopilotPreLaunchStatus }.forEach { status ->
changed.filter { it is IAutopilotBeforeLaunchStatus }.forEach { status ->
val isError = status.isException() && CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().state != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING
Logger.d(TAG, "--- onChanged ---:$isError")
when(status) {

View File

@@ -9,8 +9,7 @@ import androidx.recyclerview.widget.*
import com.mogo.eagle.core.utilcode.kotlin.*
import com.mogo.eagle.core.utilcode.rv.divider.*
import com.zhjt.mogo_core_function_devatools.R
import com.zhjt.mogo_core_function_devatools.status.entity.FSMStatus
import com.zhjt.mogo_core_function_devatools.status.entity.IAutopilotPreLaunchStatus
import com.zhjt.mogo_core_function_devatools.status.entity.IAutopilotLaunchStatus
import com.zhjt.mogo_core_function_devatools.status.entity.Status
import com.zhjt.mogo_core_function_devatools.status.model.StatusModel
import com.zhjt.mogo_core_function_devatools.status.ui.adapter.StatusAdapter
@@ -36,12 +35,12 @@ internal class StatusView(private val model: StatusModel, ctx: Context): Constra
override fun onAttachedToWindow() {
super.onAttachedToWindow()
val adapter = model.status.value?.let { data -> StatusAdapter(context, data.second.filter { it !is IAutopilotPreLaunchStatus }) }?.also { adapter -> rv.adapter = adapter }
val adapter = model.status.value?.let { data -> StatusAdapter(context, data.second.filter { (it !is IAutopilotLaunchStatus) }) }?.also { adapter -> rv.adapter = adapter }
adapter?.let { _ ->
observer?.also { model.status.removeObserver(it) }
model.status.observeForever(Observer<Pair<Status?, ArrayList<Status>>> { data ->
val old = adapter.data
val update = data.second.filter { it !is IAutopilotPreLaunchStatus }
val update = data.second.filter { it !is IAutopilotLaunchStatus }
val result = DiffUtil.calculateDiff(StatusDiffCallback(old, update))
adapter.data = update
result.dispatchUpdatesTo(adapter)
@@ -65,10 +64,6 @@ internal class StatusView(private val model: StatusModel, ctx: Context): Constra
.build()
)
}
// onDetach {
// observer?.also { model.status.removeObserver(it) }
// }
}
override fun onVisibilityChanged(changedView: View, visibility: Int) {

View File

@@ -21,7 +21,7 @@ import com.zhjt.mogo_core_function_devatools.status.entity.DoubleFlashStatus
import com.zhjt.mogo_core_function_devatools.status.entity.FSMStateCode
import com.zhjt.mogo_core_function_devatools.status.entity.FSMStatus
import com.zhjt.mogo_core_function_devatools.status.entity.GearStatus
import com.zhjt.mogo_core_function_devatools.status.entity.IAutopilotPreLaunchStatus
import com.zhjt.mogo_core_function_devatools.status.entity.IAutopilotBeforeLaunchStatus
import com.zhjt.mogo_core_function_devatools.status.entity.Status
import com.zhjt.mogo_core_function_devatools.status.entity.SteerStatus
import kotlinx.android.synthetic.main.view_start_autopilot_status.view.fSMStatusLayout
@@ -250,7 +250,7 @@ class StartAutoPilotStatusView @JvmOverloads constructor(
* @param all: 所有状态数据
*/
override fun onStatusChanged(changed: List<Status>, all: List<Status>) {
changed.filter { it is IAutopilotPreLaunchStatus }.forEach { status ->
changed.filter { it is IAutopilotBeforeLaunchStatus }.forEach { status ->
Logger.d(TAG, "onStatusChanged --> ${status::class.simpleName}")
when (status) {
is FSMStatus -> {

View File

@@ -7,6 +7,12 @@ import android.view.Gravity
import android.view.View
import android.view.ViewGroup
import android.view.ViewStub
import android.view.WindowManager
import android.view.animation.AccelerateDecelerateInterpolator
import android.widget.FrameLayout
import androidx.core.content.ContextCompat
import androidx.core.view.ViewCompat
import androidx.core.view.doOnAttach
import androidx.lifecycle.ProcessLifecycleOwner
import androidx.lifecycle.lifecycleScope
import androidx.transition.Slide
@@ -61,6 +67,7 @@ import com.mogo.eagle.core.function.hmi.ui.widget.StatusBarView
import com.mogo.eagle.core.function.hmi.xiaozhi.XiaoZhiStateManager
import com.mogo.eagle.core.utilcode.floating.MoGoPopWindow
import com.mogo.eagle.core.utilcode.kotlin.safeCancel
import com.mogo.eagle.core.utilcode.kotlin.scope
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_HMI
@@ -107,6 +114,11 @@ class MoGoHmiProvider : IMoGoHmiProvider {
*/
private val popOfVisualAngleAdjust by lazy { AtomicReference<WeakReference<MoGoPopWindow>>() }
/**
* fsm异常触发异常停车弹窗
*/
private val popOfSafetyStopCar by lazy { AtomicReference<WeakReference<MoGoPopWindow>>() }
override fun init(context: Context?) {
this.context = context
}
@@ -599,4 +611,39 @@ class MoGoHmiProvider : IMoGoHmiProvider {
}
}
override fun toggleSafeStopCarWarning(show: Boolean) {
val activity = AppStateManager.currentActivity() ?: return
val old = popOfSafetyStopCar.get()?.get()
if (show) {
if (old != null && old.isShowing()) {
return
}
val content = FrameLayout(activity)
ViewCompat.setBackground(content, ContextCompat.getDrawable(activity, R.drawable.fg_fsm_exception_status))
content.scope.launch {
while (true) {
content.animate().setInterpolator(AccelerateDecelerateInterpolator()).alpha(0f).setDuration(500).start()
delay(500)
content.animate().setInterpolator(AccelerateDecelerateInterpolator()).alpha(1.0f).setDuration(500).start()
delay(500)
}
}
MoGoPopWindow.Builder()
.attachToActivity(activity)
.width(WindowManager.LayoutParams.MATCH_PARENT)
.height(WindowManager.LayoutParams.MATCH_PARENT)
.contentView(content)
.onDismissed {
popOfSafetyStopCar.set(null)
}
.build()
.also {
popOfSafetyStopCar.set(WeakReference(it))
it.show()
}
} else {
old?.takeIf { it.isShowing() }?.also { it.hide() }
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 KiB