merge origin dev2_aiSdk

This commit is contained in:
zhongchao
2021-04-23 15:59:06 +08:00
76 changed files with 489 additions and 845 deletions

View File

@@ -23,7 +23,11 @@ enum AdasRecognizedType {
//bus
classIdTrafficBus( "traffic_bus", 6 ),
//truck
classIdTrafficTruck( "traffic_truck", 8 );
classIdTrafficTruck( "traffic_truck", 8 ),
//stopLine
classIdStopLine("warning_stop_line",9),
//预警箭头
classIdWarningArrows("warning_arrows",10);
AdasRecognizedType( int code ) {
this.code = code;
@@ -38,7 +42,7 @@ enum AdasRecognizedType {
}
public static AdasRecognizedType[] VAL = {
classIdBackground,
classIdBackground,//0
classIdPerson,
classIdBicycle,
classIdCar,
@@ -47,6 +51,8 @@ enum AdasRecognizedType {
classIdTrafficBus,
null,
classIdTrafficTruck,
classIdStopLine,
classIdWarningArrows,
};
public String getRes() {

View File

@@ -19,7 +19,7 @@ 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";

View File

@@ -226,6 +226,10 @@ class BaseDrawer {
} else if (recognizedType == AdasRecognizedType.classIdBicycle
|| recognizedType == AdasRecognizedType.classIdMoto) {
return R.raw.motorbike;
} else if (recognizedType == AdasRecognizedType.classIdStopLine) {
return R.raw.stopline;
} else if (recognizedType == AdasRecognizedType.classIdWarningArrows) {
return R.raw.arraw;
}
return R.raw.people;
}

View File

@@ -1,6 +1,7 @@
package com.mogo.module.common.drawer;
import android.util.Log;
import android.widget.LinearLayout;
import com.mogo.map.MogoLatLng;
import com.mogo.map.marker.IMogoMarker;
@@ -21,6 +22,9 @@ import com.mogo.utils.UiThreadHandler;
import com.mogo.utils.ViewUtils;
import com.mogo.utils.logger.Logger;
import java.util.ArrayList;
import java.util.List;
import static com.mogo.module.common.constants.DataTypes.TYPE_MARKER_CLOUD_STOP_LINE_DATA;
import static com.mogo.module.common.constants.DataTypes.TYPE_MARKER_CLOUD_WARN_DATA;
@@ -87,8 +91,8 @@ public class V2XWarnDataDrawer extends BaseDrawer implements IMogoStatusChangedL
MogoLatLng mogoLatLng = new MogoLatLng(data.getCollisionLat(), data.getCollisionLon());
//2D资源图片位置调整
MogoLatLng stopLineNew = Trigonometric.getNewLocation(data.getStopLines().get(1), 8, 180);
MogoLatLng newLocation = Trigonometric.getNewLocation(mogoLatLng, 8, 180);
MogoLatLng stopLineNew = Trigonometric.getNewLocation(data.getStopLines().get(1), 5, 180);
MogoLatLng newLocation = Trigonometric.getNewLocation(mogoLatLng, 5, 180);
IMogoMarker marker = drawMarker(markerShowEntity);
Log.d("liyz", "renderWarnData marker != null direction = " + data.getDirection());
@@ -115,7 +119,7 @@ public class V2XWarnDataDrawer extends BaseDrawer implements IMogoStatusChangedL
.latitude(markerShowEntity.getMarkerLocation().getLat())
.longitude(markerShowEntity.getMarkerLocation().getLon());
IMarkerView iMarkerView = MapMarkerAdapter.getMarkerView(mContext, markerShowEntity, options);
options.icon3DRes(getModelRes(2)); //TODO
options.icon3DRes(getModelRes(1)); //TODO
options.anchorColor("#FB3C3CFF"); //红色#FF3036 蓝色:#256BFF
IMogoMarker marker = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager(mContext).addMarker(markerShowEntity.getMarkerType(), options);
@@ -125,18 +129,17 @@ public class V2XWarnDataDrawer extends BaseDrawer implements IMogoStatusChangedL
return marker;
}
public void drawerMarkerWithLocation(MarkerShowEntity markerShowEntity, MogoLatLng location) {
public void drawerArrowsMarkerWithLocation(MogoLatLng location, String markerType, int type, int rotate) {
MogoMarkerOptions options = new MogoMarkerOptions()
.object(markerShowEntity)
.latitude(location.getLat())
.longitude(location.getLon());
IMarkerView iMarkerView = MapMarkerAdapter.getMarkerView(mContext, markerShowEntity, options);
options.icon3DRes(getModelRes(2)); //TODO
options.anchorColor("#FB3C3CFF"); //红色#FF3036 蓝色:#256BFF
IMogoMarker marker = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager(mContext).addMarker(markerShowEntity.getMarkerType(), options);
iMarkerView.setMarker(marker);
marker.setToTop();
.longitude(location.getLon())
.set3DMode(true)
.controlAngle(true)
.icon3DRes(getModelRes(type))
.anchorColor("#FB3C3CFF")
.flat(true);
IMogoMarker marker = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager(mContext).addMarker(markerType, options);
marker.setRotateAngle(rotate);
}
/*
@@ -144,7 +147,7 @@ public class V2XWarnDataDrawer extends BaseDrawer implements IMogoStatusChangedL
* */
private IMogoMarker drawMarkerWith2Resource(MarkerShowEntity markerShowEntity) {
MogoLatLng mogoLatLng = new MogoLatLng(markerShowEntity.getMarkerLocation().getLat(), markerShowEntity.getMarkerLocation().getLon());
MogoLatLng newLocation = Trigonometric.getNewLocation(mogoLatLng, 8, 180);
MogoLatLng newLocation = Trigonometric.getNewLocation(mogoLatLng, 5, 180);
MogoMarkerOptions optionsRipple = new MogoMarkerOptions()
.latitude(newLocation.getLat())
.longitude(newLocation.getLon())
@@ -182,15 +185,18 @@ public class V2XWarnDataDrawer extends BaseDrawer implements IMogoStatusChangedL
}
/**
* 停止线绘制
*/
public IMogoMarker drawStopLineMarker(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(getModelRes(1)); //TODO
options.icon3DRes(getModelRes(9));
options.anchorColor("#FB3C3CFF"); //红色#FF3036 蓝色:#256BFF
options.anchorColor("#FB3C3CFF");
IMogoMarker marker = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager(mContext).addMarker(markerShowEntity.getMarkerType(), options);
iMarkerView.setMarker(marker);
marker.setToTop();

Binary file not shown.

View File

@@ -3,6 +3,6 @@
<gradient
android:angle="90"
android:endColor="#00F03232"
android:startColor="#A5F03232"
android:startColor="#3FF03232"
android:type="linear"></gradient>
</shape>

View File

@@ -3,6 +3,6 @@
<gradient
android:angle="0"
android:endColor="#00F03232"
android:startColor="#A5F03232"
android:startColor="#3FF03232"
android:type="linear"></gradient>
</shape>

View File

@@ -3,6 +3,6 @@
<gradient
android:angle="180"
android:endColor="#00F03232"
android:startColor="#A5F03232"
android:startColor="#3FF03232"
android:type="linear"></gradient>
</shape>

View File

@@ -3,6 +3,6 @@
<gradient
android:angle="270"
android:endColor="#00FF0606"
android:startColor="#8CFF0606"
android:startColor="#3FFF0606"
android:type="linear"></gradient>
</shape>

View File

@@ -1 +0,0 @@
{"systemTime":1615529718585,"satelliteTime":1615529718585,"lon":116.411411222501,"lat":39.9753341630918,"alt":34.4018669128417,"heading":0.342695406938048,"speed":0.003303937,"type":3,"uuid":"2_1"}

View File

@@ -1 +0,0 @@
{"systemTime":1615529718585,"satelliteTime":1615529718585,"lon":116.411411222501,"lat":39.9753341630918,"alt":34.4018669128417,"heading":0.342695406938048,"speed":0.003303937,"type":3,"uuid":"2_1"}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -62,7 +62,7 @@ import java.util.List;
* @author congtaowang
* @since 2020-04-17
* <p>
* 描述
* 使用控制台发送广播这里接收intent来处理场景
*/
public class MockIntentHandler implements IntentHandler {
@@ -90,7 +90,7 @@ public class MockIntentHandler implements IntentHandler {
TipToast.shortTip( msg );
}
break;
case 4:
case 4:// 测试左侧按钮1
TextView button1 = MarkerServiceHandler.getApis().getEntranceButtonController().getButton( ButtonIndex.BUTTON1 );
if ( button1 != null ) {
button1.setVisibility( View.VISIBLE );
@@ -99,18 +99,18 @@ public class MockIntentHandler implements IntentHandler {
} );
}
break;
case 5:
TextView button2 = MarkerServiceHandler.getApis().getEntranceButtonController().getButton( ButtonIndex.BUTTON1 );
case 5:// 测试左侧按钮2
TextView button2 = MarkerServiceHandler.getApis().getEntranceButtonController().getButton( ButtonIndex.BUTTON2 );
if ( button2 != null ) {
button2.setOnClickListener( null );
button2.setVisibility( View.GONE );
}
break;
case 6:
case 6://
boolean status1 = intent.getBooleanExtra( "status", false );
MarkerServiceHandler.getMogoStatusManager().setUploadingStatus( TAG, status1 );
break;
case 7:
case 7:// 打开微信
TextView button11 = MarkerServiceHandler.getApis().getEntranceButtonController().getButton( ButtonIndex.BUTTON1 );
if ( button11 != null ) {
button11.setVisibility( View.VISIBLE );
@@ -130,11 +130,11 @@ public class MockIntentHandler implements IntentHandler {
} );
}
break;
case 8:
case 8:// 测试修改车头角度
float bearing = intent.getFloatExtra( "bearing", 0 );
MarkerServiceHandler.getMapUIController().changeBearing( bearing );
break;
case 9:
case 9:// 测试弹窗
new WMDialog.Builder( context )
.setOkButton( "确认", ( dlg, which ) -> {
dlg.dismiss();
@@ -146,7 +146,7 @@ public class MockIntentHandler implements IntentHandler {
.build()
.show();
break;
case 10:
case 10://测试GEO查询
IMogoGeoSearch geoSearch = MarkerServiceHandler.getMapService().getGeoSearch( context );
geoSearch.setGeoSearchListener( new IMogoGeoSearchListener() {
@Override
@@ -165,10 +165,10 @@ public class MockIntentHandler implements IntentHandler {
query.setRadius( 1000 );
geoSearch.getFromLocationAsyn( query );
break;
case 11:
case 11:// 控制ADAS中的设置页面
MarkerServiceHandler.getADASController().setSettingStatus( intent.getBooleanExtra( "status", false ) );
break;
case 12: {
case 12: {// 控制ADAS显示隐藏
boolean status2 = intent.getBooleanExtra( "status", false );
if ( status2 ) {
MarkerServiceHandler.getADASController().showADAS();
@@ -177,7 +177,7 @@ public class MockIntentHandler implements IntentHandler {
}
}
break;
case 13: {
case 13: {// 唤起高德地图
double lat = intent.getFloatExtra( "lat", 0.0f );
double lon = intent.getFloatExtra( "lon", 0.0f );
boolean real = intent.getBooleanExtra( "real", false );
@@ -225,7 +225,7 @@ public class MockIntentHandler implements IntentHandler {
} );
MarkerServiceHandler.getNavi().naviTo( new MogoLatLng( lat, lon ) );
}
case 14: {
case 14: {//测试点的动画移动,模拟周边车辆移动
List< MogoLatLng > mogoLatLngs = new ArrayList<>();
mogoLatLngs.add( new MogoLatLng( 39.615986, 116.396716 ) );
mogoLatLngs.add( new MogoLatLng( 39.616007, 116.396995 ) );
@@ -355,30 +355,30 @@ public class MockIntentHandler implements IntentHandler {
// case 16:
// MarkerServiceHandler.getGpsSimulatorManager().close();
// break;
case 17:
case 17:// 查询在线车辆数据
DebugConfig.setRequestOnlineCarData( intent.getBooleanExtra( "status", true ) );
break;
case 18:
case 18:// 设置是否使用自研地图
TipToast.shortTip( "设置完成,下次启动生效" );
SharedPrefsMgr.getInstance( context ).putBoolean( "useCustomMap", intent.getBooleanExtra( "useCustomMap", false ) );
break;
case 30:
case 30:// 强制刷新地图
MarkerServiceHandler.getMapService().getMapUIController().forceRender();
break;
case 31:
case 31://
Intent intent3 = new Intent();
intent3.setAction( "AUTONAVI_STANDARD_BROADCAST_RECV" );
intent3.putExtra( "KEY_TYPE", 12404 );
intent3.putExtra( "EXTRA_REQUEST_AUTO_STATE", 0 );
context.sendBroadcast( intent3 );
break;
case 32:
case 32:// 控制实时路况
MarkerServiceHandler.getMapService().getMapUIController().setTrafficEnabled( true );
break;
case 33:
case 33:// 测试小智语音
AIAssist.getInstance( context ).speakTTSVoice( "庞帆说这个是一个 hard coding." );
break;
case 34:
case 34:// 修改地图模式VR OR 2D
int type = intent.getIntExtra( "type", 0 );
if ( type != 0 ) {
MogoApisHandler.getInstance().getApis().getMapFrameControllerApi().changeToVRMode();
@@ -386,10 +386,10 @@ public class MockIntentHandler implements IntentHandler {
MogoApisHandler.getInstance().getApis().getMapFrameControllerApi().changeTo2dMode();
}
break;
case 35:
case 35://测试GPS数据
MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapUIController().testGpsData();
break;
case 36:
case 36:// 测试打点功能
MogoLatLng center = MogoApisHandler.getInstance().getApis()
.getMapServiceApi().getMapUIController()
.getWindowCenterLocation();
@@ -399,16 +399,16 @@ public class MockIntentHandler implements IntentHandler {
.position( center )
.icon( BitmapFactory.decodeResource( context.getResources(), R.drawable.bg_map_marker_red ) ) );
break;
case 37:
case 37:// 销毁测试打点
if ( centerMarker != null ) {
centerMarker.destroy();
}
break;
case 38:
case 38:// 控制RTK
MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapUIController()
.rtkEnable( false );
break;
case 39:
case 39:// 使用自动驾驶车的定位数据
MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapUIController()
.syncLocation2Map( null );
break;
@@ -494,12 +494,12 @@ public class MockIntentHandler implements IntentHandler {
Logger.d( TAG, "偏差值:%s", delta );
}
break;
case 41:
case 41://
// adb shell am broadcast -a com.mogo.mock --ei oper 41 --ei type 0 平滑移动
// adb shell am broadcast -a com.mogo.mock --ei oper 41 --ei type 1 直接打点
DebugConfig.setNotSmooth( intent.getIntExtra( "type", 0 ) == 1 );
break;
case 42:
case 42://
WorkThreadHandler.getInstance().post( () -> {
try {
InputStream is = context.getAssets().open( "coors.json" );
@@ -531,13 +531,13 @@ public class MockIntentHandler implements IntentHandler {
}
} );
break;
case 43:
case 43://
MogoApisHandler.getInstance()
.getApis()
.getAdasControllerApi()
.onAutopilotArriveLike( intent.getIntExtra( "type", 8 ) );
break;
case 44:
case 44:// 控制自动驾驶
RemoteControlAutoPilotParameters parameters = new RemoteControlAutoPilotParameters();
parameters.vehicleType = 9;
parameters.startLatLon = new RemoteControlAutoPilotParameters.AutoPilotLonLat( 40.1690522746, 116.567374558 );
@@ -547,21 +547,21 @@ public class MockIntentHandler implements IntentHandler {
.getAdasControllerApi()
.aiCloudToAdasData( parameters );
break;
case 45:
case 45:// 测试开启鹰眼模式
MogoApisHandler.getInstance()
.getApis()
.getMapServiceApi()
.getMapUIController()
.openVrMode( false );
break;
case 46:
case 46:// 模拟 自车周边数据
String json = "{\"allList\":[{\"type\":3,\"uuid\":\"10009-5152\",\"lat\":40.1990809296,\"lon\":116.7393252195,\"speed\":0.0,\"heading\":0.0,\"systemTime\":1614329151909,\"vehicleType\":0,\"distance\":576.0,\"fromType\":3,\"isOnline\":0},{\"type\":3,\"uuid\":\"10009-5161\",\"lat\":40.1990827227,\"lon\":116.739325826,\"speed\":0.0,\"heading\":0.0,\"systemTime\":1614329151909,\"vehicleType\":0,\"distance\":576.0,\"fromType\":3,\"isOnline\":0}],\"nearList\":[],\"time\":1614329152238}";
SnapshotSetDataDrawer.getInstance().renderSnapshotData( GsonUtil.objectFromJson( json, MogoSnapshotSetData.class ) );
break;
case 47:
case 47:// 模拟鹰眼模式下绘制车辆周边的数据
mTimeTickHandler.sendEmptyMessageDelayed( 1, 0L );
break;
case 48:
case 48:// 模拟3D模型绘制
MogoMarkerOptions options = new MogoMarkerOptions()
.owner( DataTypes.TYPE_MARKER_ADAS )
.anchor( 0.5f, 0.5f )
@@ -577,7 +577,7 @@ public class MockIntentHandler implements IntentHandler {
latLngs.add( new MogoLatLng( 39.981990561932, 116.412893641626 ) );
marker.startSmoothInMs( latLngs, 20_000L );
break;
case 49:
case 49:// 绘制marker
// 39.96741320378243, 116.41045709250723
// 39.98232698552779,116.41879656379113;
MogoMarkerOptions options1 = new MogoMarkerOptions()
@@ -611,20 +611,23 @@ public class MockIntentHandler implements IntentHandler {
.rotate( ( float ) 358.526123 );
IMogoMarker marker3 = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( context ).addMarker( DataTypes.TYPE_MARKER_ADAS, options3 );
break;
case 50:
case 50://
DebugConfig.setSelfCarSpeedYOffset( intent.getIntExtra( "yOffset", 20 ) );
break;
case 51:
case 51:// 模拟路口车辆移动
mLocationMockHandler.sendEmptyMessageDelayed( 100, 0L );
mLocationMockHandler.sendEmptyMessageDelayed( 101, 1000L );
break;
case 52:
case 52:// 打开连调工控机、ADAS的控制面板
EnvStatusManager.getInstance().showPanel( context );
break;
case 53:
case 53:// 控制 Adas识别 是否可用
boolean isUseAdasRecognize = intent.getBooleanExtra( "status", false );
DebugConfig.setUseAdasRecognize( isUseAdasRecognize );
break;
case 54:
mTimeTickCarHandler.sendEmptyMessageDelayed( 1, 0L );
break;
}
}
@@ -679,6 +682,7 @@ public class MockIntentHandler implements IntentHandler {
}
}
private Handler mLocationMockHandler = new Handler( WorkThreadHandler.newInstance( "loc-mock-thread" ).getLooper() ) {
@Override
public void handleMessage( Message msg ) {
@@ -740,9 +744,28 @@ public class MockIntentHandler implements IntentHandler {
}
roadSizeBr = null;
}
} else if (msg.what == 8) {
try {
handleMockAdasCarIntent();
} catch ( Exception e ) {
try {
if ( readers2 != null ) {
for ( BufferedReader reader : readers2 ) {
if (reader != null) {
reader.close();
}
}
}
} catch ( IOException ex ) {
ex.printStackTrace();
}
readers2 = null;
}
}
}
};
private Handler mLocationMockHandler1 = new Handler( WorkThreadHandler.newInstance( "loc-mock-thread1" ).getLooper() ) {
@Override
public void handleMessage( Message msg ) {
@@ -780,6 +803,19 @@ public class MockIntentHandler implements IntentHandler {
}
};
private Handler mTimeTickCarHandler = new Handler( WorkThreadHandler.newInstance( "loc-time-mock-thread" ).getLooper() ) {
@Override
public void handleMessage( Message msg ) {
super.handleMessage( msg );
mLocDelay += 50;
if ( mLocDelay > 4_000L ) {
mLocationMockHandler1.sendEmptyMessageDelayed( 1, 0L );
}
mLocationMockHandler.sendEmptyMessageDelayed( 8, 0L );
mTimeTickCarHandler.sendEmptyMessageDelayed( 0, 50L );
}
};
private BufferedReader br;
private boolean handleMockLocationIntent() throws Exception {
@@ -792,6 +828,7 @@ public class MockIntentHandler implements IntentHandler {
throw new Exception( "end of file." );
}
JSONObject jo = new JSONObject( line );
//改变rtk定位数据触发自车移动
MarkerServiceHandler.getApis().getMapServiceApi().getMapUIController().syncLocation2Map( jo );
Log.i( "mock-timer-loc-map", "cost " + ( System.currentTimeMillis() - start ) + "ms" );
SnapshotLocationController.getInstance().syncAdasLocationInfo( jo );
@@ -830,6 +867,7 @@ public class MockIntentHandler implements IntentHandler {
}
private BufferedReader[] readers = null;
private BufferedReader[] readers2 = null;
private boolean handleMockAdasIntent() throws Exception {
final long start = System.currentTimeMillis();
@@ -858,6 +896,33 @@ public class MockIntentHandler implements IntentHandler {
return true;
}
private boolean handleMockAdasCarIntent() throws Exception {
final long start = System.currentTimeMillis();
if ( readers2 == null ) {
readers2 = new BufferedReader[3];
for ( int i = 0; i < 3; i++ ) {
readers2[i] = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "adascar" + i + ".txt" ) ) );
}
}
List< ADASRecognizedResult > allList = new ArrayList<>();
for ( BufferedReader reader : readers2 ) {
String line = reader.readLine();
ADASRecognizedResult adasRecognizedResult = GsonUtil.objectFromJson( line, ADASRecognizedResult.class );
if ( adasRecognizedResult != null ) {
allList.add( adasRecognizedResult );
}
}
AdasRec adasRec = new AdasRec();
adasRec.models = allList;
MogoApisHandler.getInstance().getApis().getAdasControllerApi().mockAdasRecognized( GsonUtil.jsonFromObject( adasRec ) );
Log.i( "mock-timer-adas", "cost " + ( System.currentTimeMillis() - start ) + "ms" );
return true;
}
public static class AdasRec{
public String action = "view";
public List<ADASRecognizedResult> models;

View File

@@ -153,6 +153,11 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
MarkerServiceHandler.getApis().getAdasControllerApi().addAdasRecognizedDataCallback( resultList -> {
// 绘制近景识别到的车辆
AdasRecognizedResultDrawer.getInstance().renderAdasRecognizedResult( resultList );
//绘制他车的线 lixp TODO
//添加自车的定位图标 TODO
} );
}

View File

@@ -1,6 +1,7 @@
package com.mogo.module.v2x;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import com.mogo.map.MogoLatLng;
@@ -80,12 +81,22 @@ public class V2XWaringManager {
/**
* 测试数据
*/
private void testData() {
private void testData(String adasResult) {
try {
int id = R.raw.scenario_warning_event_data;
switch (adasResult) {
case "left":
id = R.raw.scenario_warning_event_data_left;
break;
case "pedestrians":
id = R.raw.scenario_warning_event_data_pedestrians;
break;
default:
}
InputStream inputStream = V2XUtils.getApp()
.getResources()
.openRawResource(R.raw.scenario_warning_event_data);
.openRawResource(id);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int len = -1;
byte[] buffer = new byte[1024];
@@ -111,7 +122,7 @@ public class V2XWaringManager {
if (v2XWarnMessageListener != null) {
V2XServiceManager
.getMoGoSocketManager()
.unregisterOnMessageListener(10116, v2XWarnMessageListener);
.unregisterOnMessageListener(401018, v2XWarnMessageListener);
}
}
@@ -123,8 +134,8 @@ public class V2XWaringManager {
V2XServiceManager
.getMoGoSocketManager()
.registerOnMessageListener(
10116,
v2XWarnMessageListener );
401018,
v2XWarnMessageListener);
}
public V2XWarnMessageListener getV2XMessageListener() {
@@ -135,11 +146,11 @@ public class V2XWaringManager {
/**
* 处理adas返回的数据
*/
public void handleAdasData() {
public void handleAdasData(Intent intent) {
Log.d(V2XConst.LOG_NAME_WARN, "V2XWaringManager ---- handleAdasData ");
String adasResult = (String) intent.getSerializableExtra(V2XConst.BROADCAST_ADAS_EXTRA_KEY);
//测试数据
testData();
testData(adasResult);
// adas 每隔一秒传递的他车或行人数据,避免重复。
// V2XServiceManager.getmIMogoADASController().addAdasRecognizedDataCallback(resultList -> {
@@ -158,6 +169,7 @@ public class V2XWaringManager {
/**
* 添加2d的碰撞 marker
*
* @param markerShowEntity
* @return
*/

View File

@@ -69,7 +69,7 @@ public class V2XLocationListener
private CarLocationSubject mCarLocationSubject;
private V2XLocationListener() {
mCarLocationSubject = new CarLocationSubject();
mCarLocationSubject = CarLocationSubject.getInstance();
// 注册最优路线的推荐观察者
mCarLocationSubject.registerObserver(
V2XOptimalRouteObserver.TYPE,

View File

@@ -10,6 +10,7 @@ import com.mogo.service.connection.IMogoOnMessageListener;
/**
* desc: 下发的云端预警数据
*
*/
public class V2XWarnMessageListener implements IMogoOnMessageListener<V2XWarningEntity> {

View File

@@ -7,11 +7,12 @@ import android.util.Log;
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.V2XWarnDataDrawer;
import com.mogo.module.common.entity.MarkerShowEntity;
import com.mogo.module.common.entity.V2XWarningEntity;
import com.mogo.module.common.utils.Trigonometric;
import com.mogo.module.service.MarkerServiceHandler;
@@ -20,7 +21,9 @@ import com.mogo.module.v2x.MoGoV2XServicePaths;
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.listener.V2XLocationListener;
import com.mogo.module.v2x.manager.IMoGoV2XCloundDataManager;
import com.mogo.module.v2x.scenario.scene.warning.V2XFrontWarningScenario;
import com.mogo.utils.UiThreadHandler;
import com.mogo.utils.WorkThreadHandler;
@@ -28,6 +31,8 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static com.mogo.module.common.constants.DataTypes.TYPE_MARKER_CLOUD_STOP_LINE_DATA;
import static com.mogo.module.common.constants.DataTypes.TYPE_MARKER_CLOUD_WARN_DATA;
import static com.mogo.module.v2x.V2XServiceManager.getContext;
/**
@@ -35,6 +40,7 @@ import static com.mogo.module.v2x.V2XServiceManager.getContext;
*/
@Route(path = MoGoV2XServicePaths.PATH_V2X_WARN_CLOUND_DATA_MANAGER)
public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMogoCarLocationChangedListener2 {
private static String WARNING_ARROWS = "WARNING_ARROWS";
private V2XWarningEntity mCloundWarningInfo;
private static String TAG = "MoGoV2XCloundDataManager";
private boolean isSelfLineClear;
@@ -45,7 +51,15 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLon()
);
/*
* 自车前方的点,在停止线上--通过自车位置与距离停止线之间的距离计算
* */
private MogoLatLng middleLocationInStopLine;
private V2XFrontWarningScenario mV2XScenario;
private static long showTime = 0;
private float bearing;
@Override
public void init(Context context) {
@@ -56,27 +70,37 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
@Override
public void analysisV2XCloundDataEvent(V2XWarningEntity cloundWarningInfo) {
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
Log.d(V2XConst.LOG_NAME_WARN, "analysisV2XCloundDataEvent -----> ");
mCloundWarningInfo = cloundWarningInfo;
showTime = mCloundWarningInfo.getShowTime();
pointsBetween();
bearing = V2XLocationListener.getInstance().getLastCarLocation().getBearing();
//顶部弹框
if (mV2XScenario == null) {
mV2XScenario = new V2XFrontWarningScenario();
}
mV2XScenario.setWarningEntity(cloundWarningInfo);
mV2XScenario.init(null);
//预警蒙层
MarkerServiceHandler.getApis().getV2XListenerManager().warningChangedForListenerWithDirection(cloundWarningInfo.getType(), MogoReceiver.ACTION_V2X_FRONT_WARNING);
isSelfLineClear = false;
isFirstLocation = false;
if (cloundWarningInfo.getDirection() == 1) { //前方
MogoLatLng startLatLng = getMiddleLocationInStopLine();
MogoLatLng warningLocation = Trigonometric.getNewLocation(startLatLng, 80, cloundWarningInfo.getAngle());
V2XServiceManager.getMarkerManager().removeMarkers(WARNING_ARROWS);
if (cloundWarningInfo.getDirection() == 1) { //前方 TODO
middleLocationInStopLine = getMiddleLocationInStopLine();
MogoLatLng warningLocation = Trigonometric.getNewLocation(middleLocationInStopLine, 50, cloundWarningInfo.getAngle());
//停止线前方画线
WorkThreadHandler.getInstance().postDelayed(() -> {
//二轮车和行人的渲染和移动
V2XServiceManager.getMarkerManager().removeMarkers(TYPE_MARKER_CLOUD_WARN_DATA);
V2XWarnDataDrawer.getInstance().renderWarnData(cloundWarningInfo);
//绘制识别物与交汇点连线,并且更新连线数据
drawStopLine(cloundWarningInfo, startLatLng, warningLocation);
drawRedWarningLineFrontOfStopLine(cloundWarningInfo, middleLocationInStopLine, warningLocation);
//添加停止线marker
handleStopLine();
//自车画线
drawSlefCarLine(carLocation.lon, carLocation.lat, bearing);
}, 500);
UiThreadHandler.postDelayed(() -> {
@@ -91,7 +115,12 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
//绘制识别物与交汇点连线,并且更新连线数据
drawOtherObjectLine(cloundWarningInfo);
//二轮车和行人的渲染和移动
V2XServiceManager.getMarkerManager().removeMarkers(TYPE_MARKER_CLOUD_WARN_DATA);
V2XWarnDataDrawer.getInstance().renderWarnData(cloundWarningInfo);
//车辆静止的时候
drawSlefCarLine(carLocation.lon, carLocation.lat, bearing);
}, 500);
//延迟3秒清理线
@@ -104,32 +133,39 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
}
}
/*
* 停止线绘制
* */
private void handleStopLine() {
if (mCloundWarningInfo != null) {
for (int i = 0; i < fillPoints.size(); i++) {
V2XWarningEntity entity = new V2XWarningEntity();
MogoLatLng latLng = (MogoLatLng) fillPoints.get(i);
entity.setLat(latLng.lat);
entity.setLon(latLng.lon);
entity.setCollisionLat(mCloundWarningInfo.getCollisionLat());
entity.setCollisionLon(mCloundWarningInfo.getCollisionLon());
entity.heading = mCloundWarningInfo.heading;
V2XWarnDataDrawer.getInstance().renderStopLineData(entity);
try {
if (mCloundWarningInfo != null) {
V2XServiceManager.getMarkerManager().removeMarkers(TYPE_MARKER_CLOUD_STOP_LINE_DATA);
for (int i = 0; i < fillPoints.size(); i++) {
V2XWarningEntity entity = new V2XWarningEntity();
MogoLatLng latLng = (MogoLatLng) fillPoints.get(i);
entity.setLat(latLng.lat);
entity.setLon(latLng.lon);
entity.setCollisionLat(mCloundWarningInfo.getCollisionLat());
entity.setCollisionLon(mCloundWarningInfo.getCollisionLon());
entity.heading = mCloundWarningInfo.heading;
V2XWarnDataDrawer.getInstance().renderStopLineData(entity);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 场景如:车辆行驶正前方绘制红色区域(停止线继续前行的预警区域) TODO 需要实时给行人当前位置
*/
private void drawStopLine(V2XWarningEntity info, MogoLatLng startLatLng, MogoLatLng mogoLatLng) {
private void drawRedWarningLineFrontOfStopLine(V2XWarningEntity info, MogoLatLng startLatLng, MogoLatLng mogoLatLng) {
if (info != null) {
IMogoPolyline polyLine = V2XServiceManager.getMoGoStopPolylineManager().getMogoStopPolyline();
MogoLatLng endLatlng = new MogoLatLng(mogoLatLng.lat, mogoLatLng.lon);
float distance = CoordinateUtils.calculateLineDistance(startLatLng.lon, startLatLng.lat, endLatlng.lon, endLatlng.lat);
MogoLatLng addMiddleLoc = Trigonometric.getNewLocation(startLatLng, distance / 2, mCloundWarningInfo.getAngle());
Log.d(V2XConst.LOG_NAME_WARN, "红色区域起始点 = " + startLatLng.lon + "," + startLatLng.lat +
Log.d(TAG, "红色区域起始点 = " + startLatLng.lon + "," + startLatLng.lat +
"中间点坐标:" + addMiddleLoc.lon + "," + addMiddleLoc.lat
+ "终点" + endLatlng.lon + "," + endLatlng.lat);
if (polyLine != null) {
@@ -145,11 +181,12 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
lineInfo.setLocations(locations);
lineInfo.setHeading(info.heading);
Log.d(V2XConst.LOG_NAME_WARN, "drawStopLine width = " + info.getRoadwidth());
lineInfo.setWidth(info.getRoadwidth() * 10 + 5);
lineInfo.setWidth(info.getRoadwidth() * 14 + 5);
V2XServiceManager.getMoGoStopPolylineManager().drawStopPolyline(getContext(), lineInfo);
}
} else {
V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine();
V2XServiceManager.getMoGoStopPolylineManager().clearLine();
}
}
@@ -160,10 +197,11 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
private void drawOtherObjectLine(V2XWarningEntity info) {
if (info != null) {
IMogoPolyline polyLine = V2XServiceManager.getMoGoPersonWarnPolylineManager().getMogoPersonWarnPolyline();
MogoLatLng startLatlng = new MogoLatLng(info.getLat(), info.getLon());
MogoLatLng endLatlng = new MogoLatLng(info.getCollisionLat(), info.getCollisionLon());
float distance = CoordinateUtils.calculateLineDistance(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat);
MogoLatLng addMiddleLoc = Trigonometric.getNewLocation(startLatlng, distance / 2, mCloundWarningInfo.getAngle());
MogoLatLng startLatlng = new MogoLatLng(info.getLat(), info.getLon());//识别物坐标
MogoLatLng endLatlng = new MogoLatLng(info.getCollisionLat(), info.getCollisionLon());//预碰撞点坐标
float distance = CoordinateUtils.calculateLineDistance(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat);//识别物到碰撞点之间的距离
MogoLatLng addMiddleLoc = Trigonometric.getNewLocation(startLatlng, distance / 2,
Trigonometric.getAngle(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat));//补点
if (polyLine != null) {
Log.d(V2XConst.LOG_NAME_WARN, "polyLine != null");
polyLine.setPoints(Arrays.asList(startLatlng, addMiddleLoc, endLatlng));
@@ -178,8 +216,10 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
lineInfo.setLocations(locations);
lineInfo.setHeading(info.heading);
Log.d(V2XConst.LOG_NAME_WARN, "drawOtherObjectLine width = " + info.getRoadwidth());
lineInfo.setWidth(info.getRoadwidth() * 10 + 5);
lineInfo.setWidth(info.getRoadwidth() * 14 + 5);
V2XServiceManager.getMoGoPersonWarnPolylineManager().drawPersonWarnPolyline(getContext(), lineInfo);
//识别物到预碰撞点之间的箭头
addArrows(startLatlng, endLatlng);
}
} else {
Log.e(V2XConst.LOG_NAME_WARN, "info == null");
@@ -189,17 +229,24 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
//侧面目标物与碰撞点之间添加多个小箭头
private void addArrows(MogoLatLng startLatLng, MogoLatLng endLatLng) {
MarkerShowEntity markerShowEntity = new MarkerShowEntity();
float distance = CoordinateUtils.calculateLineDistance(
startLatLng.lon, startLatLng.lat, endLatLng.lon, endLatLng.lat);
double rotate = Trigonometric.getAngle(startLatLng.lon, startLatLng.lat, endLatLng.lon, endLatLng.lat);
Log.d(TAG, "添加小箭头--目标物与预碰撞点之间的距离是" + String.valueOf(distance));
if (distance > 5) {
int count = (int) (distance / 5);
for (int i = 0; i < count; i++) {
MogoLatLng newLo = Trigonometric.getNewLocation(
startLatLng, 5 * i, mCloundWarningInfo.getAngle());
V2XWarnDataDrawer.getInstance().drawerMarkerWithLocation(markerShowEntity, newLo);
startLatLng, 5 * (i + 1), Trigonometric.getAngle(startLatLng.lon, startLatLng.lat, endLatLng.lon, endLatLng.lat));
Log.d(TAG, "小箭头位置" + newLo);
V2XWarnDataDrawer.getInstance().drawerArrowsMarkerWithLocation(newLo, WARNING_ARROWS, 10, new Double(rotate).intValue());
}
}
//延迟3秒清理线
UiThreadHandler.postDelayed(() -> {
V2XServiceManager.getMarkerManager().removeMarkers(WARNING_ARROWS);
}, showTime);
}
@Override
@@ -207,48 +254,52 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
}
/**
* 自车定位 移动完成需要 3s消失,这里何时清理,应该是没有数据的时候
*/
@Override
public void onCarLocationChanged2(Location latLng) {
// Log.d(V2XConst.LOG_NAME_WARN, "onCarLocationChanged2 latLng = " + latLng.getLatitude() + "--" + latLng.getLongitude() + "---isSelfLineClear = " + isSelfLineClear);
// Log.d(V2XConst.LOG_NAME_WARN, "onCarLocationChanged2 lat = " + latLng.getLatitude() + "--lon =" + latLng.getLongitude() + "---isSelfLineClear = " + isSelfLineClear);
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
//当行人经纬度交点 开始画线,否则清理
if (mCloundWarningInfo != null) {
mCloundWarningInfo.setCarLocation(new MogoLatLng(latLng.getLatitude(), latLng.getLongitude()));
}
drawSlefCarLine(latLng);
drawSlefCarLine(latLng.getLongitude(), latLng.getLatitude(), latLng.getBearing());
}
carLocation = new MogoLatLng(latLng.getLatitude(), latLng.getLongitude());
drawSlefCarLine(latLng);
}
@Override
public void onCarLocationChanged(MogoLatLng latLng) {
}
/**
* 绘制安全区域,自车与碰撞点之间的蓝色线
* 自车为起点绘制(根据设计,前方行人/弱势交通参与者预警 getDirection() == 1 自车与停止线之间为蓝色预警;其他侧方预警自车与预碰撞点之间显示红色预警)
*/
private void drawSlefCarLine(Location latLng) {
private void drawSlefCarLine(double lon, double lat, float bearing) {
if (!isSelfLineClear) {
IMogoPolyline mogoPolyline = V2XServiceManager.getMoGoWarnPolylineManager().getMogoWarnPolyline();
if (mCloundWarningInfo != null) {
MogoLatLng startLatlng = null;
MogoLatLng endLatlng = null;
MogoLatLng addMiddleLoc = null;
if (!isFirstLocation) {
startLatlng = new MogoLatLng(latLng.getLatitude(), latLng.getLongitude());
carLocation = getMogoLat(new MogoLatLng(latLng.getLatitude(), latLng.getLongitude()));
endLatlng = new MogoLatLng(mCloundWarningInfo.getDirection() == 1 ? carLocation.lat : mCloundWarningInfo.getCollisionLat(),
mCloundWarningInfo.getDirection() == 1 ? carLocation.lon : mCloundWarningInfo.getCollisionLon());
float distance = CoordinateUtils.calculateLineDistance(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat);
addMiddleLoc = Trigonometric.getNewLocation(startLatlng, distance / 2, mCloundWarningInfo.getAngle());
Log.d(V2XConst.LOG_NAME_WARN, "drawSlefCarLine lon = " + carLocation.lon + "---lat = " + carLocation.lat);
carLocation = getMogoLat(new MogoLatLng(lat, lon));
isFirstLocation = true;
}
//自车位置
endLatlng = new MogoLatLng(mCloundWarningInfo.getDirection() == 1 ? middleLocationInStopLine.lat : mCloundWarningInfo.getCollisionLat(),
mCloundWarningInfo.getDirection() == 1 ? middleLocationInStopLine.lon : mCloundWarningInfo.getCollisionLon());
startLatlng = new MogoLatLng(lat, lon);
float distance = CoordinateUtils.calculateLineDistance(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat);
addMiddleLoc = Trigonometric.getNewLocation(startLatlng, distance / 2, Trigonometric.getAngle(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat));
Log.d(TAG, "自车为起点绘制 自车;" + startLatlng.lat + "," + startLatlng.lon +
"中间扩展点" + addMiddleLoc.lon + "," + addMiddleLoc.lat + "终点:" + endLatlng.lon + "," + endLatlng.lat);
if (mogoPolyline != null) {
mogoPolyline.setPoints(Arrays.asList(startLatlng, addMiddleLoc, endLatlng));
mogoPolyline.setTransparency(0.5f);
@@ -260,8 +311,8 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
locations.add(addMiddleLoc);
locations.add(endLatlng);
info.setLocations(locations);
info.setHeading(latLng.getBearing());
info.setWidth(mCloundWarningInfo.getRoadwidth() * 10 + 5);
info.setHeading(bearing);
info.setWidth(mCloundWarningInfo.getRoadwidth() * 14 + 5);
info.setDirection(mCloundWarningInfo.getDirection());
V2XServiceManager.getMoGoWarnPolylineManager().drawWarnPolyline(getContext(), info);
}

View File

@@ -35,7 +35,9 @@ public class MoGoV2XPolylineManager implements IMoGoV2XPolylineManager {
}
if ((V2XServiceManager.getMoGoV2XStatusManager().isRoadEventPOIShow()
|| V2XServiceManager.getMoGoV2XStatusManager().isOtherSeekHelpPOIShow())
&& V2XServiceManager.getV2XStatusManager().getTargetMoGoLatLng() != null) {
&& V2XServiceManager.getV2XStatusManager().getTargetMoGoLatLng() != null
&& !V2XServiceManager.getMoGoStatusManager().isVrMode()
) {
// 连接线参数
MogoPolylineOptions options = new MogoPolylineOptions();

View File

@@ -56,7 +56,6 @@ public class MoGoWarnPolylineManager implements IMoGoWarnPolylineManager {
// 线条粗细,渐变,渐变色值
// 当前车辆位置
options.width(info.getWidth() == 0.0 ? 60 : info.getWidth()).useGradient(true).colorValues(colors);
// options.width(60).useGradient(true).colorValues(colors);
List<MogoLatLng> locations = info.getLocations();
for (int i = 0; i < locations.size(); i++) {
options.add(locations.get(i));

View File

@@ -12,12 +12,27 @@ import java.util.Set;
*/
public class CarLocationSubject {
private static CarLocationSubject mCarLocationSubject;
// 车辆位置
public MogoLocation carLocation;
// 观察者集合
private HashMap<String, CarLocationObserver> observers = new HashMap<String, CarLocationObserver>();
private HashMap<String, CarLocationObserver> mObservers = new HashMap<>();
private CarLocationSubject() {
}
public static CarLocationSubject getInstance() {
if (mCarLocationSubject == null) {
synchronized (CarLocationSubject.class) {
if (mCarLocationSubject == null) {
mCarLocationSubject = new CarLocationSubject();
}
}
}
return mCarLocationSubject;
}
/**
* 设置新的车辆位置
*
@@ -35,7 +50,7 @@ public class CarLocationSubject {
* @param observer 新的观察者
*/
public void registerObserver(String observerType, CarLocationObserver observer) {
observers.put(observerType, observer);
mObservers.put(observerType, observer);
}
/**
@@ -44,16 +59,16 @@ public class CarLocationSubject {
* @param observerType 观察者类型
*/
public void removeObserver(String observerType) {
observers.remove(observerType);
mObservers.remove(observerType);
}
/**
* 通知所有观察者更新
*/
private void notifyAllObservers() {
Set<String> keySet = observers.keySet();
Set<String> keySet = mObservers.keySet();
for (String s : keySet) {
CarLocationObserver observer = observers.get(s);
CarLocationObserver observer = mObservers.get(s);
if (observer != null) {
observer.update(carLocation);
}

View File

@@ -6,6 +6,7 @@ import com.mogo.map.overlay.IMogoPolyline;
import com.mogo.map.overlay.MogoPolylineOptions;
import com.mogo.module.v2x.V2XServiceManager;
import com.mogo.module.v2x.utils.LocationUtils;
import com.mogo.utils.ColorUtils;
import java.util.ArrayList;
import java.util.List;
@@ -22,16 +23,15 @@ public class V2XOptimalRouteOverlay {
private MogoPolylineOptions mPolylineOptions;
// 线路径集合
private List<MogoLatLng> mPolylinePointList;
// 渐变色
private List<Integer> mPolylineColors;
public V2XOptimalRouteOverlay() {
mPolylineOptions = new MogoPolylineOptions();
// 渐变色
List<Integer> colors = new ArrayList<>();
colors.add(0xFFF95959);
// 线条粗细,渐变,渐变色值
mPolylineOptions.width(25).useGradient(true).colorValues(colors);
// 绘制路径集合
mPolylinePointList = new ArrayList<>();
// 引导线颜色
mPolylineColors = new ArrayList<>();
}
/**
@@ -43,8 +43,10 @@ public class V2XOptimalRouteOverlay {
if (mMoGoPolyline != null) {
mMoGoPolyline.remove();
mPolylinePointList.clear();
mPolylineColors.clear();
}
if (polylinePoint != null) {
// 将当前车辆位置放进去
mPolylinePointList.add(new MogoLatLng(carLocal.getLatitude(), carLocal.getLongitude()));
// 过滤后台推送的推荐路线集合
@@ -54,8 +56,13 @@ public class V2XOptimalRouteOverlay {
mPolylinePointList.add(polyline);
}
}
mPolylineColors.addAll(ColorUtils.gradientAlpha("#002965ED", "#FF2965ED", mPolylinePointList.size() / 3));
// 替换路径集合
mPolylineOptions.points(mPolylinePointList);
// 线条粗细,渐变,渐变色值
mPolylineOptions.width(25).useGradient(true).colorValues(mPolylineColors);
// 绘制线
mMoGoPolyline = V2XServiceManager.getMogoOverlayManager().addPolyline(mPolylineOptions);
}

View File

@@ -23,7 +23,7 @@ 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().handleAdasData();
V2XWaringManager.getInstance().handleAdasData(intent);
} catch (Exception e) {
e.printStackTrace();

View File

@@ -40,6 +40,9 @@ public class V2XFatigueDrivingScenario extends AbsV2XScenario<V2XPushMessageEnti
@Override
public void init(@Nullable V2XMessageEntity<V2XPushMessageEntity> v2XMessageEntity) {
if (V2XServiceManager.getMoGoStatusManager().isVrMode()) {
return;
}
if (!isSameScenario(v2XMessageEntity)) {
setV2XMessageEntity(v2XMessageEntity);
if (v2XMessageEntity != null) {

View File

@@ -362,17 +362,21 @@ public class V2XTestConsoleWindow extends ConstraintLayout {
});
/*
*障碍物绕行
*车路云场景预警-左侧
* */
btnTriggerObstacleDetour.setOnClickListener(v -> {
Intent intent = new Intent(V2XConst.BROADCAST_ADAS_SCENE_HANDLER_ACTION);
intent.putExtra(V2XConst.BROADCAST_ADAS_EXTRA_KEY, "left");
getContext().sendBroadcast(intent);
});
/*
*行人预警,行人路线预测
*行人预警,行人路线预测 车路云预警-前方行人
* */
btnTriggerPedestrianWarning.setOnClickListener(v -> {
Intent intent = new Intent(V2XConst.BROADCAST_ADAS_SCENE_HANDLER_ACTION);
intent.putExtra(V2XConst.BROADCAST_ADAS_EXTRA_KEY, "pedestrians");
getContext().sendBroadcast(intent);
});
/*

View File

@@ -48,24 +48,35 @@ public class V2XFrontWarningScenario extends AbsV2XScenario implements IMogoTopV
public V2XFrontWarningScenario() {
setV2XWindow(new V2XWarningWindow());
setV2XMarker(new V2XWarningMarker());
// setV2XMarker(new V2XWarningMarker());
}
@Override
public void init(@Nullable V2XMessageEntity v2XMessageEntity) {
try {
if (v2XMessageEntity != null && V2XServiceManager.getMoGoStatusManager().isMainPageOnResume()) {
mMarkerEntity = (V2XWarningEntity) v2XMessageEntity.getContent();
if (v2XMessageEntity != null) {
if (V2XServiceManager.getMoGoStatusManager().isMainPageOnResume()) {
mMarkerEntity = (V2XWarningEntity) v2XMessageEntity.getContent();
direction = mMarkerEntity.getDirection();
MarkerServiceHandler.getApis().getV2XListenerManager().warningChangedForListenerWithDirection(direction, MogoReceiver.ACTION_V2X_FRONT_WARNING);
show();
drawPOI();
}
} else {
direction = mMarkerEntity.getDirection();
MarkerServiceHandler.getApis().getV2XListenerManager().warningChangedForListenerWithDirection(direction, MogoReceiver.ACTION_V2X_FRONT_WARNING);
show();
drawPOI();
// drawPOI();
}
} catch (Exception e) {
e.printStackTrace();
}
}
public void setWarningEntity(V2XWarningEntity markerEntity) {
mMarkerEntity = markerEntity;
}
@Override
public void show() {
showWindow();
@@ -84,7 +95,7 @@ public class V2XFrontWarningScenario extends AbsV2XScenario implements IMogoTopV
.getMogoTopViewManager()
.addView(getV2XWindow().getView(), layoutParams, this);
getV2XWindow().show(mMarkerEntity);
getV2XMarker().drawPOI(mMarkerEntity);
// getV2XMarker().drawPOI(mMarkerEntity);
}
}
@@ -105,8 +116,10 @@ public class V2XFrontWarningScenario extends AbsV2XScenario implements IMogoTopV
@Override
public void drawPOI() {
getV2XMarker().drawPOI(mMarkerEntity);
Log.d(TAG, "drawPOI");
if (getV2XMarker() != null) {
getV2XMarker().drawPOI(mMarkerEntity);
Log.d(TAG, "drawPOI");
}
}
@Override

View File

@@ -237,6 +237,7 @@
android:textColor="#FFFFFF"
android:textSize="@dimen/dp_22"
android:textStyle="bold" />
<Button
android:id="@+id/btnTriggerWarningEvent"
android:layout_width="wrap_content"
@@ -426,7 +427,21 @@
android:layout_marginBottom="@dimen/dp_10"
android:background="#00BCD4"
android:padding="@dimen/dp_10"
android:text="障碍物绕行"
android:text="车路云场景预警-左侧"
android:textColor="#FFFFFF"
android:textSize="@dimen/dp_22"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<Button
android:id="@+id/btnAdasDataWarn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/dp_10"
android:layout_marginBottom="@dimen/dp_10"
android:background="#8BC34A"
android:padding="@dimen/dp_10"
android:text="车路云场景预警-右侧"
android:textColor="#FFFFFF"
android:textSize="@dimen/dp_22"
app:layout_constraintBottom_toBottomOf="parent"
@@ -440,7 +455,7 @@
android:layout_marginBottom="@dimen/dp_10"
android:background="#009688"
android:padding="@dimen/dp_10"
android:text="行人预警,行人路线预测"
android:text="车路云场景预警-前方行人"
android:textColor="#FFFFFF"
android:textSize="@dimen/dp_22"
app:layout_constraintBottom_toBottomOf="parent"
@@ -473,21 +488,6 @@
android:textSize="@dimen/dp_22"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<Button
android:id="@+id/btnAdasDataWarn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/dp_10"
android:layout_marginBottom="@dimen/dp_10"
android:background="#8BC34A"
android:padding="@dimen/dp_10"
android:text="adas预警数据发送"
android:textColor="#FFFFFF"
android:textSize="@dimen/dp_22"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</com.google.android.flexbox.FlexboxLayout>

View File

@@ -1,7 +1,7 @@
{
"type": 10013,
"lat": 39.977148,
"lon": 116.417478,
"lon": 116.417886,
"distance": 2,
"collisionLat": 39.977094,
"collisionLon": 116.417634,
@@ -11,13 +11,13 @@
"lon": 116.417651
},
{
"lat": 39.976874,
"lon": 116.417757
"lat": 39.976858,
"lon": 116.417683
}
],
"from": 1,
"angle": 0,
"direction": 1,
"direction": 3,
"speed": 11.108121,
"targetColor": "#FF4040",
"stopLineDistance": 60,

View File

@@ -0,0 +1,32 @@
{
"type": 10013,
"lat": 39.977148,
"lon": 116.417478,
"distance": 2,
"collisionLat": 39.977094,
"collisionLon": 116.417634,
"stopLines": [
{
"lat": 39.976858,
"lon": 116.417651
},
{
"lat": 39.976874,
"lon": 116.417757
}
],
"from": 1,
"angle": 0,
"direction": 3,
"speed": 11.108121,
"targetColor": "#FF4040",
"stopLineDistance": 60,
"warningContent": "小心行人",
"heading": 0,
"showTime": 8000,
"roadwidth": 4.0,
"carLocation": {
"lat": 39.97665425,
"lon": 116.41769983
}
}

View File

@@ -0,0 +1,32 @@
{
"type": 10013,
"lat": 39.977148,
"lon": 116.417886,
"distance": 2,
"collisionLat": 39.977094,
"collisionLon": 116.417634,
"stopLines": [
{
"lat": 39.976858,
"lon": 116.417651
},
{
"lat": 39.976858,
"lon": 116.417683
}
],
"from": 1,
"angle": 0,
"direction": 1,
"speed": 11.108121,
"targetColor": "#FF4040",
"stopLineDistance": 60,
"warningContent": "小心行人",
"heading": 0,
"showTime": 8000,
"roadwidth": 4.0,
"carLocation": {
"lat": 39.97665425,
"lon": 116.41769983
}
}

View File

@@ -23,7 +23,7 @@ public
* @author congtaowang
* @since 2020/8/12
*
* 描述
* 高德地图启动的时候才会用到这个模块
*/
@Route( path = MogoWidgetsProvider.PATH )
class MogoWidgetsProvider implements IMogoModuleProvider {