完成了自动驾驶状态信息回传

Signed-off-by: 董宏宇 <martindhy@gmail.com>
This commit is contained in:
董宏宇
2021-10-12 21:24:58 +08:00
parent 870af04059
commit 9802124169
15 changed files with 309 additions and 37 deletions

2
.idea/misc.xml generated
View File

@@ -16,7 +16,7 @@
<entry key="core/function-impl/mogo-core-function-hmi/src/main/res/layout/fragment_hmi.xml" value="0.33" />
<entry key="core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_autopilot_status.xml" value="0.25833333333333336" />
<entry key="core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_check_status.xml" value="1.0" />
<entry key="core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_debug_setting.xml" value="0.5" />
<entry key="core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_debug_setting.xml" value="0.26614583333333336" />
<entry key="core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_traffic_light_vr.xml" value="1.0" />
<entry key="modules/mogo-module-adas/src/main/res/drawable/module_adas_left_corner_bg.xml" value="0.22125" />
<entry key="modules/mogo-module-adas/src/main/res/layout/dialog_adas_dispatch_remind.xml" value="0.22658490296325878" />

View File

@@ -5,7 +5,6 @@ import android.content.Context;
import com.mogo.eagle.core.data.autopilot.AdasControlCommandParameter;
import com.mogo.eagle.core.data.autopilot.RemoteControlAutoPilotParameters;
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutoPilotProvider;
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutoPilotStatusListener;
import com.mogo.eagle.core.utilcode.util.GsonUtils;
import com.mogo.eagle.core.utilcode.util.LogUtils;
import com.zhidao.support.adas.high.AdasManager;

View File

@@ -6,9 +6,13 @@ import android.view.LayoutInflater
import androidx.constraintlayout.widget.ConstraintLayout
import com.mogo.cloud.passport.MoGoAiCloudClient
import com.mogo.eagle.core.data.app.AppConfigInfo
import com.mogo.eagle.core.data.autopilot.AdasOCHData
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo
import com.mogo.eagle.core.data.constants.MoGoConfig
import com.mogo.eagle.core.data.obu.ObuStatusInfo
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutoPilotStatusListener
import com.mogo.eagle.core.function.api.obu.IMoGoObuStatusListener
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
import com.mogo.eagle.core.function.call.obu.CallerOBUManager
import com.mogo.eagle.core.function.call.obu.CallerObuListenerManager
import com.mogo.eagle.core.function.hmi.R
@@ -30,7 +34,8 @@ class DebugSettingView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : ConstraintLayout(context, attrs, defStyleAttr), IMoGoObuStatusListener {
) : ConstraintLayout(context, attrs, defStyleAttr), IMoGoObuStatusListener,
IMoGoAutoPilotStatusListener {
private val TAG = "DebugSettingView"
@@ -42,16 +47,19 @@ class DebugSettingView @JvmOverloads constructor(
override fun onAttachedToWindow() {
super.onAttachedToWindow()
CallerObuListenerManager.addListener(TAG, this)
CallerAutoPilotStatusListenerManager.addListener(TAG, this)
}
override fun onDetachedFromWindow() {
super.onDetachedFromWindow()
CallerObuListenerManager.removeListener(TAG)
CallerAutoPilotStatusListenerManager.removeListener(TAG)
}
private fun initView() {
tvObuInfo.text = CallerObuListenerManager.getObuStatusInfo()
tvObuInfo.text = CallerObuListenerManager.getObuStatusInfoJsonString()
tvAutopilotInfo.text =
CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfoJsonString()
// 初始化App 配置信息
val appConfigInfo = AppConfigInfo()
@@ -89,4 +97,19 @@ class DebugSettingView @JvmOverloads constructor(
tvObuInfo.text = GsonUtils.toJson(obuStatusInfo)
}
/**
* 自动驾驶相关回调
*/
override fun onAutoPilotArriveAtStation(data: AdasOCHData?) {
}
override fun onAutoPilotStateChanged(state: Int, reason: String?) {
}
override fun onAutoPilotStatusResponse(autopilotStatusInfo: AutopilotStatusInfo?) {
tvAutopilotInfo.text = GsonUtils.toJson(autopilotStatusInfo)
}
}

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="@dimen/dp_1000"
android:layout_height="@dimen/dp_700"
android:layout_width="@dimen/dp_1300"
android:layout_height="@dimen/dp_1000"
android:background="#FFFFFF">
<ScrollView
@@ -21,6 +21,8 @@
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#B200BCD4"
android:padding="@dimen/dp_10"
android:text="鹰眼应用配置信息"
android:textColor="#000"
android:textSize="@dimen/dp_34"
@@ -44,20 +46,22 @@
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#B200BCD4"
android:padding="@dimen/dp_10"
android:text="OBU 配置信息"
android:textColor="#000"
android:textSize="@dimen/dp_34"
android:textStyle="bold" />
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/etObuIP"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#32009688"
android:gravity="center"
android:padding="@dimen/dp_5"
android:text="192.168.1.199"
android:textSize="@dimen/dp_34" />
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/etObuIP"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#32009688"
android:gravity="center"
android:padding="@dimen/dp_5"
android:text="192.168.1.199"
android:textSize="@dimen/dp_34" />
<Button
android:id="@+id/btnSetObuIP"
@@ -83,6 +87,23 @@
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#B200BCD4"
android:padding="@dimen/dp_10"
android:text="域控制器(工控机)配置信息"
android:textColor="#000"
android:textSize="@dimen/dp_34"
android:textStyle="bold" />
<TextView
android:id="@+id/tvAutopilotInfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#000"
android:textSize="@dimen/dp_34" />
</LinearLayout>
</LinearLayout>

View File

@@ -3,7 +3,6 @@ package com.mogo.eagle.core.function.obu.mogo
import android.content.Context
import com.alibaba.android.arouter.launcher.ARouter
import com.mogo.eagle.core.data.enums.WarningDirectionEnum
import com.mogo.eagle.core.data.obu.ObuStatusInfo
import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
import com.mogo.eagle.core.function.call.obu.CallerObuListenerManager
@@ -39,7 +38,7 @@ class MogoPrivateObuManager private constructor() {
private var mMogoServiceApis: IMogoServiceApis? = null
private var mIMogoMapService: IMogoMapService? = null
private var mContext: Context? = null
private var mObuStatusInfo = ObuStatusInfo()
private var mObuStatusInfo = CallerObuListenerManager.getObuStatusInfo()
fun init(context: Context, ipAddress: String) {
Logger.d(MogoObuConst.TAG_MOGO_OBU, "obuManager初始化--")
@@ -447,7 +446,10 @@ class MogoPrivateObuManager private constructor() {
-> {
if (info.ext_info != null) {
// 计算为千米每小时 TODO 这里需要做一下向上取整数406080120等
Logger.d(MogoObuConst.TAG_MOGO_OBU, "info.ext_info.speed_limit_max ------> ${info.ext_info.speed_limit_max}")
Logger.d(
MogoObuConst.TAG_MOGO_OBU,
"info.ext_info.speed_limit_max ------> ${info.ext_info.speed_limit_max}"
)
CallerHmiManager.showLimitingVelocity((Math.ceil(((info.ext_info.speed_limit_max * 60 * 60) / 1000) / 10) * 10).toInt())
}
}

View File

@@ -0,0 +1,57 @@
package com.mogo.eagle.core.data.autopilot
/**
* @author xiaoyuzhou
* @date 2021/10/12 8:16 下午
* 域控制器状态信息
* 不建议自己初始化此对象,建议使用 CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo();
*/
class AutopilotStatusInfo {
/**
* 当前链接的IP地址, 默认地址 192.168.1.102
*/
var connectIP: String = "192.168.1.102"
var connectStatus = false
/**
* 定位是否可用
*/
var locationStatus = false
var locationLat = 0.0
var locationLon = 0.0
/**
* 车速 m/s
*/
var speed = 0f
/**
* 自动驾驶状态 0是不可用 1是ready 2是自动驾驶start
*/
var autopilotStatus = 0
/**
* 自动驾驶状态 0非自动驾驶1自动驾驶
*/
var autoDriveStatus = 0
/**
* 不可用原因
*/
var errorReason: String = ""
/**
* 摄像头状态 1代表开启0代表关闭
*/
var camera = 0
/**
* 雷达状态 1代表开启0代表关闭
*/
var radar = 0
/**
* RTK状态 1代表开启0代表关闭
*/
var rtk = 0
}

View File

@@ -1,6 +1,7 @@
package com.mogo.eagle.core.function.api.autopilot;
import com.mogo.eagle.core.data.autopilot.AdasOCHData;
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo;
/**
* @author xiaoyuzhou
@@ -24,15 +25,24 @@ public interface IMoGoAutoPilotStatusListener {
/**
* 到站
* 自动驾驶到站
*
* @param data 所到车站的简单信息
*/
void onArriveAt( AdasOCHData data );
void onAutoPilotArriveAtStation(AdasOCHData data);
/**
* 自动驾驶状态发生改变
* @param state {@link #STATUS_AUTOPILOT_DISABLE}
*
* @param state {@link #STATUS_AUTOPILOT_DISABLE}
* @param reason 不能自动驾驶的原因
*/
void onStateChanged(int state, String reason);
void onAutoPilotStateChanged(int state, String reason);
/**
* 自动驾驶状态信息
*
* @param autopilotStatusInfo 状态信息
*/
void onAutoPilotStatusResponse(AutopilotStatusInfo autopilotStatusInfo);
}

View File

@@ -0,0 +1,127 @@
package com.mogo.eagle.core.function.call.autopilot
import androidx.annotation.Nullable
import com.mogo.eagle.core.data.autopilot.AdasOCHData
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutoPilotStatusListener
import com.mogo.eagle.core.function.api.obu.IMoGoObuStatusListener
import com.mogo.eagle.core.function.call.base.CallerBase
import com.mogo.eagle.core.utilcode.util.GsonUtils
import com.mogo.eagle.core.utilcode.util.LogUtils
/**
* @author xiaoyuzhou
* @date 2021/9/30 5:48 下午
* 域控制器相关的回调监听
*/
object CallerAutoPilotStatusListenerManager : CallerBase() {
private val TAG = "CallerAutopilotListenerManager"
// 存储最后一次回调的数据,当有新当位置注册了监听将此数据回调过去,防止有些模块注册顺序问题导致无法获取最新状态
private var mAutopilotStatusInfo: AutopilotStatusInfo = AutopilotStatusInfo()
// 存储所有注册了监听的对象invokeXXXX进行遍历回调将信息同步
private val mAutoPilotStatusListeners: HashMap<String, IMoGoAutoPilotStatusListener> = HashMap()
/**
* 查询AutoPilot状态
*/
fun getAutoPilotStatusInfo(): AutopilotStatusInfo {
return mAutopilotStatusInfo
}
/**
* 查询AutoPilot状态
*/
fun getAutoPilotStatusInfoJsonString(): String {
return GsonUtils.toJson(mAutopilotStatusInfo)
}
/**
* 添加监听
* @param tag 标记,用来注销监听使用
* @param listener 监听回调
*/
fun addListener(
@Nullable tag: String,
@Nullable listener: IMoGoAutoPilotStatusListener
) {
mAutoPilotStatusListeners[tag] = listener
listener.onAutoPilotStatusResponse(mAutopilotStatusInfo)
}
/**
* 删除监听
* @param tag 标记,用来注销监听使用
*/
fun removeListener(@Nullable tag: String) {
mAutoPilotStatusListeners.remove(tag)
}
/**
* 删除自动驾驶按钮选中监听
* @param listener 要删除的监听对象
*/
fun removeListener(@Nullable listener: IMoGoObuStatusListener) {
mAutoPilotStatusListeners.forEach {
if (it.value == listener) {
mAutoPilotStatusListeners.remove(it.key)
}
}
}
/**
* 自动驾驶状态信息回调
*/
@Synchronized
fun invokeAutoPilotStatusListener() {
LogUtils.dTag(TAG, "$mAutopilotStatusInfo")
invokeAutoPilotStatusListener(mAutopilotStatusInfo)
}
/**
* 自动驾驶状态信息回调
* @param autopilotStatusInfo 自动驾驶状态信息
*/
@Synchronized
fun invokeAutoPilotStatusListener(autopilotStatusInfo: AutopilotStatusInfo) {
LogUtils.dTag(TAG, "$autopilotStatusInfo")
mAutopilotStatusInfo = autopilotStatusInfo
mAutoPilotStatusListeners.forEach {
val tag = it.key
val listener = it.value
LogUtils.dTag(TAG, "tag:$tag listener:$listener")
listener.onAutoPilotStatusResponse(mAutopilotStatusInfo)
}
}
/**
* 自动驾驶网约车回调数据 回调
* @param adasOCHData 自动驾驶网约车回调数据
*/
fun invokeArriveAtStationListener(adasOCHData: AdasOCHData) {
LogUtils.dTag(TAG, "$adasOCHData")
mAutoPilotStatusListeners.forEach {
val tag = it.key
val listener = it.value
LogUtils.dTag(TAG, "tag:$tag listener:$listener")
listener.onAutoPilotArriveAtStation(adasOCHData)
}
}
/**
* 自动驾驶状态回调
* @param state
* @param reason
*/
fun invokeStateChangedListener(state: Int, reason: String) {
LogUtils.dTag(TAG, "$state $reason")
mAutoPilotStatusListeners.forEach {
val tag = it.key
val listener = it.value
LogUtils.dTag(TAG, "tag:$tag listener:$listener")
listener.onAutoPilotStateChanged(state, reason)
}
}
}

View File

@@ -24,7 +24,14 @@ object CallerObuListenerManager : CallerBase() {
/**
* 查询OBU状态
*/
fun getObuStatusInfo(): String {
fun getObuStatusInfo(): ObuStatusInfo {
return mObuStatusInfo
}
/**
* 查询OBU状态
*/
fun getObuStatusInfoJsonString(): String {
return GsonUtils.toJson(mObuStatusInfo)
}
@@ -61,6 +68,14 @@ object CallerObuListenerManager : CallerBase() {
}
}
/**
* 触发自动驾驶按钮选中监听
*/
fun invokeListener() {
LogUtils.dTag(TAG, "isChecked:$mObuStatusInfo")
invokeListener(mObuStatusInfo)
}
/**
* 触发自动驾驶按钮选中监听
* @param obuStatusInfo 选中状态

View File

@@ -59,7 +59,9 @@ dependencies {
api project(":foudations:mogo-commons")
api project(':services:mogo-service-api')
implementation project(':modules:mogo-module-common')
implementation project(':core:mogo-core-data')
implementation project(':core:mogo-core-function-call')
}
}
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()

View File

@@ -1,10 +1,9 @@
package com.mogo.module.adas;
import com.google.gson.Gson;
import com.mogo.module.adas.entity.WarnMessageModel;
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo;
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager;
import com.mogo.module.adas.model.AdasServiceModel;
import com.mogo.module.adas.network.IAdasApiService;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.utils.logger.Logger;
import com.mogo.utils.network.utils.GsonUtil;
import com.zhidao.autopilotservice.model.AdasAIDLAutopilotArriveModel;
@@ -20,7 +19,6 @@ import com.zhidao.support.adas.high.bean.LightStatueInfo;
import com.zhidao.support.adas.high.bean.ObstaclesInfo;
import com.zhidao.support.adas.high.bean.RectInfo;
import com.zhidao.support.adas.high.bean.WarnMessageInfo;
import com.zhidao.support.adas.high.common.MsgActionType;
import com.zhidao.support.obu.ami.AmiClientManager;
import java.util.ArrayList;
@@ -31,8 +29,6 @@ import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
import static com.mogo.module.adas.AdasConstant.getBaseUrl;
/**
* Created by XuYong on 2021/4/25 14:43
*/
@@ -187,6 +183,18 @@ public class AdasEventManager implements OnAdasListener, OnAdasMsgConnectStatusL
Logger.d(TAG, "autopilotStatus " + autopilotStatus);
AutopilotStatus.ValuesBean autopilotStatusValues = autopilotStatus.getValues();
if (autopilotStatusValues != null) {
// 初始化自动驾驶状态信息
AutopilotStatusInfo autopilotStatusInfo = CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo();
autopilotStatusInfo.setAutopilotStatus(autopilotStatusValues.getState());
autopilotStatusInfo.setAutoDriveStatus(autopilotStatusValues.getPilotmode());
autopilotStatusInfo.setErrorReason(autopilotStatusValues.getReason());
autopilotStatusInfo.setCamera(autopilotStatusValues.getCamera());
autopilotStatusInfo.setRtk(autopilotStatusValues.getRtk());
autopilotStatusInfo.setRadar(autopilotStatusValues.getRadar());
autopilotStatusInfo.setSpeed(autopilotStatusValues.getSpeed());
CallerAutoPilotStatusListenerManager.INSTANCE.invokeAutoPilotStatusListener();
int state = autopilotStatusValues.getState();
float speed = autopilotStatusValues.getSpeed();
mCurrentAutopilotStatus = state;
@@ -252,6 +260,8 @@ public class AdasEventManager implements OnAdasListener, OnAdasMsgConnectStatusL
@Override
public void onWebSocketConnectSuccess() {
Logger.d(TAG, "webSocket 连接成功");
CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().setConnectStatus(true);
CallerAutoPilotStatusListenerManager.INSTANCE.invokeAutoPilotStatusListener();
for (IAdasStatusListener listener : iAdasStatusListeners) {
listener.onServiceConnected();
}
@@ -261,6 +271,8 @@ public class AdasEventManager implements OnAdasListener, OnAdasMsgConnectStatusL
@Override
public void onWebSocketConnectFailed() {
Logger.d(TAG, "webSocket 连接失败");
CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().setConnectStatus(false);
CallerAutoPilotStatusListenerManager.INSTANCE.invokeAutoPilotStatusListener();
for (IAdasStatusListener listener : iAdasStatusListeners) {
listener.onServiceDisconnected();
}

View File

@@ -1,16 +1,11 @@
package com.mogo.module.adas;
import com.mogo.module.adas.entity.WarnMessageModel;
import com.zhidao.autopilotservice.model.AdasAIDLAutopilotArriveModel;
import com.zhidao.autopilotservice.model.AdasAIDLOwnerCarRectModel;
import com.zhidao.autopilotservice.model.AdasAIDLOwnerCarStateModel;
import com.zhidao.support.adas.high.bean.AutopilotRoute;
import com.zhidao.support.adas.high.bean.AutopilotStatus;
import com.zhidao.support.adas.high.bean.RectInfo;
import com.zhidao.support.adas.high.bean.WarnMessageInfo;
import java.util.List;
public interface IAdasDataListener {

View File

@@ -70,6 +70,7 @@ dependencies {
api project(':services:mogo-service-api')
implementation project(':core:mogo-core-data')
implementation project(':core:mogo-core-function-call')
}
annotationProcessor 'com.elegant.spi:compiler:1.0.3'

View File

@@ -2,6 +2,8 @@ package com.mogo.module.common.datacenter;
import com.mogo.commons.FunctionBuildConfig;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo;
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.service.cloud.location.CloudLocationInfo;
@@ -87,11 +89,16 @@ public class SnapshotLocationDataCenter {
double speed = data.optDouble("speed", -1);
long satelliteTime = data.optLong("satelliteTime");
long systemTime = data.optLong("systemTime");
int gpsProvider = data.optInt("gpsProvider",1);
int gpsProvider = data.optInt("gpsProvider", 1);
// 使用与渠道配置一样的gps提供者提供的数据
if (gpsProvider == FunctionBuildConfig.gpsProvider) {
//测试面板状态同步
AutopilotStatusInfo autopilotStatusInfo = CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo();
autopilotStatusInfo.setLocationLat(lat);
autopilotStatusInfo.setLocationLon(lon);
CallerAutoPilotStatusListenerManager.INSTANCE.invokeAutoPilotStatusListener();
DebugConfig.setStatusData(DebugConfig.sLon, lon);
DebugConfig.setStatusData(DebugConfig.sLat, lat);
@@ -168,7 +175,7 @@ public class SnapshotLocationDataCenter {
return mCurLat;
}
public long getSatelliteTime(){
public long getSatelliteTime() {
return mSatelliteTime;
}
}

View File

@@ -396,6 +396,7 @@ public class MogoADASController implements IMogoADASController {
public void notifyAutopilotState(AutopilotStatus autopilotStatus) {
Logger.d(TAG, "notifyAutopilotState: " + GsonUtil.jsonFromObject(autopilotStatus));
DebugConfig.setAutoPilotStatus(autopilotStatus.getValues().getState() + "");
if (!mAdasOCHCallback.isEmpty()) {
for (IMogoAdasOCHCallback cb : mAdasOCHCallback) {
cb.onStateChanged(autopilotStatus.getValues().getState(), autopilotStatus.getValues().getReason());