[644][adas] 能否启动自驾 添加原始数据日志

This commit is contained in:
xinfengkun
2024-05-22 20:01:14 +08:00
parent d8f7b53444
commit 98edf0ca49
23 changed files with 432 additions and 178 deletions

View File

@@ -59,11 +59,10 @@ import com.mogo.support.obu.ObuScene
import com.zhidao.support.adas.high.OnAdasListener
import com.zhjt.mogo.adas.data.bean.AdasParam
import com.zhidao.support.adas.high.common.ProtocolStatus
import com.zhjt.mogo.adas.data.AdasConstants
import com.zhjt.mogo.adas.data.AiCloudTask
import com.zhjt.mogo.adas.data.bean.AutopilotStatistics
import com.zhjt.mogo.adas.data.bean.ReceivedAck
import com.zhjt.mogo.adas.data.bean.UnableLaunchData
import com.zhjt.mogo.adas.data.bean.LaunchConditionData
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason
import com.zhjt.mogo.adas.data.sweeper.bootable.SweeperBootable
import com.zhjt.mogo.adas.data.sweeper.task.SweeperTask
@@ -168,6 +167,7 @@ class MoGoAdasListenerImpl : OnAdasListener {
header: MessagePad.Header,
vehicleState: VehicleStateOuterClass.VehicleState?
) {
CallerAutopilotActionsListenerManager.setVehicleState(vehicleState)
if (vehicleState != null) {
//转向灯数据
// CallerChassisLamplightListenerManager.invokeAutopilotLightSwitchData(vehicleState.light)
@@ -230,6 +230,7 @@ class MoGoAdasListenerImpl : OnAdasListener {
header: MessagePad.Header,
chassisStates: ChassisStatesOuterClass.ChassisStates?
) {
CallerAutopilotActionsListenerManager.setChassisStates(chassisStates)
if (chassisStates != null) {
chassisStates.bcmSystemStates?.let { bcmSystemStates ->
// bcmSystemStates.turnLightState?.let {
@@ -937,13 +938,13 @@ class MoGoAdasListenerImpl : OnAdasListener {
*/
override fun onAutopilotAbility(
isAutopilotAbility: Boolean,
unableLaunchData: UnableLaunchData,
launchConditionData: LaunchConditionData,
unableAutopilotReasons: ArrayList<UnableLaunchReason>?
) {
if (unableAutopilotReasons != null && unableAutopilotReasons.size > 0) {
autopilotAbilityCheck(isAutopilotAbility, unableAutopilotReasons.toString(), unableLaunchData)
autopilotAbilityCheck(isAutopilotAbility, unableAutopilotReasons.toString(), launchConditionData)
}
invokeAutopilotAbility(isAutopilotAbility, unableLaunchData, unableAutopilotReasons)
invokeAutopilotAbility(isAutopilotAbility, launchConditionData, unableAutopilotReasons)
}
override fun onParallelDrivingAbility(
@@ -968,7 +969,7 @@ class MoGoAdasListenerImpl : OnAdasListener {
nodeAliasCode = CHAIN_CODE_ADAS_ABILITY,
paramIndexes = [0, 1]
)
private fun autopilotAbilityCheck(isAutopilotAbility: Boolean, reason: String, unableLaunchData: UnableLaunchData) {
private fun autopilotAbilityCheck(isAutopilotAbility: Boolean, reason: String, launchConditionData: LaunchConditionData) {
}

View File

@@ -9,6 +9,7 @@ import androidx.lifecycle.Lifecycle.Event
import androidx.lifecycle.Lifecycle.Event.ON_CREATE
import androidx.lifecycle.Lifecycle.Event.ON_DESTROY
import com.mogo.commons.utils.MogoAnalyticUtils
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotActionsListenerManager
import com.mogo.eagle.core.utilcode.kotlin.*
import com.mogo.eagle.core.utilcode.mogo.logger.*
import com.mogo.eagle.core.utilcode.util.*
@@ -192,6 +193,7 @@ object StatusManager {
if (source != -2) {
l.filter { it.isException() }.also { ll ->
val time = System.currentTimeMillis()
val launchCondition = CallerAutopilotActionsListenerManager.getLaunchCondition()
ThreadUtils.getIoPool().execute {
val result = runCatching {
MogoAnalyticUtils.track(
@@ -210,6 +212,7 @@ object StatusManager {
else -> "其它"
}
}
itx["launch_condition"] = launchCondition
itx["data"] = GsonUtils.toJson(ll)
})
}

View File

@@ -5,7 +5,7 @@ import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotActionsListener
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisThrottleStateListener
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotActionsListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerChassisThrottleStateListenerManager
import com.zhjt.mogo.adas.data.bean.UnableLaunchData
import com.zhjt.mogo.adas.data.bean.LaunchConditionData
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason.UnableType.CHASSIS_THROTTLE
import com.zhjt.mogo_core_function_devatools.status.entity.AcceleratorStatus
@@ -47,7 +47,7 @@ internal class AcceleratorImpl(ctx: Context): IFlow<AcceleratorStatus>(ctx), IMo
}
}
override fun onAutopilotAbility(isAutopilotAbility: Boolean, unableLaunchData: UnableLaunchData?, unableAutopilotReasons: ArrayList<UnableLaunchReason>?) {
override fun onAutopilotAbility(isAutopilotAbility: Boolean, launchConditionData: LaunchConditionData?, unableAutopilotReasons: ArrayList<UnableLaunchReason>?) {
if (!isAutopilotAbility) {
val target = unableAutopilotReasons?.find { it.unableType == CHASSIS_THROTTLE }?.also { itx ->
isError = true

View File

@@ -5,7 +5,7 @@ import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotActionsListener
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisBrakeStateListener
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotActionsListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerChassisBrakeStateListenerManager
import com.zhjt.mogo.adas.data.bean.UnableLaunchData
import com.zhjt.mogo.adas.data.bean.LaunchConditionData
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason.UnableType.CHASSIS_BRAKE
import com.zhjt.mogo_core_function_devatools.status.entity.BrakeStatus
@@ -46,7 +46,7 @@ internal class BrakeImpl(ctx: Context): IFlow<BrakeStatus>(ctx), IMoGoChassisBra
}
}
override fun onAutopilotAbility(isAutopilotAbility: Boolean, unableLaunchData: UnableLaunchData?, unableAutopilotReasons: ArrayList<UnableLaunchReason>?) {
override fun onAutopilotAbility(isAutopilotAbility: Boolean, launchConditionData: LaunchConditionData?, unableAutopilotReasons: ArrayList<UnableLaunchReason>?) {
if (!isAutopilotAbility) {
val target = unableAutopilotReasons?.find { it.unableType == CHASSIS_BRAKE }?.also { itx ->
isError = true

View File

@@ -8,11 +8,9 @@ import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLamplightListener
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotActionsListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLamplightListenerManager
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
import com.zhjt.mogo.adas.data.bean.UnableLaunchData
import com.zhjt.mogo.adas.data.bean.LaunchConditionData
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason.UnableType.CHASSIS_HAZARD_LIGHTS
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason.UnableType.CHASSIS_THROTTLE
import com.zhjt.mogo_core_function_devatools.status.entity.AcceleratorStatus
import com.zhjt.mogo_core_function_devatools.status.entity.DoubleFlashStatus
import com.zhjt.mogo_core_function_devatools.status.flow.IFlow
@@ -54,7 +52,7 @@ internal class DoubleFlashImpl(ctx: Context): IFlow<DoubleFlashStatus>(ctx), IMo
}
override fun onAutopilotAbility(isAutopilotAbility: Boolean, unableLaunchData: UnableLaunchData?, unableAutopilotReasons: ArrayList<UnableLaunchReason>?) {
override fun onAutopilotAbility(isAutopilotAbility: Boolean, launchConditionData: LaunchConditionData?, unableAutopilotReasons: ArrayList<UnableLaunchReason>?) {
if (!isAutopilotAbility) {
val target = unableAutopilotReasons?.find { it.unableType == CHASSIS_HAZARD_LIGHTS }?.also { itx ->
isError = true

View File

@@ -7,12 +7,10 @@ import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotActionsListener
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisGearStateListener
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotActionsListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerChassisGearStateListenerManager
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
import com.zhjt.mogo.adas.data.bean.UnableLaunchData
import com.zhjt.mogo.adas.data.bean.LaunchConditionData
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason.UnableType.CHASSIS_GEAR
import com.zhjt.mogo_core_function_devatools.status.entity.GearStatus
import com.zhjt.mogo_core_function_devatools.status.entity.SteerStatus
import com.zhjt.mogo_core_function_devatools.status.flow.IFlow
internal class GearImpl(ctx: Context): IFlow<GearStatus>(ctx), IMoGoChassisGearStateListener, IMoGoAutopilotActionsListener {
@@ -48,7 +46,7 @@ internal class GearImpl(ctx: Context): IFlow<GearStatus>(ctx), IMoGoChassisGearS
}
}
override fun onAutopilotAbility(isAutopilotAbility: Boolean, unableLaunchData: UnableLaunchData?, unableAutopilotReasons: ArrayList<UnableLaunchReason>?) {
override fun onAutopilotAbility(isAutopilotAbility: Boolean, launchConditionData: LaunchConditionData?, unableAutopilotReasons: ArrayList<UnableLaunchReason>?) {
if (!isAutopilotAbility) {
val target = unableAutopilotReasons?.find { it.unableType == CHASSIS_GEAR }?.also { itx ->
isError = true

View File

@@ -6,7 +6,7 @@ import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisSteeringStateListe
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotActionsListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerChassisSteeringStateListenerManager
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
import com.zhjt.mogo.adas.data.bean.UnableLaunchData
import com.zhjt.mogo.adas.data.bean.LaunchConditionData
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason.UnableType.CHASSIS_STEERING
import com.zhjt.mogo_core_function_devatools.status.entity.SteerStatus
@@ -45,8 +45,8 @@ internal class SteerImpl(ctx: Context): IFlow<SteerStatus>(ctx), IMoGoChassisSte
}
}
override fun onAutopilotAbility(isAutopilotAbility: Boolean, unableLaunchData: UnableLaunchData?, unableAutopilotReasons: ArrayList<UnableLaunchReason>?) {
Logger.d(TAG, "onAutopilotAbility->($isAutopilotAbility, $unableLaunchData, ${unableAutopilotReasons?.joinToString(",")}")
override fun onAutopilotAbility(isAutopilotAbility: Boolean, launchConditionData: LaunchConditionData?, unableAutopilotReasons: ArrayList<UnableLaunchReason>?) {
Logger.d(TAG, "onAutopilotAbility->($isAutopilotAbility, $launchConditionData, ${unableAutopilotReasons?.joinToString(",")}")
if (!isAutopilotAbility) {
val target = unableAutopilotReasons?.find { it.unableType == CHASSIS_STEERING }?.also { itx ->
isError = true

View File

@@ -1,6 +1,6 @@
package com.mogo.eagle.core.function.api.autopilot
import com.zhjt.mogo.adas.data.bean.UnableLaunchData
import com.zhjt.mogo.adas.data.bean.LaunchConditionData
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason
@@ -9,5 +9,5 @@ import com.zhjt.mogo.adas.data.bean.UnableLaunchReason
*/
interface IMoGoAutopilotActionsListener {
fun onAutopilotAbility(isAutopilotAbility: Boolean, unableLaunchData: UnableLaunchData?, unableAutopilotReasons: ArrayList<UnableLaunchReason>?)
fun onAutopilotAbility(isAutopilotAbility: Boolean, launchConditionData: LaunchConditionData?, unableAutopilotReasons: ArrayList<UnableLaunchReason>?)
}

View File

@@ -1,9 +1,14 @@
package com.mogo.eagle.core.function.call.autopilot
import chassis.ChassisStatesOuterClass
import chassis.VehicleStateOuterClass
import com.google.protobuf.TextFormat
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotActionsListener
import com.mogo.eagle.core.function.call.base.CallerBase
import com.zhjt.mogo.adas.data.bean.UnableLaunchData
import com.zhjt.mogo.adas.data.bean.LaunchConditionData
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason
import org.json.JSONException
import org.json.JSONObject
/**
@@ -17,16 +22,27 @@ object CallerAutopilotActionsListenerManager : CallerBase<IMoGoAutopilotActionsL
private var isAutopilotAbility: Boolean = false
@Volatile
private var unableLaunchData: UnableLaunchData? = null
private var launchConditionData: LaunchConditionData? = null
@Volatile
private var unableAutopilotReasons: ArrayList<UnableLaunchReason>? = null
private var vehicleState: VehicleStateOuterClass.VehicleState? = null
private var chassisStates: ChassisStatesOuterClass.ChassisStates? = null
init {
isAutopilotAbility = false
unableAutopilotReasons = disconnectedReason()
}
fun setVehicleState(vehicleState: VehicleStateOuterClass.VehicleState?) {
this.vehicleState = vehicleState;
}
fun setChassisStates(chassisStates: ChassisStatesOuterClass.ChassisStates?) {
this.chassisStates = chassisStates;
}
private fun disconnectedReason(): ArrayList<UnableLaunchReason> {
val list = ArrayList<UnableLaunchReason>()
list.add(
@@ -47,12 +63,134 @@ object CallerAutopilotActionsListenerManager : CallerBase<IMoGoAutopilotActionsL
}
//获取域控发的原始数据目前包括新老SSM和FM数据
fun getOriginalData(): String {
return unableLaunchData?.json ?: ""
fun getLaunchConditionOriginalData(): String {
return launchConditionData?.json ?: ""
}
fun getUnableLaunchData(): UnableLaunchData? {
return unableLaunchData
fun getLaunchConditionData(): LaunchConditionData? {
return launchConditionData
}
fun getLaunchCondition(): String {
val jsonObject = JSONObject()
val chassisStatesObject = JSONObject()
val vehicleStateObject = JSONObject()
if (chassisStates != null) {
try {
if (chassisStates!!.hasHeader()) {
chassisStatesObject.put(
"data_header", TextFormat.printer().escapingNonAscii(false).printToString(
chassisStates!!.header
)
)
}
//制动踏板
var temp = "未知"
if (chassisStates!!.hasBrakeSystemStates()) {
val brake = chassisStates!!.brakeSystemStates.brakePedalResponsePosition
temp = brake.toString()
}
chassisStatesObject.put("brake", temp)
//油门踏板
temp = "未知"
if (chassisStates!!.hasDrivingSystemStates()) {
val throttle = chassisStates!!.drivingSystemStates.throttleResponsePosition
temp = throttle.toString()
}
chassisStatesObject.put("throttle", temp)
//档位
temp = "未知"
if (chassisStates!!.hasGearSystemStates()) {
val gear = chassisStates!!.gearSystemStates.gearPosition
temp = gear.name
}
chassisStatesObject.put("gear", temp)
//方向盘
temp = "未知"
if (chassisStates!!.hasSteerSystemStates()) {
val steerSystemStates = chassisStates!!.steerSystemStates
if (steerSystemStates.hasSteeringWheelAngle()) {
val throttle = steerSystemStates.steeringWheelAngle
temp = throttle.toString()
}
}
chassisStatesObject.put("steering", temp)
//车灯
temp = "未知"
if (chassisStates!!.hasBcmSystemStates()) {
val bcm = chassisStates!!.bcmSystemStates
temp = bcm.turnLightState.name
}
chassisStatesObject.put("light", temp)
} catch (e: Exception) {
e.printStackTrace()
}
}
if (vehicleState != null) {
if (vehicleState!!.hasHeader()) {
vehicleStateObject.put(
"data_header", TextFormat.printer().escapingNonAscii(false).printToString(
vehicleState!!.header
)
)
}
try {
//制动踏板
var temp = "未知"
if (vehicleState!!.hasBrake()) {
val brake = vehicleState!!.brake
temp = brake.toString()
}
vehicleStateObject.put("brake", temp)
//油门踏板
temp = "未知"
if (vehicleState!!.hasThrottle()) {
val throttle = vehicleState!!.throttle
temp = throttle.toString()
}
vehicleStateObject.put("throttle", temp)
//档位
temp = "未知"
if (vehicleState!!.hasGear()) {
val gear = vehicleState!!.gear
temp = gear.name
}
vehicleStateObject.put("gear", temp)
//方向盘
temp = "未知"
if (vehicleState!!.hasSteering()) {
val steering = vehicleState!!.steering
temp = steering.toString()
}
vehicleStateObject.put("steering", temp)
//车灯
temp = "未知"
if (vehicleState!!.hasLight()) {
val light = vehicleState!!.light
temp = light.name
}
vehicleStateObject.put("light", temp)
} catch (e: Exception) {
e.printStackTrace()
}
}
try {
jsonObject.put("chassis_states", chassisStatesObject)
} catch (e: JSONException) {
e.printStackTrace()
}
try {
jsonObject.put("vehicle_state", vehicleStateObject)
} catch (e: JSONException) {
e.printStackTrace()
}
try {
jsonObject.put("launch_condition_data", launchConditionData?.json ?: "")
} catch (e: JSONException) {
e.printStackTrace()
}
return jsonObject.toString()
}
/**
@@ -75,9 +213,10 @@ object CallerAutopilotActionsListenerManager : CallerBase<IMoGoAutopilotActionsL
@Synchronized
fun invokeAutopilotAbility(
isAutopilotAbility: Boolean,
unableLaunchData: UnableLaunchData,
launchCondition: LaunchConditionData,
unableAutopilotReasons: ArrayList<UnableLaunchReason>?
) {
this.launchConditionData = launchCondition
if (isConnected) {
var isEquals = true
if (unableAutopilotReasons != null && this.unableAutopilotReasons != null) {
@@ -92,7 +231,6 @@ object CallerAutopilotActionsListenerManager : CallerBase<IMoGoAutopilotActionsL
!(unableAutopilotReasons != null || this.unableAutopilotReasons != null)
if (this.isAutopilotAbility != isAutopilotAbility || !isEquals) {
this.isAutopilotAbility = isAutopilotAbility
this.unableLaunchData = unableLaunchData
this.unableAutopilotReasons = unableAutopilotReasons
notification()
}
@@ -104,7 +242,7 @@ object CallerAutopilotActionsListenerManager : CallerBase<IMoGoAutopilotActionsL
val listener = it.value
listener.onAutopilotAbility(
isAutopilotAbility,
unableLaunchData,
launchConditionData,
unableAutopilotReasons
)
}