[644][adas] 能否启动自驾 添加原始数据日志
This commit is contained in:
@@ -0,0 +1,163 @@
|
||||
package com.zhjt.mogo.adas.data.bean;
|
||||
|
||||
import com.google.protobuf.GeneratedMessageV3;
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
import com.google.protobuf.TextFormat;
|
||||
import com.google.protobuf.util.JsonFormat;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import chassis.Chassis;
|
||||
import chassis.ChassisStatesOuterClass;
|
||||
import function_state_management.FSMStatusReasonQueryOuterClass;
|
||||
import system_master.SsmInfo;
|
||||
import system_master.SystemStatusInfo;
|
||||
|
||||
/**
|
||||
* 检测启动自动驾驶的数据
|
||||
* 此类目前主要用于启动自驾命令下发后的域控数据记录
|
||||
*/
|
||||
public class LaunchConditionData {
|
||||
/**
|
||||
* 所使用的检测版本
|
||||
*/
|
||||
public final String abilityVersion;
|
||||
|
||||
|
||||
/**
|
||||
* 底盘数据
|
||||
* null表示未用到此数据
|
||||
*/
|
||||
public final ChassisStatesOuterClass.ChassisStates chassisStates;
|
||||
public final Chassis.LightSwitch light;
|
||||
public final float oldSteering;
|
||||
/**
|
||||
* 老SSM数据
|
||||
* null表示未用到此数据
|
||||
*/
|
||||
public final SystemStatusInfo.StatusInfo statusInfo;
|
||||
|
||||
/**
|
||||
* 新SSM数据
|
||||
* null表示未用到此数据
|
||||
*/
|
||||
public final SsmInfo.SsmStatusInf ssmInfo;
|
||||
public final FSMStatusReasonQueryOuterClass.FSMStatusReasonRespond fsmStatusReasonRespond;//FSM数据
|
||||
|
||||
public final long createTime;
|
||||
|
||||
public LaunchConditionData(String abilityVersion,
|
||||
SystemStatusInfo.StatusInfo statusInfo,
|
||||
SsmInfo.SsmStatusInf ssmInfo,
|
||||
FSMStatusReasonQueryOuterClass.FSMStatusReasonRespond fsmStatusReasonRespond) {
|
||||
this(abilityVersion, null, Float.MAX_VALUE, null, statusInfo, ssmInfo, fsmStatusReasonRespond);
|
||||
}
|
||||
|
||||
public LaunchConditionData(String abilityVersion,
|
||||
ChassisStatesOuterClass.ChassisStates chassisStates,
|
||||
float oldSteering,
|
||||
Chassis.LightSwitch light,
|
||||
SystemStatusInfo.StatusInfo statusInfo,
|
||||
SsmInfo.SsmStatusInf ssmInfo,
|
||||
FSMStatusReasonQueryOuterClass.FSMStatusReasonRespond fsmStatusReasonRespond) {
|
||||
this.abilityVersion = abilityVersion;
|
||||
this.chassisStates = chassisStates;
|
||||
this.oldSteering = oldSteering;
|
||||
this.light = light;
|
||||
this.statusInfo = statusInfo;
|
||||
this.ssmInfo = ssmInfo;
|
||||
this.fsmStatusReasonRespond = fsmStatusReasonRespond;
|
||||
createTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public String getJson() {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
try {
|
||||
jsonObject.put("ability_version", abilityVersion);
|
||||
jsonObject.put("create_object_time", createTime);
|
||||
JSONArray array = new JSONArray();
|
||||
JSONObject chassisStatesObject = new JSONObject();
|
||||
chassisStatesObject.put("name", "ChassisStates");
|
||||
if (chassisStates != null) {
|
||||
if (chassisStates.hasHeader()) {
|
||||
chassisStatesObject.put("data_header", TextFormat.printer().escapingNonAscii(false).printToString(chassisStates.getHeader()));
|
||||
}
|
||||
//制动踏板
|
||||
String temp = "未知";
|
||||
if (chassisStates.hasBrakeSystemStates()) {
|
||||
float brake = chassisStates.getBrakeSystemStates().getBrakePedalResponsePosition();
|
||||
temp = String.valueOf(brake);
|
||||
}
|
||||
chassisStatesObject.put("brake", temp);
|
||||
//油门踏板
|
||||
temp = "未知";
|
||||
if (chassisStates.hasDrivingSystemStates()) {
|
||||
float throttle = chassisStates.getDrivingSystemStates().getThrottleResponsePosition();
|
||||
temp = String.valueOf(throttle);
|
||||
}
|
||||
chassisStatesObject.put("throttle", temp);
|
||||
//档位
|
||||
temp = "未知";
|
||||
if (chassisStates.hasGearSystemStates()) {
|
||||
Chassis.GearPosition gear = chassisStates.getGearSystemStates().getGearPosition();
|
||||
temp = gear.name();
|
||||
}
|
||||
chassisStatesObject.put("gear", temp);
|
||||
|
||||
//方向盘
|
||||
temp = "未知";
|
||||
if (chassisStates.hasSteerSystemStates()) {
|
||||
ChassisStatesOuterClass.SteerSystemStates steerSystemStates = chassisStates.getSteerSystemStates();
|
||||
if (steerSystemStates.hasSteeringWheelAngle()) {
|
||||
float steering = steerSystemStates.getSteeringWheelAngle();
|
||||
temp = String.valueOf(steering);
|
||||
}
|
||||
}
|
||||
chassisStatesObject.put("old_steering", oldSteering == Float.MAX_VALUE ? "未知" : oldSteering);
|
||||
chassisStatesObject.put("steering", temp);
|
||||
}
|
||||
//车灯
|
||||
if (light != null) {
|
||||
chassisStatesObject.put("light", light.name());
|
||||
}
|
||||
array.put(chassisStatesObject);
|
||||
if (statusInfo != null) {
|
||||
arrayPut(array, statusInfo.getClass().getName(), statusInfo.getAutoPilotReady(), statusInfo.getAutoPilotUnreadyReason());
|
||||
}
|
||||
if (ssmInfo != null) {
|
||||
arrayPut(array, ssmInfo.getClass().getName(), ssmInfo.getAutoPilotReady(), ssmInfo.getAutoPilotUnreadyReason());
|
||||
}
|
||||
if (fsmStatusReasonRespond != null) {
|
||||
arrayPut(array, fsmStatusReasonRespond);
|
||||
}
|
||||
if (array.length() > 0) {
|
||||
jsonObject.put("data", array);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return jsonObject.toString();
|
||||
}
|
||||
|
||||
private void arrayPut(JSONArray array, String name, boolean isReady, String reason) throws JSONException {
|
||||
JSONObject objectParse = new JSONObject();
|
||||
objectParse.put("auto_pilot_ready", isReady);
|
||||
if (reason != null) {
|
||||
objectParse.put("auto_pilot_unready_reason", reason);
|
||||
}
|
||||
JSONObject object = new JSONObject();
|
||||
object.put("name", name);
|
||||
object.put("parse", objectParse);
|
||||
array.put(object);
|
||||
}
|
||||
|
||||
private void arrayPut(JSONArray array, GeneratedMessageV3 message) throws JSONException, InvalidProtocolBufferException {
|
||||
JSONObject object = new JSONObject();
|
||||
object.put("name", message.getClass().getName());
|
||||
// object.put("original", ByteUtil.byteArrToHex(message.toByteArray(), false));
|
||||
object.put("parse", new JSONObject(JsonFormat.printer().print(message)));
|
||||
array.put(object);
|
||||
}
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
package com.zhjt.mogo.adas.data.bean;
|
||||
|
||||
import com.google.protobuf.GeneratedMessageV3;
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
import com.google.protobuf.util.JsonFormat;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import function_state_management.FSMStatusReasonQueryOuterClass;
|
||||
import system_master.SsmInfo;
|
||||
import system_master.SystemStatusInfo;
|
||||
|
||||
/**
|
||||
* 检测到不能启动自动驾驶的数据
|
||||
* 此类目前主要用于启动自驾命令下发后的域控数据记录
|
||||
*/
|
||||
public class UnableLaunchData {
|
||||
/**
|
||||
* 所使用的检测版本
|
||||
*/
|
||||
public final String abilityVersion;
|
||||
|
||||
/**
|
||||
* 老底盘数据
|
||||
* null表示未用到此数据
|
||||
* TODO 不需要底盘数据,如果底盘数据存在不能启动自驾的原因会限制启动自驾命令的下发
|
||||
*/
|
||||
// public final VehicleStateOuterClass.VehicleState vehicleState;
|
||||
|
||||
/**
|
||||
* 新底盘数据
|
||||
* null表示未用到此数据
|
||||
* TODO 不需要底盘数据,如果底盘数据存在不能启动自驾的原因会限制启动自驾命令的下发
|
||||
*/
|
||||
// public final ChassisStatesOuterClass.ChassisStates chassisStates;
|
||||
|
||||
/**
|
||||
* 老SSM数据
|
||||
* null表示未用到此数据
|
||||
*/
|
||||
public final SystemStatusInfo.StatusInfo statusInfo;
|
||||
|
||||
/**
|
||||
* 新SSM数据
|
||||
* null表示未用到此数据
|
||||
*/
|
||||
public final SsmInfo.SsmStatusInf ssmInfo;
|
||||
public final FSMStatusReasonQueryOuterClass.FSMStatusReasonRespond fsmStatusReasonRespond;//FSM数据
|
||||
|
||||
public UnableLaunchData(String abilityVersion,
|
||||
SystemStatusInfo.StatusInfo statusInfo,
|
||||
SsmInfo.SsmStatusInf ssmInfo,
|
||||
FSMStatusReasonQueryOuterClass.FSMStatusReasonRespond fsmStatusReasonRespond) {
|
||||
this.abilityVersion = abilityVersion;
|
||||
this.statusInfo = statusInfo;
|
||||
this.ssmInfo = ssmInfo;
|
||||
this.fsmStatusReasonRespond = fsmStatusReasonRespond;
|
||||
}
|
||||
|
||||
public String getJson() {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
try {
|
||||
jsonObject.put("ability_version", abilityVersion);
|
||||
JSONArray array = new JSONArray();
|
||||
if (statusInfo != null) {
|
||||
arrayPut(array, statusInfo.getClass().getName(), statusInfo.getAutoPilotReady(), statusInfo.getAutoPilotUnreadyReason());
|
||||
}
|
||||
if (ssmInfo != null) {
|
||||
arrayPut(array, ssmInfo.getClass().getName(), ssmInfo.getAutoPilotReady(), ssmInfo.getAutoPilotUnreadyReason());
|
||||
}
|
||||
if (fsmStatusReasonRespond != null) {
|
||||
arrayPut(array, fsmStatusReasonRespond);
|
||||
}
|
||||
if (array.length() > 0) {
|
||||
jsonObject.put("data", array);
|
||||
}
|
||||
} catch (JSONException | InvalidProtocolBufferException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return jsonObject.toString();
|
||||
}
|
||||
|
||||
private void arrayPut(JSONArray array, String name, boolean isReady, String reason) throws JSONException {
|
||||
JSONObject objectParse = new JSONObject();
|
||||
objectParse.put("auto_pilot_ready", isReady);
|
||||
if (reason != null) {
|
||||
objectParse.put("auto_pilot_unready_reason", reason);
|
||||
}
|
||||
JSONObject object = new JSONObject();
|
||||
object.put("name", name);
|
||||
object.put("parse", objectParse);
|
||||
array.put(object);
|
||||
}
|
||||
|
||||
private void arrayPut(JSONArray array, GeneratedMessageV3 message) throws JSONException, InvalidProtocolBufferException {
|
||||
JSONObject object = new JSONObject();
|
||||
object.put("name", message.getClass().getName());
|
||||
// object.put("original", ByteUtil.byteArrToHex(message.toByteArray(), false));
|
||||
object.put("parse", new JSONObject(JsonFormat.printer().print(message)));
|
||||
array.put(object);
|
||||
}
|
||||
}
|
||||
@@ -58,12 +58,12 @@ public class UnableLaunchReason {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
UnableLaunchReason that = (UnableLaunchReason) o;
|
||||
return source == that.source && TextUtils.equals(unableLaunchReason, that.unableLaunchReason);
|
||||
return source == that.source && unableType == that.unableType && TextUtils.equals(unableLaunchReason, that.unableLaunchReason);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(source, unableLaunchReason);
|
||||
return Objects.hash(source, unableType, unableLaunchReason);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user