Merge branch 'dev2_aiSdk' of http://gitlab.zhidaoauto.com/ecos/yycp-service/Launcher into dev2_aiSdk
This commit is contained in:
@@ -1,20 +1,21 @@
|
||||
package com.mogo.module.v2x.manager.impl;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.location.Location;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.cloud.commons.utils.CoordinateUtils;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.map.navi.IMogoCarLocationChangedListener2;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.drawer.MarkerDrawer;
|
||||
import com.mogo.module.common.drawer.V2XWarnDataDrawer;
|
||||
import com.mogo.module.common.entity.V2XMessageEntity;
|
||||
import com.mogo.module.common.drawer.marker.EmptyMarkerView;
|
||||
import com.mogo.module.common.drawer.marker.SimpleWindow3DAdapter;
|
||||
import com.mogo.module.common.entity.V2XWarningEntity;
|
||||
import com.mogo.module.service.MarkerServiceHandler;
|
||||
import com.mogo.module.service.receiver.MogoReceiver;
|
||||
@@ -23,15 +24,17 @@ 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.module.v2x.marker.V2XFrontTargetMarkerView;
|
||||
import com.mogo.module.v2x.utils.LocationUtils;
|
||||
import com.mogo.utils.UiThreadHandler;
|
||||
import com.mogo.utils.ViewUtils;
|
||||
import com.mogo.utils.WorkThreadHandler;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static com.mogo.module.v2x.V2XConst.V2X_FRONT_WARNING_MARKER;
|
||||
import static com.mogo.module.v2x.V2XServiceManager.getContext;
|
||||
|
||||
/**
|
||||
@@ -73,8 +76,8 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
|
||||
//绘制识别物与交汇点连线,并且更新连线数据
|
||||
drawStopLine(cloundWarningInfo, newLocation);
|
||||
//添加停止线marker
|
||||
handleStopLine();
|
||||
}, 0);
|
||||
drawStopLineWith2Resource();
|
||||
}, 200);
|
||||
|
||||
UiThreadHandler.postDelayed(() -> {
|
||||
V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine();
|
||||
@@ -90,7 +93,7 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
|
||||
drawOtherObjectLine(cloundWarningInfo);
|
||||
//二轮车和行人的渲染和移动
|
||||
V2XWarnDataDrawer.getInstance().renderWarnData(cloundWarningInfo);
|
||||
}, 0);
|
||||
}, 200);
|
||||
|
||||
//延迟3秒清理线
|
||||
UiThreadHandler.postDelayed(() -> {
|
||||
@@ -118,6 +121,32 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 2D资源绘制停止线
|
||||
* */
|
||||
private void drawStopLineWith2Resource() {
|
||||
mCloundWarningInfo.setCarLocation(new MogoLatLng(39.976866,116.417622));//测试数据
|
||||
MogoLatLng carlo = mCloundWarningInfo.getCarLocation();
|
||||
if (carlo == null){
|
||||
double lon = MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLon();
|
||||
double lat = MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLat();
|
||||
carlo = new MogoLatLng(lat, lon);
|
||||
}
|
||||
MogoLatLng drawStopLineLon = LocationUtils.getNewLocation(carlo, mCloundWarningInfo.getStopLineDistance(), mCloundWarningInfo.getAngle());
|
||||
|
||||
MogoMarkerOptions optionsRipple = new MogoMarkerOptions()
|
||||
.latitude(drawStopLineLon.getLat())
|
||||
.longitude(drawStopLineLon.getLon())
|
||||
.anchor(0.5f, 0.5f)
|
||||
.zIndex(MarkerDrawer.MARKER_Z_INDEX_HIGH);
|
||||
|
||||
optionsRipple
|
||||
.icon(ViewUtils.fromView(new EmptyMarkerView(V2XServiceManager.getContext())));
|
||||
IMogoMarker stopLine = V2XServiceManager.getMarkerManager().addMarker(V2X_FRONT_WARNING_MARKER, optionsRipple);
|
||||
stopLine.setInfoWindowAdapter(new SimpleWindow3DAdapter(new V2XFrontTargetMarkerView(V2XServiceManager.getContext())));
|
||||
stopLine.showInfoWindow();
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制停止线前方线 TODO 需要实时给行人当前位置
|
||||
*/
|
||||
@@ -193,8 +222,20 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
|
||||
*/
|
||||
@Override
|
||||
public void onCarLocationChanged2(Location latLng) {
|
||||
// Log.d(V2XConst.LOG_NAME_WARN, "onCarLocationChanged2 latLng = " + latLng.getLatitude() + "--" + latLng.getLongitude() + "---isSelfLineClear = " + isSelfLineClear);
|
||||
//当行人经纬度交点 经纬度不为空,开始画线,否则清理
|
||||
Log.e(V2XConst.LOG_NAME_WARN, "onCarLocationChanged2 latLng = " + latLng.getLatitude() + "--" + latLng.getLongitude() + "---isSelfLineClear = " + isSelfLineClear);
|
||||
//当行人经纬度交点 开始画线,否则清理
|
||||
drawSlefCarLine(latLng);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCarLocationChanged(MogoLatLng latLng) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制自车连线
|
||||
*/
|
||||
private void drawSlefCarLine(Location latLng) {
|
||||
if (!isSelfLineClear) {
|
||||
IMogoPolyline mogoPolyline = V2XServiceManager.getMoGoWarnPolylineManager().getMogoWarnPolyline();
|
||||
if (mCloundWarningInfo != null) {
|
||||
@@ -223,12 +264,6 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCarLocationChanged(MogoLatLng latLng) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 补点后的停止线经纬度合集
|
||||
*/
|
||||
@@ -261,7 +296,7 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
|
||||
private MogoLatLng getMogoLat(MogoLatLng latlng) {
|
||||
MogoLatLng newLocation = LocationUtils.getNewLocation(latlng, mCloundWarningInfo.getDistance(), mCloundWarningInfo.getDirection());
|
||||
|
||||
return newLocation;
|
||||
return newLocation;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.mogo.module.v2x.marker;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.mogo.module.common.drawer.marker.MapMarkerBaseView;
|
||||
import com.mogo.module.common.entity.MarkerShowEntity;
|
||||
import com.mogo.module.v2x.R;
|
||||
|
||||
/**
|
||||
* @author liujing
|
||||
* @description 前方预警目标物2D资源实现,目前只有停止线,可以按需添加其他类型
|
||||
* @since: 2021/4/9
|
||||
*/
|
||||
public class V2XFrontTargetMarkerView extends MapMarkerBaseView {
|
||||
private String TAG = "V2XFrontTargetMarkerView";
|
||||
|
||||
|
||||
public V2XFrontTargetMarkerView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public V2XFrontTargetMarkerView(Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public V2XFrontTargetMarkerView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView(Context context) {
|
||||
LayoutInflater.from( context ).inflate(R.layout.v2x_front_target_info_view, this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateView(MarkerShowEntity markerShowEntity) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -53,6 +53,7 @@ public class V2XTestConsoleWindow extends ConstraintLayout {
|
||||
private Button mBtnTriggerRoadEvent;
|
||||
private Button mBtnClearRoadEvent;
|
||||
private Button mBtnTriggerPushEvent;
|
||||
private Button mBtnTriggerWarningEvent;
|
||||
private Button mBtnTriggerPushLiveCarEvent;
|
||||
private Button mBtnTriggerAnimationEvent;
|
||||
private Button mBtnbtnFrontCarLiveEvent;
|
||||
@@ -67,6 +68,7 @@ public class V2XTestConsoleWindow extends ConstraintLayout {
|
||||
private ToggleButton nBtnTriggerVR;
|
||||
private Button mBtnAdasDataWarn;
|
||||
|
||||
|
||||
private Button btnTriggerRearVIPCarTip,
|
||||
btnTriggerVehicleBrakes,
|
||||
btnTriggerRearDangerousVehicles,
|
||||
@@ -114,6 +116,7 @@ public class V2XTestConsoleWindow extends ConstraintLayout {
|
||||
flTestPanelShunYi = findViewById(R.id.flTestPanelShunYi);
|
||||
flTestPanelVR = findViewById(R.id.flTestPanelVR);
|
||||
mBtnTriggerOpen = findViewById(R.id.btnTriggerOpen);
|
||||
mBtnTriggerWarningEvent = findViewById(R.id.btnTriggerWarningEvent);
|
||||
mBtnClearRoadEvent = findViewById(R.id.btnClearRoadEvent);
|
||||
mBtnTriggerRoadEvent = findViewById(R.id.btnTriggerRoadEvent);
|
||||
mBtnTriggerPushEvent = findViewById(R.id.btnTriggerPushEvent);
|
||||
@@ -220,6 +223,16 @@ public class V2XTestConsoleWindow extends ConstraintLayout {
|
||||
|
||||
});
|
||||
|
||||
//车路云—场景预警-V1.0 碰撞预警
|
||||
mBtnTriggerWarningEvent.setOnClickListener(v -> {
|
||||
V2XMessageEntity<V2XWarningEntity> v2XMessageEntity =
|
||||
TestOnLineCarUtils.getV2XScenarioPushFrontWarningEventData();
|
||||
|
||||
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
|
||||
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity);
|
||||
LocalBroadcastManager.getInstance(getContext()).sendBroadcast(intent);
|
||||
});
|
||||
|
||||
mBtnTriggerPushEvent.setOnClickListener(v -> {
|
||||
V2XMessageEntity<V2XPushMessageEntity> v2XMessageEntity =
|
||||
TestOnLineCarUtils.getV2XScenarioPushEventData();
|
||||
|
||||
@@ -8,21 +8,31 @@ import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.drawer.MarkerDrawer;
|
||||
import com.mogo.module.common.drawer.marker.EmptyMarkerView;
|
||||
import com.mogo.module.common.drawer.marker.IMarkerView;
|
||||
import com.mogo.module.common.drawer.marker.MapMarkerAdapter;
|
||||
import com.mogo.module.common.drawer.marker.SimpleWindow3DAdapter;
|
||||
import com.mogo.module.common.entity.MarkerLocation;
|
||||
import com.mogo.module.common.entity.MarkerShowEntity;
|
||||
import com.mogo.module.common.entity.V2XWarningEntity;
|
||||
import com.mogo.module.v2x.R;
|
||||
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.marker.OptimalSpeedMarkerView;
|
||||
import com.mogo.module.v2x.marker.V2XFrontTargetMarkerView;
|
||||
import com.mogo.module.v2x.scenario.view.IV2XMarker;
|
||||
import com.mogo.module.v2x.utils.LocationUtils;
|
||||
import com.mogo.utils.ViewUtils;
|
||||
import com.mogo.utils.WorkThreadHandler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.mogo.module.v2x.V2XConst.V2X_FRONT_WARNING_MARKER;
|
||||
import static com.mogo.module.v2x.V2XConst.V2X_OPTIMAL_SPEED_MARKER;
|
||||
|
||||
/**
|
||||
* @author liujing
|
||||
* @description 前方预警marker打点 绘制安全线和预警线
|
||||
@@ -33,7 +43,7 @@ public class V2XWarningMarker implements IV2XMarker {
|
||||
private V2XWarningEntity mMarkerEntity;
|
||||
private MarkerShowEntity markerShowEntity = new MarkerShowEntity();
|
||||
private Context mContext = V2XServiceManager.getContext();
|
||||
private List fillPoints = new ArrayList();//停止线经纬度合集
|
||||
private IMogoMarker optimalMarker = null;
|
||||
|
||||
@Override
|
||||
public void drawPOI(Object entity) {
|
||||
@@ -45,16 +55,19 @@ public class V2XWarningMarker implements IV2XMarker {
|
||||
|
||||
markerShowEntity.setMarkerLocation(location);
|
||||
|
||||
MogoMarkerOptions optionsRipple = new MogoMarkerOptions()
|
||||
.latitude(mMarkerEntity.getLat())
|
||||
.longitude(mMarkerEntity.getLon())
|
||||
.anchor(0.5f, 0.5f)
|
||||
.zIndex(MarkerDrawer.MARKER_Z_INDEX_HIGH);
|
||||
|
||||
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);
|
||||
}
|
||||
optionsRipple
|
||||
.icon(ViewUtils.fromView(new EmptyMarkerView(V2XServiceManager.getContext())));
|
||||
optimalMarker = V2XServiceManager.getMarkerManager().addMarker(V2X_FRONT_WARNING_MARKER, optionsRipple);
|
||||
optimalMarker.setInfoWindowAdapter(new SimpleWindow3DAdapter(new V2XFrontTargetMarkerView(V2XServiceManager.getContext())));
|
||||
optimalMarker.showInfoWindow();
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -62,61 +75,6 @@ public class V2XWarningMarker implements IV2XMarker {
|
||||
|
||||
}
|
||||
|
||||
//绘制安全距离
|
||||
private void drawSafeLine() {
|
||||
clearPOI();
|
||||
WorkThreadHandler.getInstance().postDelayed(() -> {
|
||||
//自车位置
|
||||
MogoLatLng car = V2XServiceManager.getNavi().getCarLocation();
|
||||
if (car != null) {
|
||||
//根据到停止线的距离和方向角获取经纬度
|
||||
MogoLatLng
|
||||
stopLineLo = LocationUtils.getNewLocation(car, mMarkerEntity.getStopLineDistance(), mMarkerEntity.getAngle());
|
||||
// if (mMarkerEntity.getCollisionLat() > 0 && mMarkerEntity.getCollisionLon() > 0) {
|
||||
// drawLine(car, stopLineLo);
|
||||
// }
|
||||
} else {
|
||||
Log.d(TAG, "自车位置没有拿到");
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
|
||||
//补点后的停止线经纬度合集
|
||||
public void pointsBetween() {
|
||||
try {
|
||||
fillPoints.clear();
|
||||
List stopLines = mMarkerEntity.getStopLines();
|
||||
if (stopLines.size() > 1) {
|
||||
MogoLatLng x = mMarkerEntity.getStopLines().get(0);
|
||||
MogoLatLng y = mMarkerEntity.getStopLines().get(1);
|
||||
//两点间的距离
|
||||
float distance = CoordinateUtils.calculateLineDistance(x.lon, x.lat, y.lon, y.lat);
|
||||
float average = distance / 3;
|
||||
//两点间的角度
|
||||
double angle = LocationUtils.getAngle(x.lon, x.lat, y.lon, y.lat);
|
||||
//根据距离和角度获取下个点的经纬度
|
||||
fillPoints.add(x);
|
||||
for (int i = 1; i < 3; i++) {
|
||||
MogoLatLng newLocation = LocationUtils.getNewLocation(x, average * i, angle);
|
||||
fillPoints.add(newLocation);
|
||||
}
|
||||
fillPoints.add(y);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//绘制停止线-通过打点的方式实现
|
||||
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, V2XConst.V2X_FRONT_STOP_LINE);
|
||||
}
|
||||
}
|
||||
|
||||
private void drawMarkerWithLocation(MogoLatLng latLng, String tag) {
|
||||
MogoMarkerOptions options = new MogoMarkerOptions()
|
||||
@@ -132,47 +90,10 @@ public class V2XWarningMarker implements IV2XMarker {
|
||||
marker.setToTop();
|
||||
}
|
||||
|
||||
//绘制并返回marker
|
||||
public IMogoMarker drawMarkerAndReturn(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(V2XConst.V2X_FRONT_WARNING_MARKER, options);
|
||||
iMarkerView.setMarker(marker);
|
||||
marker.setToTop();
|
||||
return marker;
|
||||
}
|
||||
|
||||
//绘制线
|
||||
public void drawLine(MogoLatLng s, MogoLatLng e) {
|
||||
DrawLineInfo drawLineInfo = new DrawLineInfo();
|
||||
drawLineInfo.setStartLocation(s);
|
||||
drawLineInfo.setEndLocation(e);
|
||||
drawLineInfo.setWidth(60);
|
||||
V2XServiceManager.getMoGoWarnPolylineManager().drawWarnPolyline(mContext, drawLineInfo);
|
||||
}
|
||||
|
||||
//平移
|
||||
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);
|
||||
V2XServiceManager.getMarkerManager().removeMarkers(V2X_FRONT_WARNING_MARKER);
|
||||
}
|
||||
|
||||
public void clearLine() {
|
||||
|
||||
Reference in New Issue
Block a user