优化他车道路吸附变道突兀问题

This commit is contained in:
tongchenfei
2021-03-04 19:45:32 +08:00
parent 6ba2e5eeea
commit 6d5e0d952b
4 changed files with 36 additions and 12 deletions

View File

@@ -31,6 +31,7 @@ public class SimpleHandlerThreadPool {
private static final String TAG = "SimpleHandlerThreadPool";
private HandlerThread renderThread = new HandlerThread("one-frame-render-thread");
private Handler renderHandler;
private SimpleHandlerThreadPool() {
renderThread.start();
renderHandler = new Handler(renderThread.getLooper());
@@ -108,6 +109,7 @@ public class SimpleHandlerThreadPool {
private final Map<String, IMogoMarker> markerCache = new ArrayMap<>();
private final Map<String, CloudRoadData> roadDataCache = new ArrayMap<>();
private final Map<String, Long> lastExecutionTimeCache = new ArrayMap<>();
private final Map<String, Boolean> isMatchStatusCache = new ArrayMap<>();
private void rendCarOneFrame(CloudRoadData cloudRoadData) {
if (cloudRoadData == null) {
@@ -127,6 +129,7 @@ public class SimpleHandlerThreadPool {
|| AdasRecognizedResultDrawer.getInstance().hasCached(uniqueKey)) {
return;
}
IMogoMarker marker = markerCache.get(uniqueKey);
CloudRoadData lastPosition = roadDataCache.put(uniqueKey, cloudRoadData);
if (marker == null || marker.isDestroyed()) {
@@ -140,22 +143,39 @@ public class SimpleHandlerThreadPool {
}
}
if(cloudRoadData.getFromType() == CloudRoadData.FROM_MY_LOCATION) {
if (cloudRoadData.getFromType() == CloudRoadData.FROM_MY_LOCATION) {
double[] matchedPoint = SnapshotSetDataDrawer.getInstance().matchRoad(cloudRoadData.getLon(),
cloudRoadData.getLat(),
cloudRoadData.getHeading(),
true
);
Boolean isMathch = isMatchStatusCache.get(uniqueKey);
if (matchedPoint != null) {
cloudRoadData.setLon(matchedPoint[0]);
cloudRoadData.setLat(matchedPoint[1]);
if ((isMathch == null || !isMathch)) {
if (matchedPoint[2] < 0.5) {
isMathch = true;
}
} else {
if (matchedPoint[2] > 1) {
isMathch = false;
}
}
if (isMathch == null) {
isMathch = false;
}
isMatchStatusCache.put(uniqueKey, isMathch);
if (isMathch) {
cloudRoadData.setLon(matchedPoint[0]);
cloudRoadData.setLat(matchedPoint[1]);
}
}
}
final IMogoMarker finalMarker = marker;
Logger.d(TAG, "work in " + Thread.currentThread().getName());
renderHandler.post(()->{
renderHandler.post(() -> {
// 由于地图现在不支持addDynamicAnchorPosition并发所以工作线程仅做相关计算真正绘制发送到另外一条绘制线程中做
if (lastPosition != null && !lastPosition.equals(cloudRoadData)) {
long interval = SnapshotSetDataDrawer.getInstance().computeAnimDuration(lastPosition.getSystemTime(), cloudRoadData.getSystemTime(), lastPosition.getSatelliteTime(), cloudRoadData.getSatelliteTime());
@@ -176,11 +196,11 @@ public class SimpleHandlerThreadPool {
public void removeDirtyMarker(Collection<String> keys) {
Map<String, IMogoMarker> result = new ArrayMap<>(keys.size());
for (String key : keys) {
if(markerCache.containsKey(key)) {
if (markerCache.containsKey(key)) {
result.put(key, markerCache.remove(key));
}
}
SnapshotSetDataDrawer.getInstance().sendMessage( MSG_REMOVE_DIRTY_MARKERS, result );
SnapshotSetDataDrawer.getInstance().sendMessage(MSG_REMOVE_DIRTY_MARKERS, result);
}
}
}