This commit is contained in:
zhongchao
2021-04-01 17:34:35 +08:00
13 changed files with 184 additions and 122 deletions

View File

@@ -7,12 +7,18 @@ import com.mogo.map.MogoLatLng;
import com.mogo.map.overlay.IMogoPolyline;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.drawer.AdasRecognizedResultDrawer;
import com.mogo.module.common.entity.V2XMessageEntity;
import com.mogo.module.common.entity.V2XWarningEntity;
import com.mogo.module.v2x.entity.model.DrawLineInfo;
import com.mogo.module.v2x.listener.V2XMessageListener_401011;
import com.mogo.module.v2x.listener.V2XWarnMessageListener;
import com.mogo.module.v2x.utils.V2XUtils;
import com.mogo.realtime.entity.ADASRecognizedResult;
import com.mogo.utils.UiThreadHandler;
import com.mogo.utils.logger.Logger;
import com.mogo.utils.network.utils.GsonUtil;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
@@ -57,6 +63,34 @@ public class V2XWaringManager {
registerWarnListener();
// handleAdasData();
}
/**
* TODO 测试数据
*/
private void testData() {
try {
InputStream inputStream = V2XUtils.getApp()
.getResources()
.openRawResource(R.raw.scenario_warning_event_data);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int len = -1;
byte[] buffer = new byte[1024];
while ((len = inputStream.read(buffer)) != -1) {
baos.write(buffer, 0, len);
}
inputStream.close();
// 加载数据源
V2XWarningEntity warningEntity = GsonUtil.objectFromJson(baos.toString(), V2XWarningEntity.class);
V2XServiceManager.getMoGoV2XCloundDataManager().analysisV2XCloundDataEvent(warningEntity);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
@@ -93,55 +127,64 @@ public class V2XWaringManager {
* 处理adas返回的数据
*/
public void handleAdasData() {
Logger.d(V2XConst.LOG_NAME_WARN, "V2XWaringManager ---- handleAdasData ");
Log.d(V2XConst.LOG_NAME_WARN, "V2XWaringManager ---- handleAdasData ");
//测试数据
testData();
// 绘制连接线
DrawLineInfo info1 = new DrawLineInfo();
MogoLatLng startLatlng1 = new MogoLatLng(39.968919,116.407642);
MogoLatLng endLatlng1 = new MogoLatLng(40.010906,116.423821);
info1.setHeading(10);
info1.setStartLocation(startLatlng1);
info1.setEndLocation(endLatlng1);
// DrawLineInfo info1 = new DrawLineInfo();
// MogoLatLng startLatlng1 = new MogoLatLng(39.968919,116.407642);
// MogoLatLng endLatlng1 = new MogoLatLng(40.010906,116.423821);
// info1.setHeading(10);
// info1.setStartLocation(startLatlng1);
// info1.setEndLocation(endLatlng1);
//
// //只有在3d模型下才有值
// if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() ) {
// float roadWidth = V2XServiceManager.getMapUIController().getRoadWidth(116.411194781192,
// 39.9808395231999, 10, true, true);
// float roadWidth = V2XServiceManager.getMapUIController().getRoadWidth(116.411198243370,
// 39.9809517154582, (float) 3.13919341919472 , true, true);
// Log.d(V2XConst.LOG_NAME_WARN, "roadWidth = " + roadWidth);
// info1.setWidth(roadWidth);
// }
//
// V2XServiceManager.getMoGoWarnPolylineManager().drawWarnPolyline(getContext(), info1);
//
// //延迟3秒清理线
// UiThreadHandler.postDelayed( () -> {
// V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
// }, 3000 );
V2XServiceManager.getMoGoWarnPolylineManager().drawWarnPolyline(getContext(), info1);
// adas 每隔一秒传递的他车或行人数据
V2XServiceManager.getmIMogoADASController().addAdasRecognizedDataCallback(resultList -> {
// 绘制近景识别到的车辆,行人和二轮车
AdasRecognizedResultDrawer.getInstance().renderAdasRecognizedResult( resultList );
//清理
V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
// 绘制连接线
DrawLineInfo info = new DrawLineInfo();
MogoLatLng startLatlng = new MogoLatLng(39.969247,116.407299);
MogoLatLng endLatlng = new MogoLatLng(39.971089,116.407384);
info.setStartLocation(startLatlng);
info.setEndLocation(endLatlng);
V2XServiceManager.getMoGoWarnPolylineManager().drawWarnPolyline(mContext, info);
//更新数据
for (ADASRecognizedResult result : resultList) {
MogoLatLng latLng = new MogoLatLng(result.lat, result.lon);
lonLats.add(latLng);
}
IMogoPolyline mMogoPolyline = V2XServiceManager.getMoGoWarnPolylineManager().getMogoWarnPolyline();
mMogoPolyline.setPoints(lonLats);
} );
double lon = MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLon();
double lat = MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLat();
Log.d(V2XConst.LOG_NAME_WARN, "lon = " + lon + "----lat = " + lat);
// adas 每隔一秒传递的他车或行人数据 TODO
// V2XServiceManager.getmIMogoADASController().addAdasRecognizedDataCallback(resultList -> {
// // 绘制近景识别到的车辆,行人和二轮车
// AdasRecognizedResultDrawer.getInstance().renderAdasRecognizedResult( resultList );
//
// //清理
// V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
//
// // 绘制连接线
// DrawLineInfo info = new DrawLineInfo();
// MogoLatLng startLatlng = new MogoLatLng(39.969247,116.407299);
// MogoLatLng endLatlng = new MogoLatLng(39.971089,116.407384);
// info.setStartLocation(startLatlng);
// info.setEndLocation(endLatlng);
// V2XServiceManager.getMoGoWarnPolylineManager().drawWarnPolyline(mContext, info);
//
// //更新数据
// for (ADASRecognizedResult result : resultList) {
// MogoLatLng latLng = new MogoLatLng(result.lat, result.lon);
// lonLats.add(latLng);
// }
// IMogoPolyline mMogoPolyline = V2XServiceManager.getMoGoWarnPolylineManager().getMogoWarnPolyline();
// mMogoPolyline.setPoints(lonLats);
//
// } );
//
//adas自车定位
// double lon = MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLon();
// double lat = MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLat();
}

View File

@@ -1,6 +1,9 @@
package com.mogo.module.v2x.listener;
import android.util.Log;
import com.mogo.module.common.entity.V2XWarningEntity;
import com.mogo.module.v2x.V2XConst;
import com.mogo.module.v2x.V2XServiceManager;
import com.mogo.module.v2x.utils.V2XUtils;
import com.mogo.service.connection.IMogoOnMessageListener;
@@ -22,6 +25,7 @@ public class V2XWarnMessageListener implements IMogoOnMessageListener<V2XWarning
// 解析不同的Marker类型然后对应的进行绘制
if (info != null) {
// 解析存储道路事件 liyz
Log.d(V2XConst.LOG_NAME_WARN, "V2XWarnMessageListener onMsgReceived ----> ");
V2XServiceManager.getMoGoV2XCloundDataManager().analysisV2XCloundDataEvent(info);
}
});

View File

@@ -16,6 +16,7 @@ import com.mogo.module.v2x.V2XConst;
import com.mogo.module.v2x.V2XServiceManager;
import com.mogo.module.v2x.entity.model.DrawLineInfo;
import com.mogo.module.v2x.manager.IMoGoV2XCloundDataManager;
import com.mogo.utils.UiThreadHandler;
import java.util.Arrays;
@@ -37,13 +38,11 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
mCloundWarningInfo = cloundWarningInfo;
//TODO 根据判断条件,决定是否画线或者删除线
//绘制识别物与交汇点连线,并且更新连线数据
drawOtherObjectLine(cloundWarningInfo);
//绘制识别物与交汇点连线,并且更新连线数据 TODO VR模式无法获取道路宽度
// drawOtherObjectLine(cloundWarningInfo);
//二轮车和行人的移动和渲染
// SnapshotSetDataDrawer.getInstance().renderWarnData(cloundWarningInfo);
SnapshotSetDataDrawer.getInstance().renderWarnData(cloundWarningInfo);
}
/**
@@ -53,20 +52,18 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
IMogoPolyline polyLine = V2XServiceManager.getMoGoPersonWarnPolylineManager().getMogoPersonWarnPolyline();
if (info != null) {
if (polyLine != null) {
Log.d(V2XConst.LOG_NAME_WARN, "polyLine != null");
polyLine.setPoints(Arrays.asList(new MogoLatLng(info.getLat(), info.getLon()),
new MogoLatLng(info.getCollisionLat(), info.getCollisionLon())));
} else {
Log.d(V2XConst.LOG_NAME_WARN, "polyLine == null");
DrawLineInfo lineInfo = new DrawLineInfo();
// MogoLatLng startLatlng = new MogoLatLng(39.968919,116.407642);
// MogoLatLng endLatlng = new MogoLatLng(40.010906,116.423821);
MogoLatLng startLatlng = new MogoLatLng(info.getLat(), info.getLon());
MogoLatLng endLatlng = new MogoLatLng(info.getCollisionLat(), info.getCollisionLon());
lineInfo.setStartLocation(startLatlng);
lineInfo.setEndLocation(endLatlng);
lineInfo.setHeading(info.heading);
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() ) {
// float roadWidth = V2XServiceManager.getMapUIController().getRoadWidth(116.411194781192,
// 39.9808395231999, 10, true, true);
float roadWidth = V2XServiceManager.getMapUIController().getRoadWidth(info.getLon(),
info.getLat(), (float) info.heading, true, true);
Log.d(V2XConst.LOG_NAME_WARN, "roadWidth = " + roadWidth);
@@ -74,8 +71,14 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
}
V2XServiceManager.getMoGoPersonWarnPolylineManager().drawPersonWarnPolyline(getContext(), lineInfo);
}
//延迟3秒清理线
UiThreadHandler.postDelayed( () -> {
V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine();
}, 6000 );
} else {
Log.e(V2XConst.LOG_NAME_WARN, "mCloundWarningInfo == null");
Log.e(V2XConst.LOG_NAME_WARN, "info == null");
V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine();
}
@@ -87,7 +90,7 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
}
/**
* 自车定位 移动完成需要 3s消失 TODO
* 自车定位 移动完成需要 3s消失
*/
@Override
public void onCarLocationChanged2(Location latLng) {
@@ -101,19 +104,24 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
new MogoLatLng(mCloundWarningInfo.getCollisionLat(), mCloundWarningInfo.getCollisionLon())));
} else {
Log.e(V2XConst.LOG_NAME_WARN, "V2XServiceManager.getMoGoWarnPolylineManager().getMogoWarnPolyline() == null");
DrawLineInfo info = new DrawLineInfo(); // 对象 TODO
// MogoLatLng startLatlng = new MogoLatLng(39.968919, 116.407642);
// MogoLatLng endLatlng = new MogoLatLng(40.010906, 116.423821);
Log.e(V2XConst.LOG_NAME_WARN, "mogoPolyline == null");
DrawLineInfo info = new DrawLineInfo(); // 对象
MogoLatLng startLatlng = new MogoLatLng(latLng.getLatitude(), latLng.getLongitude());
MogoLatLng endLatlng = new MogoLatLng(mCloundWarningInfo.getCollisionLat(), mCloundWarningInfo.getCollisionLon());
info.setHeading(latLng.getBearing());
info.setStartLocation(startLatlng);
info.setEndLocation(endLatlng);
info.setWidth(60); //TODO
V2XServiceManager.getMoGoWarnPolylineManager().drawWarnPolyline(getContext(), info);
}
//延迟3秒清理线
UiThreadHandler.postDelayed( () -> {
V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
}, 3000 );
} else {
Log.e(V2XConst.LOG_NAME_WARN, "mCloundWarningInfo == null");
Log.e(V2XConst.LOG_NAME_WARN, "onCarLocationChanged2 mCloundWarningInfo == null");
V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
}
}

View File

@@ -42,7 +42,6 @@ public class MoGoWarnPolylineManager implements IMoGoWarnPolylineManager {
// 连接线参数
MogoPolylineOptions options = new MogoPolylineOptions();
List<Integer> colors = new ArrayList<>();
if (info.getType() != null) {
@@ -54,7 +53,7 @@ public class MoGoWarnPolylineManager implements IMoGoWarnPolylineManager {
colors.add(0xFFE32F46);
}
} else {
Log.e(V2XConst.LOG_NAME_WARN, "info.getType() == null ");
Log.e(V2XConst.LOG_NAME_WARN, "drawWarnPolyline info.getType() == null ");
colors.add(0xFFE32F46);
colors.add(0xFFE32F46);
}

View File

@@ -60,11 +60,11 @@ public class V2XPushLiveCarScenario extends AbsV2XScenario<V2XPushMessageEntity>
@Override
public void showWindow() {
if (getV2XWindow() != null) {
ViewGroup.LayoutParams layoutParams =
new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
(int) V2XUtils.getApp().getResources()
.getDimension(R.dimen.v2x_video_window_height));
int width = (int) V2XUtils.getApp().getResources().getDimension(V2XServiceManager.getMoGoStatusManager().isVrMode() ?
R.dimen.module_v2x_event_window_width_vr : R.dimen.module_v2x_event_window_width);
int height = (int) V2XUtils.getApp().getResources().getDimension(V2XServiceManager.getMoGoStatusManager().isVrMode() ?
R.dimen.module_v2x_event_see_live_window_height_vr : R.dimen.module_v2x_event_see_live_window_height);
ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(width, height);
V2XServiceManager
.getMogoTopViewManager()
.addViewNoLinkage(getV2XWindow().getView(), layoutParams, this);

View File

@@ -142,7 +142,7 @@ public class V2XPushLiveCarWindow extends V2XBasWindow implements IV2XWindow<V2X
if (runnableV2XEvent == null) {
runnableV2XEvent = () -> {
//Logger.d(MODULE_NAME, "V2X=== Window 30秒倒计时结束。。。");
// 移出Window详细信息
//移出Window详细信息
//移除窗体
V2XServiceManager
.getMogoTopViewManager()

View File

@@ -73,11 +73,11 @@ public class V2XRoadLiveCarScenario extends AbsV2XScenario<List<V2XEventShowEnti
public void showWindow() {
Log.d(TAG, getV2XWindow().toString());
if (getV2XWindow() != null) {
ViewGroup.LayoutParams layoutParams =
new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
(int) V2XUtils.getApp().getResources()
.getDimension(R.dimen.v2x_video_window_height));
int width = (int) V2XUtils.getApp().getResources().getDimension(V2XServiceManager.getMoGoStatusManager().isVrMode() ?
R.dimen.module_v2x_event_window_width_vr : R.dimen.module_v2x_event_window_width);
int height = (int) V2XUtils.getApp().getResources().getDimension(V2XServiceManager.getMoGoStatusManager().isVrMode() ?
R.dimen.module_v2x_event_see_live_window_height_vr : R.dimen.module_v2x_event_see_live_window_height);
ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(width, height);
V2XServiceManager
.getMogoTopViewManager()
.addViewNoLinkage(getV2XWindow().getView(), layoutParams, this);