[670][adas][data-center] FSM2024升级;SM2024数据解析兼容,如果RepeatedPilotNotStandbyReason没有数据将获取PilotNotStandbyReason赋值到RepeatedPilotNotStandbyReason中;老版本fsm2024 pb中没有beautiful_mode和beautiful_mode字段,域控给的新pb这两个字段标识符为required,当连接老板域控时将会解析包错,估修改为optional修饰

This commit is contained in:
xinfengkun
2024-09-25 14:59:52 +08:00
parent e5889a3af8
commit 45526304ba
8 changed files with 188 additions and 47 deletions

View File

@@ -69,8 +69,8 @@ object OchAutoPilotManager : IMoGoReceiveReceivedAckListener, IMoGoFsm2024Listen
fun canStartAutoPilotSSM(): Boolean {
if (!FunctionBuildConfig.isDemoMode && !OCHAdasAbilityManager.getInstance().autopilotAbilityStatus) {
val reasons = OCHAdasAbilityManager.getInstance().unableAutopilotReasons
if ("AutopilotAbility440" == OCHAdasAbilityManager.getInstance().abilityVersion && !reasons.isNullOrEmpty()) {
val msg = reasons[0].unableLaunchReason + " 来源:" + reasons[0].source
if ("AutopilotAbilityFSM" == OCHAdasAbilityManager.getInstance().abilityVersion && !reasons.isNullOrEmpty()) {
val msg = reasons[0].getUnableLaunchReason() + " 来源:" + reasons[0].source
CallerMsgBoxManager.saveMsgBox(
MsgBoxBean(
MsgBoxType.AUTOPILOT,

View File

@@ -15,8 +15,8 @@ import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02Lis
import com.mogo.eagle.core.function.call.autopilot.CallerChassisStatesListenerManager
import com.mogo.eagle.core.function.main.MainLauncherActivity
import com.mogo.eagle.core.utilcode.util.ToastUtils
import com.zhjt.mogo.adas.data.bean.MogoReport
import com.zhjt.mogo.adas.data.bean.LaunchConditionData
import com.zhjt.mogo.adas.data.bean.MogoReport
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason.SourceType.CHASSIS
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason.UnableType.CHASSIS_BRAKE
@@ -154,7 +154,12 @@ class TestAutoPilotBeforeLaunch {
.setRemotePilotReady(false).build(),
FSMStatusReasonRespond.getDefaultInstance()
), ArrayList<UnableLaunchReason>().also {
it += UnableLaunchReason(CHASSIS, CHASSIS_GEAR, "gear")
it += UnableLaunchReason(CHASSIS, CHASSIS_GEAR,
object : ArrayList<String>() {
init {
add("gear")
}
})
})
}
@@ -169,7 +174,12 @@ class TestAutoPilotBeforeLaunch {
.setRemotePilotReady(false).build(),
FSMStatusReasonRespond.getDefaultInstance()
), ArrayList<UnableLaunchReason>().also {
it += UnableLaunchReason(CHASSIS, CHASSIS_STEERING, "steering")
it += UnableLaunchReason(CHASSIS, CHASSIS_STEERING,
object : ArrayList<String>() {
init {
add("steering")
}
})
})
}
@@ -185,7 +195,12 @@ class TestAutoPilotBeforeLaunch {
.setRemotePilotReady(false).build(),
FSMStatusReasonRespond.getDefaultInstance()
), ArrayList<UnableLaunchReason>().also {
it += UnableLaunchReason(CHASSIS, CHASSIS_BRAKE, "brake")
it += UnableLaunchReason(CHASSIS, CHASSIS_BRAKE,
object : ArrayList<String>() {
init {
add("brake")
}
})
})
}
@@ -200,7 +215,12 @@ class TestAutoPilotBeforeLaunch {
.setRemotePilotReady(false).build(),
FSMStatusReasonRespond.getDefaultInstance()
), ArrayList<UnableLaunchReason>().also {
it += UnableLaunchReason(CHASSIS, CHASSIS_HAZARD_LIGHTS, "lights")
it += UnableLaunchReason(CHASSIS, CHASSIS_HAZARD_LIGHTS,
object : ArrayList<String>() {
init {
add("lights")
}
})
})
}
@@ -215,7 +235,12 @@ class TestAutoPilotBeforeLaunch {
.setRemotePilotReady(false).build(),
FSMStatusReasonRespond.getDefaultInstance()
), ArrayList<UnableLaunchReason>().also {
it += UnableLaunchReason(CHASSIS, CHASSIS_THROTTLE, "throttle")
it += UnableLaunchReason(CHASSIS, CHASSIS_THROTTLE,
object : ArrayList<String>() {
init {
add("throttle")
}
})
})
}
@@ -230,11 +255,36 @@ class TestAutoPilotBeforeLaunch {
.setRemotePilotReady(false).build(),
FSMStatusReasonRespond.getDefaultInstance()
), ArrayList<UnableLaunchReason>().also {
it += UnableLaunchReason(CHASSIS, CHASSIS_GEAR, "gear")
it += UnableLaunchReason(CHASSIS, CHASSIS_STEERING, "steering")
it += UnableLaunchReason(CHASSIS, CHASSIS_HAZARD_LIGHTS, "lights")
it += UnableLaunchReason(CHASSIS, CHASSIS_THROTTLE, "throttle")
it += UnableLaunchReason(CHASSIS, CHASSIS_BRAKE, "brake")
it += UnableLaunchReason(CHASSIS, CHASSIS_GEAR,
object : ArrayList<String>() {
init {
add("gear")
}
})
it += UnableLaunchReason(CHASSIS, CHASSIS_STEERING,
object : ArrayList<String>() {
init {
add("steering")
}
})
it += UnableLaunchReason(CHASSIS, CHASSIS_HAZARD_LIGHTS,
object : ArrayList<String>() {
init {
add("lights")
}
})
it += UnableLaunchReason(CHASSIS, CHASSIS_THROTTLE,
object : ArrayList<String>() {
init {
add("throttle")
}
})
it += UnableLaunchReason(CHASSIS, CHASSIS_BRAKE,
object : ArrayList<String>() {
init {
add("brake")
}
})
})
}
CallerAutoPilotControlManager.isCanStartAutopilot(true)

View File

@@ -55,7 +55,11 @@ object CallerAutopilotActionsListenerManager : CallerBase<IMoGoAutopilotActionsL
UnableLaunchReason(
UnableLaunchReason.SourceType.LIB,
UnableLaunchReason.UnableType.DISCONNECTED,
"未连接自动驾驶系统"
object : ArrayList<String>() {
init {
add("未连接自动驾驶系统")
}
}
)
)
return list

View File

@@ -1,7 +1,8 @@
package com.zhjt.mogo.adas.data.bean;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import java.util.List;
import java.util.Objects;
/**
@@ -40,28 +41,46 @@ public class UnableLaunchReason {
/**
* 來源
*/
@NonNull
public final SourceType source;
/**
* 影响启动自驾或启动平行驾驶的具体类型
*/
@NonNull
public final UnableType unableType;
/**
* 具體原因
* 只有 unableType==UnableType.FSM2024_OFFER unableLaunchReason 才会有多个,其他状态有且仅有一个
*/
public final String unableLaunchReason;
@NonNull
public final List<String> unableLaunchReason;
public UnableLaunchReason(SourceType source, UnableType unableType, String unableLaunchReason) {
public UnableLaunchReason(@NonNull SourceType source, @NonNull UnableType unableType, @NonNull List<String> unableLaunchReason) {
this.source = source;
this.unableType = unableType;
this.unableLaunchReason = unableLaunchReason;
}
public String getUnableLaunchReason() {
if (unableLaunchReason.isEmpty()) {
return "";
}
StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i < unableLaunchReason.size(); i++) {
stringBuilder.append(unableLaunchReason.get(i));
if (i < unableLaunchReason.size() - 1) {
stringBuilder.append(" && ");
}
}
return stringBuilder.toString();
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
UnableLaunchReason that = (UnableLaunchReason) o;
return source == that.source && unableType == that.unableType && TextUtils.equals(unableLaunchReason, that.unableLaunchReason);
return source == that.source && unableType == that.unableType && Objects.equals(unableLaunchReason, that.unableLaunchReason);
}
@Override

View File

@@ -1,53 +1,96 @@
syntax = "proto2";
package fsm;
import "header.proto";
enum State {
OFF = 0;
STANDBY = 1; //Standby 未来会弃用, 并入OFF
REQUESTING = 1;
ACTIVATING = 2;
PILOT_DRIVING_ACTIVE = 3; //未来会被弃用所有激活状态统一在Active状态下作为子状态管理
PARALLEL_DRIVING_ACTIVE = 4; //未来会被弃用所有激活状态统一在Active状态下作为子状态管理
SAFETY_STOP = 5;
ACTIVE = 6;
SAFETY_STOP = 10;
SAFETY_STOPPED = 11;
STANDBY = 80; //已弃用
PILOT_DRIVING_ACTIVE = 81; //已弃用
PARALLEL_DRIVING_ACTIVE = 82; //已弃用
}
enum SafetyStopMode {
NOT_NEEDED = 0;
PLANNER_STOP = 1;
CONTROLLER_COMFORT_STOP = 2;
CONTROLLER_EMERGENCY_STOP = 3;
}
enum ActiveMode {
enum ActiveMode { //数字定义与请求的数字对齐
NOT_ACTIVE= 0;
PILOT_ACTIVE= 1;
PARALLEL_ACTIVE= 2;
SIMULATOR_ACTIVE= 3; //模拟器驾驶, M1上专用
PARALLEL_ACTIVE= 6;
M1_STEER_ACTIVE= 9; //模拟器驾驶, M1上专用
}
enum SessionResult{
NO_REQUEST_RECEIVED= 0; //还没收到任何请求
ATTEMPTING= 1; //已收到请求,激活自驾(或其他模式)中
REQUEST_SUCCEED= 2; //请求成功
REQUEST_FAILED= 3; //请求失败
}
enum ExitType{
NO_EXIT =0;
NORMAL_EXIT= 1;
ABNORMAL_EXIT= 2;
}
message Session{
optional ActiveMode session_active_mode = 1 ; //这次点击是要进入哪个模式
optional uint64 session_id= 2; //最新收到的请求的session id 暂时不区分 自驾平行驾驶、方向盘驾驶以及发送源头。没收到或者请求不带id时置为0
optional SessionResult session_result = 3; //当前session的结果
optional string session_fail_reason = 4; // 如果最新的session请求失败原因是什么
}
message ExitActive{
optional ActiveMode exit_active_mode = 1;
optional ExitType exit_type= 2;
optional string exit_reason = 3;
optional string exit_time = 4;
}
message FSMStateMsg {
required common.Header header = 1;
required State function_state = 2;
required SafetyStopMode fsm_safety_stop_mode = 4; //FSM如果进入safety stop是planning 进行停车还是control进行舒适停车还是control进行紧急停车
required ActiveMode active_mode = 6;
optional bool beautiful_mode = 7;//原始PB是required 由于老版本PB中不含有此字段使用required解析会报错所以改成optional
optional string version = 9; //目前是2.0 原始PB是required 由于老版本PB中不含有此字段使用required解析会报错所以改成optional
required bool new_msg_flag = 10;
required bool pilot_standby_flag = 11;
required bool parallel_standby_flag = 12;
required bool simulator_standby_flag = 13;
required bool parallel_standby_flag = 12;
required bool m1steer_standby_flag = 13;
optional string pilot_not_standby_reason= 21; //FSM 无法自驾无法就绪的原因。
optional string parallel_not_standby_reason= 22; //FSM 无法平行即使就绪原因
optional string simulator_not_standby_reason= 23; //FSM 无法模拟器驾驶原因
optional uint64 fail_to_pilot_session_id= 36;
optional uint64 fail_to_parallel_session_id= 37;
optional uint64 fail_to_simulator_session_id= 38;
optional string abnormal_state_trans_reason= 41; //FSM 异常退出ACTIVATING/自驾/平行驾驶/模拟器驾驶原因 (包括接管)
}
optional string m1steer_not_standby_reason= 23; //FSM 无法模拟器驾驶原因
repeated string repeated_pilot_not_standby_reason= 26; // repeated reason
repeated string repeated_parallel_not_standby_reason= 27;
repeated string repeated_m1steer_not_standby_reason= 28;
optional Session session = 30; //包含某次点击的所有信息
optional uint64 fail_to_pilot_session_id= 36; //2.0起废弃
optional uint64 fail_to_parallel_session_id= 37; //2.0起废弃
optional uint64 fail_to_m1steer_session_id= 38; //2.0起废弃
optional string abnormal_state_trans_reason= 41; //2.0起废弃
optional ExitActive exit_active= 42; //存储最近一次离开Active状态的情况 (包括正常退出,掉自驾,接管,停车)
}

View File

@@ -6,6 +6,7 @@ import com.zhjt.mogo.adas.data.bean.LaunchConditionData;
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason;
import java.util.ArrayList;
import java.util.List;
import fsm.Fsm2024;
@@ -40,7 +41,16 @@ public class AutopilotAbilityFSM {
unableAutopilotReasons = manager.addUnableAutopilotReason(unableAutopilotReasons, UnableLaunchReason.SourceType.LIB, UnableLaunchReason.UnableType.FSM2024_TIMEOUT, "FSM超时无响应");
} else {
if (!fsmState.getPilotStandbyFlag()) {
unableAutopilotReasons = manager.addUnableAutopilotReason(unableAutopilotReasons, UnableLaunchReason.SourceType.FSM2024, UnableLaunchReason.UnableType.FSM2024_OFFER, fsmState.getPilotNotStandbyReason());
List<String> list = null;
if (fsmState.getRepeatedPilotNotStandbyReasonCount() > 0) {
list = fsmState.getRepeatedPilotNotStandbyReasonList();
}
if (list == null || list.isEmpty()) {
unableAutopilotReasons = manager.addUnableAutopilotReason(unableAutopilotReasons, UnableLaunchReason.SourceType.FSM2024, UnableLaunchReason.UnableType.FSM2024_OFFER, fsmState.getPilotNotStandbyReason());
} else {
unableAutopilotReasons = manager.addUnableAutopilotReason(unableAutopilotReasons, UnableLaunchReason.SourceType.FSM2024, UnableLaunchReason.UnableType.FSM2024_OFFER, list);
}
}
}
if (listener != null) {

View File

@@ -124,6 +124,15 @@ public class AutopilotAbilityManager implements OnAutopilotAbilityListener {
* @return 原因列表
*/
protected ArrayList<UnableLaunchReason> addUnableAutopilotReason(ArrayList<UnableLaunchReason> unableAutopilotReasons, UnableLaunchReason.SourceType source, UnableLaunchReason.UnableType unableType, String unableAutopilotReason) {
if (TextUtils.isEmpty(unableAutopilotReason)) {
unableAutopilotReason = "未知";
}
List<String> list = new ArrayList<>();
list.add(unableAutopilotReason);
return addUnableAutopilotReason(unableAutopilotReasons, source, unableType, list);
}
protected ArrayList<UnableLaunchReason> addUnableAutopilotReason(ArrayList<UnableLaunchReason> unableAutopilotReasons, UnableLaunchReason.SourceType source, UnableLaunchReason.UnableType unableType, List<String> unableAutopilotReason) {
if (unableAutopilotReasons == null) {
unableAutopilotReasons = new ArrayList<>();
}
@@ -131,7 +140,6 @@ public class AutopilotAbilityManager implements OnAutopilotAbilityListener {
return unableAutopilotReasons;
}
public void setCarConfig(@NonNull MessagePad.CarConfigResp carConfig) {
if (!isInitCarConfig.get()) {
int version = carConfig.getMapVersion();

View File

@@ -22,6 +22,7 @@ public class FSM2024StateMessage extends MyAbstractMessageHandler {
public FSM2024StateMessage(AutopilotReview autopilotReview) {
this.autopilotReview = autopilotReview;
}
@Override
public void handlerMsg(RawData raw, OnAdasListener adasListener) throws InvalidProtocolBufferException {
Fsm2024.FSMStateMsg fsmState = Fsm2024.FSMStateMsg.parser().parseFrom(raw.originalData.toByteArray(), raw.getOffsetValue(), raw.getPackageLengthValue() - raw.getOffsetValue());
@@ -33,7 +34,13 @@ public class FSM2024StateMessage extends MyAbstractMessageHandler {
if (CupidLogUtils.isEnableLog())
nowTime = SystemClock.elapsedRealtime();
if (adasListener != null) {
adasListener.onFSM2024State(raw.getHeader(), fsmState, autopilotState, mode);
if (fsmState.getRepeatedPilotNotStandbyReasonCount() == 0) {
Fsm2024.FSMStateMsg.Builder builder = fsmState.toBuilder();
builder.addRepeatedPilotNotStandbyReason(fsmState.getPilotNotStandbyReason());
adasListener.onFSM2024State(raw.getHeader(), builder.build(), autopilotState, mode);
} else {
adasListener.onFSM2024State(raw.getHeader(), fsmState, autopilotState, mode);
}
}
ParallelDrivingManager.getInstance().setAutopilotState(autopilotState);
if (autopilotReview != null) {