[644][adas] 能否启动自驾 添加原始数据日志
This commit is contained in:
@@ -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
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user