1
.idea/misc.xml
generated
1
.idea/misc.xml
generated
@@ -13,6 +13,7 @@
|
||||
<map>
|
||||
<entry key="../../../../../../layout/custom_preview.xml" value="0.390625" />
|
||||
<entry key="../../../../../layout/custom_preview.xml" value="0.19947916666666668" />
|
||||
<entry key="OCH/mogo-och/src/main/res/layout/module_mogo_och_base_fragment.xml" value="0.24010416666666667" />
|
||||
<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" />
|
||||
|
||||
@@ -173,7 +173,7 @@ object CallerAutoPilotStatusListenerManager : CallerBase() {
|
||||
* 识别交通元素数据发生更新 回调
|
||||
*/
|
||||
@Synchronized
|
||||
fun invokeIdentifyDataUpdate(trafficData: List<TrafficData>?) {
|
||||
fun invokeAutopilotIdentifyDataUpdate(trafficData: List<TrafficData>?) {
|
||||
LogUtils.dTag(TAG, "$trafficData")
|
||||
M_AUTOPILOT_STATUS_LISTENERS.forEach {
|
||||
val tag = it.key
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
package com.mogo.module.adas;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotCarStateInfo;
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotGuardianStatusInfo;
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotRouteInfo;
|
||||
@@ -14,6 +17,8 @@ import com.mogo.eagle.core.data.traffic.TrafficData;
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager;
|
||||
import com.mogo.module.adas.model.AdasServiceModel;
|
||||
import com.mogo.module.common.drawer.IdentifyDataDrawer;
|
||||
import com.mogo.service.statusmanager.IMogoStatusManager;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.mogo.utils.network.utils.GsonUtil;
|
||||
import com.zhidao.autopilotservice.model.AdasAIDLAutopilotStateModel;
|
||||
@@ -234,6 +239,18 @@ public class AdasEventManager implements OnAdasMsgConnectStatusListener, IMoGoAu
|
||||
@Override
|
||||
public void onAutopilotIdentifyDataUpdate(@Nullable List<TrafficData> trafficData) {
|
||||
Logger.d(TAG, "onRectData " + trafficData);
|
||||
// 仅在 vr 模式下显示 adas 识别车辆
|
||||
if (trafficData == null) {
|
||||
Logger.w(TAG, "--->action is null");
|
||||
} else {
|
||||
final long start = System.nanoTime();
|
||||
try {
|
||||
IdentifyDataDrawer.getInstance().renderAdasRecognizedResult(trafficData);
|
||||
Log.i(TAG, "接收数据 -> 发出 cost :" + TimeUnit.NANOSECONDS.toMillis((System.nanoTime() - start)) + "ms");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
try {
|
||||
for (IAdasDataListener listener : iAdasEventListeners) {
|
||||
if (listener != null) {
|
||||
|
||||
@@ -37,7 +37,7 @@ public class OnAdasListenerAdapter implements OnAdasListener {
|
||||
@Override
|
||||
public void onRectData(RectInfo rectInfo) {
|
||||
List<TrafficData> recognizedListResults = AdasObjectUtils.INSTANCE.regroupTrafficDataData(rectInfo.getModels());
|
||||
CallerAutoPilotStatusListenerManager.INSTANCE.invokeIdentifyDataUpdate(recognizedListResults);
|
||||
CallerAutoPilotStatusListenerManager.INSTANCE.invokeAutopilotIdentifyDataUpdate(recognizedListResults);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -31,7 +31,7 @@ import java.util.concurrent.TimeUnit;
|
||||
*/
|
||||
public class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
|
||||
private static final String TAG = "RecognizedResultDrawer";
|
||||
private static final String TAG = "AdasRecognizedResultDrawer";
|
||||
|
||||
private static volatile AdasRecognizedResultDrawer sInstance;
|
||||
|
||||
|
||||
@@ -0,0 +1,252 @@
|
||||
package com.mogo.module.common.drawer;
|
||||
|
||||
import static com.mogo.cloud.socket.entity.SocketDownDataHelper.FROM_ADAS;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.data.traffic.TrafficData;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.constants.DataTypes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @author xiaoyuzhou
|
||||
* @date 2021/10/19 10:45 上午
|
||||
* 域控制器识别信息绘制
|
||||
*/
|
||||
public class IdentifyDataDrawer extends BaseDrawer {
|
||||
|
||||
private static final String TAG = "IdentifyDataDrawer";
|
||||
|
||||
private static volatile IdentifyDataDrawer sInstance;
|
||||
|
||||
/**
|
||||
* 上一帧数据的缓存
|
||||
*/
|
||||
private static Map<String, IMogoMarker> mMarkersCaches = new ConcurrentHashMap<>();
|
||||
|
||||
public IdentifyDataDrawer() {
|
||||
super();
|
||||
}
|
||||
|
||||
private final Map<String, TrafficData> mLastPositions = new ConcurrentHashMap<>();
|
||||
|
||||
public static IdentifyDataDrawer getInstance() {
|
||||
if (sInstance == null) {
|
||||
synchronized (IdentifyDataDrawer.class) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new IdentifyDataDrawer();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public synchronized void release() {
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 渲染 adas 识别的数据
|
||||
*
|
||||
* @param resultList adas感知融合数据
|
||||
*/
|
||||
public void renderAdasRecognizedResult(List<TrafficData> resultList) {
|
||||
|
||||
final long start = System.nanoTime();
|
||||
if (resultList == null || resultList.isEmpty() || !DebugConfig.isUseAdasRecognize()) {
|
||||
clearOldMarker();
|
||||
Log.w("ADAS数据延时绘制", "resultList==>" + resultList + " DebugConfig.isUseAdasRecognize()==>" + DebugConfig.isUseAdasRecognize());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
|
||||
clearOldMarker();
|
||||
Log.w("ADAS数据延时绘制", "当前不是VR模式");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Map<String, IMogoMarker> newAdasRecognizedMarkersCaches = new ConcurrentHashMap<>();
|
||||
List<TrafficData> newDiffSet = new ArrayList<>();
|
||||
for (TrafficData recognizedListResult : resultList) {
|
||||
|
||||
if (isUselessValue(recognizedListResult)) {
|
||||
continue;
|
||||
}
|
||||
// 复用之前存在的 marker
|
||||
String uniqueKey = recognizedListResult.getUuid();
|
||||
IMogoMarker marker = mMarkersCaches.remove(uniqueKey);
|
||||
if (marker != null && !marker.isDestroyed()) {
|
||||
// Log.d(TAG, "发现缓存marker id : " + uniqueKey);
|
||||
updateCacheMarkerRes(marker, recognizedListResult);
|
||||
renderAdasOneFrame(marker, uniqueKey, recognizedListResult, newAdasRecognizedMarkersCaches);
|
||||
} else {
|
||||
// 新增添加进差集
|
||||
newDiffSet.add(recognizedListResult);
|
||||
}
|
||||
}
|
||||
removeUselessMarker(mMarkersCaches);
|
||||
removeUselessLastRecord();
|
||||
int newDiffSetSize = newDiffSet.size();
|
||||
// Log.d(TAG, "原数据量 : " + resultList.size() + " 新增marker数量 : " + newDiffSetSize);
|
||||
// 复用过期 marker
|
||||
if (newDiffSetSize > 0) {
|
||||
for (int i = 0; i < newDiffSetSize; i++) {
|
||||
TrafficData recognizedListResult = newDiffSet.get(i);
|
||||
String uniqueKey = recognizedListResult.getUuid();
|
||||
IMogoMarker marker = drawAdasRecognizedDataMarker(recognizedListResult);
|
||||
if (marker == null) {
|
||||
continue;
|
||||
}
|
||||
// Log.d(TAG, "新增marker id : " + uniqueKey);
|
||||
renderAdasOneFrame(marker, uniqueKey, recognizedListResult, newAdasRecognizedMarkersCaches);
|
||||
}
|
||||
}
|
||||
sendMessage(MSG_REMOVE_DIRTY_MARKERS, mMarkersCaches);
|
||||
mMarkersCaches.clear();
|
||||
mMarkersCaches = newAdasRecognizedMarkersCaches;
|
||||
Log.d("ADAS数据延时绘制", "render 接收数据 -> 处理结束 " + TimeUnit.NANOSECONDS.toMillis((System.nanoTime() - start)) + "ms");
|
||||
}
|
||||
|
||||
/**
|
||||
* todo 后面涉及到此类变化的数据均改动
|
||||
*
|
||||
* @param marker
|
||||
* @param recognizedListResult
|
||||
*/
|
||||
private void updateCacheMarkerRes(IMogoMarker marker, TrafficData recognizedListResult) {
|
||||
String resIdVal;
|
||||
int resId = getModelRes(recognizedListResult.getType().getType());
|
||||
resIdVal = resId + "";
|
||||
String resName = mMarkerCachesResMd5Values.get(resIdVal);
|
||||
if (!TextUtils.isEmpty(resName)) {
|
||||
if (!TextUtils.equals(resName, marker.getMarkerResName())) {
|
||||
marker.use3DResource(resName);
|
||||
}
|
||||
} else {
|
||||
resName = marker.use3DResource(resId);
|
||||
mMarkerCachesResMd5Values.put(resIdVal, resName);
|
||||
}
|
||||
}
|
||||
|
||||
private void removeUselessLastRecord() { // todo 最好重新设计一个数据结构,用于多线程数据过期失效的场景,参见redis数据过期
|
||||
if (mLastPositions.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Iterator<TrafficData> iterator = mLastPositions.values().iterator();
|
||||
Log.d("EmArrow", "removeUselessLastRecord size : " + mLastPositions.size());
|
||||
while (iterator.hasNext()) {
|
||||
TrafficData result = iterator.next();
|
||||
long internal = result.getSatelliteTime() - getCurSatelliteTime();
|
||||
if (internal > 3000) { //防止帧率过低导致误删除上一个节点对象,从而出现跳跃现象
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 过滤无用数据
|
||||
*
|
||||
* @param recognizedListResult {@link TrafficData}
|
||||
* @return useless
|
||||
*/
|
||||
private boolean isUselessValue(TrafficData recognizedListResult) {
|
||||
if (recognizedListResult == null) {
|
||||
return true;
|
||||
}
|
||||
if (nonRenderType(recognizedListResult.getType().getType())) {
|
||||
return true;
|
||||
}
|
||||
String uniqueKey = recognizedListResult.getUuid();
|
||||
return TextUtils.isEmpty(uniqueKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制某个物体的一个数据
|
||||
*
|
||||
* @param recognizedListResult {@link TrafficData}
|
||||
* @param newAdasRecognizedMarkersCaches 缓存集合
|
||||
*/
|
||||
private void renderAdasOneFrame(IMogoMarker marker,
|
||||
String uniqueKey,
|
||||
TrafficData recognizedListResult,
|
||||
Map<String, IMogoMarker> newAdasRecognizedMarkersCaches) {
|
||||
final long start = System.nanoTime();
|
||||
// Log.d(TAG, "renderAdasOneFrame uuid : " + uniqueKey + " type : " + recognizedListResult.type + " heading : " + recognizedListResult.heading);
|
||||
TrafficData lastPosition = mLastPositions.remove(uniqueKey);
|
||||
|
||||
mLastPositions.put(uniqueKey, recognizedListResult);
|
||||
// Log.d(TAG, "使用缓存 id : " + uniqueKey);
|
||||
long interval = 45;
|
||||
if (lastPosition != null) {
|
||||
interval = computeAnimDuration(lastPosition.getSatelliteTime(), recognizedListResult.getSatelliteTime());
|
||||
}
|
||||
final MogoLatLng renderLoc = new MogoLatLng(recognizedListResult.getLat(), recognizedListResult.getLon());
|
||||
long cost = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start);
|
||||
Log.d("ADAS动画数据", "cost : " + cost);
|
||||
final long intervalRef = interval - cost;
|
||||
Log.d("ADAS动画数据", "最终赋值 : " + intervalRef + " 两帧间隔 : " + interval + " uuid : " + recognizedListResult.getUuid());
|
||||
marker.addDynamicAnchorPosition(renderLoc, (float) recognizedListResult.getHeading(), intervalRef);
|
||||
String carColor = getModelRenderColor(recognizedListResult.getType().getType(), FROM_ADAS, recognizedListResult.getThreatLevel());
|
||||
marker.setAnchorColor(carColor);
|
||||
|
||||
newAdasRecognizedMarkersCaches.put(uniqueKey, marker);
|
||||
Log.d("ADAS数据延时", "render 刷新一台车 cost : " + TimeUnit.NANOSECONDS.toMillis((System.nanoTime() - start)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制 marker
|
||||
*
|
||||
* @param recognizedListResult {@link TrafficData}
|
||||
* @return {@link IMogoMarker}
|
||||
*/
|
||||
private IMogoMarker drawAdasRecognizedDataMarker(TrafficData recognizedListResult) {
|
||||
long start = System.nanoTime();
|
||||
if (recognizedListResult == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int resId = getModelRes(recognizedListResult.getType().getType());
|
||||
String resIdVal = resId + "";
|
||||
|
||||
String carColor = getModelRenderColor(recognizedListResult.getType().getType(), FROM_ADAS, recognizedListResult.getThreatLevel());
|
||||
MogoMarkerOptions options = new MogoMarkerOptions()
|
||||
.owner(DataTypes.TYPE_MARKER_ADAS)
|
||||
.anchor(0.5f, 0.5f)
|
||||
.set3DMode(true)
|
||||
.gps(true)
|
||||
.anchorColor(carColor)
|
||||
.controlAngle(true)
|
||||
.resName(mMarkerCachesResMd5Values.get(resIdVal))
|
||||
.icon3DRes(resId)
|
||||
.rotate((float) recognizedListResult.getHeading())
|
||||
.position(new MogoLatLng(recognizedListResult.getLat(), recognizedListResult.getLon()));
|
||||
IMogoMarker marker = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager(mContext).addMarker(DataTypes.TYPE_MARKER_ADAS, options);
|
||||
cacheMarkerIconResMd5Val(resIdVal, marker);
|
||||
Log.d("ADAS数据延时", "创建一个新 marker cost : " + TimeUnit.NANOSECONDS.toMillis((System.nanoTime() - start)));
|
||||
return marker;
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除旧的 marker 数据
|
||||
*/
|
||||
public void clearOldMarker() {
|
||||
if (mMarkersCaches != null) {
|
||||
mMarkersCaches.clear();
|
||||
}
|
||||
mLastPositions.clear();
|
||||
sendMessage(MSG_REMOVE_DIRTY_MARKERS, DataTypes.TYPE_MARKER_ADAS);
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ import com.mogo.module.common.ModuleNames;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.api.CallChatApi;
|
||||
import com.mogo.module.common.drawer.AdasRecognizedResultDrawer;
|
||||
import com.mogo.module.common.drawer.IdentifyDataDrawer;
|
||||
import com.mogo.module.common.drawer.MarkerDrawer;
|
||||
import com.mogo.module.common.drawer.OnlineCarDrawer;
|
||||
import com.mogo.module.common.drawer.RoadConditionDrawer;
|
||||
@@ -184,7 +185,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
// 使用与渠道配置一样的gps提供者提供的数据 修改fPadLenovo.gradle文件中的GPS_PROVIDER字段控制渲染来源
|
||||
Logger.d(TAG, "result.addAdasRecognizedDataCallback == 3 ------> ");
|
||||
if (FunctionBuildConfig.gpsProvider != 2) {
|
||||
AdasRecognizedResultDrawer.getInstance().renderAdasRecognizedResult(resultList);
|
||||
IdentifyDataDrawer.getInstance().renderAdasRecognizedResult(resultList);
|
||||
}
|
||||
|
||||
//添加自车的定位图标,碰撞只有一个预警,还需要和adas 联调,
|
||||
|
||||
@@ -237,27 +237,6 @@ public class MogoADASController implements IMogoADASController {
|
||||
|
||||
@Override
|
||||
public void onRectData(List<TrafficData> trafficData) {
|
||||
// 仅在 vr 模式下显示 adas 识别车辆
|
||||
if (!SingletonsHolder.get(IMogoStatusManager.class).isVrMode()) {
|
||||
return;
|
||||
}
|
||||
if (!SingletonsHolder.get(IMogoStatusManager.class).isMainPageLaunched()) {
|
||||
return;
|
||||
}
|
||||
if (trafficData == null) {
|
||||
Logger.w(TAG, "--->action is null");
|
||||
return;
|
||||
}
|
||||
final long start = System.nanoTime();
|
||||
try {
|
||||
Message message = mAdasRecognizedRecHandler.obtainMessage();
|
||||
message.obj = trafficData;
|
||||
message.sendToTarget();
|
||||
Log.i("ADAS数据延时", "接收数据 -> 发出 cost :" + TimeUnit.NANOSECONDS.toMillis((System.nanoTime() - start)) + "ms");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
DebugConfig.setStatus(DebugConfig.sAdasRecognized, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user