From 4ea5137cdfb939131dc459e76d7cca5e6588f054 Mon Sep 17 00:00:00 2001 From: liujing Date: Thu, 15 Apr 2021 17:58:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BE=A7=E6=96=B9=E8=AF=86=E5=88=AB=E7=89=A9?= =?UTF-8?q?=E4=B8=8E=E9=A2=84=E7=A2=B0=E6=92=9E=E7=82=B9=E4=B9=8B=E9=97=B4?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=AE=AD=E5=A4=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/gradle.xml | 1 - .../common/constants/AdasRecognizedType.java | 10 ++++-- .../common/drawer/V2XWarnDataDrawer.java | 10 ++---- .../impl/MoGoV2XCloundDataManager.java | 34 +++++++++++++------ .../res/raw/scenario_warning_event_data.json | 2 +- 5 files changed, 35 insertions(+), 22 deletions(-) diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 4ff10f68a5..83405b8de1 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -91,7 +91,6 @@ diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/constants/AdasRecognizedType.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/constants/AdasRecognizedType.java index 30182b7620..7758ceb9eb 100644 --- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/constants/AdasRecognizedType.java +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/constants/AdasRecognizedType.java @@ -23,7 +23,11 @@ enum AdasRecognizedType { //bus classIdTrafficBus( "traffic_bus", 6 ), //truck - classIdTrafficTruck( "traffic_truck", 8 ); + classIdTrafficTruck( "traffic_truck", 8 ), + //stopLine + classIdStopLine("warning_stop_line",9), + //预警箭头 + classIdWarningArrows("warning_arrows",10); AdasRecognizedType( int code ) { this.code = code; @@ -45,8 +49,10 @@ enum AdasRecognizedType { classIdMoto, classIdTrafficSign, classIdTrafficBus, - null, classIdTrafficTruck, + classIdStopLine, + classIdWarningArrows, + null, }; public String getRes() { 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 b0cc4aba36..630d9d5d2d 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 @@ -125,17 +125,13 @@ public class V2XWarnDataDrawer extends BaseDrawer implements IMogoStatusChangedL return marker; } - public void drawerMarkerWithLocation(MarkerShowEntity markerShowEntity, MogoLatLng location) { + public void drawerArrowsMarkerWithLocation(MogoLatLng location, String markerType, int type) { MogoMarkerOptions options = new MogoMarkerOptions() - .object(markerShowEntity) .latitude(location.getLat()) .longitude(location.getLon()); - IMarkerView iMarkerView = MapMarkerAdapter.getMarkerView(mContext, markerShowEntity, options); - options.icon3DRes(getModelRes(2)); //TODO - + options.icon3DRes(getModelRes(type)); //TODO options.anchorColor("#FB3C3CFF"); //红色#FF3036 蓝色:#256BFF - IMogoMarker marker = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager(mContext).addMarker(markerShowEntity.getMarkerType(), options); - iMarkerView.setMarker(marker); + IMogoMarker marker = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager(mContext).addMarker(markerType, options); marker.setToTop(); } diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/manager/impl/MoGoV2XCloundDataManager.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/manager/impl/MoGoV2XCloundDataManager.java index f65be53a7c..02939d2583 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/manager/impl/MoGoV2XCloundDataManager.java +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/manager/impl/MoGoV2XCloundDataManager.java @@ -10,11 +10,13 @@ import com.mogo.map.MogoLatLng; import com.mogo.map.navi.IMogoCarLocationChangedListener2; import com.mogo.map.overlay.IMogoPolyline; import com.mogo.module.common.MogoApisHandler; +import com.mogo.module.common.constants.AdasRecognizedType; import com.mogo.module.common.drawer.V2XWarnDataDrawer; import com.mogo.module.common.entity.MarkerShowEntity; import com.mogo.module.common.entity.V2XWarningEntity; import com.mogo.module.common.utils.Trigonometric; import com.mogo.module.service.MarkerServiceHandler; +import com.mogo.module.service.ServiceConst; import com.mogo.module.service.receiver.MogoReceiver; import com.mogo.module.v2x.MoGoV2XServicePaths; import com.mogo.module.v2x.V2XConst; @@ -35,6 +37,7 @@ import static com.mogo.module.v2x.V2XServiceManager.getContext; */ @Route(path = MoGoV2XServicePaths.PATH_V2X_WARN_CLOUND_DATA_MANAGER) public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMogoCarLocationChangedListener2 { + private static String WARNING_ARROWS = "WARNING_ARROWS"; private V2XWarningEntity mCloundWarningInfo; private static String TAG = "MoGoV2XCloundDataManager"; private boolean isSelfLineClear; @@ -44,6 +47,7 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLat(), MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLon() ); + private MogoLatLng middleLocationInStopLine; private static long showTime = 0; @@ -67,14 +71,14 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog isFirstLocation = false; if (cloundWarningInfo.getDirection() == 1) { //前方 - MogoLatLng startLatLng = getMiddleLocationInStopLine(); - MogoLatLng warningLocation = Trigonometric.getNewLocation(startLatLng, 80, cloundWarningInfo.getAngle()); + middleLocationInStopLine = getMiddleLocationInStopLine(); + MogoLatLng warningLocation = Trigonometric.getNewLocation(middleLocationInStopLine, 30, cloundWarningInfo.getAngle()); //停止线前方画线 WorkThreadHandler.getInstance().postDelayed(() -> { //二轮车和行人的渲染和移动 V2XWarnDataDrawer.getInstance().renderWarnData(cloundWarningInfo); //绘制识别物与交汇点连线,并且更新连线数据 - drawStopLine(cloundWarningInfo, startLatLng, warningLocation); + drawStopLine(cloundWarningInfo, middleLocationInStopLine, warningLocation); //添加停止线marker handleStopLine(); }, 500); @@ -160,10 +164,10 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog private void drawOtherObjectLine(V2XWarningEntity info) { if (info != null) { IMogoPolyline polyLine = V2XServiceManager.getMoGoPersonWarnPolylineManager().getMogoPersonWarnPolyline(); - MogoLatLng startLatlng = new MogoLatLng(info.getLat(), info.getLon()); - MogoLatLng endLatlng = new MogoLatLng(info.getCollisionLat(), info.getCollisionLon()); - float distance = CoordinateUtils.calculateLineDistance(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat); - MogoLatLng addMiddleLoc = Trigonometric.getNewLocation(startLatlng, distance / 2, mCloundWarningInfo.getAngle()); + MogoLatLng startLatlng = new MogoLatLng(info.getLat(), info.getLon());//识别物坐标 + MogoLatLng endLatlng = new MogoLatLng(info.getCollisionLat(), info.getCollisionLon());//预碰撞点坐标 + float distance = CoordinateUtils.calculateLineDistance(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat);//识别物到碰撞点之间的距离 + MogoLatLng addMiddleLoc = Trigonometric.getNewLocation(startLatlng, distance / 2, mCloundWarningInfo.getAngle());//补点 if (polyLine != null) { Log.d(V2XConst.LOG_NAME_WARN, "polyLine != null"); polyLine.setPoints(Arrays.asList(startLatlng, addMiddleLoc, endLatlng)); @@ -180,6 +184,8 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog Log.d(V2XConst.LOG_NAME_WARN, "drawOtherObjectLine width = " + info.getRoadwidth()); lineInfo.setWidth(info.getRoadwidth() * 10 + 5); V2XServiceManager.getMoGoPersonWarnPolylineManager().drawPersonWarnPolyline(getContext(), lineInfo); + //识别物到预碰撞点之间的箭头 + addArrows(startLatlng, endLatlng); } } else { Log.e(V2XConst.LOG_NAME_WARN, "info == null"); @@ -189,17 +195,22 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog //侧面目标物与碰撞点之间添加多个小箭头 private void addArrows(MogoLatLng startLatLng, MogoLatLng endLatLng) { - MarkerShowEntity markerShowEntity = new MarkerShowEntity(); float distance = CoordinateUtils.calculateLineDistance( startLatLng.lon, startLatLng.lat, endLatLng.lon, endLatLng.lat); + Log.d(TAG, "添加小箭头--目标物与预碰撞点之间的距离是" + String.valueOf(distance)); if (distance > 5) { int count = (int) (distance / 5); - for (int i = 0; i < count; i++) { + for (int i = 0; i < count - 1; i++) { MogoLatLng newLo = Trigonometric.getNewLocation( - startLatLng, 5 * i, mCloundWarningInfo.getAngle()); - V2XWarnDataDrawer.getInstance().drawerMarkerWithLocation(markerShowEntity, newLo); + startLatLng, 5 * (i + 1), 120); + V2XWarnDataDrawer.getInstance().drawerArrowsMarkerWithLocation(newLo, WARNING_ARROWS, 10); } } + //延迟3秒清理线 + UiThreadHandler.postDelayed(() -> { + V2XServiceManager.getMarkerManager().removeMarkers(WARNING_ARROWS); + }, showTime); + } @Override @@ -240,6 +251,7 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog MogoLatLng endLatlng = null; MogoLatLng addMiddleLoc = null; if (!isFirstLocation) { + //自车位置 startLatlng = new MogoLatLng(latLng.getLatitude(), latLng.getLongitude()); carLocation = getMogoLat(new MogoLatLng(latLng.getLatitude(), latLng.getLongitude())); endLatlng = new MogoLatLng(mCloundWarningInfo.getDirection() == 1 ? carLocation.lat : mCloundWarningInfo.getCollisionLat(), diff --git a/modules/mogo-module-v2x/src/main/res/raw/scenario_warning_event_data.json b/modules/mogo-module-v2x/src/main/res/raw/scenario_warning_event_data.json index dd781a966a..0333d06e79 100644 --- a/modules/mogo-module-v2x/src/main/res/raw/scenario_warning_event_data.json +++ b/modules/mogo-module-v2x/src/main/res/raw/scenario_warning_event_data.json @@ -17,7 +17,7 @@ ], "from": 1, "angle": 0, - "direction": 1, + "direction": 2, "speed": 11.108121, "targetColor": "#FF4040", "stopLineDistance": 60,