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

This commit is contained in:
aibingbing
2024-09-24 16:33:44 +08:00
3 changed files with 133 additions and 0 deletions

View File

@@ -79,6 +79,7 @@ import com.mogo.eagle.core.function.call.autopilot.CallerStartAutopilotFailedLis
import com.mogo.eagle.core.function.call.autopilot.CallerSweeperFutianCleanSystemListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerSweeperFutianCloudTaskListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerNodeStateListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerTakeoverListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerV2XListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerV2nNioEventListenerManager
import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager
@@ -204,6 +205,7 @@ class MoGoAdasListenerImpl : OnAdasListener {
vehicleState: VehicleStateOuterClass.VehicleState?
) {
CallerAutopilotActionsListenerManager.setVehicleState(vehicleState)
CallerTakeoverListenerManager.setVehicleState(vehicleState)
if (vehicleState != null) {
// 处理车辆状态
CallerChassisStatesListenerManager.invokeStates(vehicleState)
@@ -248,6 +250,7 @@ class MoGoAdasListenerImpl : OnAdasListener {
chassisStates: ChassisStatesOuterClass.ChassisStates?
) {
CallerAutopilotActionsListenerManager.setChassisStates(chassisStates)
CallerTakeoverListenerManager.setChassisStates(chassisStates)
if (chassisStates != null) {
CallerChassisStatesListenerManager.invokeNewStates(chassisStates)
chassisStates.taskSystemStates?.let { taskSystemStates ->

View File

@@ -0,0 +1,14 @@
package com.mogo.eagle.core.function.api.autopilot
/**
* 接管状态回调
*/
interface IMoGoTakeoverListener {
/**
* 接管状态
* @param state 0:未接管,1:油门接管,2:刹车接管,3:方向盘接管,4:遥控器接管,5:远程人工接管,6:硬件开关接管,7:软件接管,8:云端计算机接管,9:其他接管方式,255:缺省(鹰眼中表示数据异常)
*/
fun onTakeoverState(state: Int)
}

View File

@@ -0,0 +1,116 @@
package com.mogo.eagle.core.function.call.autopilot
import chassis.Chassis
import chassis.ChassisStatesOuterClass
import chassis.VehicleStateOuterClass
import com.mogo.eagle.core.function.api.autopilot.IMoGoTakeoverListener
import com.mogo.eagle.core.function.call.base.CallerBase
/**
* 接管状态
*/
object CallerTakeoverListenerManager : CallerBase<IMoGoTakeoverListener>() {
private fun invokeTakeoverState(state: Int) {
M_LISTENERS.forEach {
val listener = it.value
listener.onTakeoverState(state)
}
}
private fun calculate(
pilotMode: Chassis.PilotMode,
accelInference: Boolean,
brakeInference: Boolean,
steerInference: Boolean,
gearSwitchInference: Boolean
) {
var takeover = 0;
if (pilotMode == Chassis.PilotMode.MODE_REMOTE_DRIVE) {
takeover = 5;
} else if (accelInference) {
takeover = 1;
} else if (brakeInference) {
takeover = 2;
} else if (steerInference) {
takeover = 3;
} else if (gearSwitchInference) {
takeover = 9;
}
invokeTakeoverState(takeover)
}
fun setVehicleState(vehicleState: VehicleStateOuterClass.VehicleState?) {
if (vehicleState != null) {
calculate(
vehicleState.pilotMode,
vehicleState.accelInference,
vehicleState.brakeInference,
vehicleState.steerInference,
vehicleState.gearSwitchInference
);
} else {
invokeTakeoverState(255)
}
}
fun setChassisStates(chassisStates: ChassisStatesOuterClass.ChassisStates?) {
var pilotMode: Chassis.PilotMode? = null
var accelInference: Boolean? = null
var brakeInference: Boolean? = null
var steerInference: Boolean? = null
var gearSwitchInference: Boolean? = null
if (chassisStates != null) {
if (chassisStates.hasChassisAutopilotAssistanceInformation()) {
if (chassisStates.chassisAutopilotAssistanceInformation != null) {
if (chassisStates.chassisAutopilotAssistanceInformation.hasChassisPilotModeState()) {
pilotMode =
chassisStates.chassisAutopilotAssistanceInformation.chassisPilotModeState
}
}
}
if (chassisStates.hasDrivingSystemStates()) {
if (chassisStates.drivingSystemStates != null) {
if (chassisStates.drivingSystemStates.hasAccelerationPedalInferenceState()) {
accelInference =
chassisStates.drivingSystemStates.accelerationPedalInferenceState
}
}
}
if (chassisStates.hasBrakeSystemStates()) {
if (chassisStates.brakeSystemStates != null) {
if (chassisStates.brakeSystemStates.hasBrakePedalInferenceState()) {
brakeInference =
chassisStates.brakeSystemStates.brakePedalInferenceState
}
}
}
if (chassisStates.hasSteerSystemStates()) {
if (chassisStates.steerSystemStates != null) {
if (chassisStates.steerSystemStates.hasSteeringWheelInferenceState()) {
steerInference =
chassisStates.steerSystemStates.steeringWheelInferenceState
}
}
}
if (chassisStates.hasGearSystemStates()) {
if (chassisStates.gearSystemStates != null) {
if (chassisStates.gearSystemStates.hasGearSwitchInferenceState()) {
gearSwitchInference =
chassisStates.gearSystemStates.gearSwitchInferenceState
}
}
}
}
if (pilotMode != null && accelInference != null && brakeInference != null && steerInference != null && gearSwitchInference != null) {
calculate(
pilotMode, accelInference, brakeInference, steerInference, gearSwitchInference
);
} else {
invokeTakeoverState(255)
}
}
}