[Change]
整理ADAS相关代码 Signed-off-by: donghongyu <donghongyu@zhidaoauto.com>
This commit is contained in:
@@ -1,52 +1,28 @@
|
||||
package com.mogo.module.adas;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
import com.mogo.eagle.core.data.autopilot.ADASTrajectoryInfo;
|
||||
import com.mogo.eagle.core.data.autopilot.AutoPilotRecordResult;
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotCarStateInfo;
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotGuardianStatusInfo;
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotRouteInfo;
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotStationInfo;
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo;
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotWarnMessage;
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
|
||||
import com.mogo.eagle.core.data.traffic.TrafficData;
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotCarStateListener;
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotIdentifyListener;
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotPlanningListener;
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotCarStatusListenerManager;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListenerManager;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotPlanningListenerManager;
|
||||
import com.mogo.eagle.core.network.utils.GsonUtil;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
|
||||
import com.mogo.eagle.core.utilcode.util.GsonUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils;
|
||||
import com.mogo.module.adas.model.AdasServiceModel;
|
||||
import com.mogo.module.common.drawer.IdentifyDataDrawer;
|
||||
import com.zhidao.support.adas.high.AdasManager;
|
||||
import com.zhidao.support.adas.high.OnAdasMsgConnectStatusListener;
|
||||
import com.zhidao.support.adas.high.bean.BasicInfo;
|
||||
import com.zhidao.support.obu.ami.AmiClientManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.reactivex.Flowable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
* Created by XuYong on 2021/4/25 14:43
|
||||
*/
|
||||
public class AdasEventManager implements
|
||||
OnAdasMsgConnectStatusListener,
|
||||
IMoGoAutopilotStatusListener,
|
||||
IMoGoAutopilotPlanningListener,
|
||||
IMoGoAutopilotIdentifyListener,
|
||||
IMoGoAutopilotCarStateListener {
|
||||
|
||||
@@ -55,18 +31,9 @@ public class AdasEventManager implements
|
||||
private static volatile AdasEventManager adasEventManager;
|
||||
private static final byte[] obj = new byte[0];
|
||||
|
||||
private final Gson gson;
|
||||
private final ArrayList<IAdasDataListener> iAdasEventListeners = new ArrayList<>();
|
||||
//自动驾驶状态
|
||||
private int mCurrentAutopilotStatus = -1;
|
||||
//自动驾驶车速度
|
||||
private float mCurrentAutopilotSpeed = 0;
|
||||
|
||||
|
||||
private AdasEventManager() {
|
||||
gson = GsonUtil.getGson();
|
||||
CallerAutoPilotStatusListenerManager.INSTANCE.addListener(TAG, this);
|
||||
CallerAutopilotPlanningListenerManager.INSTANCE.addListener(TAG, this);
|
||||
CallerAutopilotIdentifyListenerManager.INSTANCE.addListener(TAG, this);
|
||||
CallerAutopilotCarStatusListenerManager.INSTANCE.addListener(TAG, this);
|
||||
}
|
||||
@@ -95,89 +62,11 @@ public class AdasEventManager implements
|
||||
iAdasEventListeners.remove(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步SN信息给工控机
|
||||
*/
|
||||
public void syncBasicInfoToAutopilot() {
|
||||
Logger.d(TAG, "同步PAD的SN给工控机……");
|
||||
BasicInfo info = new BasicInfo();
|
||||
info.setSn(MoGoAiCloudClientConfig.getInstance().getSn());
|
||||
AdasManager.getInstance().setBasicInfo(info);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotSNRequest() {
|
||||
syncBasicInfoToAutopilot();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWebSocketConnectSuccess() {
|
||||
Logger.d(TAG, "webSocket 连接成功");
|
||||
// 初始化自动驾驶状态信息
|
||||
CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().setConnectIP(AdasManager.getInstance().getAdasConfig().getAddress());
|
||||
CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().setConnectStatus(true);
|
||||
|
||||
CallerAutoPilotStatusListenerManager.INSTANCE.invokeAutoPilotStatus();
|
||||
|
||||
// 同步SN给工控机
|
||||
syncBasicInfoToAutopilot();
|
||||
|
||||
// 开启轮训上传自动驾驶状态
|
||||
updateDriveStatusTask();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWebSocketConnectFailed(String reason) {
|
||||
Logger.d(TAG, "webSocket 连接失败 reason:" + reason);
|
||||
CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().setConnectIP(AdasManager.getInstance().getAdasConfig().getAddress());
|
||||
CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().setConnectStatus(false);
|
||||
CallerAutoPilotStatusListenerManager.INSTANCE.invokeAutoPilotStatus();
|
||||
}
|
||||
|
||||
public void updateDriveStatusTask() {
|
||||
Logger.d(TAG, "updateDriveStatusTask");
|
||||
Flowable.interval(0, 5, TimeUnit.SECONDS)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.unsubscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(aLong -> updateDriveStatus());
|
||||
}
|
||||
|
||||
private void updateDriveStatus() {
|
||||
AdasServiceModel.getInstance().updateDriveStatus(mCurrentAutopilotStatus, mCurrentAutopilotSpeed);
|
||||
}
|
||||
|
||||
private void reportSite(double lon, double lat) {
|
||||
AdasServiceModel.getInstance().reportSite(lon, lat);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotStatusResponse(@NonNull AutopilotStatusInfo autoPilotStatusInfo) {
|
||||
int state = autoPilotStatusInfo.getState();
|
||||
float speed = autoPilotStatusInfo.getSpeed();
|
||||
mCurrentAutopilotStatus = state;
|
||||
mCurrentAutopilotSpeed = speed;
|
||||
for (IAdasDataListener listener : iAdasEventListeners) {
|
||||
if (listener != null) {
|
||||
listener.notifyAutopilotState(autoPilotStatusInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotArriveAtStation(AutopilotStationInfo autopilotWayArrive) {
|
||||
if (autopilotWayArrive != null) {
|
||||
double lon = autopilotWayArrive.getLon();
|
||||
double lat = autopilotWayArrive.getLat();
|
||||
reportSite(lon, lat);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotCarStateData(@Nullable AutopilotCarStateInfo autoPilotCarStateInfo) {
|
||||
for (IAdasDataListener listener : iAdasEventListeners) {
|
||||
if (listener != null) {
|
||||
listener.ownerCarStateInfo(gson.toJson(autoPilotCarStateInfo));
|
||||
listener.ownerCarStateInfo(GsonUtils.toJson(autoPilotCarStateInfo));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,11 +83,6 @@ public class AdasEventManager implements
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onAutopilotGuardian(@Nullable AutopilotGuardianStatusInfo guardianInfo) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotIdentifyDataUpdate(@Nullable ArrayList<TrafficData> trafficData) {
|
||||
try {
|
||||
@@ -217,16 +101,6 @@ public class AdasEventManager implements
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotTrajectory(ArrayList<ADASTrajectoryInfo> trajectoryInfo) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onAutopilotRotting(@Nullable AutopilotRouteInfo autopilotRoute) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotRecordResult(AutoPilotRecordResult result) {
|
||||
|
||||
@@ -1,103 +0,0 @@
|
||||
package com.mogo.module.adas
|
||||
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotCarStateInfo
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotGuardianStatusInfo
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotRouteInfo
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotWarnMessage
|
||||
import com.mogo.eagle.core.data.enums.TrafficTypeEnum
|
||||
import com.mogo.eagle.core.data.traffic.TrafficData
|
||||
import com.mogo.eagle.core.network.utils.GsonUtil
|
||||
import com.zhidao.support.adas.high.bean.AutopilotRoute
|
||||
import com.zhidao.support.adas.high.bean.CarStateInfo
|
||||
import com.zhidao.support.adas.high.bean.RectInfo.RectBean
|
||||
import com.zhidao.support.adas.high.bean.WarnMessageInfo
|
||||
import com.zhidao.support.adas.high.bean.guardian.AutopilotGuardianInfo
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/10/25
|
||||
*
|
||||
* 对象转换类
|
||||
*/
|
||||
object AdasObjectUtils {
|
||||
val TAG = "AdasObjectUtils"
|
||||
|
||||
fun fromAutopilotGuardianInfo(autopilotGuardianInfo: AutopilotGuardianInfo): AutopilotGuardianStatusInfo? {
|
||||
return GsonUtil.objectFromJson(
|
||||
GsonUtil.jsonFromObject(autopilotGuardianInfo),
|
||||
AutopilotGuardianStatusInfo::class.java
|
||||
)
|
||||
}
|
||||
|
||||
fun fromAdasAutopilotRoute(carStateInfo: AutopilotRoute): AutopilotRouteInfo? {
|
||||
return GsonUtil.objectFromJson(
|
||||
GsonUtil.jsonFromObject(carStateInfo),
|
||||
AutopilotRouteInfo::class.java
|
||||
)
|
||||
}
|
||||
|
||||
fun fromAdasCarStateInfoObject(carStateInfo: CarStateInfo): AutopilotCarStateInfo? {
|
||||
return GsonUtil.objectFromJson(
|
||||
GsonUtil.jsonFromObject(carStateInfo),
|
||||
AutopilotCarStateInfo::class.java
|
||||
)
|
||||
}
|
||||
|
||||
fun fromAdasObject(info: WarnMessageInfo?): AutopilotWarnMessage? {
|
||||
if (info == null) {
|
||||
return null
|
||||
}
|
||||
val warnMessage = AutopilotWarnMessage()
|
||||
warnMessage.content = info.content
|
||||
warnMessage.level = info.level
|
||||
try {
|
||||
warnMessage.type = info.type.toInt()
|
||||
} catch (e: NumberFormatException) {
|
||||
return null
|
||||
}
|
||||
warnMessage.value = info.value
|
||||
return warnMessage
|
||||
}
|
||||
|
||||
fun regroupTrafficDataData(datums: List<RectBean?>?): ArrayList<TrafficData>? {
|
||||
if (datums == null || datums.isEmpty()) {
|
||||
return null
|
||||
}
|
||||
val recognizedListResults: ArrayList<TrafficData> = ArrayList()
|
||||
for (model in datums) {
|
||||
if (model == null) {
|
||||
continue
|
||||
}
|
||||
val recognizedListResult = fromAdasTrafficDataObject(model)
|
||||
if (recognizedListResult != null) {
|
||||
recognizedListResults.add(recognizedListResult)
|
||||
}
|
||||
}
|
||||
return recognizedListResults
|
||||
}
|
||||
|
||||
fun fromAdasTrafficDataObject(model: RectBean?): TrafficData? {
|
||||
if (model == null) {
|
||||
return null
|
||||
}
|
||||
val result = TrafficData()
|
||||
result.uuid = model.uuid
|
||||
result.lat = model.lat
|
||||
result.lon = model.lon
|
||||
result.type = TrafficTypeEnum.getType(model.type.toInt())
|
||||
result.heading = model.heading
|
||||
result.systemTime = model.systemTime.toLong()
|
||||
result.satelliteTime = model.satelliteTime.toLong()
|
||||
result.alt = model.alt
|
||||
result.speed = model.speed
|
||||
result.carId = model.carId
|
||||
result.dataAccuracy = model.dataAccuracy
|
||||
result.distance = model.distance
|
||||
result.threatLevel = model.drawlevel
|
||||
|
||||
//Log.d(TAG, "TrafficData = $result")
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -4,11 +4,8 @@ import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
|
||||
import com.mogo.eagle.core.data.constants.MogoServicePaths;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
|
||||
import com.zhidao.support.adas.high.AdasManager;
|
||||
import com.zhidao.support.adas.high.common.CupidLogUtils;
|
||||
|
||||
|
||||
/**
|
||||
@@ -27,29 +24,6 @@ public class AdasProvider implements IProvider {
|
||||
public void init(Context context) {
|
||||
Logger.d(TAG, "初始化 AdasProvider 模块");
|
||||
adasEventManager = AdasEventManager.getInstance();
|
||||
initAdas(context, adasEventManager);
|
||||
}
|
||||
|
||||
private void initAdas(Context context, AdasEventManager adasEventManager) {
|
||||
CupidLogUtils.setEnableLog(false);
|
||||
CupidLogUtils.setIsWriteLog(false);
|
||||
// TODO 临时方案,根据不同的身份标识,连接不同的工控机IP
|
||||
switch (FunctionBuildConfig.appIdentityMode) {
|
||||
case 0:
|
||||
// 司机
|
||||
AdasManager.getInstance().create(context, "192.168.1.102");
|
||||
break;
|
||||
case 1:
|
||||
// 乘客
|
||||
AdasManager.getInstance().create(context, "192.168.1.103");
|
||||
break;
|
||||
default:
|
||||
// 默认采用UDP寻址方式
|
||||
AdasManager.getInstance().create(context);
|
||||
break;
|
||||
}
|
||||
AdasManager.getInstance().setOnAdasListener(new OnAdasListenerAdapter());
|
||||
AdasManager.getInstance().setOnAdasConnectStatusListener(adasEventManager);
|
||||
}
|
||||
|
||||
public void addAdasEventListener(IAdasDataListener listener) {
|
||||
@@ -60,8 +34,4 @@ public class AdasProvider implements IProvider {
|
||||
adasEventManager.removeEventListener(listener);
|
||||
}
|
||||
|
||||
public void sendWsMessage(String msg) {
|
||||
AdasManager.getInstance().aiCloudToAdasData(msg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.mogo.module.adas;
|
||||
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo;
|
||||
|
||||
public interface IAdasDataListener {
|
||||
|
||||
|
||||
@@ -13,12 +11,4 @@ public interface IAdasDataListener {
|
||||
default void ownerCarStateInfo(String ownerCarStateInfo) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动驾驶状态信息
|
||||
*
|
||||
* @param autopilotStatus {@link AutopilotStatusInfo}
|
||||
*/
|
||||
default void notifyAutopilotState(AutopilotStatusInfo autopilotStatus) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,253 +0,0 @@
|
||||
package com.mogo.module.adas;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.mogo.eagle.core.data.autopilot.ADASTrajectoryInfo;
|
||||
import com.mogo.eagle.core.data.autopilot.AutoPilotRecordResult;
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotCarStateInfo;
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotGuardianStatusInfo;
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotRouteInfo;
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotStationInfo;
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo;
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotWarnMessage;
|
||||
import com.mogo.eagle.core.data.config.HdMapBuildConfig;
|
||||
import com.mogo.eagle.core.data.traffic.TrafficData;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotCarStatusListenerManager;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListenerManager;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotPlanningListenerManager;
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
|
||||
import com.zhidao.support.adas.high.AdasManager;
|
||||
import com.zhidao.support.adas.high.OnAdasListener;
|
||||
import com.zhidao.support.adas.high.bean.AutopilotRoute;
|
||||
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.IPCUpgradeStateInfo;
|
||||
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.SSHResult;
|
||||
import com.zhidao.support.adas.high.bean.TrajectoryInfo;
|
||||
import com.zhidao.support.adas.high.bean.WarnMessageInfo;
|
||||
import com.zhidao.support.adas.high.bean.guardian.AutopilotGuardianInfo;
|
||||
import com.zhidao.support.adas.high.bean.record.AutopilotRecordResult;
|
||||
import com.zhidao.support.obu.ami.AmiClientManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/10/22
|
||||
* <p>
|
||||
* 适配ADAS 回调监听分发
|
||||
*/
|
||||
public class OnAdasListenerAdapter implements OnAdasListener {
|
||||
private final String TAG = "OnAdasListenerAdapter";
|
||||
|
||||
|
||||
@Override
|
||||
public void onRectData(RectInfo rectInfo) {
|
||||
if (HdMapBuildConfig.isMapLoaded) {
|
||||
ArrayList<TrafficData> recognizedListResults = AdasObjectUtils.INSTANCE.regroupTrafficDataData(rectInfo.getModels());
|
||||
CallerAutopilotIdentifyListenerManager.INSTANCE.invokeAutopilotIdentifyDataUpdate(recognizedListResults);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onCarStateData(CarStateInfo carStateInfo) {
|
||||
if (HdMapBuildConfig.isMapLoaded) {
|
||||
// Logger.d(TAG, "--------carStateInfo.toString() = " + carStateInfo.toString());
|
||||
//can数据转发
|
||||
CarStateInfo.ValuesBean bean = carStateInfo.getValues();
|
||||
// Log.w("DHY-location", bean.getLon() + "," + bean.getLat() + " OnAdasListenerAdapter-onCarStateData:");
|
||||
|
||||
if (bean != null) {
|
||||
int turnLight = bean.getTurnLightOften(); //转向灯状态 0是正常 1是左转 2是右转
|
||||
AmiClientManager.getInstance().setTurnLightState(turnLight);
|
||||
int brakeLight = bean.getBrake_light(); //TODO
|
||||
// Logger.d(TAG, "onCarStateData ---- turnLight = " + turnLight + "---brakeLight = " + brakeLight);
|
||||
|
||||
//设置转向灯
|
||||
CallerHmiManager.INSTANCE.showTurnLight(turnLight);
|
||||
|
||||
//设置刹车信息
|
||||
CallerHmiManager.INSTANCE.showBrakeLight(brakeLight);
|
||||
} else {
|
||||
Logger.e(TAG, "bean == null ");
|
||||
}
|
||||
|
||||
AutopilotCarStateInfo autopilotCarStateInfo = AdasObjectUtils.INSTANCE.fromAdasCarStateInfoObject(carStateInfo);
|
||||
CallerAutopilotCarStatusListenerManager.INSTANCE.invokeAutopilotCarStateData(autopilotCarStateInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void autopilotStatus(AutopilotStatus autopilotStatus) {
|
||||
if (HdMapBuildConfig.isMapLoaded) {
|
||||
AutopilotStatus.ValuesBean autopilotStatusValues = autopilotStatus.getValues();
|
||||
|
||||
if (autopilotStatusValues != null) {
|
||||
// 初始化自动驾驶状态信息
|
||||
AutopilotStatusInfo autopilotStatusInfo = CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo();
|
||||
autopilotStatusInfo.setState(autopilotStatusValues.getState());
|
||||
autopilotStatusInfo.setPilotmode(autopilotStatusValues.getPilotmode());
|
||||
autopilotStatusInfo.setControl_pilotmode(autopilotStatusValues.getControl_pilotmode());
|
||||
autopilotStatusInfo.setReason(autopilotStatusValues.getReason());
|
||||
autopilotStatusInfo.setCamera(autopilotStatusValues.getCamera());
|
||||
autopilotStatusInfo.setRtk(autopilotStatusValues.getRtk());
|
||||
autopilotStatusInfo.setRadar(autopilotStatusValues.getRadar());
|
||||
autopilotStatusInfo.setSpeed(autopilotStatusValues.getSpeed());
|
||||
// 初始化自动驾驶状态信息
|
||||
autopilotStatusInfo.setVersion(AdasManager.getInstance().getAdasConfig().getVersion());
|
||||
autopilotStatusInfo.setConnectIP(AdasManager.getInstance().getAdasConfig().getAddress());
|
||||
autopilotStatusInfo.setDockVersion(AdasManager.getInstance().getAdasConfig().getDockVersion());
|
||||
|
||||
CallerAutoPilotStatusListenerManager.INSTANCE.invokeAutoPilotStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void autopilotArrive(AutopilotWayArrive autopilotWayArrive) {
|
||||
if (HdMapBuildConfig.isMapLoaded) {
|
||||
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) {
|
||||
AutopilotStationInfo stationInfo = new AutopilotStationInfo(result.getCarType(), endLatLon.getLon(), endLatLon.getLat());
|
||||
|
||||
CallerAutoPilotStatusListenerManager.INSTANCE.invokeArriveAtStation(stationInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotRoute(AutopilotRoute route) {
|
||||
if (HdMapBuildConfig.isMapLoaded) {
|
||||
Logger.d(TAG, "onAutopilotRoute : " + route.toString());
|
||||
AutopilotRouteInfo autopilotRoute = AdasObjectUtils.INSTANCE.fromAdasAutopilotRoute(route);
|
||||
CallerAutopilotPlanningListenerManager.INSTANCE.invokeAutopilotRotting(autopilotRoute);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotTrajectory(List<TrajectoryInfo> trajectoryList) {
|
||||
if (HdMapBuildConfig.isMapLoaded) {
|
||||
Logger.d(TAG, "onAutopilotTrajectory : " + trajectoryList);
|
||||
ArrayList<ADASTrajectoryInfo> trajectoryInfoArrayList = new ArrayList<>();
|
||||
if (trajectoryList != null && trajectoryList.size() > 0) {
|
||||
for (TrajectoryInfo trajectory : trajectoryList) {
|
||||
ADASTrajectoryInfo adasTrajectoryInfo = new ADASTrajectoryInfo();
|
||||
adasTrajectoryInfo.setLat(trajectory.getLat());
|
||||
adasTrajectoryInfo.setLon(trajectory.getLon());
|
||||
adasTrajectoryInfo.setAcceleration(trajectory.getAcceleration());
|
||||
adasTrajectoryInfo.setAccumulatedDis(trajectory.getAccumulatedDis());
|
||||
adasTrajectoryInfo.setTime(trajectory.getTime());
|
||||
adasTrajectoryInfo.setVelocity(trajectory.getVelocity());
|
||||
adasTrajectoryInfo.setAlt(trajectory.getAlt());
|
||||
adasTrajectoryInfo.setKappa(trajectory.getKappa());
|
||||
adasTrajectoryInfo.setTheta(trajectory.getTheta());
|
||||
trajectoryInfoArrayList.add(adasTrajectoryInfo);
|
||||
}
|
||||
Log.e(TAG, "time:" + System.currentTimeMillis() + "trajectoryInfoArrayList:" + trajectoryInfoArrayList);
|
||||
}
|
||||
CallerAutopilotPlanningListenerManager.INSTANCE.invokeAutopilotTrajectory(trajectoryInfoArrayList);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotSNRequest() {
|
||||
CallerAutoPilotStatusListenerManager.INSTANCE.invokeAutopilotSNRequest();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotGuardian(AutopilotGuardianInfo guardianInfo) {
|
||||
if (HdMapBuildConfig.isMapLoaded) {
|
||||
AutopilotGuardianStatusInfo autopilotRoute = AdasObjectUtils.INSTANCE.fromAutopilotGuardianInfo(guardianInfo);
|
||||
CallerAutoPilotStatusListenerManager.INSTANCE.invokeAutopilotGuardian(autopilotRoute);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotRecord(AutopilotRecordResult result) {
|
||||
if (result != null) {
|
||||
AutoPilotRecordResult real = new AutoPilotRecordResult();
|
||||
real.setDiskFree(result.getDiskFree());
|
||||
real.setId(result.getId());
|
||||
real.setDuration(result.getDuration());
|
||||
real.setNote(result.getNote());
|
||||
real.setTotal(result.getTotalSize());
|
||||
real.setType(result.getType());
|
||||
real.setFileName(result.getFilename());
|
||||
real.setKey(result.getKey());
|
||||
real.setStat(result.getStat());
|
||||
real.setTimestamp(result.getTimestamp());
|
||||
CallerAutopilotIdentifyListenerManager.INSTANCE.invokeAutopilotRecordResult(real);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onLightStateData(LightStatueInfo lightStatueInfo) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onObstaclesInfo(ObstaclesInfo obstaclesInfo) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCarLaneInfo(CarLaneInfo carLaneInfo) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onWarnMessage(WarnMessageInfo warnMessageInfo) {
|
||||
final AutopilotWarnMessage warnMessage = AdasObjectUtils.INSTANCE.fromAdasObject(warnMessageInfo);
|
||||
CallerAutopilotIdentifyListenerManager.INSTANCE.invokeAutopilotWarnMessage(warnMessage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onVideoSize(int width, int height) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 工控机升级状态
|
||||
* @param info 工控机升级状态
|
||||
*/
|
||||
@Override
|
||||
public void onUpgradeStateInfo(IPCUpgradeStateInfo info) {
|
||||
if(info != null){
|
||||
Logger.d(TAG,"onUpgradeStateInfo "+
|
||||
" upgrade mode="+info.getUpgradeMode()+
|
||||
" download status="+info.getDownloadStatus()+
|
||||
" download progress current="+info.getProgress().getCurrent()+
|
||||
" download progress total="+info.getProgress().getTotal()+
|
||||
" download version="+info.getImages()+
|
||||
" upgrade status="+info.getUpgradeStatus());
|
||||
CallerHmiManager.INSTANCE.showAdUpgradeStatus(info.getUpgradeMode(),info.getDownloadStatus(),info.getProgress().getCurrent(),
|
||||
info.getProgress().getTotal(),info.getImages(),info.getUpgradeStatus());
|
||||
}else{
|
||||
Logger.d(TAG,"onUpgradeStateInfo : upgrade state info is null");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onSSHResult(SSHResult info) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package com.mogo.module.adas.entity;
|
||||
|
||||
/**
|
||||
* Created by XuYong on 2021/5/28 16:12
|
||||
*/
|
||||
public class AutonomousDriveStatusBean {
|
||||
|
||||
private String sn;
|
||||
private int status;
|
||||
private float vehicleSpeed;
|
||||
|
||||
public AutonomousDriveStatusBean(String sn, int status, float vehicleSpeed) {
|
||||
this.sn = sn;
|
||||
this.status = status;
|
||||
this.vehicleSpeed = vehicleSpeed;
|
||||
}
|
||||
|
||||
public String getSn() {
|
||||
return sn;
|
||||
}
|
||||
|
||||
public void setSn(String sn) {
|
||||
this.sn = sn;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public float getVehicleSpeed() {
|
||||
return vehicleSpeed;
|
||||
}
|
||||
|
||||
public void setVehicleSpeed(float vehicleSpeed) {
|
||||
this.vehicleSpeed = vehicleSpeed;
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package com.mogo.module.adas.entity;
|
||||
|
||||
/**
|
||||
* Created by XuYong on 2021/5/31 16:24
|
||||
*/
|
||||
public class ReportSiteBean {
|
||||
private String sn;
|
||||
private double lon;
|
||||
private double lat;
|
||||
|
||||
public ReportSiteBean(String sn, double lon, double lat) {
|
||||
this.sn = sn;
|
||||
this.lon = lon;
|
||||
this.lat = lat;
|
||||
}
|
||||
|
||||
public String getSn() {
|
||||
return sn;
|
||||
}
|
||||
|
||||
public void setSn(String sn) {
|
||||
this.sn = sn;
|
||||
}
|
||||
|
||||
public double getLon() {
|
||||
return lon;
|
||||
}
|
||||
|
||||
public void setLon(double lon) {
|
||||
this.lon = lon;
|
||||
}
|
||||
|
||||
public double getLat() {
|
||||
return lat;
|
||||
}
|
||||
|
||||
public void setLat(double lat) {
|
||||
this.lat = lat;
|
||||
}
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
package com.mogo.module.adas.model;
|
||||
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
import com.mogo.eagle.core.data.BaseData;
|
||||
import com.mogo.eagle.core.network.RequestOptions;
|
||||
import com.mogo.eagle.core.network.SubscribeImpl;
|
||||
import com.mogo.eagle.core.network.utils.GsonUtil;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
|
||||
import com.mogo.module.adas.entity.AutonomousDriveStatusBean;
|
||||
import com.mogo.module.adas.entity.ReportSiteBean;
|
||||
import com.mogo.module.adas.network.IAdasApiService;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.RequestBody;
|
||||
|
||||
import static com.mogo.commons.context.ContextHolderUtil.getContext;
|
||||
import static com.mogo.module.common.constants.HostConst.DATA_SERVICE_HOST;
|
||||
|
||||
public class AdasServiceModel {
|
||||
|
||||
private static final String TAG = "AdasServiceModel";
|
||||
private static volatile AdasServiceModel instance;
|
||||
private static final byte[] obj = new byte[0];
|
||||
|
||||
private final IAdasApiService mAdasApiService;
|
||||
|
||||
private AdasServiceModel() {
|
||||
this.mAdasApiService = MogoApisHandler.getInstance().getApis().getNetworkApi().create(IAdasApiService.class, DATA_SERVICE_HOST);
|
||||
}
|
||||
|
||||
public static AdasServiceModel getInstance() {
|
||||
if (instance == null) {
|
||||
synchronized (obj) {
|
||||
if (instance == null) {
|
||||
instance = new AdasServiceModel();
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void updateDriveStatus(int autoPilotStatus, float autoPilotSpeed) {
|
||||
String sn = MoGoAiCloudClientConfig.getInstance().getSn();
|
||||
AutonomousDriveStatusBean request = new AutonomousDriveStatusBean(sn, autoPilotStatus, autoPilotSpeed);
|
||||
RequestBody requestBody = RequestBody.create(MediaType.get("application/json;charset=UTF-8"), GsonUtil.jsonFromObject(request));
|
||||
mAdasApiService.updateAutonomousDriveStatus(requestBody).
|
||||
subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create(getContext())) {
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
super.onError(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(BaseData o) {
|
||||
super.onSuccess(o);
|
||||
Logger.d(TAG, "updateDriveStatus success");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void reportSite(double lon, double lat) {
|
||||
String sn = MoGoAiCloudClientConfig.getInstance().getSn();
|
||||
ReportSiteBean reportSiteBean = new ReportSiteBean(sn, lon, lat);
|
||||
RequestBody requestBody = RequestBody.create(MediaType.get("application/json;charset=UTF-8"), GsonUtil.jsonFromObject(reportSiteBean));
|
||||
mAdasApiService.updateReportSite(requestBody).
|
||||
subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create(getContext())) {
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
super.onError(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(BaseData o) {
|
||||
super.onSuccess(o);
|
||||
Logger.d(TAG, "autopilotArrive success");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package com.mogo.module.adas.network;
|
||||
|
||||
import com.mogo.eagle.core.data.BaseData;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import okhttp3.RequestBody;
|
||||
import retrofit2.http.Body;
|
||||
import retrofit2.http.Headers;
|
||||
import retrofit2.http.POST;
|
||||
|
||||
public interface IAdasApiService {
|
||||
|
||||
/**
|
||||
* 上传自动驾驶状态接口
|
||||
* @param requestBody
|
||||
* @return
|
||||
*/
|
||||
@Headers({"Content-Type:application/json;charset=UTF-8"})
|
||||
@POST("/dataService/autonomousDrive/updateAutonomousDriveStatus")
|
||||
Observable<BaseData> updateAutonomousDriveStatus(@Body RequestBody requestBody);
|
||||
|
||||
/**
|
||||
* 站点上报 用于网约车业务 云平台绘制路线使用
|
||||
* @param requestBody
|
||||
* @return
|
||||
*/
|
||||
@Headers({"Content-Type:application/json;charset=UTF-8"})
|
||||
@POST("/dataService/autonomousDrive/reportSite")
|
||||
Observable<BaseData> updateReportSite(@Body RequestBody requestBody);
|
||||
|
||||
}
|
||||
@@ -86,7 +86,6 @@ public class MogoServices implements IMogoMapListener,
|
||||
|
||||
private boolean mInternalUnWakeupRegisterStatus = false;
|
||||
|
||||
private Location mLastCarLocation;
|
||||
|
||||
private MogoServices() {
|
||||
// private constructor
|
||||
@@ -201,7 +200,6 @@ public class MogoServices implements IMogoMapListener,
|
||||
}
|
||||
mStatusManager.setUserInteractionStatus( ServiceConst.TYPE, true, false );
|
||||
mUiController.changeZoom( ServiceConst.DEFAULT_LOCK_CAR_ZOOM_LEVEL );
|
||||
// mUiController.setLockZoom( ServiceConst.DEFAULT_LOCK_CAR_ZOOM_LEVEL );
|
||||
mStatusManager.setUserInteractionStatus( TAG, true, false );
|
||||
mUiController.recoverLockMode();
|
||||
notifyRefreshData( mLastAutoRefreshLocation, ServiceConst.DEFAULT_AUTO_REFRESH_DATA_RADIUS, mAutoRefreshCallback );
|
||||
@@ -265,11 +263,6 @@ public class MogoServices implements IMogoMapListener,
|
||||
|
||||
private Handler mThreadHandler;
|
||||
|
||||
/**
|
||||
* 当前限速
|
||||
*/
|
||||
private int mCurrentLimit = -1;
|
||||
|
||||
private final IMogoStatusChangedListener statusChangedListener = new StatusChangedAdapter() {
|
||||
|
||||
@Override
|
||||
@@ -646,7 +639,6 @@ public class MogoServices implements IMogoMapListener,
|
||||
if ( latLng == null ) {
|
||||
return;
|
||||
}
|
||||
mLastCarLocation = latLng;
|
||||
// poi 定位无法获取时,使用该定位
|
||||
if ( mLastAutoRefreshLocation == null ) {
|
||||
MogoLatLng point = new MogoLatLng( latLng.getLatitude(), latLng.getLongitude() );
|
||||
@@ -834,10 +826,6 @@ public class MogoServices implements IMogoMapListener,
|
||||
MoGoAiCloudRealTime.stopRealTime();
|
||||
}
|
||||
|
||||
public Location getLastCarLocation() {
|
||||
return mLastCarLocation;
|
||||
}
|
||||
|
||||
private boolean mLastStatusIsVr = false;
|
||||
|
||||
public boolean isLastStatusIsVr() {
|
||||
@@ -876,7 +864,8 @@ public class MogoServices implements IMogoMapListener,
|
||||
@Override
|
||||
public void onAdasCarDataCallback( AutopilotCarStateInfo stateInfo ) {
|
||||
|
||||
if(TimeDelayUploadManager.getInstance().isMock()){ //模拟数据时,不更新由工控机传输的自车位置
|
||||
//模拟数据时,不更新由工控机传输的自车位置
|
||||
if(TimeDelayUploadManager.getInstance().isMock()){
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user