Merge remote-tracking branch 'origin/dev2_aiSdk' into dev2_aiSdk

This commit is contained in:
董宏宇
2021-04-01 15:25:24 +08:00
12 changed files with 132 additions and 87 deletions

1
.idea/gradle.xml generated
View File

@@ -91,7 +91,6 @@
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
<option name="useQualifiedModuleNames" value="true" />
</GradleProjectSettings>
</option>
</component>

View File

@@ -18,6 +18,11 @@ class DataTypes {
*/
public static final String TYPE_MARKER_CLOUD_DATA = "TYPE_MARKER_CLOUD_DATA";
/**
* 云端下发数据
*/
public static final String TYPE_MARKER_CLOUD_WARN_DATA = "TYPE_MARKER_CLOUD_WARN_DATA";
/**
* Push 事件场景 VR
*/

View File

@@ -143,43 +143,39 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
* @param data 道路数据
* @return {@link IMogoMarker}
*/
// public IMogoMarker drawWarnDataMarker( V2XWarningEntity data ) {
// if ( data == null ) {
// return null;
// }
//
// MogoMarkerOptions options = new MogoMarkerOptions()
// .owner( DataTypes.TYPE_MARKER_CLOUD_DATA )
// .anchor( 0.5f, 0.5f )
// .rotate( ( float ) data.getHeading() )
// .object( data )
// .gps( true )
// .controlAngle( true )
// .position( new MogoLatLng( data.getWgslat(), data.getWgslon() ) );
// String resIdVal = null;
// if ( MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() ) {
// options.set3DMode( true );
// // TODO: 2021/3/23 后端算法提供显示颜色
// options.anchorColor( getModelRenderColor( data.getType(), data.getSpeed(), data.getWgslon(), data.getWgslat(), data.getHeading() ) );
// int resId = getModelRes( data.getType() );
// resIdVal = resId + "";
public IMogoMarker drawWarnDataMarker( V2XWarningEntity data ) {
if ( data == null ) {
return null;
}
MogoMarkerOptions options = new MogoMarkerOptions()
.owner( DataTypes.TYPE_MARKER_CLOUD_DATA )
.anchor( 0.5f, 0.5f )
.rotate( ( float ) data.getHeading() )
.object( data )
.gps( true )
.controlAngle( true )
.position( new MogoLatLng( data.getLat(), data.getLon()));
String resIdVal = null;
if ( MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() ) {
options.set3DMode( true );
options.anchorColor(data.color);
int resId = getModelRes( data.getType() );
resIdVal = resId + "";
// options.resName( mMarkerCachesResMd5Values.get( resIdVal ) );
// options.icon3DRes( resId );
// } else {
options.icon3DRes( resId );
} else {
// options.set3DMode( false );
// View view = inflateView( data );
// options.icon( view );
// resIdVal = view.getId() + "";
// }
// IMogoMarker marker = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( mContext ).addMarker( DataTypes.TYPE_MARKER_CLOUD_DATA, options );
}
IMogoMarker marker = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( mContext ).addMarker( DataTypes.TYPE_MARKER_CLOUD_DATA, options );
// cacheMarkerIconResMd5Val( resIdVal, marker );
//
// if ( !TextUtils.isEmpty( data.getSn() ) ) {
// bindClickListener( marker );
// }
//
// return marker;
// }
return marker;
}
/**
@@ -187,17 +183,14 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
* @param data
*/
// public void renderWarnData(V2XWarningEntity data ) {
//
// IMogoMarker marker = drawWarnDataMarker(data);
//
// if ( marker == null ) {
// continue;
// }
//
//
// renderSnapshotOneFrame( marker, uniqueKey, cloudRoadData, newMarkersCaches );
//
//
// }

View File

@@ -303,7 +303,6 @@ public class V2XModuleProvider implements
V2XServiceManager.getV2XMarkerService().startAutoRefresh();
// 锁车就是将地图视图移植中心点,因为行驶中的车和地图要相对的跟随
V2XServiceManager.getMapUIController().recoverLockMode();
Log.d(V2XConst.LOG_NAME_WARN, "V2XModuleProvider ------> ");
//注册adas数据通道
V2XWaringManager.getInstance().registerAdasSocketMessage(mContext);
}

View File

@@ -56,7 +56,7 @@ public class V2XWaringManager {
//根据云端,绘制自车和交点,以及行人或二轮车与交点的绘制
registerWarnListener();
handleAdasData();
// handleAdasData();
}
/**
@@ -92,26 +92,35 @@ public class V2XWaringManager {
/**
* 处理adas返回的数据
*/
private void handleAdasData() {
Log.d(V2XConst.LOG_NAME_WARN, "V2XWaringManager ---- handleAdasData ");
public void handleAdasData() {
Logger.d(V2XConst.LOG_NAME_WARN, "V2XWaringManager ---- handleAdasData ");
// 绘制连接线 TODO 来的是列表数据
// 绘制连接线
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);
// if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() ) {
// float roadWidth = V2XServiceManager.getMapUIController().getRoadWidth(116.411194781192,
// 39.9808395231999, 10, true, true);
// Log.d(V2XConst.LOG_NAME_WARN, "roadWidth = " + roadWidth);
// info1.setWidth(roadWidth);
// }
V2XServiceManager.getMoGoWarnPolylineManager().drawWarnPolyline(getContext(), info1);
// adas 每隔一秒传递的他车或行人数据
V2XServiceManager.getmIMogoADASController().addAdasRecognizedDataCallback(resultList -> {
// 绘制近景识别到的车辆,行人和二轮车 TODO
// 绘制近景识别到的车辆,行人和二轮车
AdasRecognizedResultDrawer.getInstance().renderAdasRecognizedResult( resultList );
//清理
V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
// 绘制连接线 TODO 来的是列表数据
// 绘制连接线
DrawLineInfo info = new DrawLineInfo();
MogoLatLng startLatlng = new MogoLatLng(39.969247,116.407299);
MogoLatLng endLatlng = new MogoLatLng(39.971089,116.407384);
@@ -133,15 +142,6 @@ public class V2XWaringManager {
double lat = MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLat();
Log.d(V2XConst.LOG_NAME_WARN, "lon = " + lon + "----lat = " + lat);
//绘制自车数据 liyz
// DrawLineInfo info = new DrawLineInfo();
// MogoLatLng startLatlng = new MogoLatLng(lat,lon); //我的位置
// MogoLatLng endLatlng = new MogoLatLng(39.971089,); //交点位置
// info.setStartLocation(startLatlng);
// info.setEndLocation(endLatlng);
// V2XServiceManager.getMoGoWarnPolylineManager().drawableWarnPolyline(mContext, info);
}

View File

@@ -20,6 +20,8 @@ public class DrawLineInfo {
private double heading;
private float width;
public String getType() {
return type;
}
@@ -51,4 +53,12 @@ public class DrawLineInfo {
public void setHeading(double heading) {
this.heading = heading;
}
public float getWidth() {
return width;
}
public void setWidth(float width) {
this.width = width;
}
}

View File

@@ -25,6 +25,10 @@ public class MoGoPersonWarnPolylineManager implements IMoGoPersonWarnPolylineMan
@Override
public void drawPersonWarnPolyline(Context context, DrawLineInfo info) {
if (info == null) {
return;
}
try {
if (mMogoPolyline != null) {
mMogoPolyline.remove();
@@ -33,24 +37,26 @@ public class MoGoPersonWarnPolylineManager implements IMoGoPersonWarnPolylineMan
// 连接线参数
MogoPolylineOptions options = new MogoPolylineOptions();
float roadWidth = V2XServiceManager.getMapUIController().getRoadWidth(info.getStartLocation().lon,
info.getStartLocation().lat, (float) info.getHeading(), true, true);
// 渐变色
List<Integer> colors = new ArrayList<>();
if (info.getType().equals("1")) { //预警 TODO
colors.add(0xFFFFA31A);
colors.add(0xFFFFA31A);
if (info.getType() != null) {
if (info.getType().equals("1")) { //预警 TODO
colors.add(0xFFFFA31A);
colors.add(0xFFFFA31A);
} else {
colors.add(0xFFE32F46);
colors.add(0xFFE32F46);
}
} else {
colors.add(0xFFE32F46);
colors.add(0xFFE32F46);
}
// 线条粗细,渐变,渐变色值
Log.d(V2XConst.LOG_NAME_WARN, "MoGoPersonWarnPolylineManager roadWidth = " + roadWidth);
options.width(roadWidth).useGradient(true).colorValues(colors);
// options.width(60).useGradient(true).colorValues(colors);
// Logger.d(V2XConst.LOG_NAME_WARN, "MoGoPersonWarnPolylineManager roadWidth = " + roadWidth);
options.width(60).useGradient(true).colorValues(colors);
// options.width(info.getWidth()).useGradient(true).colorValues(colors);
// 当前车辆位置
options.add(info.getStartLocation());
// 目标车辆位置

View File

@@ -8,6 +8,7 @@ import com.alibaba.android.arouter.facade.annotation.Route;
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.drawer.SnapshotSetDataDrawer;
import com.mogo.module.common.entity.V2XWarningEntity;
import com.mogo.module.v2x.MoGoV2XServicePaths;
@@ -29,7 +30,6 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
@Override
public void init(Context context) {
}
@Override
@@ -42,7 +42,7 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
drawOtherObjectLine(cloundWarningInfo);
//二轮车和行人的移动和渲染
// SnapshotSetDataDrawer.getInstance().renderSnapshotData();
// SnapshotSetDataDrawer.getInstance().renderWarnData(cloundWarningInfo);
}
@@ -64,6 +64,14 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
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);
lineInfo.setWidth(roadWidth);
}
V2XServiceManager.getMoGoPersonWarnPolylineManager().drawPersonWarnPolyline(getContext(), lineInfo);
}
} else {

View File

@@ -38,12 +38,11 @@ public class MoGoWarnPolylineManager implements IMoGoWarnPolylineManager {
mMogoPolyline.remove();
}
Log.d(V2XConst.LOG_NAME_WARN, "MoGoWarnPolylineManager --------> ");
// 连接线参数
MogoPolylineOptions options = new MogoPolylineOptions();
// float roadWidth = V2XServiceManager.getMapUIController().getRoadWidth(info.getStartLocation().lon,
// info.getStartLocation().lat, (float) info.getHeading(), true, true);
List<Integer> colors = new ArrayList<>();
if (info.getType() != null) {
@@ -63,7 +62,7 @@ public class MoGoWarnPolylineManager implements IMoGoWarnPolylineManager {
// Log.d(V2XConst.LOG_NAME_WARN, "MoGoWarnPolylineManager roadWidth = " + roadWidth);
// 线条粗细,渐变,渐变色值
options.width(60).useGradient(true).colorValues(colors);
// options.width(roadWidth).useGradient(true).colorValues(colors);
// options.width(info.getWidth()).useGradient(true).colorValues(colors);
// 当前车辆位置
options.add(info.getStartLocation());
// 目标车辆位置

View File

@@ -23,7 +23,10 @@ public class AdasDataBroadcastReceiver extends BroadcastReceiver {
// Logger.d(V2XConst.LOG_NAME_WARN, "AdasDataBroadcastReceiver -->" + GsonUtil.jsonFromObject(adasResult));
String adasResult = (String) intent.getSerializableExtra(V2XConst.BROADCAST_ADAS_EXTRA_KEY);
Log.d(V2XConst.LOG_NAME_WARN, "AdasDataBroadcastReceiver -----> ");
V2XWaringManager.getInstance().registerAdasSocketMessage(context);
// V2XWaringManager.getInstance().registerAdasSocketMessage(context);
V2XWaringManager.getInstance().handleAdasData();
} catch (Exception e) {
e.printStackTrace();

View File

@@ -1,6 +1,7 @@
package com.mogo.module.v2x.scenario.scene.warning;
import android.content.Context;
import com.mogo.map.MogoLatLng;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.map.marker.MogoMarkerOptions;
@@ -16,6 +17,10 @@ import com.mogo.module.v2x.entity.model.DrawLineInfo;
import com.mogo.module.v2x.scenario.view.IV2XMarker;
import com.mogo.utils.WorkThreadHandler;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Handler;
/**
* @author liujing
* @description 描述
@@ -40,23 +45,14 @@ public class V2XWarningMarker implements IV2XMarker {
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
clearPOI();
WorkThreadHandler.getInstance().postDelayed(() -> {
MogoMarkerOptions options = new MogoMarkerOptions()
.object(markerShowEntity)
.latitude(markerShowEntity.getMarkerLocation().getLat())
.longitude(markerShowEntity.getMarkerLocation().getLon());
IMarkerView iMarkerView = MapMarkerAdapter.getMarkerView(mContext, markerShowEntity, options);
options.icon3DRes(com.mogo.module.service.R.raw.people);
options.anchorColor("#FF4040");
IMogoMarker marker = V2XServiceManager.getMarkerManager().addMarker(markerShowEntity.getMarkerType(), options);
iMarkerView.setMarker(marker);
marker.setToTop();
IMogoMarker marker = drawMarker(markerShowEntity);
//如果有预警碰撞点,识别物与预警碰撞点之间连线,并执行平移动画
if (mMarkerEntity.getCollisionLat() > 0 && mMarkerEntity.getCollisionLon() != 0) {
drawLine();
smooth(marker);
}
}, 0);
//如果有预警碰撞点,识别物与预警碰撞点之间连线,并执行平移动画
if (mMarkerEntity.getCollisionLat() > 0 && mMarkerEntity.getCollisionLon() != 0) {
drawLine();
smooth();
}
} else {
}
@@ -66,6 +62,20 @@ public class V2XWarningMarker implements IV2XMarker {
}
public IMogoMarker drawMarker(MarkerShowEntity markerShowEntity) {
MogoMarkerOptions options = new MogoMarkerOptions()
.object(markerShowEntity)
.latitude(markerShowEntity.getMarkerLocation().getLat())
.longitude(markerShowEntity.getMarkerLocation().getLon());
IMarkerView iMarkerView = MapMarkerAdapter.getMarkerView(mContext, markerShowEntity, options);
options.icon3DRes(com.mogo.module.service.R.raw.people);
options.anchorColor("#FF4040");
IMogoMarker marker = V2XServiceManager.getMarkerManager().addMarker(markerShowEntity.getMarkerType(), options);
iMarkerView.setMarker(marker);
marker.setToTop();
return marker;
}
public void drawLine() {
DrawLineInfo drawLineInfo = new DrawLineInfo();
MogoLatLng slatLng = new MogoLatLng(mMarkerEntity.getLat(), mMarkerEntity.getLon());
@@ -75,12 +85,25 @@ public class V2XWarningMarker implements IV2XMarker {
V2XServiceManager.getMoGoWarnPolylineManager().drawWarnPolyline(mContext, drawLineInfo);
}
public void smooth() {
public void smooth(IMogoMarker marker) {
List<MogoLatLng> latLngs = new ArrayList<>();
MogoLatLng sLocation = new MogoLatLng(mMarkerEntity.getLat(), mMarkerEntity.getLon());
MogoLatLng endLocation = new MogoLatLng(mMarkerEntity.getCollisionLat(), mMarkerEntity.getCollisionLon());
latLngs.add(sLocation);
latLngs.add(endLocation);
marker.startSmoothInMs(latLngs, 3000);
WorkThreadHandler.getInstance().postDelayed(() -> {
clearLine();
}, 3_000);
}
@Override
public void clearPOI() {
V2XServiceManager.getMarkerManager().removeMarkers(V2XConst.V2X_FRONT_WARNING_MARKER);
}
public void clearLine() {
V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
}
}

View File

@@ -3,16 +3,16 @@
"lat":39.977148,
"lon":116.417478,
"distance": 2.22,
"collisionLat": 39.977131,
"collisionLon": 116.417741,
"collisionLat": 39.977094,
"collisionLon": 116.417634,
"from": 1,
"angle": 120,
"direction": 10014,
"speed":11.108121,
"targetColor": "#FF4040",
"stopLineDistance":20,
"stopLineLat": 39.977123,
"stopLineLon": 116.417537,
"stopLineLat": 39.977094,
"stopLineLon": 116.417634,
"warningContent": "小心行人",
"heading": 30
}