remove test class
This commit is contained in:
@@ -1,212 +0,0 @@
|
||||
package com.mogo.eagle.core.function.map;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_HMI;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
|
||||
import com.mogo.eagle.core.data.enums.TrafficTypeEnum;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
import com.mogo.map.MogoMap;
|
||||
import com.mogo.map.MogoMarkerManager;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.constants.AdasRecognizedType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import mogo.telematics.pad.MessagePad;
|
||||
|
||||
/**
|
||||
* @author xiaoyuzhou
|
||||
* @date 2021/10/19 10:45 上午
|
||||
* 域控制器识别信息绘制
|
||||
*/
|
||||
public class IdentifyDataDrawerTest {
|
||||
private static final String TAG = "IdentifyDataDrawer";
|
||||
|
||||
protected final Context mContext;
|
||||
private static volatile IdentifyDataDrawerTest sInstance;
|
||||
|
||||
/**
|
||||
* 上一帧数据的缓存
|
||||
*/
|
||||
private static final ConcurrentHashMap<String, MessagePad.TrackedObject> mMarkersCaches = new ConcurrentHashMap<>();
|
||||
|
||||
private static final ConcurrentHashMap<String, KalmanFilter> algoCache = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* 记录每次实际绘制的交通元素UUID
|
||||
*/
|
||||
private final ArrayList<String> trafficDataUuidList = new ArrayList<>();
|
||||
/**
|
||||
* 过滤后的数据集合
|
||||
*/
|
||||
private final ArrayList<MessagePad.TrackedObject> mFilterTrafficData = new ArrayList<>();
|
||||
|
||||
private IdentifyDataDrawerTest() {
|
||||
mContext = AbsMogoApplication.getApp();
|
||||
addPreVehicleModel();
|
||||
}
|
||||
|
||||
public static IdentifyDataDrawerTest getInstance() {
|
||||
if (sInstance == null) {
|
||||
synchronized (IdentifyDataDrawerTest.class) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new IdentifyDataDrawerTest();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public synchronized void release() {
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 渲染 adas 识别的数据
|
||||
*
|
||||
* @param resultList adas感知融合数据
|
||||
*/
|
||||
@SuppressLint("NewApi")
|
||||
public void renderAdasRecognizedResult(List<MessagePad.TrackedObject> resultList) {
|
||||
if (resultList == null || resultList.isEmpty()) {
|
||||
clearOldMarker();
|
||||
CallerLogger.INSTANCE.w(TAG, "感知数据为空无需渲染……");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
|
||||
clearOldMarker();
|
||||
CallerLogger.INSTANCE.w(TAG, "渲染 adas 识别的数据 当前不是VR模式");
|
||||
return;
|
||||
}
|
||||
|
||||
//清除缓存
|
||||
for (MessagePad.TrackedObject data : resultList) {
|
||||
if (trafficDataUuidList.size() > 0 && trafficDataUuidList.contains("" + data.getUuid())) {
|
||||
trafficDataUuidList.remove("" + data.getUuid());
|
||||
}
|
||||
}
|
||||
trafficDataUuidList.forEach(uuid -> {
|
||||
mMarkersCaches.remove(uuid);
|
||||
algoCache.remove(uuid);
|
||||
});
|
||||
|
||||
ArrayList<MessagePad.TrackedObject> filterList = filterTrafficData(resultList);
|
||||
if (filterList.size() > 0) {
|
||||
// 绘制新数据
|
||||
MogoMarkerManager.getInstance(mContext)
|
||||
.updateBatchMarkerPosition(filterList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据过滤器
|
||||
*
|
||||
* @return 过滤后的数据集合
|
||||
*/
|
||||
private ArrayList<MessagePad.TrackedObject> filterTrafficData(List<MessagePad.TrackedObject> trafficData) {
|
||||
mFilterTrafficData.clear();
|
||||
trafficDataUuidList.clear();
|
||||
for (MessagePad.TrackedObject data : trafficData) {
|
||||
// 过滤掉未知感知数据
|
||||
if (!FunctionBuildConfig.isDrawUnknownIdentifyData && data.getType() == TrafficTypeEnum.TYPE_TRAFFIC_ID_WEI_ZHI.getType()) {
|
||||
//CallerLogger.INSTANCE.w(TAG, "未知感知类型数据,丢弃,不渲染");
|
||||
continue;
|
||||
}
|
||||
|
||||
MessagePad.TrackedObject cacheData = mMarkersCaches.get("" + data.getUuid());
|
||||
double heading = MogoMap.getInstance().getMogoMap().getUIController().getAngle(cacheData.getLongitude(), cacheData.getLatitude(), data.getLongitude(), data.getLatitude());
|
||||
CallerLogger.INSTANCE.d(M_HMI + "arrow47", " uuid : " + data.getUuid() + " , origin heading : " + data.getHeading() + " , correct heading : " + heading + " ---- " + (data.getHeading() - heading));
|
||||
|
||||
// double heading = kalmanFilter(data);
|
||||
MessagePad.TrackedObject correctData = data.toBuilder().setHeading(heading).build();
|
||||
mFilterTrafficData.add(correctData);
|
||||
//更新已存在的感知物体数据
|
||||
mMarkersCaches.put("" + correctData.getUuid(), correctData);
|
||||
trafficDataUuidList.add("" + correctData.getUuid());
|
||||
}
|
||||
return mFilterTrafficData;
|
||||
}
|
||||
|
||||
private double kalmanFilter(MessagePad.TrackedObject data) {
|
||||
String uuid = "" + data.getUuid();
|
||||
if (algoCache.containsKey(uuid)) {
|
||||
Object o = algoCache.get(uuid);
|
||||
KalmanFilter kf = (KalmanFilter) o;
|
||||
assert kf != null;
|
||||
double[] lonLat = kf.filter(data.getLongitude(), data.getLatitude());
|
||||
algoCache.put(uuid, kf);
|
||||
MessagePad.TrackedObject cacheTrackObj = mMarkersCaches.get(uuid);
|
||||
assert cacheTrackObj != null;
|
||||
double heading = MogoMap.getInstance().getMogoMap().getUIController().getAngle(cacheTrackObj.getLongitude(), cacheTrackObj.getLatitude(), lonLat[0], lonLat[1]);
|
||||
CallerLogger.INSTANCE.d(M_HMI + "arrow47", " uuid : " + uuid + " , origin heading : " + data.getHeading() + " , correct heading : " + heading + " ---- " + (data.getHeading() - heading));
|
||||
return heading;
|
||||
} else {
|
||||
double r = 0.00005;
|
||||
if (AdasRecognizedType.valueFrom(data.getType()) == AdasRecognizedType.classIdTrafficBus || AdasRecognizedType.valueFrom(data.getType()) == AdasRecognizedType.classIdTrafficTruck) {
|
||||
r = 0.0001;
|
||||
}
|
||||
algoCache.put(uuid, new KalmanFilter(data.getLongitude(), data.getLatitude(), r));
|
||||
return data.getHeading();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除旧的 marker 数据
|
||||
*/
|
||||
public void clearOldMarker() {
|
||||
for (String uuid : trafficDataUuidList) {
|
||||
MogoMarkerManager.getInstance(mContext)
|
||||
.removeMarker(uuid);
|
||||
}
|
||||
trafficDataUuidList.clear();
|
||||
}
|
||||
|
||||
private void addPreVehicleModel() {
|
||||
CallerLogger.INSTANCE.d(TAG, "添加感知模型到地图中……");
|
||||
addPreVehicleModelWeiZhi(TrafficTypeEnum.TYPE_TRAFFIC_ID_WEI_ZHI, "添加感知模型到地图中……preVehicleStrWeiZhi=");
|
||||
|
||||
addPreVehicleModelWeiZhi(TrafficTypeEnum.TYPE_TRAFFIC_ID_PEOPLE, "添加感知模型到地图中……preVehicleStrPeople=");
|
||||
|
||||
addPreVehicleModelWeiZhi(TrafficTypeEnum.TYPE_TRAFFIC_ID_BICYCLE, "添加感知模型到地图中……preVehicleStrBicycle=");
|
||||
|
||||
addPreVehicleModelWeiZhi(TrafficTypeEnum.TYPE_TRAFFIC_ID_TA_CHE, "添加感知模型到地图中……preVehicleStrTaChe=");
|
||||
|
||||
addPreVehicleModelWeiZhi(TrafficTypeEnum.TYPE_TRAFFIC_ID_MOTO, "添加感知模型到地图中……preVehicleStrMoto=");
|
||||
|
||||
addPreVehicleModelWeiZhi(TrafficTypeEnum.TYPE_TRAFFIC_ID_BUS, "添加感知模型到地图中……preVehicleStrBus=");
|
||||
|
||||
addPreVehicleModelWeiZhi(TrafficTypeEnum.TYPE_TRAFFIC_ID_TRUCK, "添加感知模型到地图中……preVehicleStrTruck=");
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加模型到地图中
|
||||
*
|
||||
* @param typeTrafficIdWeiZhi
|
||||
* @param s
|
||||
*/
|
||||
private void addPreVehicleModelWeiZhi(TrafficTypeEnum typeTrafficIdWeiZhi, String s) {
|
||||
String preVehicleStrWeiZhi = MogoMarkerManager.getInstance(mContext)
|
||||
.addPreVehicleModel(typeTrafficIdWeiZhi.getType(),
|
||||
typeTrafficIdWeiZhi.getTraffic3DIconId());
|
||||
CallerLogger.INSTANCE.d(TAG, s + preVehicleStrWeiZhi);
|
||||
|
||||
if (preVehicleStrWeiZhi == null) {
|
||||
UiThreadHandler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
CallerLogger.INSTANCE.w(TAG, "添加感知模型到地图中失败,尝试重复添加……");
|
||||
addPreVehicleModelWeiZhi(typeTrafficIdWeiZhi, s);
|
||||
}
|
||||
}, 1000L);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user