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

This commit is contained in:
董宏宇
2021-04-02 17:40:44 +08:00
6 changed files with 78 additions and 74 deletions

View File

@@ -58,40 +58,11 @@ public class V2XWarningEntity implements Serializable {
//自组字段
//tts播报
private String tts;
//打点位置
private MarkerLocation location;
//自车位置
private MogoLatLng carLocation;
public void setLocation(MarkerLocation location) {
this.location = location;
}
public MarkerLocation getLocation() {
if (location == null) {
MarkerLocation location = new MarkerLocation();
location.setLat(getLat());
location.setLon(getLon());
setLocation(location);
}
return location;
}
public void setTipContent(int type) {
switch (type) {
case 0:
this.warningContent = "行人碰撞预警";
break;
case 1:
case 3:
case 4:
this.warningContent = "前车碰撞预警";
break;
case 2:
this.warningContent = "摩托车碰撞预警";
break;
default:
break;
}
public MogoLatLng getCarLocation() {
return carLocation;
}
public void setTts(int type) {
@@ -167,6 +138,10 @@ public class V2XWarningEntity implements Serializable {
this.stopLines = stopLines;
}
public void setCarLocation(MogoLatLng carLocation) {
this.carLocation = carLocation;
}
public int getType() {
return type;
}
@@ -212,9 +187,6 @@ public class V2XWarningEntity implements Serializable {
}
public String getWarningContent() {
if (this.warningContent == null) {
setTipContent(type);
}
return warningContent;
}
@@ -270,7 +242,7 @@ public class V2XWarningEntity implements Serializable {
", systemTime=" + systemTime +
", satelliteTime=" + satelliteTime +
", tts='" + tts + '\'' +
", location=" + location +
", carLocation=" + carLocation +
'}';
}
}

View File

@@ -145,6 +145,10 @@ public class V2XConst {
* */
public static final String V2X_FRONT_WARNING_MARKER = "V2X_FRONT_WARNING_MARKER";
/*
*V2X 车路云前方预警
* */
public static final String V2X_FRONT_STOP_LINE = "V2X_FRONT_STOP_LINE";
/**
* V2X预警日志tag
*/

View File

@@ -2,6 +2,7 @@ package com.mogo.module.v2x.scenario.scene.warning;
import android.content.Context;
import android.content.Intent;
import android.location.Location;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
@@ -9,7 +10,9 @@ import android.view.ViewGroup;
import androidx.annotation.Nullable;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.mogo.map.MogoLatLng;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.map.navi.IMogoCarLocationChangedListener2;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.entity.V2XMessageEntity;
import com.mogo.module.common.entity.V2XPoiTypeEnum;
@@ -39,7 +42,7 @@ import java.util.List;
* @description 车路云—场景预警-V1.0 前车/行人/摩托车/盲区碰撞预警
* @since: 2021/3/24
*/
public class V2XFrontWarningScenario extends AbsV2XScenario implements IMogoTopViewStatusListener {
public class V2XFrontWarningScenario extends AbsV2XScenario implements IMogoTopViewStatusListener , IMogoCarLocationChangedListener2 {
private int direction;
private V2XWarningEntity mMarkerEntity;
@@ -130,4 +133,15 @@ public class V2XFrontWarningScenario extends AbsV2XScenario implements IMogoTopV
public void beforeViewRemoveAnim(View view) {
}
@Override
public void onCarLocationChanged2(Location latLng) {
}
@Override
public void onCarLocationChanged(MogoLatLng latLng) {
mMarkerEntity.setCarLocation(latLng);
drawPOI();
}
}

View File

@@ -24,14 +24,14 @@ import java.util.List;
/**
* @author liujing
* @description 描述
* @description 前方预警marker打点 绘制安全线和预警线
* @since: 2021/3/30
*/
public class V2XWarningMarker implements IV2XMarker {
private V2XWarningEntity mMarkerEntity;
private MarkerShowEntity markerShowEntity = new MarkerShowEntity();
private Context mContext = V2XServiceManager.getContext();
List fillPoints = new ArrayList();//停止线经纬度合集
private List fillPoints = new ArrayList();//停止线经纬度合集
@Override
public void drawPOI(Object entity) {
@@ -42,14 +42,17 @@ public class V2XWarningMarker implements IV2XMarker {
location.setLon(mMarkerEntity.getLon());
markerShowEntity.setMarkerLocation(location);
// drawLineAndSmooth();
pointsBetween();
//绘制停止线
drawStopLines(fillPoints);
WorkThreadHandler.getInstance().postDelayed(() -> {
clearPOI();
}, 6_000);
//绘制安全距离
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
pointsBetween();
//绘制停止线
drawStopLines(fillPoints);
drawSafeLine();
WorkThreadHandler.getInstance().postDelayed(() -> {
V2XServiceManager.getMarkerManager().removeMarkers(V2XConst.V2X_FRONT_STOP_LINE);
V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
}, 6_000);
}
} catch (Exception e) {
@@ -57,21 +60,27 @@ public class V2XWarningMarker implements IV2XMarker {
}
private void drawLineAndSmooth() {
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
clearPOI();
WorkThreadHandler.getInstance().postDelayed(() -> {
IMogoMarker marker = drawMarkerAndReturn(markerShowEntity);
//如果有预警碰撞点,识别物与预警碰撞点之间连线,并执行平移动画
if (mMarkerEntity.getCollisionLat() > 0 && mMarkerEntity.getCollisionLon() != 0) {
drawLine();
smooth(marker);
//绘制安全距离
private void drawSafeLine() {
clearPOI();
WorkThreadHandler.getInstance().postDelayed(() -> {
//自车位置
MogoLatLng car = mMarkerEntity.getCarLocation();
if (car == null) {
double lon = MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLon();
double lat = MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLat();
car = new MogoLatLng(lat, lon);
car = new MogoLatLng(39.977709,116.417703);
}
if (car != null) {
//根据到停止线的距离和方向角获取经纬度
MogoLatLng
stopLineLo = LocationUtils.getNewLocation(car, mMarkerEntity.getStopLineDistance(), mMarkerEntity.getAngle());
if (mMarkerEntity.getCollisionLat() > 0 && mMarkerEntity.getCollisionLon() > 0) {
drawLine(car, stopLineLo);
}
}, 0);
} else {
}
}
}, 0);
}
//补点后的停止线经纬度合集
@@ -101,15 +110,17 @@ public class V2XWarningMarker implements IV2XMarker {
}
//绘制停止线-通过打点的方式实现
private void drawStopLines(List points) {
clearPOI();
V2XServiceManager.getMarkerManager().removeMarkers(V2XConst.V2X_FRONT_STOP_LINE);
for (int i = 0; i < points.size(); i++) {
MogoLatLng latLng = (MogoLatLng) points.get(i);
drawMarkerWithLocation(latLng);
drawMarkerWithLocation(latLng, V2XConst.V2X_FRONT_STOP_LINE);
}
}
private void drawMarkerWithLocation(MogoLatLng latLng) {
private void drawMarkerWithLocation(MogoLatLng latLng, String tag) {
MogoMarkerOptions options = new MogoMarkerOptions()
.object(markerShowEntity)
.latitude(latLng.lat)
@@ -118,7 +129,7 @@ public class V2XWarningMarker implements IV2XMarker {
options.icon3DRes(com.mogo.module.service.R.raw.people);
options.anchor(0.5f, 0.5f);
options.anchorColor("#FF4040");
IMogoMarker marker = V2XServiceManager.getMarkerManager().addMarker(V2XConst.V2X_FRONT_WARNING_MARKER, options);
IMogoMarker marker = V2XServiceManager.getMarkerManager().addMarker(tag, options);
iMarkerView.setMarker(marker);
marker.setToTop();
}
@@ -139,12 +150,10 @@ public class V2XWarningMarker implements IV2XMarker {
}
//绘制线
public void drawLine() {
public void drawLine(MogoLatLng s, MogoLatLng e) {
DrawLineInfo drawLineInfo = new DrawLineInfo();
MogoLatLng slatLng = new MogoLatLng(mMarkerEntity.getLat(), mMarkerEntity.getLon());
MogoLatLng endLatLng = new MogoLatLng(mMarkerEntity.getCollisionLat(), mMarkerEntity.getCollisionLon());
drawLineInfo.setStartLocation(slatLng);
drawLineInfo.setEndLocation(endLatLng);
drawLineInfo.setStartLocation(s);
drawLineInfo.setEndLocation(e);
V2XServiceManager.getMoGoWarnPolylineManager().drawWarnPolyline(mContext, drawLineInfo);
}
@@ -170,4 +179,5 @@ public class V2XWarningMarker implements IV2XMarker {
public void clearLine() {
V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
}
}

View File

@@ -1,6 +1,7 @@
package com.mogo.module.v2x.scenario.scene.warning;
import android.content.Context;
import android.location.Location;
import android.os.Handler;
import android.util.AttributeSet;
import android.view.LayoutInflater;
@@ -10,6 +11,10 @@ import android.widget.TextView;
import com.mogo.commons.voice.AIAssist;
import com.mogo.commons.voice.VoicePreemptType;
import com.mogo.map.MogoLatLng;
import com.mogo.map.navi.IMogoCarLocationChangedListener;
import com.mogo.map.navi.IMogoCarLocationChangedListener2;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.entity.V2XWarningEntity;
import com.mogo.module.v2x.R;
import com.mogo.module.v2x.V2XServiceManager;
@@ -120,6 +125,5 @@ public class V2XWarningWindow extends V2XBasWindow implements IV2XWindow {
V2XServiceManager
.getMogoTopViewManager()
.removeView(this);
}
}

View File

@@ -5,7 +5,7 @@
"distance": 2,
"collisionLat": 39.977094,
"collisionLon": 116.417634,
"stopLines":[
"stopLines": [
{
"lat": 39.976858,
"lon": 116.417651
@@ -16,11 +16,11 @@
}
],
"from": 1,
"angle": 120,
"angle": 0,
"direction": 10014,
"speed": 11.108121,
"targetColor": "#FF4040",
"stopLineDistance": 20,
"stopLineDistance": 30,
"stopLineLat": 39.977094,
"stopLineLon": 116.417634,
"warningContent": "小心行人",