[6.4.0][启自驾指引] 调用启自驾接口之前进行异常状态拦截,如果处于异常状态,进行toast和语音提示
This commit is contained in:
@@ -11,6 +11,8 @@ import chassis.Chassis.GearPosition.GEAR_N
|
||||
import chassis.Chassis.GearPosition.GEAR_NONE
|
||||
import chassis.Chassis.GearPosition.GEAR_P
|
||||
import chassis.Chassis.GearPosition.GEAR_R
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import com.zhjt.mogo_core_function_devatools.R
|
||||
import com.zhjt.mogo_core_function_devatools.status.StatusManager
|
||||
@@ -61,6 +63,7 @@ class AutoPilotLaunchBeforeView: LinearLayout, IStatusListener {
|
||||
|
||||
override fun onStatusChanged(data: List<Status>, hasException: Boolean) {
|
||||
data.filter { it is IAutopilotPreLaunchStatus }.forEach { status ->
|
||||
val isError = status.isException() && CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().state != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING
|
||||
when(status) {
|
||||
is GearStatus -> {
|
||||
val position = try { GearPosition.valueOf(status.value) } catch (ignore: Throwable) { GEAR_NONE }
|
||||
@@ -73,7 +76,6 @@ class AutoPilotLaunchBeforeView: LinearLayout, IStatusListener {
|
||||
gear_d?.isEnabled = false
|
||||
gear_d?.isSelected = false
|
||||
if (position != GEAR_NONE) {
|
||||
val isError = status.isError
|
||||
when(position) {
|
||||
GEAR_N -> if (isError) gear_n?.isEnabled = true else gear_n?.isSelected = true
|
||||
GEAR_R -> if (isError) gear_r?.isEnabled = true else gear_r?.isSelected = true
|
||||
@@ -84,23 +86,19 @@ class AutoPilotLaunchBeforeView: LinearLayout, IStatusListener {
|
||||
}
|
||||
}
|
||||
is AcceleratorStatus -> {
|
||||
val isError = status.isError
|
||||
val angle = status.angle
|
||||
iv_brake_or_accelerator?.isSelected = isError
|
||||
tv_brake_or_accelerator?.text = "a:${angle.toInt()}"
|
||||
}
|
||||
is BrakeStatus -> {
|
||||
val isError = status.isError
|
||||
val angle = status.angle
|
||||
iv_brake_or_accelerator?.isSelected = isError
|
||||
tv_brake_or_accelerator?.text = "a:-${angle.toInt()}"
|
||||
}
|
||||
is DoubleFlashStatus -> {
|
||||
val isError = status.isError
|
||||
iv_double_flash?.isSelected = isError
|
||||
}
|
||||
is SteerStatus -> {
|
||||
val isError = status.isError
|
||||
iv_steer?.isSelected = isError
|
||||
}
|
||||
is SpeedStatus -> {
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.mogo.eagle.core.function.call.autopilot
|
||||
|
||||
import android.os.SystemClock
|
||||
import chassis.SpecialVehicleTaskCmdOuterClass
|
||||
import com.mogo.commons.voice.AIAssist
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters
|
||||
import com.mogo.eagle.core.data.deva.badcase.BagManagerEntity
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig
|
||||
@@ -13,7 +14,11 @@ import com.mogo.eagle.core.data.biz.trafficlight.TrafficLightResult
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_CODE_OCH_TAXI_START_AUTOPILOT_MOFANG
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotControlProvider
|
||||
import com.mogo.eagle.core.function.call.base.CallerBase
|
||||
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import com.mogo.eagle.core.utilcode.util.AppStateManager
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils
|
||||
import com.zhjt.mogo.adas.data.sweeper.bootable.SweeperBootable.IsBootable
|
||||
import com.zhjt.mogo.adas.data.sweeper.task.SweeperTask.GetTaskReq
|
||||
import com.zhjt.mogo.adas.data.sweeper.task.SweeperTask.StartTaskResp
|
||||
@@ -25,6 +30,7 @@ import com.zhjt.mogo.adas.data.sweeper.task.cloud.s_r.SweeperTaskCloudSuspendRes
|
||||
import com.zhjt.service.chain.ChainLog
|
||||
import com.zhjt.service_biz.BizConfig
|
||||
import mogo.yycp.paralleldriving.protocol.ParallelDrivingRequest
|
||||
import java.lang.StringBuilder
|
||||
import kotlin.random.Random
|
||||
|
||||
|
||||
@@ -64,6 +70,47 @@ object CallerAutoPilotControlManager {
|
||||
* @param controlParameters 开启自动驾驶的控制参数
|
||||
*/
|
||||
fun startAutoPilot(controlParameters: AutopilotControlParameters?) {
|
||||
/**
|
||||
* 方向盘: 1<<0
|
||||
* 油门 : 1<<1
|
||||
* 刹车: 1<<2
|
||||
* 双闪: 1<<3
|
||||
* 档位: 1<<4
|
||||
*/
|
||||
val exceptionValue = CallerDevaToolsManager.getExceptionStatusBeforeLaunchAutopilot()
|
||||
if (exceptionValue != 0) {
|
||||
val sb = StringBuilder("请检查车辆")
|
||||
if ((exceptionValue and 1) != 0) {
|
||||
sb.append("方向盘$")
|
||||
}
|
||||
if (((exceptionValue and (1 shl 1)) != 0)) {
|
||||
sb.append("油门$")
|
||||
}
|
||||
if ((exceptionValue and (1 shl 2)) != 0) {
|
||||
sb.append("刹车$")
|
||||
}
|
||||
if ((exceptionValue and (1 shl 3)) != 0) {
|
||||
sb.append("双闪$")
|
||||
}
|
||||
if ((exceptionValue and (1 shl 4)) != 0) {
|
||||
sb.append("档位$")
|
||||
}
|
||||
val voiceText = sb.toString().let { str ->
|
||||
val count = str.count { it == '$' }
|
||||
if (count == 1) {
|
||||
str.replace("$", "")
|
||||
} else {
|
||||
str.removeSuffix("$").replace("$", "、")
|
||||
}
|
||||
}
|
||||
Logger.d(TAG, "voiceText: $voiceText")
|
||||
ToastUtils.showShort(voiceText)
|
||||
AppStateManager.currentActivity()?.also {
|
||||
AIAssist.getInstance(it).speakTTSVoice(voiceText)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if (controlParameters == null) {
|
||||
//LogUtils.eTag(TAG, "自动驾驶控制参数异常,请检查参数信息")
|
||||
return
|
||||
|
||||
@@ -363,4 +363,8 @@ object CallerDevaToolsManager {
|
||||
fun unRegisterRouteDownloadListener(tag: String) {
|
||||
devaToolsProviderApi?.unRegisterRouteDownloadListener(tag)
|
||||
}
|
||||
|
||||
fun getExceptionStatusBeforeLaunchAutopilot(): Int {
|
||||
return devaToolsProviderApi?.getExceptionStatusBeforeLaunchAutopilot() ?: 0
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user