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

This commit is contained in:
wujifei
2021-04-02 18:04:04 +08:00
9 changed files with 82 additions and 78 deletions

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

@@ -89,12 +89,12 @@ public class V2XLocationListener implements IMogoLocationListener, CarStatusList
loc.setAltitude( location.getAltitude() );
loc.setBearing( location.getBearing() );
loc.setProvider( location.getProvider() );
// onLocationChangedImpl( loc );
onLocationChangedImpl( loc );
}
@Override
public void onLocationChanged(MogoLocation location) {
onLocationChangedImpl(location);
// onLocationChangedImpl(location);
}
private void onLocationChangedImpl(MogoLocation location){

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);
}
}