Merge branch 'qa_merge_shunyi_vr_map' into dev2

# Conflicts:
#	config.gradle
#	modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/CloudLocationInfo.java
#	services/mogo-service-api/src/main/java/com/mogo/service/adas/IMogoADASController.java
#	services/mogo-service/src/main/java/com/mogo/service/impl/adas/MogoADASController.java
This commit is contained in:
wangcongtao
2021-01-26 09:26:48 +08:00
26 changed files with 707 additions and 229 deletions

View File

@@ -157,7 +157,7 @@ ext {
gpssimulatordebug : "com.mogo.module:module-gps-simulator-debug:${MOGO_MODULE_GPS_SIMULATOR_DEBUG_VERSION}",
gpssimulatornoop : "com.mogo.module:module-gps-simulator-noop:${MOGO_MODULE_GPS_SIMULATOR_NOOP_VERSION}",
adasapi : "com.zhidao.autopilot.support:adas:1.0.6.6",
adasapi : "com.zhidao.autopilot.support:adas:1.0.6.7",
adasconfigapi : "com.zhidao.adasconfig:adasconfig:1.1.5.2",
// 个人中心的SDK

View File

@@ -403,4 +403,14 @@ public class DebugConfig {
public static void setUseAdasRtkLocationInfo( boolean sIsUseAdasRtkLocationInfo ) {
DebugConfig.sIsUseAdasRtkLocationInfo = sIsUseAdasRtkLocationInfo;
}
public static boolean sIsNotSmooth = false;
public static boolean isNotSmooth() {
return sIsNotSmooth;
}
public static void setNotSmooth( boolean sIsNotSmooth ) {
DebugConfig.sIsNotSmooth = sIsNotSmooth;
}
}

View File

@@ -1,80 +1,84 @@
package com.mogo.utils;
import org.jetbrains.annotations.NotNull;
import java.math.BigDecimal;
/**
* @author donghongyu
*/
public class CoordinateUtils {
private static double a = 6378245.0;
private static double ee = 0.00669342162296594323;
/**
* 手机GPS坐标转火星坐标
*
* @return
*/
public static double[] transformFromWGSToGCJ( double lat, double lon ) {
//如果在国外,则默认不进行转换
if ( outOfChina( lat, lon ) ) {
return new double[]{lat, lon};
}
double dLat = transformLat( lon - 105.0, lat - 35.0 );
double dLon = transformLon( lon - 105.0, lat - 35.0 );
double radLat = lat / 180.0 * Math.PI;
double magic = Math.sin( radLat );
magic = 1 - ee * magic * magic;
double sqrtMagic = Math.sqrt( magic );
dLat = ( dLat * 180.0 ) / ( ( a * ( 1 - ee ) ) / ( magic * sqrtMagic ) * Math.PI );
dLon = ( dLon * 180.0 ) / ( a / sqrtMagic * Math.cos( radLat ) * Math.PI );
return new double[]{lat + dLat, lon + dLon};
}
public static double transformLat( double x, double y ) {
double ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * Math.sqrt( x > 0 ? x : -x );
ret += ( 20.0 * Math.sin( 6.0 * x * Math.PI ) + 20.0 * Math.sin( 2.0 * x * Math.PI ) ) * 2.0 / 3.0;
ret += ( 20.0 * Math.sin( y * Math.PI ) + 40.0 * Math.sin( y / 3.0 * Math.PI ) ) * 2.0 / 3.0;
ret += ( 160.0 * Math.sin( y / 12.0 * Math.PI ) + 320 * Math.sin( y * Math.PI / 30.0 ) ) * 2.0 / 3.0;
return ret;
}
public static double transformLon( double x, double y ) {
double ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * Math.sqrt( x > 0 ? x : -x );
ret += ( 20.0 * Math.sin( 6.0 * x * Math.PI ) + 20.0 * Math.sin( 2.0 * x * Math.PI ) ) * 2.0 / 3.0;
ret += ( 20.0 * Math.sin( x * Math.PI ) + 40.0 * Math.sin( x / 3.0 * Math.PI ) ) * 2.0 / 3.0;
ret += ( 150.0 * Math.sin( x / 12.0 * Math.PI ) + 300.0 * Math.sin( x / 30.0 * Math.PI ) ) * 2.0 / 3.0;
return ret;
}
public static boolean outOfChina( double lat, double lon ) {
if ( lon < 72.004 || lon > 137.8347 )
return true;
if ( lat < 0.8293 || lat > 55.8271 )
return true;
return false;
}
public static final double[] transformGcj02toWgs84( double lat, double lng ) {
double[] var10000;
if ( outOfChina( lat, lng ) ) {
var10000 = new double[]{lng, lat};
} else {
double dlat = transformLat( lng - 105.0D, lat - 35.0D );
double dlng = transformLon( lng - 105.0D, lat - 35.0D );
double radlat = lat / 180.0D * Math.PI;
double magic = Math.sin( radlat );
magic = ( double ) 1 - 0.006693421622965943D * magic * magic;
double sqrtmagic = Math.sqrt( magic );
dlat = dlat * 180.0D / ( 6335552.717000426D / ( magic * sqrtmagic ) * Math.PI );
dlng = dlng * 180.0D / ( 6378245.0D / sqrtmagic * Math.cos( radlat ) * Math.PI );
double mglat = lat + dlat;
double mglng = lng + dlng;
var10000 = new double[]{lng * ( double ) 2 - mglng, lat * ( double ) 2 - mglat};
}
return var10000;
}
// private static double a = 6378245.0;
// private static double ee = 0.00669342162296594323;
//
// /**
// * 手机GPS坐标转火星坐标
// *
// * @return
// */
// public static double[] transformFromWGSToGCJ( double lat, double lon ) {
//
// //如果在国外,则默认不进行转换
// if ( outOfChina( lat, lon ) ) {
// return new double[]{lat, lon};
// }
// double dLat = transformLat( lon - 105.0, lat - 35.0 );
// double dLon = transformLon( lon - 105.0, lat - 35.0 );
// double radLat = lat / 180.0 * Math.PI;
// double magic = Math.sin( radLat );
// magic = 1 - ee * magic * magic;
// double sqrtMagic = Math.sqrt( magic );
// dLat = ( dLat * 180.0 ) / ( ( a * ( 1 - ee ) ) / ( magic * sqrtMagic ) * Math.PI );
// dLon = ( dLon * 180.0 ) / ( a / sqrtMagic * Math.cos( radLat ) * Math.PI );
//
// return new double[]{lat + dLat, lon + dLon};
// }
//
// public static double transformLat( double x, double y ) {
// double ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * Math.sqrt( x > 0 ? x : -x );
// ret += ( 20.0 * Math.sin( 6.0 * x * Math.PI ) + 20.0 * Math.sin( 2.0 * x * Math.PI ) ) * 2.0 / 3.0;
// ret += ( 20.0 * Math.sin( y * Math.PI ) + 40.0 * Math.sin( y / 3.0 * Math.PI ) ) * 2.0 / 3.0;
// ret += ( 160.0 * Math.sin( y / 12.0 * Math.PI ) + 320 * Math.sin( y * Math.PI / 30.0 ) ) * 2.0 / 3.0;
// return ret;
// }
//
// public static double transformLon( double x, double y ) {
// double ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * Math.sqrt( x > 0 ? x : -x );
// ret += ( 20.0 * Math.sin( 6.0 * x * Math.PI ) + 20.0 * Math.sin( 2.0 * x * Math.PI ) ) * 2.0 / 3.0;
// ret += ( 20.0 * Math.sin( x * Math.PI ) + 40.0 * Math.sin( x / 3.0 * Math.PI ) ) * 2.0 / 3.0;
// ret += ( 150.0 * Math.sin( x / 12.0 * Math.PI ) + 300.0 * Math.sin( x / 30.0 * Math.PI ) ) * 2.0 / 3.0;
// return ret;
// }
//
// public static boolean outOfChina( double lat, double lon ) {
// if ( lon < 72.004 || lon > 137.8347 )
// return true;
// if ( lat < 0.8293 || lat > 55.8271 )
// return true;
// return false;
// }
//
// public static final double[] transformGcj02toWgs84( double lat, double lng ) {
// double[] var10000;
// if ( outOfChina( lat, lng ) ) {
// var10000 = new double[]{lng, lat};
// } else {
// double dlat = transformLat( lng - 105.0D, lat - 35.0D );
// double dlng = transformLon( lng - 105.0D, lat - 35.0D );
// double radlat = lat / 180.0D * Math.PI;
// double magic = Math.sin( radlat );
// magic = ( double ) 1 - 0.006693421622965943D * magic * magic;
// double sqrtmagic = Math.sqrt( magic );
// dlat = dlat * 180.0D / ( 6335552.717000426D / ( magic * sqrtmagic ) * Math.PI );
// dlng = dlng * 180.0D / ( 6378245.0D / sqrtmagic * Math.cos( radlat ) * Math.PI );
// double mglat = lat + dlat;
// double mglng = lng + dlng;
// var10000 = new double[]{lng * ( double ) 2 - mglng, lat * ( double ) 2 - mglat};
// }
//
// return var10000;
// }
/**
* @param lon1
@@ -116,4 +120,84 @@ public class CoordinateUtils {
}
}
// ------
private static final double x_PI = 52.35987755982988D;
private static final double PI = 3.141592653589793D;
private static final double a = 6378245.0D;
private static final double ee = 0.006693421622965943D;
public static final boolean outOfChina( double lat, double lng ) {
return lng <= 73.66D || lng >= 135.05D || lat <= 3.86D || lat >= 53.55D;
}
private static final double transformLat( double lng, double lat ) {
double ret = -100.0D + 2.0D * lng + 3.0D * lat + 0.2D * lat * lat + 0.1D * lng * lat + 0.2D * Math.sqrt( Math.abs( lng ) );
ret += ( 20.0D * Math.sin( 6.0D * lng * 3.141592653589793D ) + 20.0D * Math.sin( 2.0D * lng * 3.141592653589793D ) ) * 2.0D / 3.0D;
ret += ( 20.0D * Math.sin( lat * 3.141592653589793D ) + 40.0D * Math.sin( lat / 3.0D * 3.141592653589793D ) ) * 2.0D / 3.0D;
ret += ( 160.0D * Math.sin( lat / 12.0D * 3.141592653589793D ) + ( double ) 320 * Math.sin( lat * 3.141592653589793D / 30.0D ) ) * 2.0D / 3.0D;
return ret;
}
private static final double transformLon( double lng, double lat ) {
double ret = 300.0D + lng + 2.0D * lat + 0.1D * lng * lng + 0.1D * lng * lat + 0.1D * Math.sqrt( Math.abs( lng ) );
ret += ( 20.0D * Math.sin( 6.0D * lng * 3.141592653589793D ) + 20.0D * Math.sin( 2.0D * lng * 3.141592653589793D ) ) * 2.0D / 3.0D;
ret += ( 20.0D * Math.sin( lng * 3.141592653589793D ) + 40.0D * Math.sin( lng / 3.0D * 3.141592653589793D ) ) * 2.0D / 3.0D;
ret += ( 150.0D * Math.sin( lng / 12.0D * 3.141592653589793D ) + 300.0D * Math.sin( lng / 30.0D * 3.141592653589793D ) ) * 2.0D / 3.0D;
return ret;
}
@NotNull
// World Geodetic System ==> Mars Geodetic System
public static final double[] transformWgsToGcj( double wgLat, double wgLon ) {
double[] point = new double[2];
if ( outOfChina( wgLat, wgLon ) ) {
point[0] = wgLon;
point[1] = wgLat;
return point;
} else {
double dLat = transformLat( wgLon - 105.0D, wgLat - 35.0D );
double dLon = transformLon( wgLon - 105.0D, wgLat - 35.0D );
double radLat = wgLat / 180.0D * 3.141592653589793D;
double magic = Math.sin( radLat );
magic = ( double ) 1 - 0.006693421622965943D * magic * magic;
double sqrtMagic = Math.sqrt( magic );
dLat = dLat * 180.0D / ( 6335552.717000426D / ( magic * sqrtMagic ) * 3.141592653589793D );
dLon = dLon * 180.0D / ( 6378245.0D / sqrtMagic * Math.cos( radLat ) * 3.141592653589793D );
double mgLat = wgLat + dLat;
double mgLon = wgLon + dLon;
point[0] = dealRound( mgLon );
point[1] = dealRound( mgLat );
return point;
}
}
@NotNull
public static final double[] transformGcj02toWgs84( double lat, double lng ) {
double[] var10000;
if ( outOfChina( lat, lng ) ) {
var10000 = new double[]{lng, lat};
} else {
double dlat = transformLat( lng - 105.0D, lat - 35.0D );
double dlng = transformLon( lng - 105.0D, lat - 35.0D );
double radlat = lat / 180.0D * 3.141592653589793D;
double magic = Math.sin( radlat );
magic = ( double ) 1 - 0.006693421622965943D * magic * magic;
double sqrtmagic = Math.sqrt( magic );
dlat = dlat * 180.0D / ( 6335552.717000426D / ( magic * sqrtmagic ) * 3.141592653589793D );
dlng = dlng * 180.0D / ( 6378245.0D / sqrtmagic * Math.cos( radlat ) * 3.141592653589793D );
double mglat = lat + dlat;
double mglng = lng + dlng;
var10000 = new double[]{dealRound( lng * ( double ) 2 - mglng ), dealRound( lat * ( double ) 2 - mglat )};
}
return var10000;
}
private static final double dealRound( double value ) {
BigDecimal bg = new BigDecimal( value );
double result = bg.setScale( 6, 4 ).doubleValue();
return result;
}
}

View File

@@ -67,7 +67,7 @@ dependencies {
implementation project(':foudations:mogo-commons')
}
implementation 'com.zhidaoauto.machine:map:1.0.0-vr-7.9.5'
implementation 'com.zhidaoauto.machine:map:1.0.0-vr-8.0.5'
// implementation 'com.zhidaoauto.machine:map:1.0.0-vr-test-3.4'
}

View File

@@ -33,6 +33,7 @@ import com.mogo.map.uicontroller.MapControlResult;
import com.mogo.utils.TipToast;
import com.mogo.utils.UiThreadHandler;
import com.mogo.utils.logger.Logger;
import com.mogo.utils.network.utils.GsonUtil;
import com.zhidaoauto.map.sdk.open.MapAutoApi;
import com.zhidaoauto.map.sdk.open.abs.MapStatusListener;
import com.zhidaoauto.map.sdk.open.abs.OnCameraChangeListener;
@@ -190,6 +191,7 @@ public class AMapViewWrapper implements IMogoMapView,
mMapView.setOnMapTouchListener( this );
mMapView.setOnMapClickListener( this );
mMapView.getLocationClient().registerListener( 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 );
@@ -754,7 +756,6 @@ public class AMapViewWrapper implements IMogoMapView,
try {
mSelfMarker = mMapView.getMapAutoViewHelper().getMyLocationStyle().getSelfMarker();
mSelfMarker.setInfoWindowEnable( true );
mSelfMarker.setInfoWindowOffset( 0, -200 );
} catch ( Exception e ) {
}
}
@@ -958,7 +959,7 @@ public class AMapViewWrapper implements IMogoMapView,
public void rtkEnable( boolean enable ) {
try {
mRtkEnable = !mRtkEnable;
TipToast.shortTip( mRtkEnable ? "已开启gps道路匹配" : "已开启rtk道路匹配" );
TipToast.shortTip( mRtkEnable ? "已开启rtk道路匹配" : "已开启gps道路匹配" );
mMapView.getLocationClient().rtkEnable( mRtkEnable );
} catch ( Exception e ) {
Logger.e( TAG, e, "rtkEnable" );
@@ -994,7 +995,7 @@ public class AMapViewWrapper implements IMogoMapView,
bean.setLon( lon );
bean.setGnss_speed( ( ( float ) speed ) );
bean.setLat( lat );
Logger.d( "ADASCOOR", "使用rtk定位数据%s", GsonUtil.jsonFromObject( bean ) );
mMapView.getLocationClient().updateRTKAutoPilotLocation( bean );
Logger.d( TAG, "使用rtk定位数据" );
}
}

View File

@@ -72,7 +72,7 @@ public class ALocationClient implements IMogoLocationClient {
destroyWarming();
return;
}
if ( mClient != null && mClient.isStarted() ) {
if ( mClient != null && mClient.isAGpsStarted() ) {
mClient.stop();
}
}

View File

@@ -75,6 +75,7 @@ public class ObjectUtils {
.anchor(opt.getU(), opt.getV())
.icons( descriptors )
.period( opt.getPeriod() )
.controlAngle( opt.isControlAngle() )
.rotateAngle(opt.getRotate())
.setFlat(opt.isFlat())
.visible(opt.isVisible())

View File

@@ -79,6 +79,17 @@ public class MogoMarkerOptions extends Observable {
private boolean mIs3DMode = false;
private boolean mIsControlAngle = false;
public MogoMarkerOptions controlAngle( boolean controlAngle ) {
this.mIsControlAngle = controlAngle;
return this;
}
public boolean isControlAngle() {
return mIsControlAngle;
}
public MogoMarkerOptions set3DMode( boolean is3DMode ) {
mIs3DMode = is3DMode;
return this;

View File

@@ -10,6 +10,7 @@ import androidx.fragment.app.Fragment;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.module.common.MogoModulePaths;
import com.mogo.module.common.utils.CarSeries;
import com.mogo.service.MogoServicePaths;
import com.mogo.service.module.IMogoModuleProvider;
import com.mogo.service.module.ModuleType;
@@ -48,14 +49,11 @@ public class BackToLauncherModuleProvider implements IMogoModuleProvider {
@Override
public void init( Context context ) {
final String product = DebugConfig.getProductFlavor();
if ( product != null ) {
if ( CarSeries.isF8xxSeries() ) {
BackToMainHomeManager.addMainHomeView();
} else {
final String product = DebugConfig.getProductFlavor();
switch ( product ) {
case "f80x":
case "f8xx":
case "f8Amap":
BackToMainHomeManager.addMainHomeView();
break;
case "changanauto":
if ( DebugConfig.isDebug() ) {
BackToMainHomeManager.addMainHomeView();

View File

@@ -1,13 +1,13 @@
package com.mogo.module.common.drawer;
import android.content.Context;
import android.os.SystemClock;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.map.MogoLatLng;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.map.marker.MogoMarkerOptions;
@@ -39,7 +39,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
mContext = AbsMogoApplication.getApp();
}
private Map< String, MogoLatLng > mLastPositions = new ConcurrentHashMap<>();
private Map< String, ADASRecognizedListResult > mLastPositions = new ConcurrentHashMap<>();
public static AdasRecognizedResultDrawer getInstance() {
if ( sInstance == null ) {
@@ -94,36 +94,34 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
continue;
}
mAdasRecognizedMarkersCaches.put( uniqueKey, marker );
}
MogoLatLng lastPosition = mLastPositions.get( uniqueKey );
List< MogoLatLng > points = new ArrayList<>();
MogoLatLng endLatLon = null;
if ( recognizedListResult.latLonList != null
&& recognizedListResult.latLonList.size() > 1 ) {
for ( int j = 0; j < recognizedListResult.latLonList.size(); j++ ) {
ADASRecognizedListResult.LatLon latLon = recognizedListResult.latLonList.get( j );
if ( latLon == null ) {
continue;
mLastPositions.put( uniqueKey, recognizedListResult );
} else {
ADASRecognizedListResult lastPosition = mLastPositions.get( uniqueKey );
mLastPositions.put( uniqueKey, recognizedListResult );
if ( lastPosition != null ) {
List< MogoLatLng > points = new ArrayList<>();
MogoLatLng endLatLon = new MogoLatLng( recognizedListResult.lat, recognizedListResult.lon );
points.add( new MogoLatLng( lastPosition.lat, lastPosition.lon ) );
points.add( endLatLon );
if ( DebugConfig.isNotSmooth() ) {
marker.setPosition( recognizedListResult.lat, recognizedListResult.lon );
} else {
long interval = recognizedListResult.systemTime - lastPosition.systemTime;
if ( interval < 45 ) {
interval = 45;
}
interval -= 25;
marker.startSmoothInMs( points, interval );
}
points.add( endLatLon = new MogoLatLng( latLon.lat, latLon.lon ) );
} else {
marker.setPosition( recognizedListResult.lat, recognizedListResult.lon );
}
} else if ( recognizedListResult.latLonList != null
&& recognizedListResult.latLonList.size() == 1 ) {
// 原来的点和新的点做一个数组进行平滑移动
ADASRecognizedListResult.LatLon latLon = recognizedListResult.latLonList.get( 0 );
if ( latLon == null ) {
continue;
}
points.add( lastPosition );
points.add( endLatLon = new MogoLatLng( latLon.lat, latLon.lon ) );
}
mLastPositions.put( uniqueKey, endLatLon );
if ( points.size() >= 1 ) {
marker.startSmoothInMs( points, 100 );
}
showSelfSpeed( mContext,
marker,
recognizedListResult.speed,
MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()
);
}
}
@@ -175,9 +173,10 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
.owner( DataTypes.TYPE_MARKER_ADAS )
.anchor( 0.5f, 0.5f )
.set3DMode( true )
.controlAngle( true )
.icon3DRes( getVrModel() )
.rotate( ( float ) recognizedListResult.heading )
.position( new MogoLatLng( recognizedListResult.latLonList.get( 0 ).lat, recognizedListResult.latLonList.get( 0 ).lon ) );
.position( new MogoLatLng( recognizedListResult.lat, recognizedListResult.lon ) );
return MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( mContext ).addMarker( DataTypes.TYPE_MARKER_ADAS, options );
}
@@ -185,21 +184,4 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
return R.raw.carred;
}
private View inflateView( ADASRecognizedListResult data, boolean machineVision, double curSpeed ) {
View rootView = LayoutInflater.from( AbsMogoApplication.getApp() ).inflate( R.layout.module_commons_layout_car, null );
// SafeType safeType = getSafeType( data.distanceX, data.distanceY, data.speed, curSpeed );
// TextView tv = rootView.findViewById( R.id.module_commons_marker_car_speed );
// tv.setText( safeType.getMsg() );
ImageView iv = rootView.findViewById( R.id.module_commons_marker_car_model );
// iv.setImageResource( MarkerResourceManager.getMarkerDrawableResId(
// machineVision ? VisionMode.Machine : VisionMode.User,
// AdasRecognizedType.valueFrom( data.type ),
// getCarModelType(),
// safeType
// ) );
iv.setImageResource( R.drawable.icon_map_marker_car_gray );
return rootView;
}
}

View File

@@ -21,6 +21,7 @@ import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.R;
import com.mogo.module.common.api.CallChatApi;
import com.mogo.module.common.constants.DataTypes;
import com.mogo.module.common.entity.CloudLocationInfo;
import com.mogo.module.common.entity.CloudRoadData;
import com.mogo.module.common.entity.MogoSnapshotSetData;
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
@@ -203,10 +204,20 @@ class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClickListen
} else {
List< MogoLatLng > points = new ArrayList<>();
points.add( new MogoLatLng( lastPosition.getLat(), lastPosition.getLon() ) );
points.add( new MogoLatLng( cloudRoadData.getLat(), cloudRoadData.getLon() ) );
if ( cloudRoadData.getCoordinates() != null && !cloudRoadData.getCoordinates().isEmpty() ) {
for ( CloudLocationInfo coordinate : cloudRoadData.getCoordinates() ) {
points.add( new MogoLatLng( coordinate.getLat(), coordinate.getLon() ) );
}
} else {
points.add( new MogoLatLng( cloudRoadData.getLat(), cloudRoadData.getLon() ) );
}
long interval = cloudRoadData.getSystemTime() - lastPosition.getSystemTime();
long interval2 = cloudRoadData.getSatelliteTime() - lastPosition.getSatelliteTime();
interval2 = interval < interval2 || interval2 == 0 ? interval : interval2;
if ( interval2 < 45 ) {
interval2 = 45;
}
interval2 -= 25;
marker.startSmoothInMs( points, interval2 );
Logger.d( TAG, "平滑移动 - %s duration = %s", uniqueKey, interval2 );
}
@@ -320,6 +331,7 @@ class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClickListen
.anchor( 0.5f, 0.5f )
.rotate( ( float ) data.getHeading() )
.object( data )
.controlAngle( true )
.position( new MogoLatLng( data.getLat(), data.getLon() ) );
if ( MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() ) {
options.set3DMode( true );
@@ -342,7 +354,7 @@ class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClickListen
// return R.raw.bus;
case CloudRoadData.FROM_MY_LOCATION:
default:
return R.raw.carred;
return R.raw.carblue;
}
}

View File

@@ -2,10 +2,8 @@ package com.mogo.module.common.entity;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.map.MogoLatLng;
import com.mogo.utils.CoordinateUtils;
import java.util.Objects;
@@ -43,14 +41,52 @@ public class CloudLocationInfo implements Parcelable {
this.speed = info.speed;
}
public void convertCoor2GCJ02() {
double[] amapCoord = CoordinateUtils.transformFromWGSToGCJ( lat, lon );
public void convertCoor2GCJ02(){
double[] amapCoord = CoordinateUtils.transformWgsToGcj( lat, lon );
if ( amapCoord != null ) {
this.lat = amapCoord[0];
this.lon = amapCoord[1];
this.lat = amapCoord[1];
this.lon = amapCoord[0];
}
}
protected CloudLocationInfo( Parcel in ) {
lat = in.readDouble();
lon = in.readDouble();
heading = in.readDouble();
systemTime = in.readLong();
satelliteTime = in.readLong();
alt = in.readDouble();
speed = in.readDouble();
}
@Override
public void writeToParcel( Parcel dest, int flags ) {
dest.writeDouble( lat );
dest.writeDouble( lon );
dest.writeDouble( heading );
dest.writeLong( systemTime );
dest.writeLong( satelliteTime );
dest.writeDouble( alt );
dest.writeDouble( speed );
}
@Override
public int describeContents() {
return 0;
}
public static final Creator< CloudLocationInfo > CREATOR = new Creator< CloudLocationInfo >() {
@Override
public CloudLocationInfo createFromParcel( Parcel in ) {
return new CloudLocationInfo( in );
}
@Override
public CloudLocationInfo[] newArray( int size ) {
return new CloudLocationInfo[size];
}
};
public double getLat() {
return lat;
}
@@ -142,44 +178,4 @@ public class CloudLocationInfo implements Parcelable {
public int hashCode() {
return Objects.hash( lat, lon );
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel( Parcel dest, int flags ) {
dest.writeDouble( this.lat );
dest.writeDouble( this.lon );
dest.writeDouble( this.heading );
dest.writeLong( this.systemTime );
dest.writeLong( this.satelliteTime );
dest.writeDouble( this.alt );
dest.writeDouble( this.speed );
dest.writeInt( this.vehicleType );
}
protected CloudLocationInfo( Parcel in ) {
this.lat = in.readDouble();
this.lon = in.readDouble();
this.heading = in.readDouble();
this.systemTime = in.readLong();
this.satelliteTime = in.readLong();
this.alt = in.readDouble();
this.speed = in.readDouble();
this.vehicleType = in.readInt();
}
public static final Creator< CloudLocationInfo > CREATOR = new Creator< CloudLocationInfo >() {
@Override
public CloudLocationInfo createFromParcel( Parcel source ) {
return new CloudLocationInfo( source );
}
@Override
public CloudLocationInfo[] newArray( int size ) {
return new CloudLocationInfo[size];
}
};
}

View File

@@ -50,6 +50,8 @@ import com.mogo.module.service.strategy.CarIconDisplayStrategy;
import com.mogo.module.service.ttsConfig.TtsConfigModleData;
import com.mogo.module.service.uploadintime.SnapshotUploadInTime;
import com.mogo.service.adas.IMogoADASController;
import com.mogo.service.adas.IMogoAdasCarDataCallback;
import com.mogo.service.adas.entity.ADASCarStateInfo;
import com.mogo.service.fragmentmanager.FragmentStackTransactionListener;
import com.mogo.service.fragmentmanager.IMogoFragmentManager;
import com.mogo.service.intent.IMogoIntentListener;
@@ -65,6 +67,8 @@ import com.mogo.utils.NetworkUtils;
import com.mogo.utils.WorkThreadHandler;
import com.mogo.utils.logger.Logger;
import org.json.JSONObject;
import java.util.List;
/**
@@ -86,6 +90,7 @@ public class MogoServices implements IMogoMapListener,
IMogoVoiceCmdCallBack,
FragmentStackTransactionListener,
IMogoCarLocationChangedListener2,
IMogoAdasCarDataCallback,
IDestroyable {
private boolean mInternalUnWakeupRegisterStatus = false;
@@ -370,6 +375,7 @@ public class MogoServices implements IMogoMapListener,
mIntentManager.registerIntentListener( ConnectivityManager.CONNECTIVITY_ACTION, this );
mADASController = MarkerServiceHandler.getADASController();
mADASController.setAdasCarDataCallback( this );
mFragmentManager = MarkerServiceHandler.getFragmentManager();
mFragmentManager.addMainFragmentStackTransactionListener( this );
@@ -950,4 +956,25 @@ public class MogoServices implements IMogoMapListener,
}
}
}
@Override
public void onAdasCarDataCallback( ADASCarStateInfo stateInfo ) {
if ( stateInfo != null && stateInfo.getValues() != null ) {
JSONObject data = new JSONObject();
try {
data.putOpt( "lon", stateInfo.getValues().getLon() );
data.putOpt( "lat", stateInfo.getValues().getLat() );
data.putOpt( "alt", stateInfo.getValues().getAlt() );
data.putOpt( "speed", stateInfo.getValues().getGnss_speed() );
data.putOpt( "satelliteTime", stateInfo.getValues().getSatelliteTime() );
data.putOpt( "heading", stateInfo.getValues().getHeading() );
data.putOpt( "acceleration", stateInfo.getValues().getAcceleration() );
data.putOpt( "yawRate", stateInfo.getValues().getYaw_rate() );
MarkerServiceHandler.getApis().getMapServiceApi().getMapUIController().syncLocation2Map( data );
SnapshotUploadInTime.getInstance().syncAdasLocationInfo( data );
} catch ( Exception e ) {
e.printStackTrace();
}
}
}
}

View File

@@ -9,6 +9,7 @@ import com.mogo.module.service.ServiceConst;
import com.mogo.module.service.carinfo.CarStateInfo;
import com.mogo.module.service.receiver.MogoReceiver;
import com.mogo.module.service.uploadintime.SnapshotUploadInTime;
import com.mogo.utils.logger.Logger;
import com.mogo.utils.network.utils.GsonUtil;
import org.json.JSONObject;
@@ -58,6 +59,7 @@ class ADASStatusIntentHandler implements IntentHandler {
if ( TextUtils.isEmpty( msg ) ) {
return;
}
Logger.d( "ADASCOOR", msg );
CarStateInfo stateInfo = GsonUtil.objectFromJson( msg, CarStateInfo.class );
if ( stateInfo != null && stateInfo.getValues() != null ) {
JSONObject data = new JSONObject();

View File

@@ -27,6 +27,8 @@ import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.dialog.WMDialog;
import com.mogo.module.service.MarkerServiceHandler;
import com.mogo.module.service.R;
import com.mogo.module.service.uploadintime.SnapshotUploadInTime;
import com.mogo.service.adas.entity.ADASCarStateInfo;
import com.mogo.service.entrance.ButtonIndex;
import com.mogo.utils.CoordinateUtils;
import com.mogo.utils.TipToast;
@@ -35,6 +37,11 @@ import com.mogo.utils.logger.Logger;
import com.mogo.utils.network.utils.GsonUtil;
import com.mogo.utils.storage.SharedPrefsMgr;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
@@ -434,6 +441,7 @@ public class MockIntentHandler implements IntentHandler {
{40.20254135131836, 116.74005889892578},
{40.20252990722656, 116.74007415771484},
{40.20254898071289, 116.74008178710938},
{40.20254135131836, 116.74005889892578},
{40.20252227783203, 116.74006652832031},
{40.20254898071289, 116.74002838134766},
@@ -467,11 +475,75 @@ public class MockIntentHandler implements IntentHandler {
{40.20254135131836, 116.7392807006836}};
for ( double[] coor : coors ) {
double lat = coor[0], lon = coor[1];
double[] translateCoor = CoordinateUtils.transformFromWGSToGCJ( lat, lon );
double[] originCoor = CoordinateUtils.transformGcj02toWgs84( translateCoor[0], translateCoor[1] );
double[] translateCoor = CoordinateUtils.transformWgsToGcj( lat, lon );
double[] originCoor = CoordinateUtils.transformGcj02toWgs84( translateCoor[1], translateCoor[0] );
double delta = CoordinateUtils.calculateLineDistance( lon, lat, originCoor[0], originCoor[1] );
Logger.d( TAG, "偏差值:%s", delta );
}
break;
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:
WorkThreadHandler.getInstance().post( () -> {
try {
InputStream is = context.getAssets().open( "coors.json" );
BufferedReader br = new BufferedReader( new InputStreamReader( is ) );
String line = "";
List< ADASCarStateInfo > vals = new ArrayList<>();
while ( ( line = br.readLine() ) != null ) {
String[] json = line.split( " - " );
long time = Long.valueOf( json[0] );
ADASCarStateInfo si = GsonUtil.objectFromJson( json[1], ADASCarStateInfo.class );
// si.getValues().setSatelliteTime( time + "" );
vals.add( si );
}
long interval = -1;
ADASCarStateInfo last = null;
for ( ADASCarStateInfo val : vals ) {
if ( last == null ) {
interval = 0;
} else {
interval = Long.valueOf( val.getValues().getSatelliteTime() ) - Long.valueOf( last.getValues().getSatelliteTime() );
}
last = val;
WorkThreadHandler.getInstance().postDelayed( () -> {
onAdasCarDataCallback( val );
}, interval );
}
} catch ( Exception e ) {
e.printStackTrace();
}
} );
break;
case 43:
MogoApisHandler.getInstance()
.getApis()
.getAdasControllerApi()
.onAutopilotArriveLike( intent.getIntExtra( "type", 8 ) );
break;
}
}
public void onAdasCarDataCallback( ADASCarStateInfo stateInfo ) {
if ( stateInfo != null && stateInfo.getValues() != null ) {
JSONObject data = new JSONObject();
try {
data.putOpt( "lon", stateInfo.getValues().getLon() );
data.putOpt( "lat", stateInfo.getValues().getLat() );
data.putOpt( "alt", stateInfo.getValues().getAlt() );
data.putOpt( "speed", stateInfo.getValues().getGnss_speed() );
data.putOpt( "satelliteTime", stateInfo.getValues().getSatelliteTime() );
data.putOpt( "heading", stateInfo.getValues().getHeading() );
data.putOpt( "acceleration", stateInfo.getValues().getAcceleration() );
data.putOpt( "yawRate", stateInfo.getValues().getYaw_rate() );
MarkerServiceHandler.getApis().getMapServiceApi().getMapUIController().syncLocation2Map( data );
// SnapshotUploadInTime.getInstance().syncAdasLocationInfo( data );
} catch ( Exception e ) {
e.printStackTrace();
}
}
}

View File

@@ -92,13 +92,13 @@ class SnapshotUploadInTime implements MogoRTKLocation.RTKLocationListener {
locationResult.lastCoordinate = lastInfo;
locationResult.mortonCode = MortonCode.wrapEncodeMorton( lastInfo.getLon(), lastInfo.getLat() );
}
// locationResult.coordinates = new ArrayList<>();
locationResult.coordinates = new ArrayList<>();
locationResult.sn = com.mogo.commons.network.Utils.getSn();
// if ( cloudLocationInfo == null ) {
// locationResult.coordinates.addAll( new ArrayList<>() );
// } else {
// locationResult.coordinates.addAll( cloudLocationInfo );
// }
if ( cloudLocationInfo == null || cloudLocationInfo.isEmpty() ) {
locationResult.coordinates.addAll( new ArrayList<>() );
} else {
locationResult.coordinates.addAll( cloudLocationInfo );
}
}
List< ADASRecognizedResult > recognizedResults = MarkerServiceHandler.getADASController().getLastADASRecognizedResult();
OnePerSecondSendContent content = new OnePerSecondSendContent();

View File

@@ -8,8 +8,8 @@
<dimen name="module_small_map_view_width">250px</dimen>
<dimen name="module_small_map_view_height">250px</dimen>
<dimen name="module_small_map_view_x">1490px</dimen>
<dimen name="module_small_map_view_y">650px</dimen>
<dimen name="module_small_map_view_x">1525px</dimen>
<dimen name="module_small_map_view_y">695px</dimen>
<dimen name="module_small_map_big_view_x">0px</dimen>
<dimen name="module_small_map_big_view_y">0px</dimen>

View File

@@ -293,10 +293,10 @@ public class V2XObuManager implements IObuCallback, Handler.Callback {
if (ObuConfig.useObuLocation) {
MogoLocation currentLocation = new MogoLocation();
double coor[] = CoordinateUtils.transformFromWGSToGCJ(locationInfo.getLat(), locationInfo.getLon());
double coor[] = CoordinateUtils.transformWgsToGcj(locationInfo.getLat(), locationInfo.getLon());
currentLocation.setLatitude(coor[0]);
currentLocation.setLongitude(coor[1]);
currentLocation.setLatitude(coor[1]);
currentLocation.setLongitude(coor[0]);
currentLocation.setBearing(computeCarAngle(currentLocation));
V2XObuEventScenario.getInstance().updateLocation(currentLocation);

View File

@@ -129,7 +129,16 @@ public interface IMogoADASController extends IProvider {
*/
void removeAdasRecognizedDataCallback( IMogoAdasRecognizedDataCallback callback );
/**
* 自车定位数据
*
* @param carDataCallback
*/
void setAdasCarDataCallback( IMogoAdasCarDataCallback carDataCallback );
void addAdasOCHCallback( IMogoAdasOCHCallback callback );
void removeAdasOCHCallback();
void onAutopilotArriveLike( int type );
}

View File

@@ -0,0 +1,17 @@
package com.mogo.service.adas;
import com.mogo.service.adas.entity.ADASCarStateInfo;
/**
* adas 自车位置数据回调
*
* @author tongchenfei
*/
public interface IMogoAdasCarDataCallback {
/**
* adas 数据回调
*
* @param msg 具体数据
*/
void onAdasCarDataCallback( ADASCarStateInfo msg );
}

View File

@@ -0,0 +1,142 @@
package com.mogo.service.adas.entity;
import java.io.Serializable;
/**
* @author nie yunlong
* @des 车辆状态
* @date 2020/3/12
*/
public class ADASCarStateInfo implements Serializable {
/**
* action : “state”
* values : {"lon":116.8,"lat":39.4,"alt":22.3,"heading":87.5,"acceleration":0.5,"yaw_rate":0.3}
*/
private String action;
private ValuesBean values;
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
public ValuesBean getValues() {
return values;
}
public void setValues(ValuesBean values) {
this.values = values;
}
public static class ValuesBean {
/**
* lon : 116.8
* lat : 39.4
* alt : 22.3
* heading : 87.5
* acceleration : 0.5
* yaw_rate : 0.3
*/
private double lon;
private double lat;
private double alt;
private double heading;
private double acceleration;
private double yaw_rate;
//惯导车速 m/s
private float gnss_speed;
//gps 时间
private String satelliteTime;
public float getGnss_speed() {
return gnss_speed;
}
public void setGnss_speed( float gnss_speed ) {
this.gnss_speed = gnss_speed;
}
public String getSatelliteTime() {
return satelliteTime;
}
public void setSatelliteTime( String satelliteTime ) {
this.satelliteTime = satelliteTime;
}
public double getLon() {
return lon;
}
public void setLon(double lon) {
this.lon = lon;
}
public double getLat() {
return lat;
}
public void setLat(double lat) {
this.lat = lat;
}
public double getAlt() {
return alt;
}
public void setAlt(double alt) {
this.alt = alt;
}
public double getHeading() {
return heading;
}
public void setHeading(double heading) {
this.heading = heading;
}
public double getAcceleration() {
return acceleration;
}
public void setAcceleration(double acceleration) {
this.acceleration = acceleration;
}
public double getYaw_rate() {
return yaw_rate;
}
public void setYaw_rate(double yaw_rate) {
this.yaw_rate = yaw_rate;
}
@Override
public String toString() {
return "ValuesBean{" +
"lon=" + lon +
", lat=" + lat +
", alt=" + alt +
", heading=" + heading +
", acceleration=" + acceleration +
", yaw_rate=" + yaw_rate +
'}';
}
}
@Override
public String toString() {
return "CarStateInfo{" +
"action='" + action + '\'' +
", values=" + values +
'}';
}
}

View File

@@ -39,18 +39,10 @@ class ADASRecognizedListResult {
public double distanceY;
/**
* 同一个uuid 1s内所对应的连续坐标
* 同一个uuid 1内所对应的坐标
*/
public List< LatLon > latLonList;
public double lon;
public double lat;
public static class LatLon {
public LatLon( double lat, double lon ) {
this.lat = lat;
this.lon = lon;
}
public double lat;
public double lon;
}
public long systemTime;
}

View File

@@ -65,17 +65,17 @@ class AdasObjectUtils {
if ( rectBean == null ) {
return null;
}
if( rectBean.getLat() < 1){
if ( rectBean.getLat() < 1 ) {
return null;
}
ADASRecognizedResult result = new ADASRecognizedResult();
result.uuid = rectBean.getUuid();
double amapCoord[] = CoordinateUtils.transformFromWGSToGCJ( rectBean.getLat(), rectBean.getLon() );
double amapCoord[] = CoordinateUtils.transformWgsToGcj( rectBean.getLat(), rectBean.getLon() );
if ( amapCoord != null ) {
result.lat = amapCoord[0];
result.lon = amapCoord[1];
result.lat = amapCoord[1];
result.lon = amapCoord[0];
} else {
result.lat = rectBean.getLat();
result.lon = rectBean.getLon();
@@ -96,37 +96,33 @@ class AdasObjectUtils {
if ( datums == null || datums.isEmpty() ) {
return null;
}
Map< String, ADASRecognizedListResult > result = new HashMap<>();
List< ADASRecognizedListResult > recognizedListResults = new ArrayList<>();
for ( RectInfo rectInfo : datums ) {
if ( rectInfo == null || rectInfo.getModels() == null || rectInfo.getModels().isEmpty() ) {
continue;
}
List< RectInfo.RectBean > models = rectInfo.getModels();
for ( RectInfo.RectBean model : models ) {
for ( RectInfo.RectBean model : rectInfo.getModels() ) {
if ( model == null || TextUtils.isEmpty( model.getUuid() ) ) {
continue;
}
ADASRecognizedListResult recognizedListResult = null;
if ( !result.containsKey( model.getUuid() ) ) {
recognizedListResult = new ADASRecognizedListResult();
recognizedListResult.latLonList = new ArrayList<>();
recognizedListResult.heading = model.getHeading();
recognizedListResult.speed = model.getSpeed();
recognizedListResult.type = Integer.valueOf( model.getType() );
recognizedListResult.uuid = model.getUuid();
result.put( model.getUuid(), recognizedListResult );
} else {
recognizedListResult = result.get( model.getUuid() );
recognizedListResult.distanceX = model.getDistance_x();
recognizedListResult.distanceY = model.getDistance_y();
ADASRecognizedListResult recognizedListResult = new ADASRecognizedListResult();
recognizedListResult.heading = model.getHeading();
recognizedListResult.speed = model.getSpeed();
recognizedListResult.type = Integer.valueOf( model.getType() );
recognizedListResult.uuid = model.getUuid();
recognizedListResult.distanceX = model.getDistance_x();
recognizedListResult.distanceY = model.getDistance_y();
double amapCoord[] = CoordinateUtils.transformWgsToGcj( model.getLat(), model.getLon() );
recognizedListResult.lat = amapCoord[1];
recognizedListResult.lon = amapCoord[0];
try {
recognizedListResult.systemTime = Long.valueOf( model.getSystemTime() );
} catch ( Exception e ) {
recognizedListResult.systemTime = System.currentTimeMillis();
}
double amapCoord[] = CoordinateUtils.transformFromWGSToGCJ( model.getLat(), model.getLon() );
recognizedListResult.latLonList.add( new ADASRecognizedListResult.LatLon( amapCoord[0], amapCoord[1] ) );
recognizedListResults.add( recognizedListResult );
}
}
if ( result.isEmpty() ) {
return null;
}
return new ArrayList<>( result.values() );
return recognizedListResults;
}
}

View File

@@ -0,0 +1,75 @@
package com.mogo.service.impl.adas;
import android.os.Handler;
import android.os.Message;
import com.mogo.utils.WorkThreadHandler;
import com.mogo.utils.network.utils.GsonUtil;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
public
/**
* @author congtaowang
* @since 2021/1/22
*
* 描述
*/
class LogWriter {
public static final int MAX_SIZE = 6 * 1024 * 1924;
private final String path;
private Handler writeHandler = null;
public LogWriter( String path ) {
this.path = path;
File file = new File( path );
if ( !file.exists() ) {
try {
if ( !file.getParentFile().exists() ) {
file.getParentFile().mkdirs();
}
file.createNewFile();
} catch ( Exception e ) {
e.printStackTrace();
}
}
writeHandler = new Handler( WorkThreadHandler.newInstance( "Logger-Writer" ).getLooper() ) {
@Override
public void handleMessage( Message msg ) {
super.handleMessage( msg );
if ( msg.what == 100 ) {
writeImpl( ( ( String ) msg.obj ) );
}
}
};
}
private void writeImpl( Object log ) {
try {
FileWriter fw = new FileWriter( path, true );
fw.append( System.currentTimeMillis() + " - " );
if ( log instanceof CharSequence ) {
fw.append( ( ( CharSequence ) log ) );
} else {
fw.append( GsonUtil.jsonFromObject( log ) );
}
fw.append( "\n" );
fw.flush();
fw.close();
} catch ( Exception e ) {
e.printStackTrace();
}
}
public void write( Object log ) {
Message msg = Message.obtain();
msg.obj = log;
msg.what = 100;
writeHandler.sendMessage( msg );
}
}

View File

@@ -20,11 +20,13 @@ import com.mogo.module.common.map.MyLocationUtil;
import com.mogo.module.common.utils.CarSeries;
import com.mogo.service.MogoServicePaths;
import com.mogo.service.adas.IMogoADASController;
import com.mogo.service.adas.IMogoAdasCarDataCallback;
import com.mogo.service.adas.IMogoAdasDataCallback;
import com.mogo.service.adas.IMogoAdasOCHCallback;
import com.mogo.service.adas.IMogoAdasRecognizedDataCallback;
import com.mogo.service.adas.IMogoAdasWarnMessageCallback;
import com.mogo.service.adas.RemoteControlAutoPilotParameters;
import com.mogo.service.adas.entity.ADASCarStateInfo;
import com.mogo.service.adas.entity.ADASRecognizedListResult;
import com.mogo.service.adas.entity.ADASRecognizedResult;
import com.mogo.service.adas.entity.ADASWarnMessage;
@@ -46,6 +48,7 @@ import com.zhidao.autopilot.support.api.IAutopilotServiceStatusListener;
import com.zhidao.autopilot.support.api.IAutopolitDataCallBack;
import com.zhidao.autopilotservice.model.AdasAIDLAutopilotArriveModel;
import com.zhidao.support.adas.high.OnAdasListener;
import com.zhidao.support.adas.high.bean.CarStateInfo;
import com.zhidao.support.adas.high.bean.RectInfo;
import com.zhidao.support.adas.high.bean.WarnMessageInfo;
import com.zhidao.support.adas.high.msg.MyMessageFactory;
@@ -53,8 +56,10 @@ import com.zhidao.support.adas.high.msg.MyMessageFactory;
import org.json.JSONException;
import org.json.JSONObject;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -108,15 +113,27 @@ public class MogoADASController implements IMogoADASController {
*/
private List< IMogoAdasRecognizedDataCallback > mMogoAdasRecognizedDataCallbacks = new CopyOnWriteArrayList<>();
private IMogoAdasCarDataCallback mMogoAdasCarDataCallback;
private RectInfo mLastFrameData;
private OnAdasListener mOnAdasListener = new OnAdasListenerAdapter() {
LogWriter logWriter = null;
@Override
public void onRectData( RectInfo rectInfo ) {
// 物体识别返回
Logger.d( TAG, "onRectData = %s", rectInfo.toString() );
if ( logWriter == null ) {
SimpleDateFormat sdf = new SimpleDateFormat( "yyyyMMddhhmmss" );
String date = sdf.format( new Date() );
String path = context.getExternalCacheDir().getAbsolutePath() + "/adaslog/" + date + "/log.txt";
Logger.d( TAG, path );
logWriter = new LogWriter( path );
}
mLastFrameData = rectInfo;
logWriter.write( GsonUtil.jsonFromObject( rectInfo ) );
// 仅在 vr 模式下显示 adas 识别车辆
if ( !MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() ) {
return;
@@ -315,6 +332,24 @@ public class MogoADASController implements IMogoADASController {
);
}
}
LogWriter logWriter;
@Override
public void ownerCarStateInfo( String ownerCarStateInfo ) {
if ( logWriter == null ) {
SimpleDateFormat sdf = new SimpleDateFormat( "yyyyMMddhhmmss" );
String date = sdf.format( new Date() );
String path = context.getExternalCacheDir().getAbsolutePath() + "/adaslog/" + date + "/ownerCarStateInfo.txt";
Logger.d( TAG, path );
logWriter = new LogWriter( path );
}
logWriter.write( ownerCarStateInfo );
ADASCarStateInfo stateInfo = GsonUtil.objectFromJson( ownerCarStateInfo, ADASCarStateInfo.class );
if ( mMogoAdasCarDataCallback != null ) {
mMogoAdasCarDataCallback.onAdasCarDataCallback( stateInfo );
}
}
};
AutopilotServiceManage.getInstance().registerAutopilotDataListener( mAutopolitDataCallBack );
}
@@ -595,6 +630,11 @@ public class MogoADASController implements IMogoADASController {
mMogoAdasRecognizedDataCallbacks.remove( callback );
}
@Override
public void setAdasCarDataCallback( IMogoAdasCarDataCallback carDataCallback ) {
mMogoAdasCarDataCallback = carDataCallback;
}
@Override
public void addAdasOCHCallback( IMogoAdasOCHCallback callback ) {
@@ -605,4 +645,15 @@ public class MogoADASController implements IMogoADASController {
public void removeAdasOCHCallback() {
mAdasOCHCallback = null;
}
@Override
public void onAutopilotArriveLike( int carType ) {
if ( mAdasOCHCallback != null ) {
mAdasOCHCallback.onArriveAt( new AdasOCHData(
carType,
116.09888888,
39.999999 )
);
}
}
}