fix bug of delay time problem and invisible marker when change visual problem

This commit is contained in:
zhongchao
2021-07-10 14:13:12 +08:00
parent c84646906b
commit 822e536c2b
10 changed files with 44 additions and 61 deletions

View File

@@ -217,7 +217,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
while (iterator.hasNext()) {
ADASRecognizedResult result = iterator.next();
long internal = result.satelliteTime - getCurSatelliteTime();
if (internal > 300) {
if (internal > 3000) { //防止帧率过低导致误删除上一个节点对象,从而出现跳跃现象
iterator.remove();
}
}
@@ -270,11 +270,13 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
// Log.d(TAG, "使用缓存 id : " + uniqueKey);
long interval = 45;
if (lastPosition != null) {
interval = computeAnimDuration(lastPosition.systemTime, recognizedListResult.systemTime, lastPosition.satelliteTime, recognizedListResult.satelliteTime);
interval = computeAnimDuration(lastPosition.satelliteTime, recognizedListResult.satelliteTime);
}
final MogoLatLng renderLoc = new MogoLatLng(recognizedListResult.lat, recognizedListResult.lon);
long cost = System.currentTimeMillis() - start;
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.uuid);
marker.addDynamicAnchorPosition(renderLoc, (float) recognizedListResult.heading, intervalRef);
String carColor = recognizedListResult.color;
if (TextUtils.isEmpty(carColor)) {

View File

@@ -28,7 +28,6 @@ import java.util.concurrent.ConcurrentHashMap;
import static com.mogo.cloud.socket.entity.SocketDownDataHelper.FROM_ADAS;
import static com.mogo.cloud.socket.entity.SocketDownDataHelper.FROM_MY_LOCATION;
import static com.mogo.cloud.socket.entity.SocketDownDataHelper.FROM_ROAD_UNIT;
import static com.mogo.module.common.constants.DataTypes.TYPE_MARKER_ADAS;
import static com.mogo.module.common.constants.DataTypes.TYPE_MARKER_CLOUD_DATA;
import static java.lang.Math.PI;
@@ -306,7 +305,6 @@ class BaseDrawer {
Dangerous_Visual("#FF91B7F1"),
Dangerous_Cloud("#FF260FEC");
private int fromType;
private final String color;
Car3DModelColor(String color) {
@@ -315,47 +313,6 @@ class BaseDrawer {
}
public static final int Waring_Normal = 0;
public static final int Waring_Close = 1;
public static final int Waring_Dangerous = 2;
/**
* 模型颜色
*/
public enum Car3DTestModelColor {
Normal_Type(FROM_MY_LOCATION, Waring_Normal, "#D8D8D8FF"),
Normal_Type_Visual(FROM_ADAS, Waring_Normal, "#D8CFF8BD"),
Normal_Type_Cloud(FROM_ROAD_UNIT, Waring_Normal, "#D8F83F94"),
Warming_Type(FROM_MY_LOCATION, Waring_Close, "#FFD53EFF"),
Warming_Type_Visual(FROM_ADAS, Waring_Close, "#FFC192F1"),
Warming_Type_Cloud(FROM_ROAD_UNIT, Waring_Close, "#FFEF09AD"),
Dangerous_Type(FROM_MY_LOCATION, Waring_Dangerous, "#FF3C45FF"),
Dangerous_Type_Visual(FROM_ADAS, Waring_Dangerous, "#FF91B7F1"),
Dangerous_Type_Cloud(FROM_ROAD_UNIT, Waring_Dangerous, "#FF260FEC");
private final int fromType;
private final int waringType;
private final String color;
Car3DTestModelColor(int fromType, int waringType, String color) {
this.fromType = fromType;
this.waringType = waringType;
this.color = color;
}
public static String getTestModelColor(int fromType, int waringType) {
for (Car3DTestModelColor value : Car3DTestModelColor.values()) {
if (value.fromType == fromType && value.waringType == waringType) {
return value.color;
}
}
return Normal_Type.color;
}
}
/**
* 展示车辆速度
*
@@ -378,7 +335,8 @@ class BaseDrawer {
return;
}
mogoMarker.setInfoWindowOffset(0, 20);
String text = "speed : " + speedIntVal + "\n" + uuid + "\n" + "type : " + type + "\n" + "heading : " + heading;
// String text = "speed : " + speedIntVal + "\n" + uuid + "\n" + "type : " + type + "\n" + "heading : " + heading;
String text = uuid + " " + (int) heading;
mSpeedView.setText(text);
mogoMarker.updateInfoWindowView(mSpeedView);
}
@@ -455,16 +413,18 @@ class BaseDrawer {
/**
* 使用系统时间或卫星时间计算出动画的运动时间最小值45防止两个点距离过近设置的最小动画执行时间
*
* @param lastSystemTime 上一个点系统时间,误差值
* @param curSystemTime 当前点系统时间,误差值
* @param lastSatelliteTime 上一个点SNTP时间精确值
* @param curSatelliteTime 当前点SNTP时间精确值
* @return 动画运动时间
*/
public long computeAnimDuration(long lastSystemTime, long curSystemTime, long lastSatelliteTime, long curSatelliteTime) {
long systemTimeInterval = curSystemTime - lastSystemTime;
long satelliteTimeInterval = curSatelliteTime - lastSatelliteTime;
long interval = systemTimeInterval < satelliteTimeInterval || satelliteTimeInterval == 0 ? systemTimeInterval : satelliteTimeInterval;
public long computeAnimDuration(long lastSatelliteTime, long curSatelliteTime) {
if (lastSatelliteTime == 0 || curSatelliteTime == 0) {
Log.d("ADAS动画数据", "卫星时间存在错误");
return 45;
}
long interval = curSatelliteTime - lastSatelliteTime;
Log.d("ADAS动画数据", "lastSatelliteTime : " + lastSatelliteTime +
" ---- curSatelliteTime : " + curSatelliteTime + " ===== 插值 " + interval);
if (interval < 45) {
interval = 45;
}

View File

@@ -265,7 +265,7 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
while (iterator.hasNext()) {
SocketDownData.CloudRoadDataProto result = iterator.next();
long internal = result.getSatelliteTime() - Long.parseLong(adasControllerApi.getSatelliteTime());
if (internal > 300) {
if (internal > 3000) {
iterator.remove();
}
}
@@ -320,7 +320,7 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
mLastPositions.put(uniqueKey, cloudRoadData);
if (useCache) {
long interval = computeAnimDuration(lastPosition.getSystemTime(), cloudRoadData.getSystemTime(), lastPosition.getSatelliteTime(), cloudRoadData.getSatelliteTime());
long interval = computeAnimDuration(lastPosition.getSatelliteTime(), cloudRoadData.getSatelliteTime());
final MogoLatLng point = new MogoLatLng(cloudRoadData.getWgslat(), cloudRoadData.getWgslon());
long cost = System.currentTimeMillis() - start;