@@ -2,7 +2,7 @@ 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.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;
|
||||
@@ -94,10 +94,10 @@ public class SnapshotLocationDataCenter {
|
||||
// 使用与渠道配置一样的gps提供者提供的数据
|
||||
if (gpsProvider == FunctionBuildConfig.gpsProvider) {
|
||||
//测试面板状态同步
|
||||
AutoPilotStatusInfo autopilotStatusInfo = CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo();
|
||||
AutopilotStatusInfo autopilotStatusInfo = CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo();
|
||||
autopilotStatusInfo.setLocationLat(lat);
|
||||
autopilotStatusInfo.setLocationLon(lon);
|
||||
CallerAutoPilotStatusListenerManager.INSTANCE.invokeAutoPilotStatusListener();
|
||||
CallerAutoPilotStatusListenerManager.INSTANCE.invokeAutoPilotStatus();
|
||||
|
||||
DebugConfig.setStatusData(DebugConfig.sLon, lon);
|
||||
DebugConfig.setStatusData(DebugConfig.sLat, lat);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.mogo.module.common.drawer;
|
||||
|
||||
import static com.mogo.cloud.socket.entity.SocketDownDataHelper.FROM_ADAS;
|
||||
|
||||
import android.os.Build;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
@@ -7,12 +9,12 @@ import android.util.Log;
|
||||
import com.mogo.cloud.commons.utils.CoordinateUtils;
|
||||
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 com.mogo.module.common.utils.Trigonometric;
|
||||
import com.mogo.service.adas.entity.ADASRecognizedResult;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
@@ -21,16 +23,13 @@ import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static com.mogo.cloud.socket.entity.SocketDownDataHelper.FROM_ADAS;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/10/28
|
||||
*
|
||||
* <p>
|
||||
* 绘制adas近景识别到的车辆
|
||||
*/
|
||||
class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
public class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
|
||||
private static final String TAG = "RecognizedResultDrawer";
|
||||
|
||||
@@ -45,7 +44,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
super();
|
||||
}
|
||||
|
||||
private final Map<String, ADASRecognizedResult> mLastPositions = new ConcurrentHashMap<>();
|
||||
private final Map<String, TrafficData> mLastPositions = new ConcurrentHashMap<>();
|
||||
|
||||
public static AdasRecognizedResultDrawer getInstance() {
|
||||
if (sInstance == null) {
|
||||
@@ -76,7 +75,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
*
|
||||
* @param resultList adas感知融合数据
|
||||
*/
|
||||
public void renderAdasRecognizedResult(List<ADASRecognizedResult> resultList) {
|
||||
public void renderAdasRecognizedResult(List<TrafficData> resultList) {
|
||||
|
||||
final long start = System.nanoTime();
|
||||
if (resultList == null || resultList.isEmpty() || !DebugConfig.isUseAdasRecognize()) {
|
||||
@@ -91,18 +90,18 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
return;
|
||||
}
|
||||
|
||||
// List<ADASRecognizedResult> allDatumsList = new ArrayList<>();
|
||||
// List<TrafficData> allDatumsList = new ArrayList<>();
|
||||
// prepareData(resultList, allDatumsList);
|
||||
|
||||
Map<String, IMogoMarker> newAdasRecognizedMarkersCaches = new ConcurrentHashMap<>();
|
||||
List<ADASRecognizedResult> newDiffSet = new ArrayList<>();
|
||||
for (ADASRecognizedResult recognizedListResult : resultList) {
|
||||
List<TrafficData> newDiffSet = new ArrayList<>();
|
||||
for (TrafficData recognizedListResult : resultList) {
|
||||
|
||||
if (isUselessValue(recognizedListResult)) {
|
||||
continue;
|
||||
}
|
||||
// 复用之前存在的 marker
|
||||
String uniqueKey = recognizedListResult.uuid;
|
||||
String uniqueKey = recognizedListResult.getUuid();
|
||||
IMogoMarker marker = mMarkersCaches.remove(uniqueKey);
|
||||
if (marker != null && !marker.isDestroyed()) {
|
||||
// Log.d(TAG, "发现缓存marker id : " + uniqueKey);
|
||||
@@ -120,8 +119,8 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
// 复用过期 marker
|
||||
if (newDiffSetSize > 0) {
|
||||
for (int i = 0; i < newDiffSetSize; i++) {
|
||||
ADASRecognizedResult recognizedListResult = newDiffSet.get(i);
|
||||
String uniqueKey = recognizedListResult.uuid;
|
||||
TrafficData recognizedListResult = newDiffSet.get(i);
|
||||
String uniqueKey = recognizedListResult.getUuid();
|
||||
IMogoMarker marker = drawAdasRecognizedDataMarker(recognizedListResult);
|
||||
if (marker == null) {
|
||||
continue;
|
||||
@@ -142,7 +141,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
* @param in
|
||||
* @param out
|
||||
*/
|
||||
private void prepareData(List<ADASRecognizedResult> in, List<ADASRecognizedResult> out) {
|
||||
private void prepareData(List<TrafficData> in, List<TrafficData> out) {
|
||||
// foreCastPoint(in);
|
||||
out.addAll(in);
|
||||
}
|
||||
@@ -154,22 +153,22 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
*
|
||||
* @param in 数据源
|
||||
*/
|
||||
private void foreCastPoint(List<ADASRecognizedResult> in) {
|
||||
private void foreCastPoint(List<TrafficData> in) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
for (ADASRecognizedResult adasResult : in) {
|
||||
Log.d(FORECAST, "ready to foreCast current uuid : " + adasResult.uuid);
|
||||
long internal = getCurSatelliteTime() - adasResult.satelliteTime;
|
||||
for (TrafficData adasResult : in) {
|
||||
Log.d(FORECAST, "ready to foreCast current uuid : " + adasResult.getUuid());
|
||||
long internal = getCurSatelliteTime() - adasResult.getSatelliteTime();
|
||||
if (internal <= 0) {
|
||||
Log.d(FORECAST, "time internal less than 0 , uuid : " + adasResult.uuid);
|
||||
Log.d(FORECAST, "time internal less than 0 , uuid : " + adasResult.getUuid());
|
||||
continue;
|
||||
}
|
||||
long startTime = System.currentTimeMillis();
|
||||
// 预测点
|
||||
Log.d(FORECAST, "time internal : " + internal + " speed : " + adasResult.speed);
|
||||
double foreCastDistance = adasResult.speed * internal / 1000;
|
||||
Log.d(FORECAST, "time internal : " + internal + " speed : " + adasResult.getSpeed());
|
||||
double foreCastDistance = adasResult.getSpeed() * internal / 1000;
|
||||
Log.d(FORECAST, "foreCastDistance : " + foreCastDistance);
|
||||
MogoLatLng mogoLatLng = new MogoLatLng(adasResult.lat, adasResult.lon);
|
||||
MogoLatLng foreCastMogoLatLon = Trigonometric.getNewLocation(mogoLatLng, foreCastDistance, adasResult.heading);
|
||||
MogoLatLng mogoLatLng = new MogoLatLng(adasResult.getLat(), adasResult.getLon());
|
||||
MogoLatLng foreCastMogoLatLon = Trigonometric.getNewLocation(mogoLatLng, foreCastDistance, adasResult.getHeading());
|
||||
|
||||
// 计算与自车距离
|
||||
float distanceFromSelf = CoordinateUtils.calculateLineDistance(getCurCoordinates()[0], getCurCoordinates()[1]
|
||||
@@ -178,10 +177,10 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
long foreCastInternal = System.currentTimeMillis() - startTime;
|
||||
Log.d(FORECAST, "foreCastInternal :" + foreCastInternal); //todo 耗时1~2毫秒 需要测试是否由于补点算法造成
|
||||
|
||||
adasResult.lat = foreCastMogoLatLon.getLat();
|
||||
adasResult.lon = foreCastMogoLatLon.getLon();
|
||||
adasResult.satelliteTime = (getCurSatelliteTime() - foreCastInternal);
|
||||
adasResult.distance = distanceFromSelf;
|
||||
adasResult.setLat(foreCastMogoLatLon.getLat());
|
||||
adasResult.setLon(foreCastMogoLatLon.getLon());
|
||||
adasResult.setSatelliteTime((getCurSatelliteTime() - foreCastInternal));
|
||||
adasResult.setDistance(distanceFromSelf);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -192,9 +191,9 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
* @param marker
|
||||
* @param recognizedListResult
|
||||
*/
|
||||
private void updateCacheMarkerRes(IMogoMarker marker, ADASRecognizedResult recognizedListResult) {
|
||||
private void updateCacheMarkerRes(IMogoMarker marker, TrafficData recognizedListResult) {
|
||||
String resIdVal;
|
||||
int resId = getModelRes(recognizedListResult.type);
|
||||
int resId = getModelRes(recognizedListResult.getType().getType());
|
||||
resIdVal = resId + "";
|
||||
String resName = mMarkerCachesResMd5Values.get(resIdVal);
|
||||
if (!TextUtils.isEmpty(resName)) {
|
||||
@@ -211,11 +210,11 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
if (mLastPositions.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Iterator<ADASRecognizedResult> iterator = mLastPositions.values().iterator();
|
||||
Iterator<TrafficData> iterator = mLastPositions.values().iterator();
|
||||
Log.d("EmArrow", "removeUselessLastRecord size : " + mLastPositions.size());
|
||||
while (iterator.hasNext()) {
|
||||
ADASRecognizedResult result = iterator.next();
|
||||
long internal = result.satelliteTime - getCurSatelliteTime();
|
||||
TrafficData result = iterator.next();
|
||||
long internal = result.getSatelliteTime() - getCurSatelliteTime();
|
||||
if (internal > 3000) { //防止帧率过低导致误删除上一个节点对象,从而出现跳跃现象
|
||||
iterator.remove();
|
||||
}
|
||||
@@ -225,33 +224,33 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
/**
|
||||
* 过滤无用数据
|
||||
*
|
||||
* @param recognizedListResult {@link ADASRecognizedResult}
|
||||
* @param recognizedListResult {@link TrafficData}
|
||||
* @return useless
|
||||
*/
|
||||
private boolean isUselessValue(ADASRecognizedResult recognizedListResult) {
|
||||
private boolean isUselessValue(TrafficData recognizedListResult) {
|
||||
if (recognizedListResult == null) {
|
||||
return true;
|
||||
}
|
||||
if (nonRenderType(recognizedListResult.type)) {
|
||||
if (nonRenderType(recognizedListResult.getType().getType())) {
|
||||
return true;
|
||||
}
|
||||
String uniqueKey = recognizedListResult.uuid;
|
||||
String uniqueKey = recognizedListResult.getUuid();
|
||||
return TextUtils.isEmpty(uniqueKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制某个物体的一个数据
|
||||
*
|
||||
* @param recognizedListResult {@link ADASRecognizedResult}
|
||||
* @param recognizedListResult {@link TrafficData}
|
||||
* @param newAdasRecognizedMarkersCaches 缓存集合
|
||||
*/
|
||||
private void renderAdasOneFrame(IMogoMarker marker,
|
||||
String uniqueKey,
|
||||
ADASRecognizedResult recognizedListResult,
|
||||
TrafficData recognizedListResult,
|
||||
Map<String, IMogoMarker> newAdasRecognizedMarkersCaches) {
|
||||
final long start = System.nanoTime();
|
||||
// Log.d(TAG, "renderAdasOneFrame uuid : " + uniqueKey + " type : " + recognizedListResult.type + " heading : " + recognizedListResult.heading);
|
||||
ADASRecognizedResult lastPosition = mLastPositions.remove(uniqueKey);
|
||||
TrafficData lastPosition = mLastPositions.remove(uniqueKey);
|
||||
// 道路吸附
|
||||
// double lastLon = -1;
|
||||
// double lastLat = -1;
|
||||
@@ -269,18 +268,15 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
// Log.d(TAG, "使用缓存 id : " + uniqueKey);
|
||||
long interval = 45;
|
||||
if (lastPosition != null) {
|
||||
interval = computeAnimDuration(lastPosition.satelliteTime, recognizedListResult.satelliteTime);
|
||||
interval = computeAnimDuration(lastPosition.getSatelliteTime(), recognizedListResult.getSatelliteTime());
|
||||
}
|
||||
final MogoLatLng renderLoc = new MogoLatLng(recognizedListResult.lat, recognizedListResult.lon);
|
||||
final MogoLatLng renderLoc = new MogoLatLng(recognizedListResult.getLat(), recognizedListResult.getLon());
|
||||
long cost = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start);
|
||||
Log.d("ADAS动画数据","cost : " + cost);
|
||||
Log.d("ADAS动画数据", "cost : " + cost);
|
||||
final long intervalRef = interval - cost;
|
||||
Log.d("ADAS动画数据", "最终赋值 : " + intervalRef + " 两帧间隔 : " + interval + " uuid : " + recognizedListResult.uuid);
|
||||
marker.addDynamicAnchorPosition(renderLoc, (float) recognizedListResult.heading, intervalRef);
|
||||
String carColor = recognizedListResult.color;
|
||||
if (TextUtils.isEmpty(carColor)) {
|
||||
carColor = getModelRenderColor(recognizedListResult.type, FROM_ADAS, recognizedListResult.drawlevel);
|
||||
}
|
||||
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);
|
||||
@@ -302,22 +298,19 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
/**
|
||||
* 绘制 marker
|
||||
*
|
||||
* @param recognizedListResult {@link ADASRecognizedResult}
|
||||
* @param recognizedListResult {@link TrafficData}
|
||||
* @return {@link IMogoMarker}
|
||||
*/
|
||||
private IMogoMarker drawAdasRecognizedDataMarker(ADASRecognizedResult recognizedListResult) {
|
||||
private IMogoMarker drawAdasRecognizedDataMarker(TrafficData recognizedListResult) {
|
||||
long start = System.nanoTime();
|
||||
if (recognizedListResult == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int resId = getModelRes(recognizedListResult.type);
|
||||
int resId = getModelRes(recognizedListResult.getType().getType());
|
||||
String resIdVal = resId + "";
|
||||
|
||||
String carColor = recognizedListResult.color;
|
||||
if (TextUtils.isEmpty(carColor)) {
|
||||
carColor = getModelRenderColor(recognizedListResult.type, FROM_ADAS, recognizedListResult.drawlevel);
|
||||
}
|
||||
String carColor = getModelRenderColor(recognizedListResult.getType().getType(), FROM_ADAS, recognizedListResult.getThreatLevel());
|
||||
MogoMarkerOptions options = new MogoMarkerOptions()
|
||||
.owner(DataTypes.TYPE_MARKER_ADAS)
|
||||
.anchor(0.5f, 0.5f)
|
||||
@@ -327,8 +320,8 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
.controlAngle(true)
|
||||
.resName(mMarkerCachesResMd5Values.get(resIdVal))
|
||||
.icon3DRes(resId)
|
||||
.rotate((float) recognizedListResult.heading)
|
||||
.position(new MogoLatLng(recognizedListResult.lat, recognizedListResult.lon));
|
||||
.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)));
|
||||
|
||||
Reference in New Issue
Block a user