增加了OBU提供自车位置的功能

This commit is contained in:
董宏宇
2021-08-25 12:53:50 +08:00
parent 152c916a8e
commit f7214481a2
10 changed files with 269 additions and 228 deletions

View File

@@ -31,5 +31,7 @@ project.android.productFlavors {
buildConfigField 'boolean', 'IS_USE_ADAS_RTK_LOCATION_INFO', 'true'
// 是否需要悬浮窗权限申请
buildConfigField 'boolean', 'IS_NEED_REQUEST_FLOAT_PERMISSION', 'true'
// GPS数据提供源 0-Android系统1-工控机2-OBU
buildConfigField 'int', 'GPS_PROVIDER', "2"
}
}

View File

@@ -10,11 +10,11 @@ import com.auto.zhidao.logsdk.CrashSystem;
import com.bytedance.boost_multidex.BoostMultiDex;
import com.mogo.cloud.httpdns.MogoHttpDnsConfig;
import com.mogo.cloud.httpdns.bean.HttpDnsSimpleLocation;
import com.mogo.cloud.httpdns.listener.IHttpDnsCurrentLocation;
import com.mogo.cloud.passport.IMoGoTokenCallback;
import com.mogo.cloud.passport.MoGoAiCloudClient;
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.commons.FunctionBuildConfig;
import com.mogo.commons.constants.SharedPrefsConstants;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.commons.network.Utils;
@@ -36,7 +36,6 @@ import com.mogo.service.MogoServicePaths;
import com.mogo.test.crashreport.ITestCrashReportProvider;
import com.mogo.test.crashreport.upgrade.UpgradeReportProvider;
import com.mogo.utils.ProcessUtils;
import com.mogo.utils.httpdns.HttpSimpleLocation;
import com.mogo.utils.logger.LogLevel;
import com.mogo.utils.logger.Logger;
import com.mogo.utils.storage.SharedPrefsMgr;
@@ -70,7 +69,7 @@ public class MogoApplication extends AbsMogoApplication {
CrashSystem crashSystem = CrashSystem.getInstance(this);
crashSystem.init();
//设置debug模式日志不上传
// crashSystem.setDebug(BuildConfig.DEBUG);
// crashSystem.setDebug(BuildConfig.DEBUG);
Logger.init(BuildConfig.DEBUG ? LogLevel.DEBUG : LogLevel.OFF);
initTipToast();
initModules();
@@ -109,6 +108,8 @@ public class MogoApplication extends AbsMogoApplication {
DebugConfig.setUseAdasRtkLocationInfo(BuildConfig.IS_USE_ADAS_RTK_LOCATION_INFO);
DebugConfig.setNeedRequestFloatPermission(BuildConfig.IS_NEED_REQUEST_FLOAT_PERMISSION);
DebugConfig.setObuType(SharedPrefsMgr.getInstance(this).getInt("OBU_TYPE", DebugConfig.OBU_TYPE_CIDI));
FunctionBuildConfig.gpsProvider = BuildConfig.GPS_PROVIDER;
}
@Override
@@ -181,11 +182,11 @@ public class MogoApplication extends AbsMogoApplication {
clientConfig.setLoopCheckDelay(5 * 1000);
// 设置DNS经纬度位置
// clientConfig.setIHttpDnsCurrentLocation(() -> {
// SocketTestBroadCastReceiver.SocketTestData socketTestData = SocketTestBroadCastReceiver.SocketTestData.getInstance();
// Log.d("TEST-SOCKET","socketTestData cityCode: " + socketTestData.getCityCode());
// return new HttpDnsSimpleLocation(socketTestData.getCityCode(),socketTestData.getLat(),socketTestData.getLon()); //todo 对象唯一实例优化
// });
// clientConfig.setIHttpDnsCurrentLocation(() -> {
// SocketTestBroadCastReceiver.SocketTestData socketTestData = SocketTestBroadCastReceiver.SocketTestData.getInstance();
// Log.d("TEST-SOCKET","socketTestData cityCode: " + socketTestData.getCityCode());
// return new HttpDnsSimpleLocation(socketTestData.getCityCode(),socketTestData.getLat(),socketTestData.getLon()); //todo 对象唯一实例优化
// });
clientConfig.setIHttpDnsCurrentLocation(() -> {
MogoLocation mogoLocation =
MogoApisHandler.getInstance()
@@ -244,7 +245,7 @@ public class MogoApplication extends AbsMogoApplication {
);
}
private void uploadLocPerFiveSecond(){
private void uploadLocPerFiveSecond() {
if (DebugConfig.getCarMachineType() != DebugConfig.CAR_MACHINE_TYPE_SELF_INNOVATE) {
IMogoServiceApis apis = MogoApisHandler.getInstance().getApis();
apis.getLocationInfoApi().start();

View File

@@ -8,9 +8,9 @@ package com.mogo.commons;
public class FunctionBuildConfig {
// 地图是否绘制Adas识别回调的Marker
public boolean isShowAdasMarker = true;
public static boolean isShowAdasMarker = true;
// 自车位置使用哪种外部数据源,0-Android系统1-工控机2-OBU
public int gpsProvider = 0;
public static int gpsProvider = 0;
}

View File

@@ -1,5 +1,9 @@
package com.mogo.map.impl.custom;
import static com.mogo.map.uicontroller.VisualAngleMode.MODE_CLOSE_SIGHT;
import static com.mogo.map.uicontroller.VisualAngleMode.MODE_LONG_SIGHT;
import static com.mogo.map.uicontroller.VisualAngleMode.MODE_MEDIUM_SIGHT;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Point;
@@ -16,6 +20,7 @@ import android.view.ViewGroup;
import android.view.animation.Interpolator;
import android.widget.TextView;
import com.mogo.commons.FunctionBuildConfig;
import com.mogo.commons.constants.SharedPrefsConstants;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.map.IMogoMap;
@@ -71,10 +76,6 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import static com.mogo.map.uicontroller.VisualAngleMode.MODE_CLOSE_SIGHT;
import static com.mogo.map.uicontroller.VisualAngleMode.MODE_LONG_SIGHT;
import static com.mogo.map.uicontroller.VisualAngleMode.MODE_MEDIUM_SIGHT;
public class AMapViewWrapper implements IMogoMapView,
IMogoMapUIController,
LocationListener,
@@ -114,7 +115,7 @@ public class AMapViewWrapper implements IMogoMapView,
public AMapViewWrapper(MapAutoView mMapView) {
startTime = System.currentTimeMillis();
Logger.i(TAG, "autoop--AMapViewWrapper: init");
// Logger.i("lianglihui", "autoop--AMapViewWrapper: init");
// Logger.i("lianglihui", "autoop--AMapViewWrapper: init");
this.mMapView = mMapView;
if (DebugConfig.isDebug()) {
GpsTester.getInstance().init(mMapView);
@@ -136,64 +137,64 @@ public class AMapViewWrapper implements IMogoMapView,
if (options != null) {
options.setZoomGesturesEnabled(true);
// 设置是否开启自动黑夜模式切换默认为false不自动切换
// options.setAutoSwitchStyle(false);
// options.setAutoSwitchStyle(false);
// 设置6秒后是否自动锁车
// options.setAutoLockCar( false );
// options.setAutoLockCar( false );
// 设置路线上的摄像头气泡是否显示
// options.setCameraBubbleShow( true );
// options.setCameraBubbleShow( true );
// 设置路线相关的配置属性,如:路线的路况颜色,路线上是否显示摄像头气泡等。
// options.setRouteOverlayOptions( MapStyleUtils.getRouteOverlayOptions() );
// 设置自车的图片对象
options.setMyLocationStyle(options.getMyLocationStyle().myLocationIcon(DEFAULT_OPTION.getCarCursorRes()));
// 设置指南针图标否在导航界面显示默认显示。true显示false隐藏。
// options.hiddenDirection();
// options.hiddenDirection();
// 黑夜模式
// options.setMapStyle(MapAutoApi.MAP_STYLE_NIGHT);
// options.setMapStyle(MapAutoApi.MAP_STYLE_NIGHT);
//设置路况光柱条是否显示(只适用于驾车导航,需要联网)。
// options.setTrafficBarEnabled( false );
// options.setTrafficBarEnabled( false );
// 设置[实时交通图层开关按钮]是否显示(只适用于驾车导航,需要联网)。
// options.setTrafficLayerEnabled( false );
// options.setTrafficLayerEnabled( false );
// 设置导航界面是否显示路线全览按钮。
// options.setRouteListButtonShow( false );
// options.setRouteListButtonShow( false );
// 设置导航状态下屏幕是否一直开启。
// options.setScreenAlwaysBright( true );
// options.setScreenAlwaysBright( true );
// 设置交通播报是否打开(只适用于驾车导航,需要联网)。
// options.setTrafficInfoUpdateEnabled( true );
// options.setTrafficInfoUpdateEnabled( true );
// 设置摄像头播报是否打开(只适用于驾车导航)。
// options.setCameraInfoUpdateEnabled( true );
// options.setCameraInfoUpdateEnabled( true );
// 设置菜单按钮是否在导航界面显示。
// options.setSettingMenuEnabled( false );
// options.setSettingMenuEnabled( false );
// 设置是否绘制显示交通路况的线路(彩虹线),拥堵-红色,畅通-绿色,缓慢-黄色,未知-蓝色。默认不绘制彩虹线。
// options.setTrafficLine( true );
// options.setTrafficLine( true );
// 设置是否绘制牵引线(当前位置到目的地的指引线)。默认不绘制牵引线。
// options.setLeaderLineEnabled( -1 );
// options.setLeaderLineEnabled( -1 );
// 设置导航界面UI是否显示。
// options.setLayoutVisible( false );
// options.setLayoutVisible( false );
// 设置是否自动画路
// options.setAutoDrawRoute( false );
// options.setAutoDrawRoute( false );
// 设置是否显示路口放大图(实景图)
// options.setRealCrossDisplayShow( false );
// options.setRealCrossDisplayShow( false );
// 设置是否显示路口放大图(路口模型图)
// options.setModeCrossDisplayShow( false );
// options.setModeCrossDisplayShow( false );
// 设置是否显示道路信息view
// options.setLaneInfoShow( false );
// options.setLaneInfoShow( false );
// 设置是否自动改变缩放等级
// options.setAutoChangeZoom( false );
// options.setAutoChangeZoom( false );
// 设置是否自动全览模式,即在算路成功后自动进入全览模式
// options.setAutoDisplayOverview( false );
// options.setAutoDisplayOverview( false );
// 设置路线转向箭头隐藏和显示
// options.setNaviArrowVisible( false );
// options.setNaviArrowVisible( false );
// 通过路线是否自动置灰,仅支持驾车导航
// options.setAfterRouteAutoGray( true );
// options.setZoom(((int) mDefaultZoomLevel));
// options.setPointToCenter( 0.5D, 0.5D );
// options.setAfterRouteAutoGray( true );
// options.setZoom(((int) mDefaultZoomLevel));
// options.setPointToCenter( 0.5D, 0.5D );
// 2D模式
// options.setMapViewPerspective(MapAutoApi.MAP_PERSPECTIVE_2D);
// mMapView.setViewOptions( options );
// options.setMapViewPerspective(MapAutoApi.MAP_PERSPECTIVE_2D);
// mMapView.setViewOptions( options );
}
// mMapView.setRouteOverlayVisible( false );
// mMapView.setCarOverlayVisible( false );
// setUIMode(EnumMapUI.CarUp_2D);
// mMapView.setRouteOverlayVisible( false );
// mMapView.setCarOverlayVisible( false );
// setUIMode(EnumMapUI.CarUp_2D);
}
private void initListeners() {
@@ -204,7 +205,7 @@ public class AMapViewWrapper implements IMogoMapView,
mMapView.setOnMapTouchListener(this);
mMapView.setOnMapClickListener(this);
mMapView.getLocationClient().registerListener(this);
// mMapView.getLocationClient().registerGpsListener( this );
// mMapView.getLocationClient().registerGpsListener( this );
mMapView.registerListener(this, MapAutoApi.LISTENER_TYPE_ZOOM);
mMapView.registerListener(this, MapAutoApi.LISTENER_TYPE_ROTATE);
mMapView.registerListener(this, MapAutoApi.LISTENER_TYPE_3D);
@@ -213,17 +214,17 @@ public class AMapViewWrapper implements IMogoMapView,
mMapView.setOnMapViewVisualAngleChangeListener(this);
Logger.d(TAG, "styleop - initListeners - setOnMapStyleListener - view %s", mMapView);
// mMapView.setOnPolylineClickListener( this );
// mMapView.setAMapNaviViewListener( this );
//
// final AMap aMap = mMapView.getMap();
// if ( aMap != null ) {
// aMap.setOnPOIClickListener( this );
// aMap.setOnMapClickListener( this );
// aMap.setOnCameraChangeListener( this );
// aMap.setOnMyLocationChangeListener( this );
// }
// AMapMessageManager.getInstance().registerAMapMessageListener( this );
// mMapView.setOnPolylineClickListener( this );
// mMapView.setAMapNaviViewListener( this );
//
// final AMap aMap = mMapView.getMap();
// if ( aMap != null ) {
// aMap.setOnPOIClickListener( this );
// aMap.setOnMapClickListener( this );
// aMap.setOnCameraChangeListener( this );
// aMap.setOnMyLocationChangeListener( this );
// }
// AMapMessageManager.getInstance().registerAMapMessageListener( this );
}
private Context getContext() {
@@ -295,7 +296,7 @@ public class AMapViewWrapper implements IMogoMapView,
@Override
public void setTrafficEnabled(boolean visible) {
if (checkAMapView()) {
// mMapView.getMapAutoViewHelper().setTraffic( visible );
// mMapView.getMapAutoViewHelper().setTraffic( visible );
}
}
@@ -351,30 +352,30 @@ public class AMapViewWrapper implements IMogoMapView,
Logger.d(TAG, "设置的样式 = %s", ui);
if (checkAMapView()) {
switch (ui) {
// case CarUp_2D:
// case CarUp_3D:
// case NorthUP_2D:
// setUIMode(ui);
// break;
// case CarUp_2D:
// case CarUp_3D:
// case NorthUP_2D:
// setUIMode(ui);
// break;
case Type_VR:
if (DebugConfig.getCarMachineType() == DebugConfig.CAR_MACHINE_TYPE_LENOVO) {
mMapView.getMapAutoViewHelper().setScaleVRMode(true);
}
mMapView.getMapAutoViewHelper().setMapStyle(MapAutoApi.MAP_STYLE_VR);
return;
// case Type_Light:
// mMapView.getMapAutoViewHelper().setAutoSwitchStyle(false);
// mMapView.getMapAutoViewHelper().setMapStyle(MapAutoApi.MAP_STYLE_DAY);
// mIsLightStyle = true;
// break;
// case Type_Night:
// mMapView.getMapAutoViewHelper().setAutoSwitchStyle(false);
// mMapView.getMapAutoViewHelper().setMapStyle(MapAutoApi.MAP_STYLE_NIGHT);
// mIsLightStyle = false;
// break;
// case Type_AUTO_LIGHT_Night:
// mMapView.getMapAutoViewHelper().setAutoSwitchStyle(true);
// break;
// case Type_Light:
// mMapView.getMapAutoViewHelper().setAutoSwitchStyle(false);
// mMapView.getMapAutoViewHelper().setMapStyle(MapAutoApi.MAP_STYLE_DAY);
// mIsLightStyle = true;
// break;
// case Type_Night:
// mMapView.getMapAutoViewHelper().setAutoSwitchStyle(false);
// mMapView.getMapAutoViewHelper().setMapStyle(MapAutoApi.MAP_STYLE_NIGHT);
// mIsLightStyle = false;
// break;
// case Type_AUTO_LIGHT_Night:
// mMapView.getMapAutoViewHelper().setAutoSwitchStyle(true);
// break;
}
}
@@ -460,9 +461,9 @@ public class AMapViewWrapper implements IMogoMapView,
if (visible && NaviClient.getInstance(getContext()).isNaviing()) {
return;
}
// if (DebugConfig.isDebug()) {
// Logger.d(TAG, Log.getStackTraceString(new Throwable()));
// }
// if (DebugConfig.isDebug()) {
// Logger.d(TAG, Log.getStackTraceString(new Throwable()));
// }
if (checkAMapView()) {
MyLocationStyle style = mMapView.getMapAutoViewHelper().getMyLocationStyle();
if (visible) {
@@ -495,10 +496,10 @@ public class AMapViewWrapper implements IMogoMapView,
MyLocationStyle style = mMapView.getMapAutoViewHelper().getMyLocationStyle();
style.setLocationType(MyLocationStyle.LOCATION_TYPE_FOLLOW_NO_CENTER);
style.interval(1000);
// style.anchor( 0.5F, 0.5F );
// style.strokeColor( Color.TRANSPARENT );
// style.strokeWidth( 0 );
// style.radiusFillColor( Color.TRANSPARENT );
// style.anchor( 0.5F, 0.5F );
// style.strokeColor( Color.TRANSPARENT );
// style.strokeWidth( 0 );
// style.radiusFillColor( Color.TRANSPARENT );
mMapView.getMapAutoViewHelper().setMyLocationStyle(style);
}
}
@@ -506,14 +507,14 @@ public class AMapViewWrapper implements IMogoMapView,
@Override
public void recoverLockMode() {
if (checkAMapView()) {
// if ( DebugConfig.isDebug() ) {
// Logger.d( TAG, Log.getStackTraceString( new Throwable() ) );
// }
// if ( DebugConfig.isDebug() ) {
// Logger.d( TAG, Log.getStackTraceString( new Throwable() ) );
// }
if (mCurrentUI == EnumMapUI.Type_VR) {
return;
}
Logger.d(TAG, "锁车");
// mMapView.getMapAutoViewHelper().setZoom(mLockZoom);
// mMapView.getMapAutoViewHelper().setZoom(mLockZoom);
mMapView.getMapAutoViewHelper().setLockMode(true);
mIsCarLocked = true;
}
@@ -622,20 +623,20 @@ public class AMapViewWrapper implements IMogoMapView,
return;
}
try {
// final LatLng latLng = ObjectUtils.fromMogo2( marker.getPosition() );
// Point point = mMapView.getMap().getProjection().toScreenLocation( latLng );
// point.y -= WindowUtils.dip2px( getContext(), high );
// LatLng target = mMapView.getMap().getProjection().fromScreenLocation( point );
// //使用TranslateAnimation,填写一个需要移动的目标点
// Animation animation = new TranslateAnimation( target );
// animation.setInterpolator( interpolator );
// //整个移动所需要的时间
// animation.setDuration( duration );
// //设置动画
// if ( marker instanceof AMapMarkerWrapper ) {
// ( ( AMapMarkerWrapper ) marker ).getMarker().setAnimation( animation );
// ( ( AMapMarkerWrapper ) marker ).getMarker().startAnimation();
// }
// final LatLng latLng = ObjectUtils.fromMogo2( marker.getPosition() );
// Point point = mMapView.getMap().getProjection().toScreenLocation( latLng );
// point.y -= WindowUtils.dip2px( getContext(), high );
// LatLng target = mMapView.getMap().getProjection().fromScreenLocation( point );
// //使用TranslateAnimation,填写一个需要移动的目标点
// Animation animation = new TranslateAnimation( target );
// animation.setInterpolator( interpolator );
// //整个移动所需要的时间
// animation.setDuration( duration );
// //设置动画
// if ( marker instanceof AMapMarkerWrapper ) {
// ( ( AMapMarkerWrapper ) marker ).getMarker().setAnimation( animation );
// ( ( AMapMarkerWrapper ) marker ).getMarker().startAnimation();
// }
} catch (Exception e) {
Logger.e(TAG, e, "error.");
}
@@ -809,18 +810,18 @@ public class AMapViewWrapper implements IMogoMapView,
} catch (Exception e) {
}
} else {
// 通过不同的方向类型来改变车模目前暂定三种模型drawlevel 1 绿,2 黄,3 红,绿色的时候需要把相应的切换为默认模型
// Logger.d("liyz", " mDrawlevel = " + mDrawlevel);
// if (mDrawlevel == 1 && isShowWarn) {
// mSelfMarker.marker3DIcon(R.raw.car);
// isShowWarn = false;
// } else if (mDrawlevel == 2) { //不处理
//
// } else if (mDrawlevel == 3 && !isShowWarn) {
// //继续判断相应的方位,目前是只有 前方 TODO
// mSelfMarker.marker3DIcon(R.raw.qfpz);
// isShowWarn = true;
// }
// 通过不同的方向类型来改变车模目前暂定三种模型drawlevel 1 绿,2 黄,3 红,绿色的时候需要把相应的切换为默认模型
// Logger.d("liyz", " mDrawlevel = " + mDrawlevel);
// if (mDrawlevel == 1 && isShowWarn) {
// mSelfMarker.marker3DIcon(R.raw.car);
// isShowWarn = false;
// } else if (mDrawlevel == 2) { //不处理
//
// } else if (mDrawlevel == 3 && !isShowWarn) {
// //继续判断相应的方位,目前是只有 前方 TODO
// mSelfMarker.marker3DIcon(R.raw.qfpz);
// isShowWarn = true;
// }
}
showSelfSpeed(location.getSpeed());
}
@@ -926,7 +927,7 @@ public class AMapViewWrapper implements IMogoMapView,
@Override
public void onMapStatusChanged(int type, int value) {
// Logger.i( TAG, "mapop--onMapStatusChanged-: " + type + "," + value );
// Logger.i( TAG, "mapop--onMapStatusChanged-: " + type + "," + value );
}
@Override
@@ -951,12 +952,12 @@ public class AMapViewWrapper implements IMogoMapView,
@Override
public void onCameraChange(int type, int value) {
// Logger.i( TAG, "mapop--onCameraChange-: " + type + "," + value );
// Logger.i( TAG, "mapop--onCameraChange-: " + type + "," + value );
}
@Override
public void onCameraChangeFinish(@Nullable CameraPosition cameraPosition) {
// Logger.i( TAG, "mapop--onCameraChangeFinish-: " + cameraPosition + "cost:" + ( System.currentTimeMillis() - startTime ) );
// Logger.i( TAG, "mapop--onCameraChangeFinish-: " + cameraPosition + "cost:" + ( System.currentTimeMillis() - startTime ) );
if (cameraPosition != null) {
Trace.beginSection("timer.onCameraChangeFinish");
MogoMapListenerHandler.getInstance().onMapChanged(ObjectUtils.fromAMap(cameraPosition.getTarget()),
@@ -983,7 +984,7 @@ public class AMapViewWrapper implements IMogoMapView,
}
//目前切换完vr之后会立即回调其他样式这里做一个判断
// private boolean mVrModeAutoChangedFlag = false;
// private boolean mVrModeAutoChangedFlag = false;
@Override
public void onChangeMapStyle(int i) {
@@ -1002,11 +1003,11 @@ public class AMapViewWrapper implements IMogoMapView,
// 进入vr模式的时候自动切换到车头朝上
change2CarUp();
}
// else if ( i == MapAutoApi.MAP_PERSPECTIVE_2D ) {
// mCurrentUI = EnumMapUI.CarUp_2D;
// } else if ( i == MapAutoApi.MAP_PERSPECTIVE_3D ) {
// mCurrentUI = EnumMapUI.CarUp_3D;
// }
// else if ( i == MapAutoApi.MAP_PERSPECTIVE_2D ) {
// mCurrentUI = EnumMapUI.CarUp_2D;
// } else if ( i == MapAutoApi.MAP_PERSPECTIVE_3D ) {
// mCurrentUI = EnumMapUI.CarUp_3D;
// }
if (last == mCurrentUI) {
Logger.d(TAG, "currentUI is same as last = %s", mCurrentUI);
@@ -1021,10 +1022,10 @@ public class AMapViewWrapper implements IMogoMapView,
changeMapMode(EnumMapUI.Type_Light);
return;
}
// if ( mVrModeAutoChangedFlag ) {
// mVrModeAutoChangedFlag = false;
// return;
// }
// if ( mVrModeAutoChangedFlag ) {
// mVrModeAutoChangedFlag = false;
// return;
// }
}
Logger.d(TAG, Log.getStackTraceString(new Throwable()));
if (mCurrentUI != null) {
@@ -1056,7 +1057,7 @@ public class AMapViewWrapper implements IMogoMapView,
if (isVrMode) {
if (mCurrentUI != EnumMapUI.Type_VR) {
Logger.d(TAG, "自动切换为vr模式");
// mVrModeAutoChangedFlag = true;
// mVrModeAutoChangedFlag = true;
changeMapMode(EnumMapUI.Type_VR);
}
} else {
@@ -1104,23 +1105,28 @@ public class AMapViewWrapper implements IMogoMapView,
long satelliteTime = data.optLong("satelliteTime");
long receiverDataTime = data.optLong("receiverDataTime");
long adasSatelliteTime = data.optLong("adasSatelliteTime");
if (lon == -1) {
return;
int gpsProvider = data.optInt("gpsProvider", 1);
// 使用与渠道配置一样的gps提供者提供的数据
if (gpsProvider == FunctionBuildConfig.gpsProvider) {
if (lon == -1) {
return;
}
RTKAutopilotLocationBean bean = new RTKAutopilotLocationBean();
bean.setYaw_rate(yawRate);
bean.setHeading(heading);
bean.setAcceleration(acceleration);
bean.setAlt(alt);
bean.setSystemTime(systemTime);
bean.setSatelliteTime(satelliteTime);
bean.setReceiverDataTime(receiverDataTime);
bean.setAdasSatelliteTime(adasSatelliteTime);
bean.setLon(lon);
bean.setGnss_speed(((float) speed));
bean.setLat(lat);
// 使用外部定位数据修改自车位置
mMapView.getLocationClient().updateRTKAutoPilotLocation(bean);
}
RTKAutopilotLocationBean bean = new RTKAutopilotLocationBean();
bean.setYaw_rate(yawRate);
bean.setHeading(heading);
bean.setAcceleration(acceleration);
bean.setAlt(alt);
bean.setSystemTime(systemTime);
bean.setSatelliteTime(satelliteTime);
bean.setReceiverDataTime(receiverDataTime);
bean.setAdasSatelliteTime(adasSatelliteTime);
bean.setLon(lon);
bean.setGnss_speed(((float) speed));
bean.setLat(lat);
// 使用外部定位数据修改自车位置
mMapView.getLocationClient().updateRTKAutoPilotLocation(bean);
}
@Override
@@ -1177,33 +1183,33 @@ public class AMapViewWrapper implements IMogoMapView,
if (roadCache == null || roadCache == noCache) {
SinglePointRoadInfo singlePointRoadInfo = MapDataApi.INSTANCE.getSinglePointMatchRoad(((float) wgs[0]), ((float) wgs[1]), ((float) angle), isGpsLocation, isRTK);
if (singlePointRoadInfo != null && singlePointRoadInfo.getCoords() != null && !singlePointRoadInfo.getCoords().isEmpty()) {
// Log.i("timer-matchRoad-4", "cost " + (System.currentTimeMillis() - start) + "ms roadId: " + singlePointRoadInfo.getRoadId());
// Log.i("timer-matchRoad-4", "cost " + (System.currentTimeMillis() - start) + "ms roadId: " + singlePointRoadInfo.getRoadId());
roadCache = new RoadCacheWrapper(singlePointRoadInfo.getCoords());
roadCache.setLaneWidth(singlePointRoadInfo.getLaneWidth());
// 在地图上画点的测试方法
// try {
// PolylineOptions options = new PolylineOptions( );
// options.setColor( colors[colorIndex++] );
// options.setId( "test-line"+new Random( ).nextLong() );
// options.setGps( true );
// options.setLineWidth( 3 );
// List<LonLatPoint> points = singlePointRoadInfo.getCoords();
// ArrayList< LonLat > lonLats = new ArrayList<>( );
// for ( LonLatPoint point : points ) {
// lonLats.add( new LonLat( point.getLongitude(), point.getLatitude() ) );
// }
// options.setLonLats( lonLats );
// mMapView.getMapAutoViewHelper().drawThickLine( options );
// if (colorIndex >= colors.length) {
// colorIndex = 0;
// }
// } catch( Exception e ){
// e.printStackTrace();
// }
// try {
// PolylineOptions options = new PolylineOptions( );
// options.setColor( colors[colorIndex++] );
// options.setId( "test-line"+new Random( ).nextLong() );
// options.setGps( true );
// options.setLineWidth( 3 );
// List<LonLatPoint> points = singlePointRoadInfo.getCoords();
// ArrayList< LonLat > lonLats = new ArrayList<>( );
// for ( LonLatPoint point : points ) {
// lonLats.add( new LonLat( point.getLongitude(), point.getLatitude() ) );
// }
// options.setLonLats( lonLats );
// mMapView.getMapAutoViewHelper().drawThickLine( options );
// if (colorIndex >= colors.length) {
// colorIndex = 0;
// }
// } catch( Exception e ){
// e.printStackTrace();
// }
}
}
// Log.i("timer-matchRoad-1", "cost " + (System.currentTimeMillis() - start) + "ms");
// Log.i("timer-matchRoad-1", "cost " + (System.currentTimeMillis() - start) + "ms");
if (roadCache != null
&& roadCache.getRoad() != null
&& !roadCache.getRoad().isEmpty()) {
@@ -1215,16 +1221,16 @@ public class AMapViewWrapper implements IMogoMapView,
if (matchThreshold > 0 && matchedPoint[2] > 0 && matchedPoint[2] <= matchThreshold) {
// 目标车在阈值范围内
roadCacheMap.put(id, roadCache);
// Logger.i("timer-matchRoad-3", "cost " + (System.currentTimeMillis() - start) + "ms");
// Logger.i("timer-matchRoad-3", "cost " + (System.currentTimeMillis() - start) + "ms");
return matchedPoint;
// Logger.i("timer-matchRoad-2", "cost " + (System.currentTimeMillis() - start) + "ms roadId: "+roadCache.getLastLat());
// Logger.i("timer-matchRoad-2", "cost " + (System.currentTimeMillis() - start) + "ms roadId: "+roadCache.getLastLat());
} else if (matchedPoint[2] > matchThreshold && matchedPoint[2] < 1.5) {
// 目标车在阈值范围外,也就是说距离道路中心线太远了,就不吸附了
return null;
} else {
// 目标车到道路中心线的映射点不在道路上也就是已经使出了缓存的那条道路需要重新获取一条道路用useCache这个参数来避免重复递归
roadCacheMap.put(id, noCache);
// Logger.i("timer-matchRoad-2", "cost " + (System.currentTimeMillis() - start) + "ms roadId: " + roadCache.getLastLat());
// Logger.i("timer-matchRoad-2", "cost " + (System.currentTimeMillis() - start) + "ms roadId: " + roadCache.getLastLat());
if (usdCache) {
return matchRoad(id, lon, lat, angle, isGpsLocation, isRTK, false);
} else {

View File

@@ -1,5 +1,6 @@
package com.mogo.module.common.datacenter;
import com.mogo.commons.FunctionBuildConfig;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.service.locationinfo.CloudLocationInfo;
@@ -86,27 +87,31 @@ public class SnapshotLocationDataCenter {
double speed = data.optDouble("speed", -1);
long satelliteTime = data.optLong("satelliteTime");
long systemTime = data.optLong("systemTime");
int gpsProvider = data.optInt("gpsProvider",1);
//测试面板状态同步
DebugConfig.setStatusData(DebugConfig.sLon, lon);
DebugConfig.setStatusData(DebugConfig.sLat, lat);
// 使用与渠道配置一样的gps提供者提供的数据
if (gpsProvider == FunctionBuildConfig.gpsProvider) {
//测试面板状态同步
DebugConfig.setStatusData(DebugConfig.sLon, lon);
DebugConfig.setStatusData(DebugConfig.sLat, lat);
CloudLocationInfo cloudLocationInfo = new CloudLocationInfo();
cloudLocationInfo.setAlt(alt);
cloudLocationInfo.setHeading(heading);
cloudLocationInfo.setLat(lat);
cloudLocationInfo.setLon(lon);
cloudLocationInfo.setSpeed(speed);
cloudLocationInfo.setSatelliteTime(satelliteTime);
cloudLocationInfo.setSystemTime(systemTime);
cloudLocationInfo.setTileId(String.valueOf(MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapUIController().getTileId(lon, lat)));
mLastLocationInfo = cloudLocationInfo;
mMachineCacheList.add(cloudLocationInfo);
CloudLocationInfo cloudLocationInfo = new CloudLocationInfo();
cloudLocationInfo.setAlt(alt);
cloudLocationInfo.setHeading(heading);
cloudLocationInfo.setLat(lat);
cloudLocationInfo.setLon(lon);
cloudLocationInfo.setSpeed(speed);
cloudLocationInfo.setSatelliteTime(satelliteTime);
cloudLocationInfo.setSystemTime(systemTime);
cloudLocationInfo.setTileId(String.valueOf(MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapUIController().getTileId(lon, lat)));
mLastLocationInfo = cloudLocationInfo;
mMachineCacheList.add(cloudLocationInfo);
mCurSpeed = cloudLocationInfo.getSpeed();
mCurLon = cloudLocationInfo.getLon();
mCurLat = cloudLocationInfo.getLat();
mSatelliteTime = cloudLocationInfo.getSatelliteTime();
mCurSpeed = cloudLocationInfo.getSpeed();
mCurLon = cloudLocationInfo.getLon();
mCurLat = cloudLocationInfo.getLat();
mSatelliteTime = cloudLocationInfo.getSatelliteTime();
}
}
/**

View File

@@ -3,11 +3,13 @@ package com.mogo.module.obu.mogo
import android.content.Context
import android.util.Log
import com.alibaba.android.arouter.launcher.ARouter
import com.mogo.module.common.datacenter.SnapshotLocationDataCenter
import com.mogo.module.common.drawer.TrafficMarkerDrawer
import com.mogo.module.common.enums.WarningTypeEnum
import com.mogo.module.obu.mogo.utils.TrafficDataConvertUtils
import com.mogo.service.IMogoServiceApis
import com.mogo.service.MogoServicePaths
import com.mogo.service.map.IMogoMapService
import com.mogo.service.warning.IMoGoWaringProvider
import com.mogo.utils.logger.Logger
import com.mogo.utils.storage.SharedPrefsMgr
@@ -16,6 +18,7 @@ import com.zhidao.support.obu.OnMogoObuListener
import com.zhidao.support.obu.constants.ObuConstants
import com.zhidao.support.obu.model.*
import com.zhidao.support.obu.model.advance.Light
import org.json.JSONObject
/**
* @description
@@ -32,6 +35,7 @@ class MogoPrivateObuManager private constructor() {
private var mMogoServiceApis: IMogoServiceApis? = null
private var mIMoGoWaringProvider: IMoGoWaringProvider? = null
private var mIMogoMapService: IMogoMapService? = null
private var mContext: Context? = null
fun init(context: Context?) {
@@ -42,6 +46,7 @@ class MogoPrivateObuManager private constructor() {
// 获取预警模块的接口
mIMoGoWaringProvider = mMogoServiceApis!!.waringProviderApi
mIMogoMapService = mMogoServiceApis!!.mapServiceApi
//自研obu
MogoObuManager.getInstance().connect(context, "192.168.1.199")
@@ -87,21 +92,52 @@ class MogoPrivateObuManager private constructor() {
Logger.d(MogoObuConst.TAG_MOGO_OBU, "onCvxAppInitIndInfo ------> $info")
}
// 设置CV2X系统的配置确认
override fun onCvxSetConfigCfm(info: CvxSetConfigCfmInfo) {
super.onCvxSetConfigCfm(info)
Logger.d(MogoObuConst.TAG_MOGO_OBU, "onCvxSetConfigCfm ------> $info")
}
// 主车车辆信息
override fun onCvxHvCarIndInfo(info: CvxHvCarIndInfo) {
Logger.d(MogoObuConst.TAG_MOGO_OBU, "onCvxHvCarIndInfo ------> $info")
}
// CVX_HV_INFO_IND 主车信息
override fun onCvxHvInfoIndInfo(info: CvxHvInfoIndInfo) {
// (2) 车辆信息CVX_HV_INFO_IND
override fun onCvxHvInfoIndInfo(info: CvxHvInfoIndInfo?) {
mContext?.let { SharedPrefsMgr.getInstance(it).putBoolean("OBU_HV", true) }
Logger.d(MogoObuConst.TAG_MOGO_OBU, "onCvxHvInfoIndInfo ------> $info")
if (info != null && info.basic_info != null && info.basic_info.position != null) {
val movingObjectInfo = info.basic_info
val position = movingObjectInfo.position
val data = JSONObject()
try {
data.putOpt("lon", position.longitude)
data.putOpt("lat", position.latitude)
data.putOpt("speed", movingObjectInfo.speed)
data.putOpt("heading", movingObjectInfo.heading)
if (info.acceleration_set != null) {
data.putOpt("acceleration", info.acceleration_set.lateral)
data.putOpt("yawRate", info.acceleration_set.yaw_rate)
}
data.putOpt("gpsProvider", 2)
try {
data.putOpt("systemTime", System.currentTimeMillis())
} catch (e: Exception) {
e.printStackTrace()
}
try {
data.putOpt("satelliteTime", System.currentTimeMillis())
} catch (e: Exception) {
e.printStackTrace()
}
try {
data.putOpt("receiverDataTime", System.currentTimeMillis())
} catch (e: Exception) {
e.printStackTrace()
}
try {
data.putOpt("adasSatelliteTime", System.currentTimeMillis())
} catch (e: Exception) {
e.printStackTrace()
}
mIMogoMapService?.mapUIController?.syncLocation2Map(data)
SnapshotLocationDataCenter.getInstance().syncAdasLocationInfo(data)
} catch (e: Exception) {
e.printStackTrace()
}
}
}
// (3) 远车信息CVX_RV_INFO_IND
@@ -510,7 +546,10 @@ class MogoPrivateObuManager private constructor() {
info: CvxV2vThreatIndInfo
) {
// 这里排除需要特殊定制的语音及文案外,其余的都可以使用 WarningTypeEnum 提供的
Log.d(MogoObuConst.TAG_MOGO_OBU, "handleSdkObu appId = $appId --- handleDirection = $direction ---level = $level")
Log.d(
MogoObuConst.TAG_MOGO_OBU,
"handleSdkObu appId = $appId --- handleDirection = $direction ---level = $level"
)
var alertContent = ""
var ttsContent = ""
when (appId) {
@@ -586,7 +625,10 @@ class MogoPrivateObuManager private constructor() {
"ACTION_V2X_FRONT_WARNING"
)
//显示弹框,语音提示
Log.d(MogoObuConst.TAG_MOGO_OBU, "appId = $appId --- level = $level --- alertContent = $alertContent")
Log.d(
MogoObuConst.TAG_MOGO_OBU,
"appId = $appId --- level = $level --- alertContent = $alertContent"
)
mIMoGoWaringProvider!!.showWarningV2X(
appId,
alertContent,

View File

@@ -6,7 +6,7 @@ import android.content.Intent
import com.mogo.module.obu.mogo.MogoObuConst
import com.mogo.module.obu.mogo.MogoPrivateObuManager
import com.mogo.utils.logger.Logger
import com.zhidao.support.obu.model.CvxRvInfoIndInfo
import com.zhidao.support.obu.model.CvxHvInfoIndInfo
import com.zhidao.support.obu.model.advance.MovingObjectInfo
import com.zhidao.support.obu.model.advance.Position
@@ -14,7 +14,7 @@ import com.zhidao.support.obu.model.advance.Position
* @author xiaoyuzhou
* @date 2021/8/11 10:50 上午
*
* OBU 周边车辆 测试使用
* OBU 模拟自车
*/
class ObuTestTriggerRecognizedReceiver : BroadcastReceiver() {
private var mContext: Context? = null
@@ -34,16 +34,15 @@ class ObuTestTriggerRecognizedReceiver : BroadcastReceiver() {
val obuLevel = intent.getIntExtra(MogoObuConst.BROADCAST_OBU_LEVEL_EXTRA_KEY, 3)
Logger.d(TAG, "obuType:$obuType obuStatus:$obuStatus obuLevel:$obuLevel")
// TODO 测试数据
val cvxRvInfoIndInfo = CvxRvInfoIndInfo(0, 1, 2)
cvxRvInfoIndInfo.vehicle_id = "123321"
val cvxHvInfoIndInfo = CvxHvInfoIndInfo(0, 1, 2)
val position = Position(0, 399739429, 1164115207, 20)
val movingObjectInfo = MovingObjectInfo(0, position, 1800, 60)
cvxRvInfoIndInfo.basic_info = movingObjectInfo
cvxHvInfoIndInfo.basic_info = movingObjectInfo
MogoPrivateObuManager.INSTANCE
.getMogoObuListener()
.onCvxRvInfoIndInfo(cvxRvInfoIndInfo)
.onCvxHvInfoIndInfo(cvxHvInfoIndInfo)
}

View File

@@ -13,6 +13,7 @@ import android.text.TextUtils;
import android.util.Log;
import android.view.MotionEvent;
import com.mogo.commons.FunctionBuildConfig;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.commons.storage.SpStorage;
import com.mogo.commons.voice.AIAssist;
@@ -978,6 +979,7 @@ public class MogoServices implements IMogoMapListener,
data.putOpt( "heading", stateInfo.getValues().getHeading() );
data.putOpt( "acceleration", stateInfo.getValues().getAcceleration() );
data.putOpt( "yawRate", stateInfo.getValues().getYaw_rate() );
data.putOpt( "gpsProvider", 1 );
try {
data.putOpt( "systemTime", Long.parseLong( stateInfo.getValues().getSystemTime() ) );
} catch ( Exception e ) {

View File

@@ -202,8 +202,6 @@ public interface IMogoADASController extends IProvider {
*/
void cancelAutopilot();
void mockAdasLoc(String json);
void mockAdasRecognized(List<ADASRecognizedResult> recognizedResults);
}

View File

@@ -49,7 +49,6 @@ import com.zhidao.adasconfig.common.config.EnumCarChatIncognitoMode;
import com.zhidao.adasconfig.common.config.EnumCarHeading;
import com.zhidao.adasconfig.common.config.EnumSkinStyle;
import com.zhidao.autopilotservice.model.AdasAIDLAutopilotArriveModel;
import com.zhidao.autopilotservice.model.AdasAIDLOwnerCarRectModel;
import com.zhidao.support.adas.high.bean.AutopilotRoute;
import com.zhidao.support.adas.high.bean.AutopilotStatus;
import com.zhidao.support.adas.high.bean.RectInfo;
@@ -233,9 +232,9 @@ public class MogoADASController implements IMogoADASController {
}
}
// TODO 以前这里是考虑ADAS独立应用现在集成ADAS-SDK到程序内了这个判断不需要了
// if (SingletonsHolder.get(IMogoStatusManager.class).isVrMode()) {
// return;
// }
// if (SingletonsHolder.get(IMogoStatusManager.class).isVrMode()) {
// return;
// }
Logger.d(TAG, Log.getStackTraceString(new Throwable()));
init(AbsMogoApplication.getApp());
adasProvider.addAdasStatusListener(new IAdasStatusListener() {
@@ -394,8 +393,6 @@ public class MogoADASController implements IMogoADASController {
Message message = mAdasLocationRecHandler.obtainMessage();
message.obj = ownerCarStateInfo;
message.sendToTarget();
}
@Override
@@ -612,7 +609,7 @@ public class MogoADASController implements IMogoADASController {
adasProvider.removeAdasStatusListener();
//AutopilotServiceManage.getInstance().release();
//关闭定时任务
// if (mDisposable != null) mDisposable.dispose();
// if (mDisposable != null) mDisposable.dispose();
}
@Override
@@ -753,17 +750,6 @@ public class MogoADASController implements IMogoADASController {
adasProvider.cancelPilot();
}
@Override
public void mockAdasLoc(String json) {
ADASCarStateInfo stateInf = GsonUtil.objectFromJson(json, ADASCarStateInfo.class);
if (stateInf == null) {
return;
}
if (mMogoAdasCarDataCallback != null) {
mMogoAdasCarDataCallback.onAdasCarDataCallback(stateInf);
}
}
@Override
public void mockAdasRecognized(List<ADASRecognizedResult> recognizedResults) {
if (!mMogoAdasRecognizedDataCallbacks.isEmpty()) {