merge dev2_adas

This commit is contained in:
zhongchao
2021-05-25 17:31:31 +08:00
53 changed files with 589 additions and 3431 deletions

1
modules/mogo-module-adas/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/build

View File

@@ -0,0 +1,66 @@
apply plugin: 'com.android.library'
apply plugin: 'com.alibaba.arouter'
android {
compileSdkVersion rootProject.ext.android.compileSdkVersion
// buildToolsVersion rootProject.ext.android.buildToolsVersion
defaultConfig {
minSdkVersion rootProject.ext.android.minSdkVersion
targetSdkVersion rootProject.ext.android.targetSdkVersion
versionCode Integer.valueOf(VERSION_CODE)
versionName getValueFromRootProperties("${project.name.replace("-", "_").toUpperCase()}_VERSION")
javaCompileOptions {
annotationProcessorOptions {
arguments = [AROUTER_MODULE_NAME: project.getName()]
}
}
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation rootProject.ext.dependencies.androidxappcompat
implementation rootProject.ext.dependencies.androidxconstraintlayout
implementation rootProject.ext.dependencies.arouter
annotationProcessor rootProject.ext.dependencies.aroutercompiler
// 现有的ADAS的通讯SDK需要将里面的东西融合到我们项目中
compileOnly rootProject.ext.dependencies.adasapi
api "com.zhidao.support.adas:high:1.1.8.3"
annotationProcessor rootProject.ext.dependencies.aroutercompiler
if (Boolean.valueOf(RELEASE)) {
api rootProject.ext.dependencies.mogoutils
api rootProject.ext.dependencies.mogocommons
api rootProject.ext.dependencies.mogoserviceapi
api
implementation rootProject.ext.dependencies.modulecommon
} else {
api project(":foudations:mogo-utils")
api project(":foudations:mogo-commons")
api project(':services:mogo-service-api')
implementation project(':modules:mogo-module-common')
}
}
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()

View File

@@ -0,0 +1,3 @@
GROUP=com.mogo.module
POM_ARTIFACT_ID=mogo-module-adas
VERSION_CODE=1

View File

@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

View File

@@ -0,0 +1,26 @@
package com.amap.navi.mogo_module_adas;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.amap.navi.mogo_module_adas.test", appContext.getPackageName());
}
}

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mogo.module.adas">
</manifest>

View File

@@ -0,0 +1,58 @@
package com.mogo.module.adas;
import com.zhidao.autopilotservice.model.AdasAIDLAutopilotArriveModel;
import com.zhidao.autopilotservice.model.AdasAIDLAutopilotStateModel;
import com.zhidao.autopilotservice.model.AdasAIDLOwnerCarRectModel;
import com.zhidao.autopilotservice.model.AdasAIDLOwnerCarStateModel;
import com.zhidao.support.adas.high.OnAdasListener;
import com.zhidao.support.adas.high.bean.AutopilotStatus;
import com.zhidao.support.adas.high.bean.AutopilotWayArrive;
import com.zhidao.support.adas.high.bean.CarLaneInfo;
import com.zhidao.support.adas.high.bean.CarStateInfo;
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 java.util.List;
/**
* Created by XuYong on 2021/4/25 16:52
*/
public abstract class AdasDataListener {
public void sendMsg( String msg ) {
}
public void cameraEyeDetectResult( String detectResult ) {
}
public void selectCarModelUrl( String carStyleUrl ) {
}
public void requestGetCarModelListInfo() {
}
public void clickSettingBack() {
}
public void showToast( String msg ) {
}
public void autopilotArrive( AdasAIDLAutopilotArriveModel autopilotArriveModel ) {
}
public void ownerCarStateInfo( String ownerCarStateInfo ) {
}
public void notifyOwnerCarState( AdasAIDLOwnerCarStateModel ownerCarStateModel ) {
}
public void notifyAutopilotState( AdasAIDLAutopilotStateModel autopilotStateModel ) {
}
public void notifyOwnerCarRect( List<AdasAIDLOwnerCarRectModel> ownerCarStateRectList ) {
}
}

View File

@@ -0,0 +1,198 @@
package com.mogo.module.adas;
import com.google.gson.Gson;
import com.mogo.utils.logger.Logger;
import com.mogo.utils.network.utils.GsonUtil;
import com.zhidao.autopilotservice.model.AdasAIDLAutopilotArriveModel;
import com.zhidao.autopilotservice.model.AdasAIDLAutopilotStateModel;
import com.zhidao.support.adas.high.OnAdasListener;
import com.zhidao.support.adas.high.OnAdasMsgConnectStatusListener;
import com.zhidao.support.adas.high.bean.AutopilotStatus;
import com.zhidao.support.adas.high.bean.AutopilotWayArrive;
import com.zhidao.support.adas.high.bean.CarLaneInfo;
import com.zhidao.support.adas.high.bean.CarStateInfo;
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 java.util.ArrayList;
/**
* Created by XuYong on 2021/4/25 14:43
*/
public class AdasEventManager implements OnAdasListener, OnAdasMsgConnectStatusListener {
private final String TAG = "\\";
private Gson gson;
private ArrayList<AdasDataListener> iAdasEventListeners;
private ArrayList<AdasStatusListener> iAdasStatusListeners;
public AdasEventManager() {
gson = GsonUtil.getGson();
}
public void addEventListener(AdasDataListener listener) {
Logger.d(TAG,"添加adas事件监听");
if (iAdasEventListeners == null) {
iAdasEventListeners = new ArrayList<AdasDataListener>();
}
iAdasEventListeners.add(listener);
}
public void removeEventListener(AdasDataListener listener) {
Logger.d(TAG,"注销adas事件监听");
if (iAdasEventListeners != null && iAdasEventListeners.contains(listener)) {
iAdasEventListeners.remove(listener);
}
}
public void addStatusListener(AdasStatusListener listener) {
Logger.d(TAG,"添加adas状态事件监听");
if (iAdasStatusListeners == null) {
iAdasStatusListeners = new ArrayList<AdasStatusListener>();
}
iAdasStatusListeners.add(listener);
}
public void removeStatusListener(AdasStatusListener listener) {
Logger.d(TAG,"注销adas状态事件监听");
if (iAdasEventListeners != null && iAdasEventListeners.contains(listener)) {
iAdasEventListeners.remove(listener);
}
}
@Override
public void onWarnMessage(WarnMessageInfo warnMessageInfo) {
Logger.d(TAG,"onWarnMessage " + warnMessageInfo);
//报警model
WarnMessageModel warnMessageModel = null;
for (AdasDataListener listener:iAdasEventListeners) {
if (listener != null) {
if (warnMessageModel == null) {
warnMessageModel = new WarnMessageModel();
warnMessageModel.setAction(MsgActionType.ACTION_WS_MSG_WARNING_TYPE.getmActionType());
}
warnMessageModel.setValues(warnMessageInfo);
listener.cameraEyeDetectResult(gson.toJson(warnMessageModel));
}
}
}
@Override
public void onVideoSize(int width, int height) {
Logger.d(TAG,"onVideoSize");
for (AdasDataListener listener:iAdasEventListeners) {
if (listener != null) {
}
}
}
@Override
public void onRectData(RectInfo rectInfo) {
Logger.d(TAG,"onRectData " + rectInfo);
for (AdasDataListener listener:iAdasEventListeners) {
if (listener != null) {
listener.cameraEyeDetectResult(gson.toJson(rectInfo));
}
}
}
@Override
public void onCarStateData(CarStateInfo carStateInfo) {
Logger.d(TAG,"onCarStateData " + carStateInfo);
for (AdasDataListener listener:iAdasEventListeners) {
if (listener != null) {
listener.ownerCarStateInfo(gson.toJson(carStateInfo));
}
}
}
@Override
public void onLightStateData(LightStatueInfo lightStatueInfo) {
Logger.d(TAG,"onLightStateData " + lightStatueInfo);
for (AdasDataListener listener:iAdasEventListeners) {
if (listener != null) {
}
}
}
@Override
public void onObstaclesInfo(ObstaclesInfo obstaclesInfo) {
Logger.d(TAG,"onObstaclesInfo " + obstaclesInfo);
for (AdasDataListener listener:iAdasEventListeners) {
if (listener != null) {
}
}
}
@Override
public void onCarLaneInfo(CarLaneInfo carLaneInfo) {
Logger.d(TAG,"onCarLaneInfo " + carLaneInfo);
for (AdasDataListener listener:iAdasEventListeners) {
if (listener != null) {
}
}
}
@Override
public void autopilotStatus(AutopilotStatus autopilotStatus) {
Logger.d(TAG,"autopilotStatus " + autopilotStatus);
AutopilotStatus.ValuesBean autopilotStatusValues = autopilotStatus.getValues();
AutopilotStatus.ValuesBean mAutopilotStatus;
if (autopilotStatusValues != null) {
AdasAIDLAutopilotStateModel adasAIDLAutopilotStateModel=new AdasAIDLAutopilotStateModel();
adasAIDLAutopilotStateModel.setReason(autopilotStatusValues.getReason());
mAutopilotStatus = autopilotStatusValues;
int state = autopilotStatusValues.getState();
float speed = autopilotStatusValues.getSpeed();
adasAIDLAutopilotStateModel.setState(state);
adasAIDLAutopilotStateModel.setSpeed(speed);
for (AdasDataListener listener:iAdasEventListeners) {
if (listener != null) {
listener.notifyAutopilotState(adasAIDLAutopilotStateModel);
}
}
}
}
@Override
public void autopilotArrive(AutopilotWayArrive autopilotWayArrive) {
Logger.d(TAG,"autopilotArrive " + autopilotWayArrive);
if (autopilotWayArrive != null) {
AutopilotWayArrive.ResultBean result = autopilotWayArrive.getResult();
if (result != null) {
AutopilotWayArrive.ResultBean.EndLatLonBean endLatLon = result.getEndLatLon();
if (endLatLon != null) {
AdasAIDLAutopilotArriveModel adasAIDLAutopilotArriveModel = new AdasAIDLAutopilotArriveModel();
adasAIDLAutopilotArriveModel.setCarType(result.getCarType());
adasAIDLAutopilotArriveModel.setLat(endLatLon.getLat());
adasAIDLAutopilotArriveModel.setLon(endLatLon.getLon());
for (AdasDataListener listener:iAdasEventListeners) {
if (listener != null) {
listener.autopilotArrive(adasAIDLAutopilotArriveModel);
}
}
}
}
}
}
@Override
public void onWebSocketConnectSuccess() {
Logger.d(TAG,"websocket连接成功");
}
@Override
public void onWebSocketConnectFailed() {
Logger.d(TAG,"websocket连接失败");
}
}

View File

@@ -0,0 +1,58 @@
package com.mogo.module.adas;
import android.content.Context;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.facade.template.IProvider;
import com.mogo.service.MogoServicePaths;
import com.mogo.utils.logger.Logger;
import com.zhidao.support.adas.high.AdasManager;
/**
* ADAS 模块
*
* @author
* @date 4/21/21 3:39 PM
* wikihttp://wiki.zhidaohulian.com/pages/viewpage.action?pageId=52840459
*/
@Route(path = MogoServicePaths.PATH_ADAS)
public class AdasProvider implements IProvider {
private final String TAG = "AdasProvider";
private AdasEventManager adasEventManager;
@Override
public void init(Context context) {
Logger.d(TAG, "初始化 AdasProvider 模块");
adasEventManager = new AdasEventManager();
initAdas(context, adasEventManager);
}
private void initAdas(Context context, AdasEventManager adasEventManager) {
AdasManager.getInstance().create(context);
AdasManager.getInstance().setOnAdasListener(adasEventManager);
AdasManager.getInstance().setOnAdasConnectStatusListener(adasEventManager);
}
public void addAdasEventListener(AdasDataListener listener) {
adasEventManager.addEventListener(listener);
}
public void removeAdasEventListener(AdasDataListener listener) {
adasEventManager.removeEventListener(listener);
}
public void addAdaStatusListener(AdasStatusListener listener) {
adasEventManager.addStatusListener(listener);
}
public void removeAdasStatusListener(AdasStatusListener listener) {
adasEventManager.removeStatusListener(listener);
}
public void sendWsMessage(String msg) {
AdasManager.getInstance().aiCloudToAdasData(msg);
}
}

View File

@@ -0,0 +1,14 @@
package com.mogo.module.adas;
/**
* Created by XuYong on 4/28/21 16:19
*/
public abstract class AdasStatusListener {
public void onServiceConnected() {
};
public void onServiceDisconnected() {
};
}

View File

@@ -0,0 +1,31 @@
package com.mogo.module.adas;
import com.zhidao.support.adas.high.bean.WarnMessageInfo;
/**
* @author nie yunlong
* @des
* @date 2020/10/22
*/
public class WarnMessageModel {
private String action;
private WarnMessageInfo values;
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
public WarnMessageInfo getValues() {
return values;
}
public void setValues(WarnMessageInfo values) {
this.values = values;
}
}

View File

@@ -0,0 +1,30 @@
package com.mogo.module.adas;
/**
* @author donghongyu
* @date 4/21/21 2:52 PM
*/
public class 占位文件可删除 {
/** TODO 本模块提供能力范围
* 1、与工控机数据交互具体能力与 @宋克难 沟通
* a、建立车机与工控机的数据通路
* b、保证数据通路的稳定性
*
* 2、暴露API接口共上层业务使用
* a、上层业务可主动订阅、取消订阅数据
* b、自动驾驶控制下发
* b、自动驾驶状态获取
* c、自动驾驶规划路径下发
* e、ADAS识别报警
*
* 3、项目中已经使用到的ADAS数据的业务如下可参考下面业务层使用情况来封装本模块的API
* AdasControlCommandParameter
* AdasLogWriter
* AdasObjectUtils
* CarModelInfoNetApiServices
* LogWriter
* MogoADASController
* OnAdasListenerAdapter
*/
}

View File

@@ -0,0 +1,17 @@
package com.amap.navi.mogo_module_adas;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
}