diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/V2XWarnDataDrawer.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/V2XWarnDataDrawer.java index 2ef39c0274..0a89862ea9 100644 --- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/V2XWarnDataDrawer.java +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/V2XWarnDataDrawer.java @@ -74,7 +74,7 @@ public class V2XWarnDataDrawer extends BaseDrawer implements IMogoStatusChangedL /** - * 绘制行人和二轮车,前方和左右 + * 识别物移动 * * @param data */ @@ -87,12 +87,10 @@ public class V2XWarnDataDrawer extends BaseDrawer implements IMogoStatusChangedL markerShowEntity.setMarkerLocation(location); markerShowEntity.setMarkerType(TYPE_MARKER_CLOUD_WARN_DATA); IMogoMarker marker = drawMarker(markerShowEntity, modeResType(data.getType())); - //识别物 - marker.addDynamicAnchorPosition(new MogoLatLng(data.getCollisionLat(), data.getCollisionLon()), (float) data.getHeading(), 5000); - //移动完成以后,3s后消失 + marker.addDynamicAnchorPosition(new MogoLatLng(data.getCollisionLat(), data.getCollisionLon()), (float) data.getHeading(), (long) (data.getShowTime() * 1000)); UiThreadHandler.postDelayed(() -> { marker.remove(); - }, data.getShowTime()); + }, data.getShowTime() * 1000); } diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/warning/V2XWarningMarker.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/warning/V2XWarningMarker.java index 7be8e07801..b4edb1fb66 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/warning/V2XWarningMarker.java +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/warning/V2XWarningMarker.java @@ -27,6 +27,7 @@ import com.mogo.module.v2x.scenario.view.IV2XMarker; import com.mogo.utils.UiThreadHandler; import com.mogo.utils.ViewUtils; import com.mogo.utils.WorkThreadHandler; +import com.mogo.utils.network.utils.Util; import java.util.ArrayList; import java.util.Arrays; @@ -59,7 +60,7 @@ public class V2XWarningMarker implements IV2XMarker { * 自车前方的点,在停止线上--通过自车位置与距离停止线之间的距离计算 * */ private MogoLatLng middleLocationInStopLine = new MogoLatLng(0, 0); - private static long showTime = 5000; + private static long showTime = 6000; private float bearing; @Override @@ -75,40 +76,38 @@ public class V2XWarningMarker implements IV2XMarker { } public void drawLineWithEntity() { - showTime = mCloundWarningInfo.getShowTime() > 0 ? mCloundWarningInfo.getShowTime() * 1000 : 5000; + showTime = mCloundWarningInfo.getShowTime() > 0 ? mCloundWarningInfo.getShowTime() * 1000 : 6000; Log.d(TAG, "显示时间为++" + String.valueOf(showTime) + "识别物类型:" + String.valueOf(mCloundWarningInfo.getType())); - pointsBetween(); + fillPointOnStopLine(); bearing = V2XLocationListener.getInstance().getLastCarLocation().getBearing(); isSelfLineClear = false; isFirstLocation = false; - V2XServiceManager.getMarkerManager().removeMarkers(WARNING_ARROWS); - if (fillPoints.size() > 0) { //存在停止线的情况 TODO + if (fillPoints.size() > 0) { + //存在停止线的情况 自车与停止线之间绘制蓝色安全线 停止线向前50m绘制红色预警线 + //先获取自车与停止线之间的点 middleLocationInStopLine = getMiddleLocationInStopLine(); - //如果是正前方类型,红色绘制区域从停止线向前绘制50米 MogoLatLng warningLocation = Trigonometric.getNewLocation(middleLocationInStopLine, 50, mCloundWarningInfo.getAngle()); //停止线前方画线 WorkThreadHandler.getInstance().postDelayed(() -> { - //二轮车和行人的渲染和移动 - V2XServiceManager.getMarkerManager().removeMarkers(TYPE_MARKER_CLOUD_WARN_DATA); - V2XWarnDataDrawer.getInstance().renderWarnData(mCloundWarningInfo); - //绘制识别物与交汇点连线,并且更新连线数据 - drawRedWarningLineFrontOfStopLine(mCloundWarningInfo, middleLocationInStopLine, - warningLocation); - //添加停止线marker - handleStopLine(); if (carLocation.lat != 0 && carLocation.lon != 0) { - //自车画线 + //自车与停止线直线绘制蓝色预警线 drawSelfCarLine(carLocation.lon, carLocation.lat, bearing); } else { Log.d(TAG, "自车定位数据为空carLocation == null"); } + //二轮车和行人的渲染和移动 + V2XServiceManager.getMarkerManager().removeMarkers(TYPE_MARKER_CLOUD_WARN_DATA); + //停止线向前方50m绘制红色预警线 + drawRedWarningLineFrontOfStopLine(mCloundWarningInfo, middleLocationInStopLine, + warningLocation); + V2XWarnDataDrawer.getInstance().renderWarnData(mCloundWarningInfo); + //添加停止线marker + handleStopLine(); }, 0); - UiThreadHandler.postDelayed(() -> { - clearAllLine(); - }, showTime); + clearAllLine(); } else { //无停止线 WorkThreadHandler.getInstance().postDelayed(() -> { @@ -116,29 +115,23 @@ public class V2XWarningMarker implements IV2XMarker { drawOtherObjectLine(mCloundWarningInfo); //二轮车和行人的渲染和移动 V2XServiceManager.getMarkerManager().removeMarkers(TYPE_MARKER_CLOUD_WARN_DATA); - V2XWarnDataDrawer.getInstance().renderWarnData(mCloundWarningInfo); //车辆静止的时候 if (carLocation.lat != 0 && carLocation.lon != 0) { drawSelfCarLine(carLocation.lon, carLocation.lat, bearing); } else { Log.d(TAG, "数据为空carLocation == null"); } + V2XWarnDataDrawer.getInstance().renderWarnData(mCloundWarningInfo); }, 0); - //延迟3秒清理线 - UiThreadHandler.postDelayed(() -> { - clearAllLine(); - }, showTime); + clearAllLine(); } //预警蒙层 MarkerServiceHandler.getApis().getV2XListenerManager().warningChangedForListenerWithDirection (mCloundWarningInfo.getDirection(), MogoReceiver.ACTION_V2X_FRONT_WARNING); } - /** - * 场景如:车辆行驶正前方绘制红色区域(停止线继续前行的预警区域) TODO 需要实时给行人当前位置 - */ private void drawRedWarningLineFrontOfStopLine(V2XWarningEntity info, MogoLatLng startLatLng, MogoLatLng mogoLatLng) { if (info != null) { @@ -148,7 +141,7 @@ public class V2XWarningMarker implements IV2XMarker { endLatlng.lon, endLatlng.lat); MogoLatLng addMiddleLoc = Trigonometric.getNewLocation(startLatLng, distance / 2, mCloundWarningInfo.getAngle()); - Log.d(TAG, "红色区域起始点 = " + startLatLng.lon + "," + startLatLng.lat + + Log.d(TAG, "停止线前方50m区域的三个坐标点是:" + startLatLng.lon + "," + startLatLng.lat + "中间点坐标:" + addMiddleLoc.lon + "," + addMiddleLoc.lat + "终点" + endLatlng.lon + "," + endLatlng.lat); if (polyLine != null) { @@ -167,25 +160,33 @@ public class V2XWarningMarker implements IV2XMarker { lineInfo.setWidth(info.getRoadwidth() * 14 + 5); V2XServiceManager.getMoGoStopPolylineManager().drawStopPolyline(getContext(), lineInfo); } - UiThreadHandler.postDelayed(() -> { - clearAllLine(); - }, showTime); + clearAllLine(); } else { clearAllLine(); } } public void clearAllLine() { - V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine(); - V2XServiceManager.getMoGoWarnPolylineManager().clearLine(); - V2XServiceManager.getMoGoStopPolylineManager().clearLine(); - isSelfLineClear = true; + UiThreadHandler.postDelayed(() -> { + Log.d(TAG, "清除所有预警线的时间是:" + String.valueOf(System.currentTimeMillis())); + //清除识别物到碰撞点预警线 + V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine(); + //清除车到碰撞点预警线 + V2XServiceManager.getMoGoWarnPolylineManager().clearLine(); + //清除停止线 + V2XServiceManager.getMoGoStopPolylineManager().clearLine(); + //清除小箭头 + V2XServiceManager.getMarkerManager().removeMarkers(WARNING_ARROWS); + //清除停止线 + V2XServiceManager.getMarkerManager().removeMarkers(TYPE_MARKER_CLOUD_STOP_LINE_DATA); + isSelfLineClear = true; + }, showTime); } /** * 补点后的停止线经纬度合集 */ - public void pointsBetween() { + public void fillPointOnStopLine() { try { fillPoints.clear(); List stopLines = mCloundWarningInfo.getStopLines(); @@ -223,13 +224,11 @@ public class V2XWarningMarker implements IV2XMarker { entity.setLat(latLng.lat); entity.setLon(latLng.lon); entity.heading = mCloundWarningInfo.heading; + Log.d(TAG, "绘制停止线+time=" + String.valueOf(System.currentTimeMillis())); V2XWarnDataDrawer.getInstance().renderStopLineData(entity); } + clearAllLine(); } - //移动完成以后,3s后消失 - UiThreadHandler.postDelayed(() -> { - V2XServiceManager.getMarkerManager().removeMarkers(TYPE_MARKER_CLOUD_STOP_LINE_DATA); - }, mCloundWarningInfo.getShowTime()); } catch (Exception e) { e.printStackTrace(); } @@ -256,8 +255,7 @@ public class V2XWarningMarker implements IV2XMarker { } /** - * 自车为起点绘制(根据设计,前方行人/弱势交通参与者预警 getDirection() == ALERT_THE_FRONT_CRASH_WARNING_TOP - * 自车与停止线之间为蓝色预警;其他侧方预警自车与预碰撞点之间显示红色预警) + * 自车与停止线之间为蓝色预警 * lon 自车经度 * lat 自车纬度 */ @@ -274,7 +272,7 @@ public class V2XWarningMarker implements IV2XMarker { isFirstLocation = true; } //绘制线的终点(在停止线上或者预碰撞点上) - endLatlng = new MogoLatLng(mCloundWarningInfo.getDirection() == ALERT_THE_FRONT_CRASH_WARNING_TOP ? + endLatlng = new MogoLatLng(mCloundWarningInfo.getStopLines().size() > 0 ? middleLocationInStopLine.lat : mCloundWarningInfo.getCollisionLat(), mCloundWarningInfo.getDirection() == ALERT_THE_FRONT_CRASH_WARNING_TOP ? middleLocationInStopLine.lon : mCloundWarningInfo.getCollisionLon()); @@ -292,7 +290,7 @@ public class V2XWarningMarker implements IV2XMarker { mogoPolyline.setTransparency(0.5f); } else { DrawLineInfo info = new DrawLineInfo(); // 对象 - Log.d(TAG, "安全区域的画线点为" + "起点:" + startLatlng + "中间点:" + addMiddleLoc + "终点:" + endLatlng); + Log.d(TAG, "安全区域蓝色预警线" + "起点:" + startLatlng + "中间点:" + addMiddleLoc + "终点:" + endLatlng); List locations = new ArrayList(); locations.add(startLatlng); locations.add(addMiddleLoc); @@ -301,11 +299,10 @@ public class V2XWarningMarker implements IV2XMarker { info.setHeading(bearing); info.setWidth(mCloundWarningInfo.getRoadwidth() * 14 + 5); info.setDirection(mCloundWarningInfo.getDirection()); + Log.d(TAG, "绘制自车与碰撞点之间的预警线+time=" + String.valueOf(System.currentTimeMillis())); V2XServiceManager.getMoGoWarnPolylineManager().drawWarnPolyline(getContext(), info); } - UiThreadHandler.postDelayed(() -> { - clearAllLine(); - }, showTime+3000); + clearAllLine(); } else { clearAllLine(); } @@ -328,6 +325,8 @@ public class V2XWarningMarker implements IV2XMarker { polyLine.setPoints(Arrays.asList(startLatlng, addMiddleLoc, endLatlng)); polyLine.setTransparency(0.5f); } else { + //识别物到预碰撞点之间的箭头 + addArrows(startLatlng, endLatlng); DrawLineInfo lineInfo = new DrawLineInfo(); Log.d(TAG, "目标物与预碰撞点画线点为" + "起点:" + startLatlng + "中间点:" + addMiddleLoc + "终点:" + endLatlng); List locations = new ArrayList(); @@ -339,8 +338,6 @@ public class V2XWarningMarker implements IV2XMarker { Log.d(V2XConst.LOG_NAME_WARN, "drawOtherObjectLine width = " + info.getRoadwidth()); lineInfo.setWidth(info.getRoadwidth() * 14 + 5); V2XServiceManager.getMoGoPersonWarnPolylineManager().drawPersonWarnPolyline(getContext(), lineInfo); - //识别物到预碰撞点之间的箭头 - addArrows(startLatlng, endLatlng); } } else { Log.e(V2XConst.LOG_NAME_WARN, "info == null"); @@ -363,42 +360,9 @@ public class V2XWarningMarker implements IV2XMarker { V2XWarnDataDrawer.getInstance().drawerArrowsMarkerWithLocation(newLo, WARNING_ARROWS, 10, new Double(rotate).intValue()); } } - //延迟3秒清理线 - UiThreadHandler.postDelayed(() -> { - V2XServiceManager.getMarkerManager().removeMarkers(WARNING_ARROWS); - }, showTime); } - /* - * 2D资源绘制停止线 暂时不需要 - * */ - private void drawStopLineWith2Resource() { - MogoLatLng carlo = mCloundWarningInfo.getCarLocation(); - if (carlo == null) { - double lon = MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLon(); - double lat = MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLat(); - carlo = new MogoLatLng(lat, lon); - } - //自车行驶方向的前方*米的经纬度,该经纬度在停止线上 - MogoLatLng drawStopLineLon = Trigonometric.getNewLocation(carlo, mCloundWarningInfo.getStopLineDistance(), mCloundWarningInfo.getAngle()); - Log.d(TAG, "2D资源绘" + drawStopLineLon); - MogoMarkerOptions optionsRipple = new MogoMarkerOptions() - .latitude(drawStopLineLon.getLat()) - .longitude(drawStopLineLon.getLon()) - .anchor(1.0f, 1.0f) - .zIndex(MarkerDrawer.MARKER_Z_INDEX_HIGH); - - optionsRipple - .icon(ViewUtils.fromView(new EmptyMarkerView(V2XServiceManager.getContext()))); - IMogoMarker stopLine = V2XServiceManager.getMarkerManager().addMarker(TYPE_MARKER_CLOUD_STOP_LINE_DATA, optionsRipple); - stopLine.setInfoWindowAdapter(new SimpleWindow3DAdapter(new V2XFrontTargetMarkerView(V2XServiceManager.getContext()))); - stopLine.showInfoWindow(); - UiThreadHandler.postDelayed(() -> { - stopLine.hideInfoWindow(); - }, showTime); - } - public void onCarLocationChanged2(Location latLng) { carLocation = new MogoLatLng(latLng.getLatitude(), latLng.getLongitude()); if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() && isSelfLineClear == false) { diff --git a/modules/mogo-module-v2x/src/main/res/raw/scenario_warning_event_data_left.json b/modules/mogo-module-v2x/src/main/res/raw/scenario_warning_event_data_left.json index 6fe3edc623..eb56e7cb5d 100644 --- a/modules/mogo-module-v2x/src/main/res/raw/scenario_warning_event_data_left.json +++ b/modules/mogo-module-v2x/src/main/res/raw/scenario_warning_event_data_left.json @@ -16,6 +16,6 @@ "stopLineDistance": 60, "warningContent": "注意自行车", "heading": 0, - "showTime": 3, + "showTime": 6, "roadwidth": 4.0 } \ No newline at end of file diff --git a/modules/mogo-module-v2x/src/main/res/raw/scenario_warning_event_data_pedestrians.json b/modules/mogo-module-v2x/src/main/res/raw/scenario_warning_event_data_pedestrians.json index 0a48613c3c..77ca4304dd 100644 --- a/modules/mogo-module-v2x/src/main/res/raw/scenario_warning_event_data_pedestrians.json +++ b/modules/mogo-module-v2x/src/main/res/raw/scenario_warning_event_data_pedestrians.json @@ -24,6 +24,6 @@ "stopLineDistance": 60, "warningContent": "小心行人", "heading": 0, - "showTime": 3, + "showTime": 6, "roadwidth": 4.0 } \ No newline at end of file diff --git a/modules/mogo-module-v2x/src/main/res/raw/scenario_warning_event_data_right.json b/modules/mogo-module-v2x/src/main/res/raw/scenario_warning_event_data_right.json index 6bba8cf023..95f60d2eb8 100644 --- a/modules/mogo-module-v2x/src/main/res/raw/scenario_warning_event_data_right.json +++ b/modules/mogo-module-v2x/src/main/res/raw/scenario_warning_event_data_right.json @@ -15,6 +15,6 @@ "stopLineDistance": 60, "warningContent": "注意摩托车", "heading": 0, - "showTime": 3, + "showTime": 6, "roadwidth": 4.0 }