Merge branch 'dev_robotaxi-d_230711_3.4.0_600' into dev_robotaxi-d_230809_6.0.0

This commit is contained in:
xinfengkun
2023-08-10 14:38:18 +08:00
22 changed files with 485 additions and 224 deletions

View File

@@ -2,36 +2,31 @@ package com.mogo.och.common.module.manager;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo;
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotActionsListener;
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatisticsListener;
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener;
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager;
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager;
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotActionsListenerManager;
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotStatisticsListenerManager;
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
import com.mogo.och.common.module.callback.OchAdasStartFailureCallback;
import com.zhjt.mogo.adas.data.bean.AutopilotStatistics;
import com.zhjt.mogo.adas.data.bean.UnableAutopilotReason;
import mogo.telematics.pad.MessagePad;
import mogo_msg.MogoReportMsg;
import system_master.SystemStatusInfo;
import java.util.ArrayList;
import java.util.List;
/**
* Created on 2022/10/9
* 工控机状态信息回调(判断是否能否启动自动驾驶的回调)
* 目前定的是3秒回调一次
*/
public class OCHAdasAbilityManager implements IMoGoAutopilotActionsListener, IMoGoAutopilotStatisticsListener, IMoGoAutopilotStatusListener {
public class OCHAdasAbilityManager implements IMoGoAutopilotActionsListener, IMoGoAutopilotStatisticsListener {
private static final String TAG = OCHAdasAbilityManager.class.getSimpleName();
private boolean isAutopilotAbility;
private String autopilotAbilityReason;
private ArrayList<UnableAutopilotReason> unableAutopilotReasons;
private String startFailedCode = "";
private String startFailedMessage = "";
@@ -46,7 +41,8 @@ public class OCHAdasAbilityManager implements IMoGoAutopilotActionsListener, IMo
}
public void init(Context context) {
ipcConnectStatusChanged();
this.isAutopilotAbility = CallerAutopilotActionsListenerManager.INSTANCE.isAutopilotAbility();
this.unableAutopilotReasons = CallerAutopilotActionsListenerManager.INSTANCE.getUnableAutopilotReasons();
initListeners();
}
@@ -59,7 +55,7 @@ public class OCHAdasAbilityManager implements IMoGoAutopilotActionsListener, IMo
}
public String getAutopilotUnAbilityReason(){
return autopilotAbilityReason;
return unableAutopilotReasons.toString();//TODO 临时toString 需要拼接数据
}
public String getStartFailedCode() {
@@ -74,28 +70,20 @@ public class OCHAdasAbilityManager implements IMoGoAutopilotActionsListener, IMo
//2022.10.9 工控机状态信息回调(判断是否能否启动自动驾驶的回调), 目前定的是3秒回调一次
CallerAutopilotActionsListenerManager.INSTANCE.addListener(TAG, this);
CallerAutopilotStatisticsListenerManager.INSTANCE.addListener(TAG,this);
CallerAutoPilotStatusListenerManager.INSTANCE.addListener(TAG, this);
}
private void releaseListeners() {
CallerAutopilotActionsListenerManager.INSTANCE.removeListener(this);
CallerAutopilotStatisticsListenerManager.INSTANCE.removeListener(this);
CallerAutoPilotStatusListenerManager.INSTANCE.removeListener(this);
}
private void ipcConnectStatusChanged() {
this.isAutopilotAbility = CallerAutoPilotControlManager.INSTANCE.isConnected();
this.autopilotAbilityReason = isAutopilotAbility ? "" : "未连接自动驾驶系统";
}
@Override
public void onAutopilotAbility(boolean isAutopilotAbility, String unableAutopilotReason) {
public void onAutopilotAbility(boolean isAutopilotAbility, @Nullable ArrayList<UnableAutopilotReason> unableAutopilotReasons) {
this.isAutopilotAbility = isAutopilotAbility;
this.autopilotAbilityReason = unableAutopilotReason;
Logger.d(TAG, "是否可以启动自动驾驶=" + isAutopilotAbility + " 原因=" + autopilotAbilityReason);
this.unableAutopilotReasons = unableAutopilotReasons;
Logger.d(TAG, "是否可以启动自动驾驶=" + isAutopilotAbility + " 原因=" + (unableAutopilotReasons == null ? null : unableAutopilotReasons.toString()));
}
@Override
public void onAutopilotStatistics(@Nullable AutopilotStatistics statistics) {
if (statistics == null) return;
@@ -112,41 +100,4 @@ public class OCHAdasAbilityManager implements IMoGoAutopilotActionsListener, IMo
public void release() {
releaseListeners();
}
@Override
public void onAutopilotIpcConnectStatusChanged(int status, @Nullable String reason) {
ipcConnectStatusChanged();
}
@Override
public void onAutopilotStatusResponse(@NonNull AutopilotStatusInfo autoPilotStatusInfo) {
}
@Override
public void onAutopilotStatusResponse(int state) {
}
@Override
public void onAutopilotDockerInfo(@NonNull String dockerVersion) {
}
@Override
public void onAutopilotArriveAtStation(@Nullable MessagePad.ArrivalNotification arrivalNotification) {
}
@Override
public void onAutopilotSNRequest() {
}
@Override
public void onAutopilotGuardian(@Nullable MogoReportMsg.MogoReportMessage guardianInfo) {
}
@Override
public void onAutopilotStatusRespByQuery(@NonNull SystemStatusInfo.StatusInfo status) {
}
@Override
public void onAutopilotRouteLineId(long lineId) {
}
}

View File

@@ -0,0 +1 @@
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":1,"versionName":"1.0","enabled":true,"outputFile":"app_mogo_magic_ring-release.apk","fullName":"release","baseName":"release"},"path":"app_mogo_magic_ring-release.apk","properties":{}}]

View File

@@ -53,6 +53,7 @@ import com.zhidao.support.adas.high.common.CupidLogUtils;
import com.zhidao.support.adas.high.common.ProtocolStatus;
import com.zhjt.mogo.adas.data.bean.AdasParam;
import com.zhjt.mogo.adas.data.bean.AutopilotStatistics;
import com.zhjt.mogo.adas.data.bean.UnableAutopilotReason;
import com.zhjt.mogo.adas.data.sweeper.SweeperCloudTask;
import com.zhjt.mogo.adas.data.sweeper.bootable.SweeperBootable;
import com.zhjt.mogo.adas.data.sweeper.task.SweeperTask;
@@ -657,7 +658,7 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
}
@Override
public void onAutopilotAbility(boolean isAutopilotAbility, String unableAutopilotReason) {
public void onAutopilotAbility(boolean isAutopilotAbility, @Nullable List<UnableAutopilotReason> unableAutopilotReasons) {
}

View File

@@ -408,6 +408,10 @@ class MoGoAutopilotControlProvider :
AdasManager.getInstance().sendTrajectoryDownloadReq(autoPilotLine.toAutoPilotLine())
}
override fun sendTrajectoryDownloadReq(autoPilotLine: AutopilotControlParameters.AutoPilotLine, downloadType: Int) {
AdasManager.getInstance().sendTrajectoryDownloadReq(autoPilotLine.toAutoPilotLine(), downloadType)
}
override fun cancelAutoPilot() {
if (AdasManager.getInstance().ipcConnectionStatus == Constants.IPC_CONNECTION_STATUS.CONNECTED) {
AdasManager.getInstance().sendAutoPilotModeReq(0, 1, null)

View File

@@ -55,6 +55,7 @@ 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.bean.AutopilotStatistics
import com.zhjt.mogo.adas.data.bean.UnableAutopilotReason
import com.zhjt.mogo.adas.data.sweeper.SweeperCloudTask
import com.zhjt.mogo.adas.data.sweeper.bootable.SweeperBootable
import com.zhjt.mogo.adas.data.sweeper.task.SweeperTask
@@ -754,8 +755,8 @@ class MoGoAdasListenerImpl : OnAdasListener {
* 是否可以启动自动驾驶
* 使用方法查看app_ipc_monitoring/uiMainActivity/onAutopilotAbility
*/
override fun onAutopilotAbility(isAutopilotAbility: Boolean, unableAutopilotReason: String?) {
invokeAutopilotAbility(isAutopilotAbility, unableAutopilotReason)
override fun onAutopilotAbility(isAutopilotAbility: Boolean, unableAutopilotReasons: ArrayList<UnableAutopilotReason>?) {
invokeAutopilotAbility(isAutopilotAbility, unableAutopilotReasons)
}
/**

View File

@@ -8,6 +8,7 @@ import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
import com.mogo.eagle.core.function.api.cloud.IMoGoCloudListener
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotActionsListenerManager
import com.mogo.eagle.core.function.call.cloud.CallerCloudListenerManager
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
@@ -40,6 +41,7 @@ class MoGoAdasMsgConnectStatusListenerImpl :
}
override fun onConnectionIPCStatus(ipcConnectionStatus: Int, reason: String?) {
CallerAutopilotActionsListenerManager.setConnected(ipcConnectionStatus == Constants.IPC_CONNECTION_STATUS.CONNECTED)
CallerAutoPilotStatusListenerManager.invokeAutoPilotIPCStatusChanged(
ipcConnectionStatus,
reason

View File

@@ -1,13 +1,15 @@
package com.mogo.eagle.core.function.api.autopilot
import com.zhjt.mogo.adas.data.bean.UnableAutopilotReason
/**
* pnc actions 决策 驾驶的意图
* 自动驾驶能力 能否启动自动驾驶
*/
interface IMoGoAutopilotActionsListener {
/**
* pnc actions 决策 驾驶的意图
*/
fun onAutopilotAbility(isAutopilotAbility: Boolean, unableAutopilotReason: String?)
fun onAutopilotAbility(isAutopilotAbility: Boolean, unableAutopilotReasons: ArrayList<UnableAutopilotReason>?)
}

View File

@@ -55,6 +55,11 @@ interface IMoGoAutopilotControlProvider : IMoGoFunctionServerProvider {
*/
fun sendTrajectoryDownloadReq(autoPilotLine: AutopilotControlParameters.AutoPilotLine)
/**
* 发送 轨迹下载请求
* @param downloadType 下载类型: 0:正常下载 1:预下载
*/
fun sendTrajectoryDownloadReq(autoPilotLine: AutopilotControlParameters.AutoPilotLine, downloadType: Int)
/**
* 结束自动驾驶
*/

View File

@@ -106,6 +106,16 @@ object CallerAutoPilotControlManager {
}
}
/**
* 发送 轨迹下载请求
* @param downloadType 下载类型: 0:正常下载 1:预下载
*/
fun sendTrajectoryDownloadReq(autoPilotLine: AutopilotControlParameters.AutoPilotLine, downloadType: Int) {
if (AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) {
providerApi?.sendTrajectoryDownloadReq(autoPilotLine, downloadType)
}
}
/**
* 结束自动驾驶
*/

View File

@@ -1,19 +1,103 @@
package com.mogo.eagle.core.function.call.autopilot
import android.util.Log
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotActionsListener
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager.isConnected
import com.mogo.eagle.core.function.call.base.CallerBase
import com.zhjt.mogo.adas.data.bean.UnableAutopilotReason
/**
* pnc actions 决策 驾驶的意图
* 能否启动自驾管理类
*/
object CallerAutopilotActionsListenerManager : CallerBase<IMoGoAutopilotActionsListener>() {
@Volatile
private var isConnected = false
private var isAutopilotAbility: Boolean = false
private var unableAutopilotReasons: ArrayList<UnableAutopilotReason>? = null
@Synchronized
fun invokeAutopilotAbility(isAutopilotAbility: Boolean, unableAutopilotReason: String?) {
M_LISTENERS.forEach {
val listener = it.value
listener.onAutopilotAbility(isAutopilotAbility, unableAutopilotReason)
init {
isConnected = isConnected()
isAutopilotAbility = false
unableAutopilotReasons = disconnectedReason()
printLog("初始化")
}
private fun disconnectedReason(): ArrayList<UnableAutopilotReason> {
val list = ArrayList<UnableAutopilotReason>()
list.add(UnableAutopilotReason(UnableAutopilotReason.SourceType.LIB, "未连接自动驾驶系统"))
return list
}
/**
* 能否启动自动驾驶
*/
fun isAutopilotAbility(): Boolean {
return isAutopilotAbility
}
/**
* 获取不能启动自驾的原因
* null表示没有任何原因证证明isAutopilotAbility为true
*/
fun getUnableAutopilotReasons(): ArrayList<UnableAutopilotReason>? {
return unableAutopilotReasons
}
fun setConnected(isConnected: Boolean) {
if (this.isConnected != isConnected) {
this.isConnected = isConnected
this.isAutopilotAbility = isConnected
unableAutopilotReasons = if (isConnected) null else disconnectedReason()
notification()
printLog("更新数据 连接状态变更")
}
}
@Synchronized
fun invokeAutopilotAbility(
isAutopilotAbility: Boolean, unableAutopilotReasons: ArrayList<UnableAutopilotReason>?
) {
if (isConnected) {
var isEquals: Boolean = true
if (unableAutopilotReasons != null && this.unableAutopilotReasons != null) {
unableAutopilotReasons.let { onw ->
onw.sortWith(compareBy(UnableAutopilotReason::hashCode));
this.unableAutopilotReasons?.let { old ->
old.sortWith(compareBy(UnableAutopilotReason::hashCode));
isEquals = onw.toTypedArray() contentEquals old.toTypedArray()
Log.i(
"ddd",
"都不为null时=${isEquals}=${this.isAutopilotAbility} ${(if (this.unableAutopilotReasons == null) null else this.unableAutopilotReasons.toString())}"
)
}
}
} else isEquals =
!(unableAutopilotReasons != null || this.unableAutopilotReasons != null)
Log.i(
"ddd",
" 两个List是否相同=${isEquals} 新是否能启动自驾=${isAutopilotAbility} 老是否能启动自驾=${this.isAutopilotAbility} 新List是否为空=${unableAutopilotReasons == null} 老List是否为空=${this.unableAutopilotReasons == null}"
)
if (this.isAutopilotAbility != isAutopilotAbility || !isEquals) {
this.isAutopilotAbility = isAutopilotAbility
this.unableAutopilotReasons = unableAutopilotReasons
notification()
printLog("更新数据")
}
}
}
private fun notification() {
M_LISTENERS.forEach {
val listener = it.value
listener.onAutopilotAbility(isAutopilotAbility, unableAutopilotReasons)
}
}
fun printLog(tag: String) {
Log.i(
"ddd",
"${tag}=${isAutopilotAbility} ${(if (unableAutopilotReasons == null) null else unableAutopilotReasons.toString())}"
)
}
}

View File

@@ -2,15 +2,16 @@ package com.zhjt.mogo.adas.data.bean;
/**
* 监控事件报告中定义的事件以及解释
* 根据MAP3.3.1事件定义编写
* 根据MAP3.5.0事件定义编写
* http://wiki.zhidaohulian.com/pages/viewpage.action?pageId=113713916 最后修改于2023-07-27
*/
public class MogoReport {
public static final String RESULT_AUTOPILOT_SYSTEM_UNSTARTED = "RESULT_AUTOPILOT_SYSTEM_UNSTARTED";
public static final String RESULT_AUTOPILOT_DISABLE = "RESULT_AUTOPILOT_DISABLE";
public static final String RESULT_AUTOPILOT_INFERIOR = "RESULT_AUTOPILOT_INFERIOR";
public static final String RESULT_REMOTEPILOT_DISABLE = "RESULT_REMOTEPILOT_DISABLE";
public static final String RESULT_REMOTEPILOT_INFERIOR = "RESULT_REMOTEPILOT_INFERIOR";
public static final String RESULT_SHOW_WARNING = "RESULT_SHOW_WARNING";
public static final String RESULT_AUTOPILOT_SYSTEM_UNSTARTED = "RESULT_AUTOPILOT_SYSTEM_UNSTARTED";//自动驾驶系统启动失败
public static final String RESULT_AUTOPILOT_DISABLE = "RESULT_AUTOPILOT_DISABLE";//无法启动自动驾驶
public static final String RESULT_AUTOPILOT_INFERIOR = "RESULT_AUTOPILOT_INFERIOR";//自动驾驶效果受影响
public static final String RESULT_REMOTEPILOT_DISABLE = "RESULT_REMOTEPILOT_DISABLE";//无法启动远程驾驶
public static final String RESULT_REMOTEPILOT_INFERIOR = "RESULT_REMOTEPILOT_INFERIOR";//远程驾驶效果受影响
public static final String RESULT_SHOW_WARNING = "RESULT_SHOW_WARNING";//存在不确定因素
public enum Result {
@@ -159,12 +160,11 @@ public class MogoReport {
String TRA_NOT_EXIST = "EMAP_TRA_NOT_EXIST";//无法找到轨迹文件
String TRA_LOAD_FAILED = "EMAP_TRA_LOAD_FAILED";//加载轨迹文件失败
String ENGINE_INIT_FAILED = "EMAP_ENGINE_INIT_FAILED";//引擎初始化失败包括轨迹路径不存在vehicle_config.txt加载失败
String ATTITUDE_INIT_FAILED = "EMAP_ATTITUDE_INIT_FAILED";//当前位置距离轨迹距离大于15m
String EXIT_AUTOPILOT_FOR_PLANNING = "EMAP_EXIT_AUTOPILOT_FOR_PLANNING";//因planning掉帧强退自动驾驶
String EXIT_AUTOPILOT_FOR_LOCATION = "EMAP_EXIT_AUTOPILOT_FOR_LOCATION";//因location掉帧强退自动驾驶
String EXIT_AUTOPILOT_FOR_CHASSIS = "EMAP_EXIT_AUTOPILOT_FOR_CHASSIS";//因底盘消息掉帧强退自动驾驶
String EXIT_AUTOPILOT_FOR_DISTANCE = "EMAP_EXIT_AUTOPILOT_FOR_DISTANCE";//因planning起点距离当前过远强退自动驾驶
String EPARALLEL_AICLOUD_CONNECTION_ERROR = "EPARALLEL_AICLOUD_CONNECTION_ERROR";//断网(此时不符合平行驾驶条件) 平行驾驶退出到自驾,同时减速停车
String EPARALLEL_AICLOUD_NETWORK_WEAK = "EPARALLEL_AICLOUD_NETWORK_WEAK";//弱网,平行驾驶退出到自驾,同时减速停车
String EXIT_AUTOPILOT_FOR_BRAKE = "EMAP_EXIT_AUTOPILOT_FOR_BRAKE";//制动踏板干预而强退自动驾驶
String EXIT_AUTOPILOT_FOR_ACCEL = "EMAP_EXIT_AUTOPILOT_FOR_ACCEL";//加速踏板干预而强退自动驾驶
String EXIT_AUTOPILOT_FOR_STEER = "EMAP_EXIT_AUTOPILOT_FOR_STEER";//方向盘干预而强退自动驾驶
@@ -189,6 +189,9 @@ public class MogoReport {
String CONTROL_ABNORMAL_COMMAND = "EMAP_CONTROL_ABNORMAL_COMMAND";//controller发布的控制指令异常
String CAN_ADAPTER_NO_CHASSIS_INFO = "EMAP_CAN_ADAPTER_NO_CHASSIS_INFO";//can_adapter未成功转发地盘信息
String TRAJECTORY_LOST_WHEN_AUTOPILOT = "EMAP_TRAJECTORY_LOST_WHEN_AUTOPILOT";//自驾状态但是全局轨迹丢失超过1.5s
String PLANNING_FOR_PERCEPTION_TIMEOUT = "EMAP_PLANNING_FOR_PERCEPTION_TIMEOUT";//鹰眼下发进入自驾指令自车还未进入自驾感知延迟超过1s
String PLANNING_FOR_HADMAP_ENGINE_LANES_MSG_TIMEOUT = "EMAP_PLANNING_FOR_HADMAP_ENGINE_LANES_MSG_TIMEOUT";//鹰眼下发进入自驾指令自车还未进入自驾地图车道数据延迟超过1s
String PLANNING_FOR_PREDICTION_TIMEOUT = "EMAP_PLANNING_FOR_PREDICTION_TIMEOUT";//鹰眼下发进入自驾指令自车还未进入自驾预测数据延迟超过1s
}
/**
@@ -208,6 +211,7 @@ public class MogoReport {
String ACCEL_INFERENCE = "EVHC_ACCEL_INFERENCE";//由于油门干预退出自动驾驶或无法进入自动驾驶
String CSS = "EVHC_CSS";//底盘不允许进入自动驾驶
String GEAR = "EVHC_GEAR";//档位不是D或N档
String EPB = "EVHC_EPB";//驻车(手刹)不是锁止(拉起)状态
}
/**
@@ -227,6 +231,7 @@ public class MogoReport {
String ROUTING_REQ_TIMEOUT = "ESYS_ROUTING_REQ_TIMEOUT";//自动驾驶开始前routing请求无响应
String PLANNING_CHANGE_FAILIED = "ESYS_PLANNING_CHANGE_FAILIED";//planning版本切换启动失败
String CHECK_TRAJECTORY_FAILURE = "ESYS_CHECK_TRAJECTORY_FAILURE";//轨迹文件检查超时或检查结果无可用轨迹
String TRAJECTORY_AGENT_NOT_READY = "ESYS_TRAJECTORY_AGENT_NOT_READY";//轨迹下载客户端未就绪拒绝轨迹下载请求
String MAP_ENGINE_NOT_READY = "ESYS_MAP_ENGINE_NOT_READY";//地图引擎未就绪拒绝自驾
String FAULT = "ESYS_FAULT";//master启动10分钟仍有agent未连接
String REBOOT_WARNING = "ESYS_REBOOT_WARNING";//命令重启不完全提示(部分模块没有关闭成功)
@@ -239,6 +244,7 @@ public class MogoReport {
String CONFIG_UPDATING_URL_NOT_ARRIVED = "ESYS_CONFIG_UPDATING_URL_NOT_ARRIVED";//url不可达
String CONFIG_UPDATING_MD5_CHECK_ERROR = "ESYS_CONFIG_UPDATING_MD5_CHECK_ERROR";//md5检查失败
String CONFIG_UPDATING_REJECT_SAME_TRAJ_TASK = "ESYS_CONFIG_UPDATING_REJECT_SAME_TRAJ_TASK";//拒绝同名轨迹任务
String CONFIG_UPDATING_HTTP_FAILED = "ESYS_CONFIG_UPDATING_HTTP_FAILED";//获取下载列表失败
}
/**
@@ -269,6 +275,7 @@ public class MogoReport {
String INIT = "ECAM_INIT";//相机初始化失败
String CALIB = "ECAM_CALIB";//标定信息读取失败
String GRAB_FATAL = "ECAM_GRAB_FATAL";//相机数据采集异常
String TS_ERROR = "ECAM_TS_ERROR";//图像时间戳异常
}
/**
@@ -311,6 +318,14 @@ public class MogoReport {
interface EVEHICLE {
String IN_TROUBLE = "EVEHICLE_IN_TROUBLE";//planning 检测到车处于困境,把困境状态汇报给 SSMssm 发出该事件,等待驾舱端开始平行驾驶
}
/**
* EFM(FM故障)
*/
interface EFM {
String ERROR3_STOP_PILOT = "EFM_ERROR3_STOP_PILOT";//触发降级停车策略
String ERROR2_FUNC_FORBID = "EFM_ERROR2_FUNC_FORBID";//禁止车辆部分功能
}
}
/**
@@ -338,6 +353,16 @@ public class MogoReport {
String TRA_ROUTING = "IMAP_TRA_ROUTING";//算路成功
String TRA_TYPE = "IMAP_TRA_TYPE";//加载轨迹类型通知
String ENTRY_AUTOPILOT = "IMAP_ENTRY_AUTOPILOT";//控制进入自动驾驶成功
String PLANNING_FOR_PREDICTION_RECEIVED = "IMAP_PLANNING_FOR_PREDICTION_RECEIVED";//自车进入车自驾,收到预测消息时解除预测数据超时警报
String PLANNING_FOR_HADMAP_ENGINE_LANES_MSG_RECEIVED = "IMAP_PLANNING_FOR_HADMAP_ENGINE_LANES_MSG_RECEIVED";//自车进入车自驾,收到地图车道消息时解除地图数据超时警报
String PLANNING_FOR_PERCEPTION_RECEIVED = "IMAP_PLANNING_FOR_PERCEPTION_RECEIVED";//自车进入车自驾,收到感知消息时解除感知数据超时警报
String START_AUTOPILOT = "IMAP_START_AUTOPILOT";//控制侧开始自驾
String EXIT_AUTOPILOT = "IMAP_EXIT_AUTOPILOT";//控制侧正常退出自驾
String START_REMOTEPILOT = "IMAP_START_REMOTEPILOT";//控制侧开始平行驾驶
String ENTRY_REMOTEPILOT = "IMAP_ENTRY_REMOTEPILOT";//控制侧进入平行驾驶
String EXIT_REMOTEPILOT = "IMAP_EXIT_REMOTEPILOT";//控制侧退出平行驾驶
String CONTROLLER_START_FM_COMMAND = "IMAP_CONTROLLER_START_FM_COMMAND";//控制侧开始故障处理命令
String CONTROLLER_FINISH_FM_COMMAND = "IMAP_CONTROLLER_FINISH_FM_COMMAND";//控制侧完成故障处理命令
}
/**
@@ -371,6 +396,7 @@ public class MogoReport {
String SYSTEM_IN_IDLE = "ISYS_SYSTEM_IN_IDLE";//系统进入空闲状态
String SYSTEM_OUT_IDLE = "ISYS_SYSTEM_OUT_IDLE";//系统退出空闲状态
String ALREADY_AUTOPILOT_STATE = "ISYS_ALREADY_AUTOPILOT_STATE";//已经在自驾状态驾驶,忽略自驾命令
String AUTOPILOT_TAKEN_OVER_BY_REMOTE = "ISYS_AUTOPILOT_TAKEN_OVER_BY_REMOTE";//自动驾驶被远程驾驶接管
/*******轨迹下载相关*******/
String INIT_TRAJECTORY_START = "ISYS_INIT_TRAJECTORY_START";//轨迹管理_轨迹开始下载
@@ -387,6 +413,7 @@ public class MogoReport {
String CONFIG_UPDATING_SLAM_MAP = "ISYS_CONFIG_UPDATING_SLAM_MAP";//slam 地图更新中
String CONFIG_UPDATING_AI_MODEL = "ISYS_CONFIG_UPDATING_AI_MODEL";//AI模型更新中
String CONFIG_UPDATING_GRID_MAP = "ISYS_CONFIG_UPDATING_GRID_MAP";//珊格地图更新中
String TRAJECTORY_AGENT_READY = "ISYS_TRAJECTORY_AGENT_READY ";//配置下载客户端已就绪
}
/**
@@ -395,10 +422,14 @@ public class MogoReport {
interface ISSM {
String INIT = "ISSM_INIT";//SSM系统上电初始化
String RESTARTED = "ISSM_RESTARTED";//SSM系统发生重启
String AUTO_PILOT_STATE_CHANGE = "ISSM_AUTO_PILOT_STATE_CHANGE";//自驾状态变化msg填写 1 to 0
String REMOTE_PILOT_STATE_CHANGE = "ISSM_REMOTE_PILOT_STATE_CHANGE";//平行驾驶状态变化, msg填写 1 to 6
String AUTO_PILOT_FINISH = "ISSM_AUTO_PILOT_FINISH";//一次自驾请求处理结束
String REMOTE_PILOT_FINISH = "ISSM_REMOTE_PILOT_FINISH";//一次平行驾驶处理结束
String HAVE_AGENT_CONNECTED = "ISSM_HAVE_AGENT_CONNECTED";//agent已连接成功
// String MODE_XX_START = "ISSM_MODE_XX_START";//SSM变更模式开始
// String MODE_XX_FINISH = "ISSM_MODE_XX_FINISH";//SSM变更模式完成第一次ready
// String MODE_XX_FINISH = "ISSM_MODE_XX_FINISH";//SSM变更模式完成第一次ready
// String MODE_XX_ABORT = "ISSM_MODE_XX_ABORT";//SSM变更模式中止
// String MODE_XX_TIMEOUT = "ISSM_MODE_XX_TIMEOUT";//SSM变更模式超时
// String MODE_XX_READY = "ISSM_MODE_XX_READY";//SSM模式就绪
@@ -407,21 +438,21 @@ public class MogoReport {
//以上6组被注释掉的字段 中的MODE_XX分别替换成MODE_RUN、MODE_IDLE、MODE_STOP
String MODE_RUN_START = "ISSM_MODE_RUN_START";//SSM变更模式开始
String MODE_RUN_FINISH = "ISSM_MODE_RUN_FINISH";//SSM变更模式完成第一次ready
String MODE_RUN_FINISH = "ISSM_MODE_RUN_FINISH";//SSM变更模式完成第一次ready
String MODE_RUN_ABORT = "ISSM_MODE_RUN_ABORT";//SSM变更模式中止
String MODE_RUN_TIMEOUT = "ISSM_MODE_RUN_TIMEOUT";//SSM变更模式超时
String MODE_RUN_READY = "ISSM_MODE_RUN_READY";//SSM模式就绪
String MODE_RUN_UNREADY = "ISSM_MODE_RUN_UNREADY";//SSM未就绪
String MODE_IDLE_START = "ISSM_MODE_IDLE_START";//SSM变更模式开始
String MODE_IDLE_FINISH = "ISSM_MODE_IDLE_FINISH";//SSM变更模式完成第一次ready
String MODE_IDLE_FINISH = "ISSM_MODE_IDLE_FINISH";//SSM变更模式完成第一次ready
String MODE_IDLE_ABORT = "ISSM_MODE_IDLE_ABORT";//SSM变更模式中止
String MODE_IDLE_TIMEOUT = "ISSM_MODE_IDLE_TIMEOUT";//SSM变更模式超时
String MODE_IDLE_READY = "ISSM_MODE_IDLE_READY";//SSM模式就绪
String MODE_IDLE_UNREADY = "ISSM_MODE_IDLE_UNREADY";//SSM未就绪
String MODE_STOP_START = "ISSM_MODE_STOP_START";//SSM变更模式开始
String MODE_STOP_FINISH = "ISSM_MODE_STOP_FINISH";//SSM变更模式完成第一次ready
String MODE_STOP_FINISH = "ISSM_MODE_STOP_FINISH";//SSM变更模式完成第一次ready
String MODE_STOP_ABORT = "ISSM_MODE_STOP_ABORT";//SSM变更模式中止
String MODE_STOP_TIMEOUT = "ISSM_MODE_STOP_TIMEOUT";//SSM变更模式超时
String MODE_STOP_READY = "ISSM_MODE_STOP_READY";//SSM模式就绪
@@ -499,6 +530,26 @@ public class MogoReport {
interface IVEHICLE {
String NOT_IN_TROUBLE = "IVEHICLE_NOT_IN_TROUBLE";//车辆脱离困境,恢复正常,可继续开始自动驾驶了 触发频率:处于困境中,触发一次; 脱困后,触发一次 云端驾舱会接入该事件 建议鹰眼也接入,展示困境状态/脱困状态
}
/**
* IFSM(功能状态管理)
*/
interface IFSM {
String AUTO_PILOT_STATE_CHANGED = "IFSM_AUTO_PILOT_STATE_CHANGED";//自动驾驶状态机变化 msg 填写如 standby to active
String REMOTE_PILOT_STATE_CHANGED = "IFSM_REMOTE_PILOT_STATE_CHANGED";//平行驾驶状态机变化
String TELECTRL_PILOT_STATE_CHANGED = "IFSM_TELECTRL_PILOT_STATE_CHANGED";//遥感驾驶状态机变化
}
/**
* IFM (故障管理)
*/
interface IFM {
String HANDLE_FAULTS_START = "IFM_HANDLE_FAULTS_START";//FM开始处理故障
String HANDLE_FAULTS_STOP = "IFM_HANDLE_FAULTS_STOP";//FM停止处理故障
String ALL_FAULTS_RECOVER = "IFM_ALL_FAULTS_RECOVER";//FM当前已无故障 (只有有故障到全都消失时候上报)
String ONLY_WARNING_FAULTS = "IFM_ONLY_WARNING_FAULTS";//FM仅存在警示故障
String ERROR1_SLOW_SPEED = "IFM_ERROR1_SLOW_SPEED";//存在故障触发减速策略
}
}
}
}

View File

@@ -0,0 +1,51 @@
package com.zhjt.mogo.adas.data.bean;
import android.text.TextUtils;
import java.util.Objects;
/**
* 自动驾驶能力 能否启动自动驾驶
*/
public class UnableAutopilotReason {
public enum SourceType {
LIB,//ADAS庫
CHASSIS,//底盤
SSM,
FSM,
}
/**
* 來源
*/
public final SourceType source;
/**
* 具體原因
*/
public final String unableAutopilotReason;
public UnableAutopilotReason(SourceType source, String unableAutopilotReason) {
this.source = source;
this.unableAutopilotReason = unableAutopilotReason;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
UnableAutopilotReason that = (UnableAutopilotReason) o;
return source == that.source && TextUtils.equals(unableAutopilotReason, that.unableAutopilotReason);
}
@Override
public int hashCode() {
return Objects.hash(source, unableAutopilotReason);
}
@Override
public String toString() {
return "{原因:" + unableAutopilotReason + " 来源:" + source + "}";
}
}

View File

@@ -253,6 +253,7 @@ message TrajectoryDownloadReq
{
Line line = 1; //路线
uint32 source = 2; //指令来源: 0: default, 1:pad, 2:aicloud
uint32 downloadType = 3; //下载类型: 0:正常下载 1:预下载
}
// message definition for MessageType: MsgTypeBasicInfoReq

View File

@@ -1090,7 +1090,8 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
/**
* 发送 轨迹下载请求
*
* @param line 线路相关参数详情见PB message_pad.proto -> Line
* @param line 线路相关参数详情见PB message_pad.proto -> Line
* @param downloadType 下载类型: 0:正常下载 1:预下载
* @return boolean
*/
@ChainLog(
@@ -1100,10 +1101,13 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
paramIndexes = {0}
)
@Override
public boolean sendTrajectoryDownloadReq(MessagePad.Line line) {
public boolean sendTrajectoryDownloadReq(MessagePad.Line line, int downloadType) {
MessagePad.TrajectoryDownloadReq.Builder builder = MessagePad.TrajectoryDownloadReq.newBuilder();
builder.setSource(1);//指令来源: 0: default, 1:pad, 2:aicloud
builder.setLine(line);
if (downloadType > -1) {
builder.setDownloadType(downloadType);
}
MessagePad.TrajectoryDownloadReq req = builder.build();
return sendPBMessage(MessageType.TYPE_SEND_TRAJECTORY_DOWNLOAD_REQ.typeCode, req.toByteArray());
}

View File

@@ -514,9 +514,20 @@ public class AdasManager implements IAdasNetCommApi {
* @param line 线路相关参数详情见PB message_pad.proto -> Line
* @return boolean
*/
@Override
public boolean sendTrajectoryDownloadReq(MessagePad.Line line) {
return mChannel != null && mChannel.sendTrajectoryDownloadReq(line);
return mChannel != null && mChannel.sendTrajectoryDownloadReq(line, -1);
}
/**
* 发送 轨迹下载请求
*
* @param line 线路相关参数详情见PB message_pad.proto -> Line
* @param downloadType 下载类型: 0:正常下载 1:预下载
* @return boolean
*/
@Override
public boolean sendTrajectoryDownloadReq(MessagePad.Line line, int downloadType) {
return mChannel != null && mChannel.sendTrajectoryDownloadReq(line, downloadType);
}
/**

View File

@@ -251,10 +251,11 @@ public interface IAdasNetCommApi {
/**
* 发送 轨迹下载请求
*
* @param line 线路相关参数详情见PB message_pad.proto -> Line
* @param line 线路相关参数详情见PB message_pad.proto -> Line
* @param downloadType 下载类型: 0:正常下载 1:预下载
* @return 加入WS发送消息队列是否成功
*/
boolean sendTrajectoryDownloadReq(MessagePad.Line line);
boolean sendTrajectoryDownloadReq(MessagePad.Line line, int downloadType);
/**
* 发送 状态查询请求

View File

@@ -4,12 +4,12 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.mogo.support.obu.ObuScene;
import com.zhjt.mogo.adas.data.AdasConstants;
import com.zhidao.support.adas.high.common.MessageType;
import com.zhidao.support.adas.high.common.ProtocolStatus;
import com.zhjt.mogo.adas.data.AdasConstants;
import com.zhjt.mogo.adas.data.bean.AdasParam;
import com.zhjt.mogo.adas.data.bean.AutopilotStatistics;
import com.zhjt.mogo.adas.data.bean.UnableAutopilotReason;
import com.zhjt.mogo.adas.data.sweeper.SweeperCloudTask;
import com.zhjt.mogo.adas.data.sweeper.bootable.SweeperBootable;
import com.zhjt.mogo.adas.data.sweeper.task.SweeperTask;
@@ -19,6 +19,9 @@ import com.zhjt.mogo.adas.data.sweeper.task.confirm.SweeperTaskConfirm;
import com.zhjt.mogo.adas.data.sweeper.task.status.SweeperTaskStatus;
import com.zhjt.mogo.adas.data.sweeper.task.stop.SweeperTaskStop;
import java.util.ArrayList;
import java.util.List;
import bag_manager.BagManagerOuterClass;
import chassis.ChassisStatesOuterClass;
import chassis.VehicleStateOuterClass;
@@ -263,6 +266,7 @@ public interface OnAdasListener {
/**
* 后部摄像头视频 10Hz
* 目前用于清扫车后摄像头和Taxi右右后摄像头
*
* @param header 头
* @param data 数据
*/
@@ -418,10 +422,11 @@ public interface OnAdasListener {
/**
* 是否有能力启动自动驾驶
*
* @param isAutopilotAbility 是否能启动自动驾驶
* @param unableAutopilotReason 不能启动自动驾驶原因
* @param isAutopilotAbility 是否能启动自动驾驶
* @param unableAutopilotReasons 不能启动自动驾驶原因
*/
void onAutopilotAbility(boolean isAutopilotAbility, String unableAutopilotReason);
void onAutopilotAbility(boolean isAutopilotAbility, @Nullable ArrayList<UnableAutopilotReason> unableAutopilotReasons);
/**
* 启动自动驾驶失败回调

View File

@@ -1,5 +1,10 @@
package com.zhidao.support.adas.high.common.autopilot.ability;
import androidx.annotation.Nullable;
import com.zhjt.mogo.adas.data.bean.UnableAutopilotReason;
import java.util.ArrayList;
import java.util.Timer;
import java.util.TimerTask;
@@ -15,41 +20,44 @@ import chassis.ChassisStatesOuterClass;
*/
public class AutopilotAbility230 {
private static final String TAG = AutopilotAbility230.class.getSimpleName();
private static final long DEFAULT_DETECTION_TIME = 3 * 1000L;//默认检测时间
private volatile Timer timer;
private ChassisStatesOuterClass.ChassisStates chassisStates;
private OnAutopilotAbilityListener listener;
public AutopilotAbility230() {
protected interface OnAutopilotAbilityListener {
void onAutopilotAbility(boolean isAutopilotAbility, @Nullable ArrayList<UnableAutopilotReason> unableAutopilotReasons);
}
protected AutopilotAbility230() {
}
public void setChassisStates(ChassisStatesOuterClass.ChassisStates chassisStates) {
protected void setChassisStates(ChassisStatesOuterClass.ChassisStates chassisStates) {
this.chassisStates = chassisStates;
}
private void onCallback() {
boolean isAutopilotAbility = true;//是否能启动自动驾驶
String unableAutopilotReason = null;//不能启动自动驾驶原因
ArrayList<UnableAutopilotReason> unableAutopilotReasons = null;//不能启动自动驾驶原因
//检测底盘相关
if (chassisStates != null) {
if (chassisStates.hasBrakeSystemStates()) {
float brake = chassisStates.getBrakeSystemStates().getBrakePedalResponsePosition();
if (brake > 0) {
isAutopilotAbility = false;
unableAutopilotReason = "制动踏板被踩下";
unableAutopilotReasons = AutopilotAbilityManager.getInstance().addUnableAutopilotReason(unableAutopilotReasons, UnableAutopilotReason.SourceType.CHASSIS, "制动踏板被踩下");
}
}
if (isAutopilotAbility) {
if (chassisStates.hasGearSystemStates()) {
Chassis.GearPosition gear = chassisStates.getGearSystemStates().getGearPosition();
if (!AutopilotAbilityManager.getInstance().isLaunchAutopilot(gear)) {
isAutopilotAbility = false;
unableAutopilotReason = "档位不正常";
}
if (chassisStates.hasGearSystemStates()) {
Chassis.GearPosition gear = chassisStates.getGearSystemStates().getGearPosition();
if (!AutopilotAbilityManager.getInstance().isLaunchAutopilot(gear)) {
isAutopilotAbility = false;
unableAutopilotReasons = AutopilotAbilityManager.getInstance().addUnableAutopilotReason(unableAutopilotReasons, UnableAutopilotReason.SourceType.CHASSIS, "当前档位无法启动自驾");
}
}
//TODO 关于手刹:不同车型的实现不同所以目前没法使用此字段
// if (isAutopilotAbility) {
// //电子驻车制动系统
// if (chassisStates.hasEpbSystemStates()) {
// ChassisStatesOuterClass.EPBSystemStates epb = chassisStates.getEpbSystemStates();
@@ -57,12 +65,15 @@ public class AutopilotAbility230 {
// epb.getEpbWorkState();
// }
// }
// }
}
if (listener != null) {
listener.onAutopilotAbility(isAutopilotAbility, unableAutopilotReasons);
}
AutopilotAbilityManager.getInstance().onAutopilotAbility(isAutopilotAbility, unableAutopilotReason);
}
public synchronized void start() {
protected synchronized void start(OnAutopilotAbilityListener listener) {
this.listener = listener;
if (timer == null) {
timer = new Timer();
timer.schedule(new TimerTask() {
@@ -70,17 +81,16 @@ public class AutopilotAbility230 {
public void run() {
onCallback();
}
}, 2000L, DEFAULT_DETECTION_TIME);//延迟执行,避免刚连接成功后底盘信息无法及时同步
}, 2000L, AutopilotAbilityManager.DEFAULT_DETECTION_TIME);//延迟执行,避免刚连接成功后底盘信息无法及时同步
}
}
public synchronized void stop() {
protected synchronized void stop() {
if (timer != null) {
timer.cancel();
timer = null;
}
this.chassisStates = null;
this.listener = null;
}
}

View File

@@ -1,10 +1,12 @@
package com.zhidao.support.adas.high.common.autopilot.ability;
import android.os.Message;
import androidx.annotation.Nullable;
import com.zhidao.support.adas.high.AdasManager;
import com.zhidao.support.adas.high.common.CupidLogUtils;
import com.zhjt.mogo.adas.data.bean.UnableAutopilotReason;
import java.util.ArrayList;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
@@ -22,36 +24,42 @@ import system_master.SystemStatusInfo;
*/
public class AutopilotAbility250 {
private static final String TAG = AutopilotAbility250.class.getSimpleName();
private static final int WHAT_TIMEOUT = 0;
private static final int DEFAULT_TIMEOUT = 1500;
private static final long DEFAULT_DETECTION_TIME = 3 * 1000L;//默认检测时间
private static final String[] NODE_INFO_STATE = {"未知状态 ", "依赖未就绪 ", "启动中 ", "运行 ", "停止 ", "无法启动状态 ", "人为启动状态 ", "人为关闭状态 "};
private volatile Timer timer;
private ChassisStatesOuterClass.ChassisStates chassisStates;
private int mapVersion = -1;//MAP版本
private int masterVersion = -1;//Master版本
private OnAutopilotAbilityListener listener;
public AutopilotAbility250(int mapVersion) {
protected interface OnAutopilotAbilityListener {
void onAutopilotAbility(boolean isAutopilotAbility, @Nullable ArrayList<UnableAutopilotReason> unableAutopilotReasons);
void onStatusQuery();
void onSendTimeoutMessages();
void onRemoveTimeoutMessages();
}
protected AutopilotAbility250(int mapVersion) {
this.mapVersion = mapVersion;
this.masterVersion = -1;
}
public void setStatusInfo(SystemStatusInfo.StatusInfo statusInfo) {
if (AutopilotAbilityManager.getInstance().getHandler() != null) {
if (AutopilotAbilityManager.getInstance().getHandler().hasMessages(WHAT_TIMEOUT))
AutopilotAbilityManager.getInstance().getHandler().removeMessages(WHAT_TIMEOUT);
protected void setStatusInfo(SystemStatusInfo.StatusInfo statusInfo) {
if (listener != null) {
listener.onRemoveTimeoutMessages();
}
onCallback(statusInfo);
}
public void setChassisStates(ChassisStatesOuterClass.ChassisStates chassisStates) {
protected void setChassisStates(ChassisStatesOuterClass.ChassisStates chassisStates) {
this.chassisStates = chassisStates;
}
private void onCallback(SystemStatusInfo.StatusInfo statusInfo) {
boolean isAutopilotAbility = true;//是否能启动自动驾驶
String unableAutopilotReason = null;//不能启动自动驾驶原因
ArrayList<UnableAutopilotReason> unableAutopilotReasons = null;//不能启动自动驾驶原因
//检测节点状态相关
if (statusInfo != null) {
if (masterVersion == -1 && statusInfo.hasMasterVersion()) {
@@ -63,7 +71,7 @@ public class AutopilotAbility250 {
if (mapVersion >= 30400 && masterVersion > 2 && statusInfo.hasAutoPilotReady() && statusInfo.hasAutoPilotUnreadyReason()) {
isAutopilotAbility = statusInfo.getAutoPilotReady();
if (!isAutopilotAbility) {
unableAutopilotReason = statusInfo.getAutoPilotUnreadyReason();
unableAutopilotReasons = AutopilotAbilityManager.getInstance().addUnableAutopilotReason(unableAutopilotReasons, UnableAutopilotReason.SourceType.SSM, statusInfo.getAutoPilotUnreadyReason());
}
} else if (mapVersion >= 21000 && masterVersion > 1 && statusInfo.hasAutoPilotReady()) {//如果 maser version 大于1还需要判断AutoPilotReady字段是否存在以确保MAP版本和SSM Maser版本不陪配情况逻辑能正常执行
isAutopilotAbility = statusInfo.getAutoPilotReady();
@@ -75,15 +83,16 @@ public class AutopilotAbility250 {
for (SystemStatusInfo.NodeInfo info : list) {
builder.append(info.getNodeName());
int state = info.getState();
if (state < NODE_INFO_STATE.length) {
builder.append(NODE_INFO_STATE[state]);
if (state < AutopilotAbilityManager.NODE_INFO_STATE.length) {
builder.append(AutopilotAbilityManager.NODE_INFO_STATE[state]);
} else {
builder.append("未知异常 ");
}
unableAutopilotReasons = AutopilotAbilityManager.getInstance().addUnableAutopilotReason(unableAutopilotReasons, UnableAutopilotReason.SourceType.SSM, builder.toString());
builder.setLength(0);
}
unableAutopilotReason = builder.toString();
} else {
unableAutopilotReason = "未知异常节点";
unableAutopilotReasons = AutopilotAbilityManager.getInstance().addUnableAutopilotReason(unableAutopilotReasons, UnableAutopilotReason.SourceType.SSM, "未知异常节点");
}
}
} else {
@@ -91,6 +100,7 @@ public class AutopilotAbility250 {
// 目前已知可以下发启动自驾命令的状态: SystemState.SYS_RUNNING、SystemState.PILOT_READY、SystemState.AUTO_PILOT_STARTING、SystemState.AUTO_PILOT_RUNNING
if (systemState != SystemStatusInfo.SystemState.SYS_RUNNING && systemState != SystemStatusInfo.SystemState.PILOT_READY) {
isAutopilotAbility = false;
String unableAutopilotReason = null;
if (systemState == SystemStatusInfo.SystemState.SYS_STARTING) {
unableAutopilotReason = "系统正在启动";
} else if (systemState == SystemStatusInfo.SystemState.SYS_EXITING) {
@@ -112,34 +122,33 @@ public class AutopilotAbility250 {
} else {
unableAutopilotReason = "未知系统状态";
}
if (!isAutopilotAbility) {
unableAutopilotReasons = AutopilotAbilityManager.getInstance().addUnableAutopilotReason(unableAutopilotReasons, UnableAutopilotReason.SourceType.SSM, unableAutopilotReason);
}
}
}
} else {
isAutopilotAbility = false;//是否能启动自动驾驶
unableAutopilotReason = "SSM状态查询超时无响应";//不能启动自动驾驶原因
unableAutopilotReasons = AutopilotAbilityManager.getInstance().addUnableAutopilotReason(unableAutopilotReasons, UnableAutopilotReason.SourceType.LIB, "SSM状态查询超时无响应");
}
//检测底盘相关
if (chassisStates != null) {
if (isAutopilotAbility) {
if (chassisStates.hasBrakeSystemStates()) {
float brake = chassisStates.getBrakeSystemStates().getBrakePedalResponsePosition();
if (brake > 0) {
isAutopilotAbility = false;
unableAutopilotReason = "制动踏板被踩下";
}
if (chassisStates.hasBrakeSystemStates()) {
float brake = chassisStates.getBrakeSystemStates().getBrakePedalResponsePosition();
if (brake > 0) {
isAutopilotAbility = false;
unableAutopilotReasons = AutopilotAbilityManager.getInstance().addUnableAutopilotReason(unableAutopilotReasons, UnableAutopilotReason.SourceType.CHASSIS, "制动踏板被踩下");
}
}
if (isAutopilotAbility) {
if (chassisStates.hasGearSystemStates()) {
Chassis.GearPosition gear = chassisStates.getGearSystemStates().getGearPosition();
if (!AutopilotAbilityManager.getInstance().isLaunchAutopilot(gear)) {
isAutopilotAbility = false;
unableAutopilotReason = "档位不正常";
}
if (chassisStates.hasGearSystemStates()) {
Chassis.GearPosition gear = chassisStates.getGearSystemStates().getGearPosition();
if (!AutopilotAbilityManager.getInstance().isLaunchAutopilot(gear)) {
isAutopilotAbility = false;
unableAutopilotReasons = AutopilotAbilityManager.getInstance().addUnableAutopilotReason(unableAutopilotReasons, UnableAutopilotReason.SourceType.CHASSIS, "当前档位无法启动自驾");
}
}
//TODO 关于手刹:不同车型的实现不同所以目前没法使用此字段
// if (isAutopilotAbility) {
// //电子驻车制动系统
// if (chassisStates.hasEpbSystemStates()) {
// ChassisStatesOuterClass.EPBSystemStates epb = chassisStates.getEpbSystemStates();
@@ -147,45 +156,45 @@ public class AutopilotAbility250 {
// epb.getEpbWorkState();
// }
// }
// }
}
if (listener != null) {
listener.onAutopilotAbility(isAutopilotAbility, unableAutopilotReasons);
}
AutopilotAbilityManager.getInstance().onAutopilotAbility(isAutopilotAbility, unableAutopilotReason);
}
public synchronized void start() {
protected synchronized void start(OnAutopilotAbilityListener listener) {
this.listener = listener;
if (timer == null) {
timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
if (AutopilotAbilityManager.getInstance().getOnAutopilotAbilityListener() != null) {
AutopilotAbilityManager.getInstance().getOnAutopilotAbilityListener().onStatusQuery();
if (listener != null) {
listener.onStatusQuery();
}
AdasManager.getInstance().sendStatusQueryReq();
if (AutopilotAbilityManager.getInstance().getHandler() != null) {
if (AutopilotAbilityManager.getInstance().getHandler().hasMessages(WHAT_TIMEOUT))
AutopilotAbilityManager.getInstance().getHandler().removeMessages(WHAT_TIMEOUT);
AutopilotAbilityManager.getInstance().getHandler().sendEmptyMessageDelayed(WHAT_TIMEOUT, DEFAULT_TIMEOUT);
if (listener != null) {
listener.onSendTimeoutMessages();
}
}
}, 2000L, DEFAULT_DETECTION_TIME);//延迟执行,避免刚连接成功后底盘信息无法及时同步
}, 2000L, AutopilotAbilityManager.DEFAULT_DETECTION_TIME);//延迟执行,避免刚连接成功后底盘信息无法及时同步
}
}
public synchronized void stop() {
protected synchronized void stop() {
if (timer != null) {
timer.cancel();
timer = null;
}
this.chassisStates = null;
this.masterVersion = -1;
this.listener = null;
}
public void onHandleMessage(Message msg) {
if (msg.what == WHAT_TIMEOUT) {
onCallback(null);
}
protected void onCallTimeout() {
onCallback(null);
}

View File

@@ -1,10 +1,14 @@
package com.zhidao.support.adas.high.common.autopilot.ability;
import android.os.Message;
import android.text.TextUtils;
import androidx.annotation.Nullable;
import com.zhidao.support.adas.high.AdasManager;
import com.zhidao.support.adas.high.common.CupidLogUtils;
import com.zhjt.mogo.adas.data.bean.UnableAutopilotReason;
import java.util.ArrayList;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
@@ -22,29 +26,35 @@ import system_master.SystemStatusInfo;
*/
public class AutopilotAbility330 {
private static final String TAG = AutopilotAbility330.class.getSimpleName();
private static final int WHAT_TIMEOUT = 0;
private static final int DEFAULT_TIMEOUT = 1500;
private static final long DEFAULT_DETECTION_TIME = 3 * 1000L;//默认检测时间
private static final String[] NODE_INFO_STATE = {"未知状态 ", "依赖未就绪 ", "启动中 ", "运行 ", "停止 ", "无法启动状态 ", "人为启动状态 ", "人为关闭状态 "};
private volatile Timer timer;
private volatile FSMStatusReasonQueryOuterClass.FSMStatusReasonRespond fsmStatusReasonRespond;//自动驾驶状态为OFF的原因
private int mapVersion = -1;//MAP版本
private int masterVersion = -1;//Master版本
private OnAutopilotAbilityListener listener;
public AutopilotAbility330(int mapVersion) {
protected interface OnAutopilotAbilityListener {
void onAutopilotAbility(boolean isAutopilotAbility, @Nullable ArrayList<UnableAutopilotReason> unableAutopilotReasons);
void onStatusQuery();
void onSendTimeoutMessages();
void onRemoveTimeoutMessages();
}
protected AutopilotAbility330(int mapVersion) {
this.mapVersion = mapVersion;
this.masterVersion = -1;
}
public synchronized void setFsmStatusReasonRespond(FSMStatusReasonQueryOuterClass.FSMStatusReasonRespond fsmStatusReasonRespond) {
protected synchronized void setFsmStatusReasonRespond(FSMStatusReasonQueryOuterClass.FSMStatusReasonRespond fsmStatusReasonRespond) {
this.fsmStatusReasonRespond = fsmStatusReasonRespond;
}
public void setStatusInfo(SystemStatusInfo.StatusInfo statusInfo) {
if (AutopilotAbilityManager.getInstance().getHandler() != null) {
if (AutopilotAbilityManager.getInstance().getHandler().hasMessages(WHAT_TIMEOUT))
AutopilotAbilityManager.getInstance().getHandler().removeMessages(WHAT_TIMEOUT);
protected void setStatusInfo(SystemStatusInfo.StatusInfo statusInfo) {
if (listener != null) {
listener.onRemoveTimeoutMessages();
}
onCallback(statusInfo);
}
@@ -52,7 +62,7 @@ public class AutopilotAbility330 {
private void onCallback(SystemStatusInfo.StatusInfo statusInfo) {
boolean isAutopilotAbility = true;//是否能启动自动驾驶
String unableAutopilotReason = null;//不能启动自动驾驶原因
ArrayList<UnableAutopilotReason> unableAutopilotReasons = null;//不能启动自动驾驶原因
//检测节点状态相关
if (statusInfo != null) {
if (masterVersion == -1 && statusInfo.hasMasterVersion()) {
@@ -64,7 +74,7 @@ public class AutopilotAbility330 {
if (mapVersion >= 30400 && masterVersion > 2 && statusInfo.hasAutoPilotReady() && statusInfo.hasAutoPilotUnreadyReason()) {
isAutopilotAbility = statusInfo.getAutoPilotReady();
if (!isAutopilotAbility) {
unableAutopilotReason = statusInfo.getAutoPilotUnreadyReason();
unableAutopilotReasons = AutopilotAbilityManager.getInstance().addUnableAutopilotReason(unableAutopilotReasons, UnableAutopilotReason.SourceType.SSM, statusInfo.getAutoPilotUnreadyReason());
}
} else if (mapVersion >= 21000 && masterVersion > 1 && statusInfo.hasAutoPilotReady()) {//如果 maser version 大于1还需要判断AutoPilotReady字段是否存在以确保MAP版本和SSM Maser版本不陪配情况逻辑能正常执行
isAutopilotAbility = statusInfo.getAutoPilotReady();
@@ -76,15 +86,16 @@ public class AutopilotAbility330 {
for (SystemStatusInfo.NodeInfo info : list) {
builder.append(info.getNodeName());
int state = info.getState();
if (state < NODE_INFO_STATE.length) {
builder.append(NODE_INFO_STATE[state]);
if (state < AutopilotAbilityManager.NODE_INFO_STATE.length) {
builder.append(AutopilotAbilityManager.NODE_INFO_STATE[state]);
} else {
builder.append("未知异常 ");
}
unableAutopilotReasons = AutopilotAbilityManager.getInstance().addUnableAutopilotReason(unableAutopilotReasons, UnableAutopilotReason.SourceType.SSM, builder.toString());
builder.setLength(0);
}
unableAutopilotReason = builder.toString();
} else {
unableAutopilotReason = "未知异常节点";
unableAutopilotReasons = AutopilotAbilityManager.getInstance().addUnableAutopilotReason(unableAutopilotReasons, UnableAutopilotReason.SourceType.SSM, "未知异常节点");
}
}
} else {
@@ -92,6 +103,7 @@ public class AutopilotAbility330 {
// 目前已知可以下发启动自驾命令的状态: SystemState.SYS_RUNNING、SystemState.PILOT_READY、SystemState.AUTO_PILOT_STARTING、SystemState.AUTO_PILOT_RUNNING
if (systemState != SystemStatusInfo.SystemState.SYS_RUNNING && systemState != SystemStatusInfo.SystemState.PILOT_READY) {
isAutopilotAbility = false;
String unableAutopilotReason = null;
if (systemState == SystemStatusInfo.SystemState.SYS_STARTING) {
unableAutopilotReason = "系统正在启动";
} else if (systemState == SystemStatusInfo.SystemState.SYS_EXITING) {
@@ -113,67 +125,66 @@ public class AutopilotAbility330 {
} else {
unableAutopilotReason = "未知系统状态";
}
if (!isAutopilotAbility) {
unableAutopilotReasons = AutopilotAbilityManager.getInstance().addUnableAutopilotReason(unableAutopilotReasons, UnableAutopilotReason.SourceType.SSM, unableAutopilotReason);
}
}
}
} else {
isAutopilotAbility = false;//是否能启动自动驾驶
unableAutopilotReason = "SSM状态查询超时无响应";//不能启动自动驾驶原因
unableAutopilotReasons = AutopilotAbilityManager.getInstance().addUnableAutopilotReason(unableAutopilotReasons, UnableAutopilotReason.SourceType.LIB, "SSM状态查询超时无响应");
}
if (isAutopilotAbility) {
if (fsmStatusReasonRespond != null) {
int count = fsmStatusReasonRespond.getFsmStatusReasonRespondCount();
StringBuilder builder = null;
if (count > 0) {
builder = new StringBuilder();
for (int i = 0; i < count; i++) {
String respond = fsmStatusReasonRespond.getFsmStatusReasonRespond(i);
builder.append(respond).append(' ');
if (fsmStatusReasonRespond != null) {
int count = fsmStatusReasonRespond.getFsmStatusReasonRespondCount();
if (count > 0) {
isAutopilotAbility = false;
for (int i = 0; i < count; i++) {
String respond = fsmStatusReasonRespond.getFsmStatusReasonRespond(i);
if (!TextUtils.isEmpty(respond)) {
unableAutopilotReasons = AutopilotAbilityManager.getInstance().addUnableAutopilotReason(unableAutopilotReasons, UnableAutopilotReason.SourceType.FSM, respond);
}
}
if (builder != null) {
isAutopilotAbility = false;
builder.deleteCharAt(builder.length() - 1);//删除末尾
unableAutopilotReason = builder.toString();
if (unableAutopilotReasons == null || unableAutopilotReasons.isEmpty()) {
unableAutopilotReasons = AutopilotAbilityManager.getInstance().addUnableAutopilotReason(unableAutopilotReasons, UnableAutopilotReason.SourceType.LIB, "FSM未给出原因");
}
}
}
AutopilotAbilityManager.getInstance().onAutopilotAbility(isAutopilotAbility, unableAutopilotReason);
if (listener != null) {
listener.onAutopilotAbility(isAutopilotAbility, unableAutopilotReasons);
}
}
public synchronized void start() {
protected synchronized void start(OnAutopilotAbilityListener listener) {
this.listener = listener;
if (timer == null) {
timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
if (AutopilotAbilityManager.getInstance().getOnAutopilotAbilityListener() != null) {
AutopilotAbilityManager.getInstance().getOnAutopilotAbilityListener().onStatusQuery();
if (listener != null) {
listener.onStatusQuery();
}
AdasManager.getInstance().sendStatusQueryReq();
if (AutopilotAbilityManager.getInstance().getHandler() != null) {
if (AutopilotAbilityManager.getInstance().getHandler().hasMessages(WHAT_TIMEOUT))
AutopilotAbilityManager.getInstance().getHandler().removeMessages(WHAT_TIMEOUT);
AutopilotAbilityManager.getInstance().getHandler().sendEmptyMessageDelayed(WHAT_TIMEOUT, DEFAULT_TIMEOUT);
if (listener != null) {
listener.onSendTimeoutMessages();
}
}
}, 2000L, DEFAULT_DETECTION_TIME);//延迟执行,避免刚连接成功后底盘信息无法及时同步
}, 2000L, AutopilotAbilityManager.DEFAULT_DETECTION_TIME);//延迟执行,避免刚连接成功后底盘信息无法及时同步
}
}
public synchronized void stop() {
protected synchronized void stop() {
if (timer != null) {
timer.cancel();
timer = null;
}
this.masterVersion = -1;
this.listener = null;
}
public void onHandleMessage(Message msg) {
if (msg.what == WHAT_TIMEOUT) {
onCallback(null);
}
protected void onCallTimeout() {
onCallback(null);
}
}

View File

@@ -3,11 +3,15 @@ package com.zhidao.support.adas.high.common.autopilot.ability;
import android.os.Handler;
import android.os.Message;
import androidx.annotation.Nullable;
import com.zhidao.support.adas.high.AdasManager;
import com.zhidao.support.adas.high.OnAdasListener;
import com.zhidao.support.adas.high.common.Constants;
import com.zhidao.support.adas.high.common.CupidLogUtils;
import com.zhjt.mogo.adas.data.bean.UnableAutopilotReason;
import java.util.ArrayList;
import java.util.Set;
import java.util.Timer;
import java.util.TimerTask;
@@ -25,8 +29,12 @@ import system_master.SystemStatusInfo;
* <p>
* 此定时器不能停止 鹰眼中存在UI更新依赖循环查询系统状态
*/
public class AutopilotAbilityManager {
public class AutopilotAbilityManager implements AutopilotAbility230.OnAutopilotAbilityListener, AutopilotAbility250.OnAutopilotAbilityListener, AutopilotAbility330.OnAutopilotAbilityListener {
private static final String TAG = AutopilotAbilityManager.class.getSimpleName();
protected static final int WHAT_TIMEOUT = 0;
protected static final int DEFAULT_TIMEOUT = 2500;
protected static final long DEFAULT_DETECTION_TIME = 3 * 1000L;//默认检测周期
protected static final String[] NODE_INFO_STATE = {"未知状态 ", "依赖未就绪 ", "启动中 ", "运行 ", "停止 ", "无法启动状态 ", "人为启动状态 ", "人为关闭状态 "};
private static volatile AutopilotAbilityManager INSTANCE;
private OnAdasListener listener;
private Handler handler;
@@ -79,6 +87,22 @@ public class AutopilotAbilityManager {
return true;
}
/**
* 添加不能启动自驾的原因
*
* @param unableAutopilotReasons 原因列表
* @param source 来源
* @param unableAutopilotReason 云隐
* @return 原因列表
*/
protected ArrayList<UnableAutopilotReason> addUnableAutopilotReason(ArrayList<UnableAutopilotReason> unableAutopilotReasons, UnableAutopilotReason.SourceType source, String unableAutopilotReason) {
if (unableAutopilotReasons == null) {
unableAutopilotReasons = new ArrayList<>();
}
unableAutopilotReasons.add(new UnableAutopilotReason(source, unableAutopilotReason));
return unableAutopilotReasons;
}
public void setCarConfig(MessagePad.CarConfigResp carConfig) {
mapVersion = carConfig.getMapVersion();
isFutianSweeper = carConfig.getIsFutianSweeper();
@@ -93,9 +117,33 @@ public class AutopilotAbilityManager {
this.listener = listener;
}
public void onAutopilotAbility(boolean isAutopilotAbility, String unableAutopilotReason) {
@Override
public void onAutopilotAbility(boolean isAutopilotAbility, @Nullable ArrayList<UnableAutopilotReason> unableAutopilotReasons) {
if (listener != null) {
listener.onAutopilotAbility(isAutopilotAbility, unableAutopilotReason);
listener.onAutopilotAbility(isAutopilotAbility, unableAutopilotReasons);
}
}
@Override
public void onStatusQuery() {
if (onAutopilotAbilityListener != null) {
onAutopilotAbilityListener.onStatusQuery();
}
}
@Override
public void onSendTimeoutMessages() {
onRemoveTimeoutMessages();
if (handler != null) {
handler.sendEmptyMessageDelayed(WHAT_TIMEOUT, DEFAULT_TIMEOUT);
}
}
@Override
public void onRemoveTimeoutMessages() {
if (handler != null) {
if (handler.hasMessages(WHAT_TIMEOUT))
handler.removeMessages(WHAT_TIMEOUT);
}
}
@@ -103,18 +151,11 @@ public class AutopilotAbilityManager {
this.handler = handler;
}
public Handler getHandler() {
return handler;
}
public void setOnAutopilotAbilityListener(OnAutopilotAbilityListener onAutopilotAbilityListener) {
this.onAutopilotAbilityListener = onAutopilotAbilityListener;
}
public OnAutopilotAbilityListener getOnAutopilotAbilityListener() {
return onAutopilotAbilityListener;
}
/**
* SSM状态更新
@@ -156,8 +197,13 @@ public class AutopilotAbilityManager {
}
public void onHandleMessage(Message msg) {
if (autopilotAbility250 != null) {
autopilotAbility250.onHandleMessage(msg);
if (msg.what == WHAT_TIMEOUT) {
if (autopilotAbility250 != null) {
autopilotAbility250.onCallTimeout();
}
if (autopilotAbility330 != null) {
autopilotAbility330.onCallTimeout();
}
}
}
@@ -169,7 +215,7 @@ public class AutopilotAbilityManager {
stop250();
if (autopilotAbility330 == null) {
autopilotAbility330 = new AutopilotAbility330(mapVersion);
autopilotAbility330.start();
autopilotAbility330.start(this);
}
} else if (mapVersion >= 20500) {
CupidLogUtils.i(TAG, "是否可以启动自动驾驶能力检测使用250版本");
@@ -177,7 +223,7 @@ public class AutopilotAbilityManager {
stop330();
if (autopilotAbility250 == null) {
autopilotAbility250 = new AutopilotAbility250(mapVersion);
autopilotAbility250.start();
autopilotAbility250.start(this);
}
} else {
CupidLogUtils.i(TAG, "是否可以启动自动驾驶能力检测使用230版本");
@@ -185,7 +231,7 @@ public class AutopilotAbilityManager {
stop330();
if (autopilotAbility230 == null) {
autopilotAbility230 = new AutopilotAbility230();
autopilotAbility230.start();
autopilotAbility230.start(this);
}
}