Merge branch 'qa_hengyang_base' into feature/feature_hengyang_base

This commit is contained in:
董宏宇
2021-07-15 17:26:43 +08:00
51 changed files with 800 additions and 1293 deletions

View File

@@ -4,21 +4,17 @@ import android.content.Context;
import android.content.Intent;
import android.location.Location;
import android.net.ConnectivityManager;
import android.text.TextUtils;
import android.util.Log;
import com.mogo.cloud.commons.utils.CoordinateUtils;
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
import com.mogo.commons.data.BaseData;
import com.mogo.commons.network.SubscribeImpl;
import com.mogo.map.MogoLatLng;
import com.mogo.map.location.MogoLocation;
import com.mogo.map.navi.IMogoCarLocationChangedListener2;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.constants.HostConst;
import com.mogo.och.taxi.ui.OCHTaxiUiController;
import com.mogo.service.adas.IMogoAdasOCHCallback;
import com.mogo.service.adas.IMogoAdasRouteCallBack;
import com.mogo.service.adas.RemoteControlAutoPilotParameters;
import com.mogo.service.adas.entity.AdasOCHData;
import com.mogo.service.connection.IMogoOnMessageListener;
@@ -137,9 +133,9 @@ class MogoOCHTaxiModel {
// if ( NetworkUtils.isConnected( mContext ) ) {
// restoreOrderInfo();
// }
// if ( NetworkUtils.isConnected( mContext ) ) {
// querryCarStatus();
// }
if ( NetworkUtils.isConnected( mContext ) ) {
querryCarStatus();
}
}
public void querryCarStatus() {
@@ -186,15 +182,16 @@ class MogoOCHTaxiModel {
private void restoreOrderInfo() {
Logger.d( TAG, "重新查询订单状态" );
mRetryCounter = 0;
if ( mCurrentOCHOrder == null ) {
// 订单恢复
String orderInfo = SharedPrefsMgr.getInstance( mContext ).getString( SP_KEY_OCH_TAXI_ORDER );
Logger.d(TAG,"restoreOrderInfo:"+orderInfo);
if ( !TextUtils.isEmpty( orderInfo ) ) {
mCurrentOCHOrder = GsonUtil.objectFromJson( orderInfo, OCHTaxiOrderResponse.class );
}
}
query2RestoreOrderStatus(mCurrentOCHOrder == null ? null : mCurrentOCHOrder.orderNo);
// if ( mCurrentOCHOrder == null ) {
// // 订单恢复
// String orderInfo = SharedPrefsMgr.getInstance( mContext ).getString( SP_KEY_OCH_TAXI_ORDER );
// Logger.d(TAG,"restoreOrderInfo:"+orderInfo);
// if ( !TextUtils.isEmpty( orderInfo ) ) {
// mCurrentOCHOrder = GsonUtil.objectFromJson( orderInfo, OCHTaxiOrderResponse.class );
// }
// }
// query2RestoreOrderStatus(mCurrentOCHOrder == null ? null : mCurrentOCHOrder.orderNo);
query2RestoreOrderStatus(null);
}
// private void restoreOrderInfo_() {
@@ -236,7 +233,7 @@ class MogoOCHTaxiModel {
queryOCHOrderStatus( orderNo, new OCHOrderStatusCallback< OCHTaxiOrderResponse2 >() {
@Override
public void onSuccess( OCHTaxiOrderResponse2 data ) {
Logger.d( TAG, "query2RestoreOrderStatus:"+ data.toString());
if ( data == null || data.data == null) {
Logger.d( TAG, "订单已取消或已完成" );
clearCurrentOCHOrder();
@@ -247,7 +244,7 @@ class MogoOCHTaxiModel {
OCHOrderStatus status = OCHOrderStatus.valueOf( data.data.orderDispatchType );
OCHTaxiUiController.getInstance().onOrderStatusChanged(data.data.orderDispatchType);
switch ( status ) {
case Completed:
case JourneyCompleted:
TipToast.shortTip( mContext.getString( R.string.module_och_taxi_order_completed ) );
clearCurrentOCHOrder();
// OCHTaxiUiController.getInstance().removeFragment();
@@ -258,6 +255,7 @@ class MogoOCHTaxiModel {
// OCHTaxiUiController.getInstance().removeFragment();
break;
case ArriveAtEndStation:
case UserState:
mIsArriveAtEndStation = true;
mIsArriveAtStartStation = false;
mIsOnTheWay2EndStation = false;
@@ -332,18 +330,26 @@ class MogoOCHTaxiModel {
mCurrentOCHOrder.drivingRoutes = new ArrayList<>();
OCHTaxiOrderResponse.OCHTaxiStation startStation = new OCHTaxiOrderResponse.OCHTaxiStation();
List< Double > startStationCoordinate = data.data.startStationCoordinate;
if (startStationCoordinate != null && startStationCoordinate.size()>1){
startStation.lon = startStationCoordinate.get( 0 );
startStation.lat = startStationCoordinate.get( 1 );
List< Double > startGcjStationCoordinate = data.data.startGcjStationCoordinate;
if (startStationCoordinate != null && startStationCoordinate.size()>1 &&
startGcjStationCoordinate!= null && startGcjStationCoordinate.size() > 1){
startStation.lon = startGcjStationCoordinate.get( 0 );
startStation.lat = startGcjStationCoordinate.get( 1 );
startStation.wgsLon = startStationCoordinate.get(0);
startStation.wgsLat = startStationCoordinate.get(1);
startStation.siteId = data.data.startStationId;
startStation.siteName = data.data.startStation;
mCurrentOCHOrder.drivingRoutes.add( startStation );
}
OCHTaxiOrderResponse.OCHTaxiStation endStation = new OCHTaxiOrderResponse.OCHTaxiStation();
List< Double > endStationCoordinate = data.data.endStationCoordinate;
if (endStationCoordinate != null && endStationCoordinate.size()>1){
endStation.lon = endStationCoordinate.get( 0 );
endStation.lat = endStationCoordinate.get( 1 );
List< Double > endGcjStationCoordinate = data.data.endGcjStationCoordinate;
if (endStationCoordinate != null && endStationCoordinate.size()>1 &&
endGcjStationCoordinate!=null && endGcjStationCoordinate.size() > 1){
endStation.lon = endGcjStationCoordinate.get( 0 );
endStation.lat = endGcjStationCoordinate.get( 1 );
endStation.wgsLon = endStationCoordinate.get( 0 );
endStation.wgsLat = endStationCoordinate.get( 1 );
endStation.siteId = data.data.endStationId;
endStation.siteName = data.data.endStation;
mCurrentOCHOrder.drivingRoutes.add( endStation );
@@ -472,6 +478,7 @@ class MogoOCHTaxiModel {
updateOCHOrderStatus( OCHOrderStatus.ArriveAtStartStation, new OCHOrderStatusCallback() {
@Override
public void onSuccess( Object data ) {
OCHTaxiUiController.getInstance().onOrderStatusChanged(OCHOrderStatus.ArriveAtStartStation.getCode());
Logger.d( TAG, "更新状态成功" );
}
@@ -488,7 +495,7 @@ class MogoOCHTaxiModel {
} );
return;
}
Logger.d( TAG, "distance = %s", distance );
// Logger.d( TAG, "distance = %s", distance );
}
/**
@@ -553,6 +560,7 @@ class MogoOCHTaxiModel {
return;
}
Logger.d( TAG, "收到新订单" + GsonUtil.jsonFromObject(obj));
mCurrentOCHOrder = obj;
cacheOrderInfo2Native( mCurrentOCHOrder );
Location location = MogoApisHandler.getInstance()
@@ -623,6 +631,7 @@ class MogoOCHTaxiModel {
if (mOCHRHCarstatus != 1){
return;
}
Logger.d(TAG, "订单状态被改变:" + GsonUtil.jsonFromObject(obj));
OCHOrderStatus status = OCHOrderStatus.valueOf( obj.orderDispatchType );
switch ( status ) {
@@ -789,8 +798,8 @@ class MogoOCHTaxiModel {
RemoteControlAutoPilotParameters parameters = new RemoteControlAutoPilotParameters();
parameters.vehicleType = mCurrentOCHOrder.orderType;
parameters.startLatLon = new RemoteControlAutoPilotParameters.AutoPilotLonLat( mCurrentOCHOrder.drivingRoutes.get( 0 ).lat, mCurrentOCHOrder.drivingRoutes.get( 0 ).lon );
parameters.endLatLon = new RemoteControlAutoPilotParameters.AutoPilotLonLat( mCurrentOCHOrder.drivingRoutes.get( 1 ).lat, mCurrentOCHOrder.drivingRoutes.get( 1 ).lon );
parameters.startLatLon = new RemoteControlAutoPilotParameters.AutoPilotLonLat( mCurrentOCHOrder.drivingRoutes.get( 0 ).wgsLat, mCurrentOCHOrder.drivingRoutes.get( 0 ).wgsLon );
parameters.endLatLon = new RemoteControlAutoPilotParameters.AutoPilotLonLat( mCurrentOCHOrder.drivingRoutes.get( 1 ).wgsLat, mCurrentOCHOrder.drivingRoutes.get( 1 ).wgsLon );
MogoApisHandler.getInstance()
.getApis()
.getAdasControllerApi()
@@ -807,6 +816,16 @@ class MogoOCHTaxiModel {
return mCurrentOCHOrder;
}
public void calculateTravelDistance(Location carLocation){
if (mCurrentOCHOrder.drivingRoutes != null && mCurrentOCHOrder.drivingRoutes.size()>0){
OCHTaxiOrderResponse.OCHTaxiStation endStationOCHLocation = mCurrentOCHOrder.drivingRoutes.get(1);
double distance = CoordinateUtils.calculateLineDistance(
endStationOCHLocation.lon, endStationOCHLocation.lat,
carLocation.getLongitude(), carLocation.getLatitude());
mCurrentOCHOrder.decreaseTravelDistance(distance);
}
}
/**
* 结束自动驾驶
*/

View File

@@ -22,8 +22,9 @@ enum OCHOrderStatus {
UserArriveAtStartStation( 3 ),
OnTheWayToEndStation( 4 ),
ArriveAtEndStation( 5 ),
Completed( 6 ),
Cancel( 7 );
UserState( 6 ),//小程序用的状态 车机不处理
Cancel( 7 ),
JourneyCompleted(8);//行程完成
private int code;

View File

@@ -33,7 +33,7 @@ class OCHTaxiOrderResponse implements Parcelable {
* @param distance
*/
public void decreaseTravelDistance( double distance ) {
travelDistance -= ( ( float ) distance / 1000f );
travelDistance = ( ( float ) distance / 1000f );
if ( travelDistance < 0 ) {
travelDistance = 0;
}
@@ -42,9 +42,10 @@ class OCHTaxiOrderResponse implements Parcelable {
public static class OCHTaxiStation implements Parcelable {
public String siteId;
public String siteName;
public double lon;
public double lon;// 用于计算距离
public double lat;
public double wgsLon;//用于自动驾驶
public double wgsLat;
public OCHTaxiStation() {
}
@@ -59,6 +60,8 @@ class OCHTaxiOrderResponse implements Parcelable {
dest.writeString( this.siteName );
dest.writeDouble( this.lon );
dest.writeDouble( this.lat );
dest.writeDouble( this.wgsLon );
dest.writeDouble( this.wgsLat );
}
protected OCHTaxiStation( Parcel in ) {
@@ -66,6 +69,8 @@ class OCHTaxiOrderResponse implements Parcelable {
this.siteName = in.readString();
this.lon = in.readDouble();
this.lat = in.readDouble();
this.wgsLon = in.readDouble();
this.wgsLat = in.readDouble();
}
public static final Creator< OCHTaxiStation > CREATOR = new Creator< OCHTaxiStation >() {

View File

@@ -36,6 +36,7 @@ class OCHTaxiOrderResponse2 extends BaseData {
public String startStationId;
// 起点站点
public List< Double > startStationCoordinate;
public List< Double > startGcjStationCoordinate;//高德坐标系 用于距离计算
// 目的站名称
public String endStation;
@@ -43,6 +44,7 @@ class OCHTaxiOrderResponse2 extends BaseData {
public String endStationId;
// 终点站点
public List< Double > endStationCoordinate;
public List< Double > endGcjStationCoordinate;//高德坐标系 用于距离计算
public String orderStartTime;
public String cityCode;

View File

@@ -8,9 +8,6 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import com.mogo.cloud.commons.utils.CoordinateUtils;
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
import com.mogo.commons.network.SubscribeImpl;
import com.mogo.commons.voice.AIAssist;
import com.mogo.map.MogoLatLng;
import com.mogo.map.location.MogoLocation;
import com.mogo.map.navi.IMogoCarLocationChangedListener2;
@@ -30,23 +27,13 @@ import com.mogo.och.view.SlidePanelView;
import com.mogo.service.adas.IMogoAdasOCHCallback;
import com.mogo.service.adas.IMogoAdasRouteCallBack;
import com.mogo.service.adas.entity.AdasOCHData;
import com.mogo.service.adas.IMogoAdasRouteCallBack;
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
import com.mogo.service.statusmanager.StatusDescriptor;
import com.mogo.utils.logger.Logger;
import com.mogo.utils.network.RequestOptions;
import com.mogo.utils.network.utils.GsonUtil;
import java.util.ArrayList;
import java.util.List;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import java.util.List;
public
/**
* @author congtaowang
@@ -80,6 +67,7 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
private TextView mDistance;
private MogoPolylineOptions mogoPolylineOptions;
private int saveOrderState = -1;
@Override
public int getStationPanelViewId() {
return R.layout.module_och_taxi_panel;
@@ -170,6 +158,7 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
}
}
private boolean isSpeakedEndingNotice = false;
/**
* 初始化订单信息
*/
@@ -180,7 +169,6 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
slidePanelView.setVisibility( View.VISIBLE );
slidePanelView.setText( getString( R.string.module_och_taxi_arrive_at_end_station ) );
mOrderStatus.setText( R.string.module_och_taxi_arrive_at_end_station2 );
showNotice( getString( R.string.module_och_taxi_order_complete_1) );
} else if ( MogoOCHTaxiModel.getInstance().isOnTheWay2EndStation() ) {
Logger.d( TAG, "已经去往终点" );
slidePanelView.setVisibility( View.GONE );
@@ -188,15 +176,6 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
} else if ( MogoOCHTaxiModel.getInstance().isArriveAtStartStation() ) {
Logger.d( TAG, "已经达到起点" );
mOrderStatus.setText( R.string.module_och_taxi_waiting );
// if ( MogoOCHTaxiModel.getInstance().isUserArriveAtStartStation() ) {
// Logger.d( TAG, "乘客已上车" );
// slidePanelView.setVisibility( View.VISIBLE );
//// if ( MogoApisHandler.getInstance().getApis().getAdasControllerApi().getAutopilotStatus() == IMogoAdasOCHCallback.STATUS_AUTOPILOT_ENABLE ) {
//// } else {
//// slidePanelView.setVisibility( View.GONE );
//// }
// slidePanelView.setText( getString( R.string.module_och_taxi_arrive_at_start_station ) );
// }
slidePanelView.setVisibility( View.VISIBLE );
slidePanelView.setText( getString( R.string.module_och_taxi_arrive_at_start_station ) );
} else if ( MogoOCHTaxiModel.getInstance().checkCurrentOCHOrder() ) {
@@ -206,6 +185,13 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
}
}
public synchronized void SpeakNoticeOnce(){
if (!isSpeakedEndingNotice){
isSpeakedEndingNotice = true;
showNotice( getString( R.string.module_och_taxi_order_complete_1) );
}
}
/**
* 更新订单基本信息
*/
@@ -246,6 +232,7 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
@Override
public void onSuccess( Object data ) {
Logger.d( TAG, "更新状态成功" );
onOrderStatusChanged(OCHOrderStatus.ArriveAtEndStation.getCode());
}
@Override
@@ -259,10 +246,10 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
Logger.d( TAG, "更新状态失败2" );
}
} );
MogoApisHandler.getInstance()
.getApis()
.getRegisterCenterApi()
.unregisterCarLocationChangedListener( TAG, this );
// MogoApisHandler.getInstance()
// .getApis()
// .getRegisterCenterApi()
// .unregisterCarLocationChangedListener( TAG, this );
}
@Override
@@ -303,7 +290,7 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
private void onSlidePanelMoveToEnd() {
// 已到达终点,需要结束订单
if ( MogoOCHTaxiModel.getInstance().isArriveAtEndStation() ) {
MogoOCHTaxiModel.getInstance().updateOCHOrderStatus( OCHOrderStatus.Completed, new OCHOrderStatusCallback() {
MogoOCHTaxiModel.getInstance().updateOCHOrderStatus( OCHOrderStatus.JourneyCompleted, new OCHOrderStatusCallback() {
@Override
public void onSuccess( Object data ) {
Logger.d( TAG, "更新状态成功" );
@@ -325,7 +312,6 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
return;
// 乘客已确认到达起点,前往下一站并开启自动驾驶
} else if ( !MogoOCHTaxiModel.getInstance().isOnTheWay2EndStation() ) {
// MogoOCHTaxiModel.getInstance().isUserArriveAtStartStation() &&
MogoOCHTaxiModel.getInstance().startAutoPilot();
}
}
@@ -350,6 +336,7 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
@Override
public void onSuccess( Object data ) {
Logger.d( TAG, "更新状态成功" );
onOrderStatusChanged(OCHOrderStatus.OnTheWayToEndStation.getCode());
}
@Override
@@ -367,7 +354,6 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
@Override
public void onCarLocationChanged( MogoLatLng latLng ) {
}
private Location mLocation;
@@ -377,18 +363,17 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
OCHTaxiUiController.getInstance().runOnUIThread( () -> {
calculateTravelDistance( location );
} );
//坐标转换
MogoLocation loc = new MogoLocation();
loc.setTime(loc.getTime());
loc.setAccuracy(location.getAccuracy());
loc.setSpeed(location.getSpeed());
loc.setLongitude(location.getLongitude());
loc.setLatitude(location.getLatitude());
loc.setAltitude(location.getAltitude());
loc.setBearing(location.getBearing());
loc.setProvider(location.getProvider());
mogoLocation = loc;
// //坐标转换
// MogoLocation loc = new MogoLocation();
// loc.setTime(loc.getTime());
// loc.setAccuracy(location.getAccuracy());
// loc.setSpeed(location.getSpeed());
// loc.setLongitude(location.getLongitude());
// loc.setLatitude(location.getLatitude());
// loc.setAltitude(location.getAltitude());
// loc.setBearing(location.getBearing());
// loc.setProvider(location.getProvider());
// mogoLocation = loc;
}
/**
@@ -400,21 +385,26 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
if ( location == null ) {
return;
}
if ( !MogoOCHTaxiModel.getInstance().isOnTheWay2EndStation() ) {
return;
}
if ( MogoOCHTaxiModel.getInstance().isArriveAtEndStation() ) {
return;
}
// if ( !MogoOCHTaxiModel.getInstance().isOnTheWay2EndStation() ) {
// return;
// }
// if ( MogoOCHTaxiModel.getInstance().isArriveAtEndStation() ) {
// return;
// }
if ( mLocation == null ) {
mLocation = location;
}
double distance = CoordinateUtils.calculateLineDistance(
location.getLongitude(), location.getLatitude(),
mLocation.getLongitude(), mLocation.getLatitude()
);
if ( MogoOCHTaxiModel.getInstance().checkCurrentOCHOrder() ) {
MogoOCHTaxiModel.getInstance().getCurrentOCHOrder().decreaseTravelDistance( distance );
// double distance = CoordinateUtils.calculateLineDistance(
// location.getLongitude(), location.getLatitude(),
// mLocation.getLongitude(), mLocation.getLatitude()
// );
// Logger.e("lianglihui","calculateTravelDistance:"+distance);
if ( MogoOCHTaxiModel.getInstance().isOnTheWay2EndStation() &&
MogoOCHTaxiModel.getInstance().checkCurrentOCHOrder() &&
!MogoOCHTaxiModel.getInstance().isArriveAtEndStation()) {
MogoOCHTaxiModel.getInstance().calculateTravelDistance(location);
// MogoOCHTaxiModel.getInstance().getCurrentOCHOrder().decreaseTravelDistance( distance );
updateOrderBaseStatusInfo();
}
mLocation = location;
@@ -443,15 +433,46 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
@Override
public void onOrderStatusChanged(int status) {
// int orderState = MogoOCHTaxiModel.getInstance().getCurrentOCHOrder().orderDispatchType;
// if (orderState == status){
// return;
// }
getActivity().runOnUiThread(() -> {
if (status == OCHOrderStatus.None.getCode() || status == OCHOrderStatus.Cancel.getCode() || status == OCHOrderStatus.Completed.getCode() ){
if (status == OCHOrderStatus.None.getCode() || status == OCHOrderStatus.Cancel.getCode() || status == OCHOrderStatus.JourneyCompleted.getCode() ){
getPanelView().setVisibility(View.INVISIBLE);
hideSlidePanel();
changeOperationViewVisible(View.VISIBLE);
}else {
isSpeakedEndingNotice = false;
} else {
getPanelView().setVisibility(View.VISIBLE);
changeOperationViewVisible(View.INVISIBLE);
}
if(status != saveOrderState){
OCHOrderStatus ochStatus = OCHOrderStatus.valueOf( status );
switch (ochStatus){
case OnTheWayToStartStation:
showNotice(getString( R.string.module_och_taxi_new_order));
break;
case Cancel:
showNotice(getString( R.string.module_och_taxi_order_cancel));
break;
case ArriveAtStartStation:
showNotice( getString( R.string.module_och_taxi_order_status_ph_text) );
break;
case OnTheWayToEndStation:
// showNotice("欢迎使用蘑菇智行");
break;
case ArriveAtEndStation:
showNotice( getString( R.string.module_och_taxi_order_complete_1) );
break;
case JourneyCompleted:
showNotice( "感谢您使用蘑菇智行,再见~" );
break;
}
}
saveOrderState = status;
updateOrderStatus();
});
}
@@ -460,11 +481,11 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
@Override
public void routeResult(List<MogoLatLng> routeList) {
if (routeList == null ) return;
double distance = calculateTravelDistance(mogoLocation,routeList);
if ( MogoOCHTaxiModel.getInstance().checkCurrentOCHOrder() ) {
MogoOCHTaxiModel.getInstance().getCurrentOCHOrder().decreaseTravelDistance( distance );
updateOrderBaseStatusInfo();
}
// double distance = calculateTravelDistance(mogoLocation,routeList);
// if ( MogoOCHTaxiModel.getInstance().checkCurrentOCHOrder() ) {
// MogoOCHTaxiModel.getInstance().getCurrentOCHOrder().decreaseTravelDistance( distance );
// updateOrderBaseStatusInfo();
// }
// Logger.d("lianglihui","routeResult 剩余导航距离:"+distance);
// if (routeList != null && routeList.size() >0){
// Logger.d("lianglihui","routeResult:"+routeList.size());
@@ -482,7 +503,7 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
MogoLatLng routeLatLng;
for (int i = 0 ; i< routeList.size() ; i++) {
routeLatLng =routeList.get(i);
//需要剔除已经行驶过的经纬度,这里需要比对推荐路线集合中点是否在当前车辆行驶方向前面如果不在则抛弃
//需要剔除已经行驶过的经纬度,这里需要比对推荐路线集合中点是否在当前车w辆行驶方向前面如果不在则抛弃
if (LocationUtils.isPointOnCarFront(carLocation, routeLatLng)) {
mPolylinePointList.add(routeLatLng);
}
@@ -506,7 +527,6 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
public void onArriveAt(AdasOCHData data) {
Logger.d( TAG, "行程结束");
MogoApisHandler.getInstance().getApis().getAdasControllerApi().cancelAutopilot();
// AIAssist.getInstance( getContext() ).speakTTSVoice( "即将到达目的地,请您携带好随身物品,安全下车。" );
}
@Override

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="module_och_taxi_arrive_at_start_station">乘客已上车,准备出发</string>
<string name="module_och_taxi_arrive_at_start_station">确认上车,行程开始</string>
<string name="module_och_taxi_arrive_at_end_station">到达站点,乘客已下车</string>
<string name="module_och_taxi_order_status_ph_text">已到达上车站点,等待乘客上车</string>
<string name="module_och_taxi_order_distance_anchor_text">预计里程</string>

View File

@@ -69,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);
initMogoHttpDns();
initModules();

View File

@@ -250,6 +250,7 @@ ext {
mogoaicloudrealtime : "com.mogo.cloud:realtime:${MOGO_REALTIME_VERSION}",
mogoaicloudtanlu : "com.mogo.cloud:tanlu:${MOGO_TANLU_VERSION}",
mogoaicloudtrafficlive : "com.mogo.cloud:trafficlive:${MOGO_TRAFFICLIVE_VERSION}",
mogoaicloudlocation : "com.mogo.cloud:location:${MOGO_LOCATION_VERSION}",
]
}

View File

@@ -28,9 +28,7 @@ android {
dependencies {
implementation rootProject.ext.dependencies.mogoaicloudsocket
// 上报位置
implementation 'com.zhidao.locupload:loc-upload-sdk:1.1.7'
implementation rootProject.ext.dependencies.mogoaicloudlocation
if (Boolean.valueOf(RELEASE)) {
implementation rootProject.ext.dependencies.mogoutils

View File

@@ -4,22 +4,13 @@ import android.content.Context;
import androidx.annotation.Keep;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.cloud.location.LocationManager;
import com.mogo.map.location.MogoLocation;
import com.mogo.service.locationinfo.IMogoLocationInfoService;
import com.mogo.utils.logger.Logger;
import com.zhidao.locupload.LocUploadConfig;
import com.zhidao.locupload.LocUploadManager;
public
/*
* @author congtaowang
* @since 2020/7/16
*
* 位置服务
*/
@Keep
class MogoLocationInfoServices implements IMogoLocationInfoService {
public class MogoLocationInfoServices implements IMogoLocationInfoService {
private static final String TAG = "MogoLocationInfoServices-sdk";
@@ -31,9 +22,9 @@ class MogoLocationInfoServices implements IMogoLocationInfoService {
@Keep
public static MogoLocationInfoServices getInstance() {
if ( sInstance == null ) {
synchronized ( MogoLocationInfoServices.class ) {
if ( sInstance == null ) {
if (sInstance == null) {
synchronized (MogoLocationInfoServices.class) {
if (sInstance == null) {
sInstance = new MogoLocationInfoServices();
}
}
@@ -46,9 +37,9 @@ class MogoLocationInfoServices implements IMogoLocationInfoService {
}
@Override
public void provideLocation( MogoLocation location ) {
public void provideLocation(MogoLocation location) {
mLocation = location;
Logger.d( TAG, "sdk - provideLocation" );
Logger.d(TAG, "sdk - provideLocation");
}
public MogoLocation getLocation() {
@@ -57,23 +48,19 @@ class MogoLocationInfoServices implements IMogoLocationInfoService {
@Override
public void start() {
LocUploadManager.getInstance().startUpload();
Logger.d( TAG, "sdk - start" );
LocationManager.getInstance().start();
Logger.d(TAG, "sdk - start");
}
@Override
public void stop() {
LocUploadManager.getInstance().stopUpload();
Logger.d( TAG, "sdk - stop" );
LocationManager.getInstance().stop();
Logger.d(TAG, "sdk - stop");
}
@Override
public void init( Context context ) {
LocUploadConfig.instance().
setAppId( DebugConfig.getSocketAppId() ).
setContext( context.getApplicationContext() ).
setLoggable( DebugConfig.isDebug() ).
setLocInterval( 2000L );
Logger.d( TAG, "sdk - init" );
public void init(Context context) {
LocationManager.getInstance().init(context);
Logger.d(TAG, "sdk - init");
}
}

View File

@@ -3,19 +3,12 @@ package com.mogo.aicloud.services.locationinfo;
import com.elegant.spi.annotations.Service;
import com.zhidao.locupload.location.LocationServiceProvider;
public
/*
* @author congtaowang
* @since 2020/7/16
*
* 描述
*/
@Service( value = LocationServiceProvider.class )
class MogoLocationSource extends LocationServiceProvider {
@Service(value = LocationServiceProvider.class)
public class MogoLocationSource extends LocationServiceProvider {
@Override
public float getBearing() {
if ( MogoLocationInfoServices.getInstance().getLocation() != null ) {
if (MogoLocationInfoServices.getInstance().getLocation() != null) {
return MogoLocationInfoServices.getInstance().getLocation().getBearing();
}
return 0;
@@ -23,7 +16,7 @@ class MogoLocationSource extends LocationServiceProvider {
@Override
public float getAccuracy() {
if ( MogoLocationInfoServices.getInstance().getLocation() != null ) {
if (MogoLocationInfoServices.getInstance().getLocation() != null) {
return MogoLocationInfoServices.getInstance().getLocation().getAccuracy();
}
return 0;
@@ -31,7 +24,7 @@ class MogoLocationSource extends LocationServiceProvider {
@Override
public String getProvider() {
if ( MogoLocationInfoServices.getInstance().getLocation() != null ) {
if (MogoLocationInfoServices.getInstance().getLocation() != null) {
return MogoLocationInfoServices.getInstance().getLocation().getProvider();
}
return null;
@@ -39,7 +32,7 @@ class MogoLocationSource extends LocationServiceProvider {
@Override
public float getSpeed() {
if ( MogoLocationInfoServices.getInstance().getLocation() != null ) {
if (MogoLocationInfoServices.getInstance().getLocation() != null) {
return MogoLocationInfoServices.getInstance().getLocation().getSpeed();
}
return 0;
@@ -47,7 +40,7 @@ class MogoLocationSource extends LocationServiceProvider {
@Override
public double getAltitude() {
if ( MogoLocationInfoServices.getInstance().getLocation() != null ) {
if (MogoLocationInfoServices.getInstance().getLocation() != null) {
return MogoLocationInfoServices.getInstance().getLocation().getAltitude();
}
return 0;
@@ -55,7 +48,7 @@ class MogoLocationSource extends LocationServiceProvider {
@Override
public String getAdCode() {
if ( MogoLocationInfoServices.getInstance().getLocation() != null ) {
if (MogoLocationInfoServices.getInstance().getLocation() != null) {
return MogoLocationInfoServices.getInstance().getLocation().getAdCode();
}
return null;
@@ -63,7 +56,7 @@ class MogoLocationSource extends LocationServiceProvider {
@Override
public int getLocType() {
if ( MogoLocationInfoServices.getInstance().getLocation() != null ) {
if (MogoLocationInfoServices.getInstance().getLocation() != null) {
return MogoLocationInfoServices.getInstance().getLocation().getLocType();
}
return 0;
@@ -71,7 +64,7 @@ class MogoLocationSource extends LocationServiceProvider {
@Override
public double getLatitude() {
if ( MogoLocationInfoServices.getInstance().getLocation() != null ) {
if (MogoLocationInfoServices.getInstance().getLocation() != null) {
return MogoLocationInfoServices.getInstance().getLocation().getLatitude();
}
return 0;
@@ -79,7 +72,7 @@ class MogoLocationSource extends LocationServiceProvider {
@Override
public double getLongitude() {
if ( MogoLocationInfoServices.getInstance().getLocation() != null ) {
if (MogoLocationInfoServices.getInstance().getLocation() != null) {
return MogoLocationInfoServices.getInstance().getLocation().getLongitude();
}
return 0;
@@ -87,7 +80,7 @@ class MogoLocationSource extends LocationServiceProvider {
@Override
public long getTime() {
if ( MogoLocationInfoServices.getInstance().getLocation() != null ) {
if (MogoLocationInfoServices.getInstance().getLocation() != null) {
return MogoLocationInfoServices.getInstance().getLocation().getTime();
}
return 0;
@@ -95,7 +88,7 @@ class MogoLocationSource extends LocationServiceProvider {
@Override
public String getCityCode() {
if ( MogoLocationInfoServices.getInstance().getLocation() != null ) {
if (MogoLocationInfoServices.getInstance().getLocation() != null) {
return MogoLocationInfoServices.getInstance().getLocation().getCityCode();
}
return null;
@@ -103,7 +96,7 @@ class MogoLocationSource extends LocationServiceProvider {
@Override
public String getCityName() {
if ( MogoLocationInfoServices.getInstance().getLocation() != null ) {
if (MogoLocationInfoServices.getInstance().getLocation() != null) {
return MogoLocationInfoServices.getInstance().getLocation().getCityName();
}
return null;
@@ -111,7 +104,7 @@ class MogoLocationSource extends LocationServiceProvider {
@Override
public int getGpsAccuracyStatus() {
if ( MogoLocationInfoServices.getInstance().getLocation() != null ) {
if (MogoLocationInfoServices.getInstance().getLocation() != null) {
return MogoLocationInfoServices.getInstance().getLocation().getGpsAccuracyStatus();
}
return 0;
@@ -119,7 +112,7 @@ class MogoLocationSource extends LocationServiceProvider {
@Override
public int getSatellites() {
if ( MogoLocationInfoServices.getInstance().getLocation() != null ) {
if (MogoLocationInfoServices.getInstance().getLocation() != null) {
return MogoLocationInfoServices.getInstance().getLocation().getSatellite();
}
return 0;

View File

@@ -13,6 +13,7 @@ import android.widget.TextView;
import com.alibaba.android.arouter.launcher.ARouter;
import com.amap.api.maps.TextureMapView;
import com.amap.api.navi.AMapNaviView;
import com.mogo.commons.analytics.AnalyticsUtils;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.commons.device.Devices;
@@ -61,16 +62,16 @@ public abstract class AbsMogoApplication extends Application {
return sApp;
}
public static TextureMapView aMapNaviView;
public static AMapNaviView aMapNaviView;
public static TextureMapView getMapNaviView() {
public static AMapNaviView getMapNaviView() {
return aMapNaviView;
}
@Override
public void onCreate() {
super.onCreate();
aMapNaviView = new TextureMapView(this);
aMapNaviView = new AMapNaviView(this);
aMapNaviView.onCreate(null);
// 在设置皮肤布局填充器之前进行克隆一个出来
mLayoutInflaterNoSkin = LayoutInflater.from(new ContextThemeWrapper(this, R.style.Theme_AppCompat)).cloneInContext(new ContextThemeWrapper(this, R.style.Theme_AppCompat));

View File

@@ -159,21 +159,22 @@ LOGLIB_VERSION = 1.0.4
######## MogoAiCloudSDK Version
# 网络请求
MOGO_NETWORK_VERSION=1.1.18
MOGO_NETWORK_VERSION=1.1.21
# 鉴权
MOGO_PASSPORT_VERSION=1.1.18
MOGO_PASSPORT_VERSION=1.1.21
# 常链接
MOGO_SOCKET_VERSION=1.1.18
MOGO_SOCKET_VERSION=1.1.21
# 数据采集
MOGO_REALTIME_VERSION=1.1.18
MOGO_REALTIME_VERSION=1.1.21
# 探路,道路事件发布,获取
MOGO_TANLU_VERSION=1.1.18
MOGO_TANLU_VERSION=1.1.21
# 直播推流
MOGO_LIVE_VERSION=1.1.18
MOGO_LIVE_VERSION=1.1.21
# 直播拉流
MOGO_TRAFFICLIVE_VERSION=1.1.18
#ADAS HIGHT
MOGO_ADASHIGH_VERSION=1.1.3
MOGO_TRAFFICLIVE_VERSION=1.1.21
# 定位服务
MOGO_LOCATION_VERSION=1.1.21
######## Foundation MogoAiCloud Module
# mogoAiCloud apk services
@@ -181,11 +182,11 @@ MOGO_AICLOUD_SERVICES_APK_VERSION=1.0.0-SNAPSHOT
# mogoAiCloud sdk services
MOGO_AICLOUD_SERVICES_SDK_VERSION=1.0.0-SNAPSHOT
# 自研地图
MAP_SDK_VERSION=1.0.0-vr-8.5.61
MAP_SDK_VERSION=1.0.0-vr-8.5.75
## 产品库必备配置产品库自动对versionCode和versionName版本进行升级
applicationId=com.mogo.launcer
applicationName=IntelligentPilot
versionCode=80007
versionName=8.0.8
versionName=8.0.9

View File

@@ -107,4 +107,10 @@ fix crash
修改画线问题
8.5.60
修改崩溃
8.5.63
修改infoWindow崩溃
8.5.64
修改崩溃

View File

@@ -95,7 +95,7 @@ class CustomMapApiBuilder implements IMogoMapApiBuilder {
public IMogoMapView getMapView( Context context ) {
Log.d(TAG,"setDebugMode==true");
NavAutoApi.INSTANCE.init( context, MapParams.Companion.init()
.setDebugMode( true )
.setDebugMode( DebugConfig.isDebug() )
.setDataFileSource(1) //todo 1-使用本地地图数据0-使用在线地图数据
.setCoordinateType( MapParams.COORDINATETYPE_GCJ02 )
.setPerspectiveMode( MapParams.MAP_PERSPECTIVE_2D )

View File

@@ -568,7 +568,7 @@ public class AMapMarkerWrapper implements IMogoMarker, Observer {
@Override
public void addDynamicAnchorPosition( MogoLatLng latLng, float angle, long duration ) {
try {
mMarker.addDynamicAnchorPostion( new LonLatPoint( latLng.lon, latLng.lat, angle ), System.currentTimeMillis(), ( int ) duration ,false , true);
mMarker.addDynamicAnchorPostion( new LonLatPoint( latLng.lon, latLng.lat, angle ), System.currentTimeMillis(), ( int ) duration);
} catch ( Exception e ) {
e.printStackTrace();
}

View File

@@ -56,6 +56,12 @@ public interface IMogoMarkerManager {
*/
void inVisibleAllMarkers();
/**
* 隐藏除了某些类别的所有marker {@link MogoMarkerOptions Owner}
* @param owner
*/
void inVisibleWithoutMarkers(String owner); //todo 后续需要把Owner类别统一起来基类下沉此接口为临时方案应该设计为隐藏某一类元素
/**
* 获取某种类型的全部marker。
*

View File

@@ -61,6 +61,17 @@ public class MogoMarkersHandler implements IMogoMarkerClickListener, IMogoMarker
.forEach(mogoMarkerList -> mogoMarkerList.forEach(mogoMarker -> mogoMarker.setVisible(false)));
}
@SuppressLint("NewApi")
public synchronized void inVisibleMarkers(String owner){
mServicesMarkers.values().stream()
.filter(mogoMarkerList -> mogoMarkerList != null && !mogoMarkerList.isEmpty())
.forEach(mogoMarkerList -> mogoMarkerList.forEach(mogoMarker -> {
if(TextUtils.isEmpty(mogoMarker.getOwner()) || !mogoMarker.getOwner().equals(owner)){
mogoMarker.setVisible(false);
}
}));
}
public synchronized void removeAll() {
final Collection< List< IMogoMarker > > mogoMarkers = mServicesMarkers.values();
for ( List< IMogoMarker > mogoMarkerList : mogoMarkers ) {

View File

@@ -84,6 +84,11 @@ public class MogoMarkerManager implements IMogoMarkerManager {
MogoMarkersHandler.getInstance().inVisibleAll();
}
@Override
public void inVisibleWithoutMarkers(String owner) {
MogoMarkersHandler.getInstance().inVisibleMarkers(owner);
}
@Override
public List< IMogoMarker > getMarkers( String tag ) {
return MogoMarkersHandler.getInstance().getMarkers( tag );

View File

@@ -45,7 +45,7 @@ dependencies {
// 现有的ADAS的通讯SDK需要将里面的东西融合到我们项目中
compileOnly rootProject.ext.dependencies.adasapi
api "com.zhidao.support.adas:high:1.2.0.1"
api "com.zhidao.support.adas:high:1.2.0.2"
annotationProcessor rootProject.ext.dependencies.aroutercompiler
if (Boolean.valueOf(RELEASE)) {

View File

@@ -1,16 +1,11 @@
package com.mogo.module.adas;
import com.google.gson.Gson;
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
import com.mogo.commons.data.BaseData;
import com.mogo.commons.network.SubscribeImpl;
import com.mogo.module.adas.entity.AutonomousDriveStatusBean;
import com.mogo.module.adas.entity.ReportSiteBean;
import com.mogo.module.adas.entity.WarnMessageModel;
import com.mogo.module.adas.model.AdasServiceModel;
import com.mogo.module.adas.network.IAdasApiService;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.utils.logger.Logger;
import com.mogo.utils.network.RequestOptions;
import com.mogo.utils.network.utils.GsonUtil;
import com.zhidao.autopilotservice.model.AdasAIDLAutopilotArriveModel;
import com.zhidao.autopilotservice.model.AdasAIDLAutopilotStateModel;
@@ -32,14 +27,9 @@ import java.util.concurrent.TimeUnit;
import io.reactivex.Flowable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.annotations.NonNull;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import static com.mogo.commons.context.ContextHolderUtil.getContext;
import static com.mogo.module.adas.AdasConstant.getBaseUrl;
/**
@@ -54,8 +44,7 @@ public class AdasEventManager implements OnAdasListener, OnAdasMsgConnectStatusL
private final Gson gson;
private final ArrayList<IAdasDataListener> iAdasEventListeners = new ArrayList<>();
private final ArrayList<AdasStatusListener> iAdasStatusListeners = new ArrayList<>();
private IAdasApiService mAdasApiService;
private final ArrayList<IAdasStatusListener> iAdasStatusListeners = new ArrayList<>();
private Disposable uploadAutopilotStatus;
//自动驾驶状态
private int mCurrentAutopilotStatus = -1;
@@ -65,9 +54,10 @@ public class AdasEventManager implements OnAdasListener, OnAdasMsgConnectStatusL
//自动驾驶状态
private AutopilotStatus.ValuesBean mAutopilotValuesStatus = null;
private IAdasProviderBizListener providerBizListener;
private AdasEventManager() {
gson = GsonUtil.getGson();
mAdasApiService = MogoApisHandler.getInstance().getApis().getNetworkApi().create(IAdasApiService.class, getBaseUrl());
}
public static AdasEventManager getInstance() {
@@ -94,7 +84,7 @@ public class AdasEventManager implements OnAdasListener, OnAdasMsgConnectStatusL
iAdasEventListeners.remove(listener);
}
public void addStatusListener(AdasStatusListener listener) {
public void addStatusListener(IAdasStatusListener listener) {
Logger.d(TAG, "添加adas状态事件监听");
if (iAdasStatusListeners.contains(listener)) {
return;
@@ -102,7 +92,7 @@ public class AdasEventManager implements OnAdasListener, OnAdasMsgConnectStatusL
iAdasStatusListeners.add(listener);
}
public void removeStatusListener(AdasStatusListener listener) {
public void removeStatusListener(IAdasStatusListener listener) {
Logger.d(TAG, "注销adas状态事件监听");
iAdasStatusListeners.remove(listener);
}
@@ -116,15 +106,9 @@ public class AdasEventManager implements OnAdasListener, OnAdasMsgConnectStatusL
public void onWarnMessage(WarnMessageInfo warnMessageInfo) {
Logger.d(TAG, "onWarnMessage " + warnMessageInfo);
//报警model
WarnMessageModel warnMessageModel = null;
for (IAdasDataListener listener : iAdasEventListeners) {
if (listener != null) {
if (warnMessageModel == null) {
warnMessageModel = new WarnMessageModel();
warnMessageModel.setAction(MsgActionType.ACTION_WS_MSG_WARNING_TYPE.getmActionType());
}
warnMessageModel.setValues(warnMessageInfo);
listener.cameraEyeDetectResult(gson.toJson(warnMessageModel));
listener.onWarnMessage(warnMessageInfo);
}
}
}
@@ -144,7 +128,7 @@ public class AdasEventManager implements OnAdasListener, OnAdasMsgConnectStatusL
try {
for (IAdasDataListener listener : iAdasEventListeners) {
if (listener != null) {
listener.cameraEyeDetectResult(gson.toJson(rectInfo));
listener.onRectData(rectInfo);
}
}
} catch (Exception e) {
@@ -236,10 +220,10 @@ public class AdasEventManager implements OnAdasListener, OnAdasMsgConnectStatusL
@Override
public void onAutopilotRoute(AutopilotRoute autopilotRoute) {
if (autopilotRoute.getModels() == null || autopilotRoute.getModels().size() == 0) {
Logger.d(TAG,"onAutopilotRoute is null !");
Logger.d(TAG, "onAutopilotRoute is null !");
return;
}
Logger.d(TAG,"onAutopilotRoute : " + autopilotRoute.toString());
Logger.d(TAG, "onAutopilotRoute : " + autopilotRoute.toString());
for (IAdasDataListener listener : iAdasEventListeners) {
if (listener != null) {
listener.autopilotRoute(autopilotRoute);
@@ -247,10 +231,19 @@ public class AdasEventManager implements OnAdasListener, OnAdasMsgConnectStatusL
}
}
@Override
public void onAutopilotSNRequest() {
if (providerBizListener != null) {
providerBizListener.getDeviceSn();
} else {
Logger.e(TAG, "onAutopilotSNRequest providerBizListener is null");
}
}
@Override
public void onWebSocketConnectSuccess() {
Logger.d(TAG, "webSocket 连接成功");
for (AdasStatusListener listener : iAdasStatusListeners) {
for (IAdasStatusListener listener : iAdasStatusListeners) {
listener.onServiceConnected();
}
updateDriveStatusTask();
@@ -259,7 +252,7 @@ public class AdasEventManager implements OnAdasListener, OnAdasMsgConnectStatusL
@Override
public void onWebSocketConnectFailed() {
Logger.d(TAG, "webSocket 连接失败");
for (AdasStatusListener listener : iAdasStatusListeners) {
for (IAdasStatusListener listener : iAdasStatusListeners) {
listener.onServiceDisconnected();
}
}
@@ -270,65 +263,18 @@ public class AdasEventManager implements OnAdasListener, OnAdasMsgConnectStatusL
.subscribeOn(Schedulers.io())
.unsubscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<Long>() {
@Override
public void accept(@NonNull Long aLong) throws Exception {
updateDriveStatus();
}
});
.subscribe(aLong -> updateDriveStatus());
}
private void updateDriveStatus() {
String sn = MoGoAiCloudClientConfig.getInstance().getSn();
AutonomousDriveStatusBean request = new AutonomousDriveStatusBean(sn, mCurrentAutopilotStatus, mCurrentAutopilotSpeed);
RequestBody requestBody = RequestBody.create(MediaType.get("application/json;charset=UTF-8"), GsonUtil.jsonFromObject(request));
mAdasApiService.updateAutonomousDriveStatus(requestBody).
subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create(getContext())) {
@Override
public void onError(String message, int code) {
super.onError(message, code);
}
@Override
public void onError(Throwable e) {
super.onError(e);
}
@Override
public void onSuccess(BaseData o) {
super.onSuccess(o);
Logger.d(TAG, "updateDriveStatus success");
}
});
AdasServiceModel.getInstance().updateDriveStatus(mCurrentAutopilotStatus, mCurrentAutopilotSpeed);
}
private void reportSite(double lon, double lat) {
String sn = MoGoAiCloudClientConfig.getInstance().getSn();
ReportSiteBean reportSiteBean = new ReportSiteBean(sn, lon, lat);
RequestBody requestBody = RequestBody.create(MediaType.get("application/json;charset=UTF-8"), GsonUtil.jsonFromObject(reportSiteBean));
mAdasApiService.updateReportSite(requestBody).
subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create(getContext())) {
@Override
public void onError(String message, int code) {
super.onError(message, code);
}
@Override
public void onError(Throwable e) {
super.onError(e);
}
@Override
public void onSuccess(BaseData o) {
super.onSuccess(o);
Logger.d(TAG, "autopilotArrive success");
}
});
AdasServiceModel.getInstance().reportSite(lon, lat);
}
public AutopilotStatus.ValuesBean getAutopilotValuesStatus(){
public AutopilotStatus.ValuesBean getAutopilotValuesStatus() {
return mAutopilotValuesStatus;
}
@@ -342,5 +288,7 @@ public class AdasEventManager implements OnAdasListener, OnAdasMsgConnectStatusL
return adasAIDLAutopilotStateModel;
}
public void setProviderBizListener(IAdasProviderBizListener listener) {
providerBizListener = listener;
}
}

View File

@@ -31,7 +31,7 @@ public class AdasProvider implements IProvider {
initAdas(context, adasEventManager);
initAutoPilotBusiness(context);
addAdasStatusListener(new AdasStatusListener() {
addAdasStatusListener(new IAdasStatusListener() {
@Override
public void onServiceConnected() {
Logger.d(TAG, "adas statusListener connected & send sn");
@@ -49,6 +49,7 @@ public class AdasProvider implements IProvider {
AdasManager.getInstance().create(context);
AdasManager.getInstance().setOnAdasListener(adasEventManager);
AdasManager.getInstance().setOnAdasConnectStatusListener(adasEventManager);
adasEventManager.setProviderBizListener(this::setBasicInfo);
}
private void initAutoPilotBusiness(Context context) {
@@ -73,11 +74,11 @@ public class AdasProvider implements IProvider {
adasEventManager.removeEventListener(listener);
}
public void addAdasStatusListener(AdasStatusListener listener) {
public void addAdasStatusListener(IAdasStatusListener listener) {
adasEventManager.addStatusListener(listener);
}
public void removeAdasStatusListener(AdasStatusListener listener) {
public void removeAdasStatusListener(IAdasStatusListener listener) {
adasEventManager.removeStatusListener(listener);
}

View File

@@ -1,35 +1,32 @@
package com.mogo.module.adas;
import com.mogo.module.adas.entity.WarnMessageModel;
import com.zhidao.autopilotservice.model.AdasAIDLAutopilotArriveModel;
import com.zhidao.autopilotservice.model.AdasAIDLAutopilotStateModel;
import com.zhidao.autopilotservice.model.AdasAIDLOwnerCarRectModel;
import com.zhidao.autopilotservice.model.AdasAIDLOwnerCarStateModel;
import com.zhidao.support.adas.high.OnAdasListener;
import com.zhidao.support.adas.high.bean.AutopilotRoute;
import com.zhidao.support.adas.high.bean.AutopilotStatus;
import com.zhidao.support.adas.high.bean.AutopilotWayArrive;
import com.zhidao.support.adas.high.bean.CarLaneInfo;
import com.zhidao.support.adas.high.bean.CarStateInfo;
import com.zhidao.support.adas.high.bean.LightStatueInfo;
import com.zhidao.support.adas.high.bean.ObstaclesInfo;
import com.zhidao.support.adas.high.bean.RectInfo;
import com.zhidao.support.adas.high.bean.WarnMessageInfo;
import java.util.List;
/**
* Created by XuYong on 2021/4/25 16:52
*/
public interface IAdasDataListener {
default void sendMsg( String msg ){
default void sendMsg(String msg) {
};
default void cameraEyeDetectResult( String detectResult ) {
}
default void selectCarModelUrl( String carStyleUrl ) {
default void onRectData(RectInfo rectInfo) {
}
default void onWarnMessage(WarnMessageInfo warnMessageInfo) {
}
default void selectCarModelUrl(String carStyleUrl) {
}
default void requestGetCarModelListInfo() {
@@ -38,42 +35,41 @@ public interface IAdasDataListener {
default void clickSettingBack() {
}
default void showToast( String msg ) {
default void showToast(String msg) {
}
/**
* 自动驾驶到达站点回调接口
*
* @param autopilotArriveModel
*/
default void autopilotArrive( AdasAIDLAutopilotArriveModel autopilotArriveModel ) {
default void autopilotArrive(AdasAIDLAutopilotArriveModel autopilotArriveModel) {
}
/**
* 自动驾驶路线回调
*
* @param autopilotRoute {@link AutopilotRoute}
*/
default void autopilotRoute(AutopilotRoute autopilotRoute){
default void autopilotRoute(AutopilotRoute autopilotRoute) {
}
/**
* 自车定位信息
*
* @param ownerCarStateInfo
*/
default void ownerCarStateInfo( String ownerCarStateInfo ) {
}
default void notifyOwnerCarState( AdasAIDLOwnerCarStateModel ownerCarStateModel ) {
default void ownerCarStateInfo(String ownerCarStateInfo) {
}
/**
* 自动驾驶状态信息
*
* @param autopilotStatus {@link AutopilotStatus}
*/
default void notifyAutopilotState( AutopilotStatus autopilotStatus ) {
default void notifyAutopilotState(AutopilotStatus autopilotStatus) {
}
default void notifyOwnerCarRect( List<AdasAIDLOwnerCarRectModel> ownerCarStateRectList ) {
}
}

View File

@@ -0,0 +1,6 @@
package com.mogo.module.adas;
public interface IAdasProviderBizListener {
void getDeviceSn();
}

View File

@@ -3,7 +3,7 @@ package com.mogo.module.adas;
/**
* Created by XuYong on 4/28/21 16:19
*/
public interface AdasStatusListener {
public interface IAdasStatusListener {
void onServiceConnected();

View File

@@ -1,10 +1,11 @@
package com.mogo.module.adas.model;
import com.google.gson.Gson;
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
import com.mogo.commons.data.BaseData;
import com.mogo.commons.network.SubscribeImpl;
import com.mogo.module.adas.entity.AutonomousDriveStatusBean;
import com.mogo.module.adas.entity.ReportDispatchResult;
import com.mogo.module.adas.entity.ReportSiteBean;
import com.mogo.module.adas.entity.ReportedRoute;
import com.mogo.module.adas.network.IAdasApiService;
import com.mogo.module.common.MogoApisHandler;
@@ -14,16 +15,16 @@ import com.mogo.utils.network.utils.GsonUtil;
import com.zhidao.support.adas.high.bean.AutopilotRoute;
import com.zhidao.support.adas.high.bean.AutopilotStatus;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import static com.mogo.commons.context.ContextHolderUtil.getContext;
import static com.mogo.module.adas.AdasConstant.getBaseUrl;
import static com.mogo.module.common.constants.HostConst.DATA_SERVICE_HOST;
public class AdasServiceModel {
@@ -126,7 +127,7 @@ public class AdasServiceModel {
*
* @param dispatchResultType int
*/
public void dispatchResultUpload(int dispatchResultType,IDispatch dispatch) {
public void dispatchResultUpload(int dispatchResultType, IDispatch dispatch) {
String sn = MoGoAiCloudClientConfig.getInstance().getSn();
ReportDispatchResult reportDispatchResult = new ReportDispatchResult(sn, dispatchResultType);
Map<String, Object> map = new HashMap<>();
@@ -157,4 +158,54 @@ public class AdasServiceModel {
});
}
public void updateDriveStatus(int autoPilotStatus, float autoPilotSpeed) {
String sn = MoGoAiCloudClientConfig.getInstance().getSn();
AutonomousDriveStatusBean request = new AutonomousDriveStatusBean(sn, autoPilotStatus, autoPilotSpeed);
RequestBody requestBody = RequestBody.create(MediaType.get("application/json;charset=UTF-8"), GsonUtil.jsonFromObject(request));
mAdasApiService.updateAutonomousDriveStatus(requestBody).
subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create(getContext())) {
@Override
public void onError(String message, int code) {
super.onError(message, code);
}
@Override
public void onError(Throwable e) {
super.onError(e);
}
@Override
public void onSuccess(BaseData o) {
super.onSuccess(o);
Logger.d(TAG, "updateDriveStatus success");
}
});
}
public void reportSite(double lon, double lat){
String sn = MoGoAiCloudClientConfig.getInstance().getSn();
ReportSiteBean reportSiteBean = new ReportSiteBean(sn, lon, lat);
RequestBody requestBody = RequestBody.create(MediaType.get("application/json;charset=UTF-8"), GsonUtil.jsonFromObject(reportSiteBean));
mAdasApiService.updateReportSite(requestBody).
subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create(getContext())) {
@Override
public void onError(String message, int code) {
super.onError(message, code);
}
@Override
public void onError(Throwable e) {
super.onError(e);
}
@Override
public void onSuccess(BaseData o) {
super.onSuccess(o);
Logger.d(TAG, "autopilotArrive success");
}
});
}
}

View File

@@ -1,6 +1,7 @@
package com.mogo.module.common.drawer;
import android.os.Build;
import android.os.Message;
import android.text.TextUtils;
import android.util.Log;
@@ -11,6 +12,7 @@ import com.mogo.map.marker.IMogoMarker;
import com.mogo.map.marker.MogoMarkerOptions;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.constants.DataTypes;
import com.mogo.module.common.drawer.bean.SpeedData;
import com.mogo.module.common.utils.Trigonometric;
import com.mogo.service.adas.entity.ADASRecognizedResult;
@@ -19,6 +21,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import static com.mogo.cloud.socket.entity.SocketDownDataHelper.FROM_ADAS;
@@ -76,6 +79,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
* @param resultList
*/
public void renderAdasRecognizedResult(List<ADASRecognizedResult> resultList) {
final long start = System.nanoTime();
if (resultList == null || resultList.isEmpty() || !DebugConfig.isUseAdasRecognize()) {
clearOldMarker();
return;
@@ -100,9 +104,9 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
String uniqueKey = recognizedListResult.uuid;
IMogoMarker marker = mMarkersCaches.remove(uniqueKey);
if (marker != null && !marker.isDestroyed()) {
Log.d(TAG, "发现缓存marker id : " + uniqueKey);
// Log.d(TAG, "发现缓存marker id : " + uniqueKey);
updateCacheMarkerRes(marker, recognizedListResult);
renderAdasOneFrame(true, marker, uniqueKey, recognizedListResult, newAdasRecognizedMarkersCaches);
renderAdasOneFrame(marker, uniqueKey, recognizedListResult, newAdasRecognizedMarkersCaches);
} else {
// 新增添加进差集
newDiffSet.add(recognizedListResult);
@@ -110,37 +114,11 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
}
removeUselessMarker(mMarkersCaches);
removeUselessLastRecord();
// 能复用的 marker 数量
// int cachedMarkerSize = mMarkersCaches.size();
// 需要新增的 marker 数量
Log.d("ADAS数据延时绘制", "查找缓存绘制 cost : " + TimeUnit.NANOSECONDS.toMillis((System.nanoTime() - start)));
int newDiffSetSize = newDiffSet.size();
Log.d(TAG, "原数据量 " + resultList.size() + " 新增marker数量 " + newDiffSetSize);
// 能复用的数量
// int size = Math.min(cachedMarkerSize, newDiffSetSize);
// Log.d(TAG, "原数据量 " + resultList.size() + " 新增marker数量 " + newDiffSetSize);
// 复用过期 marker
if (newDiffSetSize > 0) {
// Iterator<Map.Entry<String, IMogoMarker>> entryIterator = mMarkersCaches.entrySet().iterator();
// for (int i = 0; i < size; i++) {
// ADASRecognizedResult recognizedListResult = newDiffSet.get(i);
// String uniqueKey = recognizedListResult.uuid;
// Map.Entry<String, IMogoMarker> entry = entryIterator.next();
// entryIterator.remove();
// ADASRecognizedResult old = mLastPositions.remove(entry.getKey());
// IMogoMarker marker = entry.getValue();
// if (marker == null) {
// continue;
// }
// // 复用更新marker 3D资源
// if (old == null || old.type != recognizedListResult.type) {
// updateCacheMarkerRes(marker, recognizedListResult);
// }
// Log.d(TAG,"复用marker id : " + uniqueKey);
// renderAdasOneFrame(false, marker, uniqueKey, recognizedListResult, newAdasRecognizedMarkersCaches);
// }
// 复用过后还需新增的 marker
// for (int i = size; i < newDiffSetSize; i++) {
for (int i = 0; i < newDiffSetSize; i++) {
ADASRecognizedResult recognizedListResult = newDiffSet.get(i);
String uniqueKey = recognizedListResult.uuid;
@@ -148,18 +126,15 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
if (marker == null) {
continue;
}
Log.d(TAG, "新增marker id : " + uniqueKey);
renderAdasOneFrame(false, marker, uniqueKey, recognizedListResult, newAdasRecognizedMarkersCaches);
// Log.d(TAG, "新增marker id : " + uniqueKey);
renderAdasOneFrame(marker, uniqueKey, recognizedListResult, newAdasRecognizedMarkersCaches);
}
}
// if (cachedMarkerSize - size > 0) {
// sendMessage(MSG_REMOVE_DIRTY_MARKERS, mMarkersCaches);
// }
sendMessage(MSG_REMOVE_DIRTY_MARKERS, mMarkersCaches);
mMarkersCaches.clear();
mMarkersCaches = newAdasRecognizedMarkersCaches;
Log.d(TAG, "更新缓存marker, size : " + mMarkersCaches.size());
// Log.d(TAG, "更新缓存marker, size : " + mMarkersCaches.size());
Log.d("ADAS数据延时绘制", "render 接收数据 -> 处理结束 " + TimeUnit.NANOSECONDS.toMillis((System.nanoTime() - start)) + "ms");
}
/**
@@ -242,7 +217,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
while (iterator.hasNext()) {
ADASRecognizedResult result = iterator.next();
long internal = result.satelliteTime - getCurSatelliteTime();
if (internal > 300) {
if (internal > 3000) { //防止帧率过低导致误删除上一个节点对象,从而出现跳跃现象
iterator.remove();
}
}
@@ -271,14 +246,14 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
* @param recognizedListResult {@link ADASRecognizedResult}
* @param newAdasRecognizedMarkersCaches 缓存集合
*/
private void renderAdasOneFrame(boolean useCache, IMogoMarker marker,
private void renderAdasOneFrame(IMogoMarker marker,
String uniqueKey,
ADASRecognizedResult recognizedListResult,
Map<String, IMogoMarker> newAdasRecognizedMarkersCaches) {
final long start = System.currentTimeMillis();
Log.d(TAG, "renderAdasOneFrame uuid : " + uniqueKey + " type : " + recognizedListResult.type);
final long start = System.nanoTime();
// Log.d(TAG, "renderAdasOneFrame uuid : " + uniqueKey + " type : " + recognizedListResult.type + " heading : " + recognizedListResult.heading);
ADASRecognizedResult lastPosition = mLastPositions.remove(uniqueKey);
// 道路吸附
// double lastLon = -1;
// double lastLat = -1;
// if (lastPosition != null) {
@@ -292,19 +267,17 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
// Log.d( "matchRoad", "cost = %s", System.currentTimeMillis() - start );
mLastPositions.put(uniqueKey, recognizedListResult);
if (useCache) {
Log.d(TAG, "使用缓存 id : " + uniqueKey);
long interval = computeAnimDuration(lastPosition.systemTime, recognizedListResult.systemTime, lastPosition.satelliteTime, recognizedListResult.satelliteTime);
final MogoLatLng renderLoc = new MogoLatLng(recognizedListResult.lat, recognizedListResult.lon);
long cost = System.currentTimeMillis() - start;
final long intervalRef = interval - cost;
marker.addDynamicAnchorPosition(renderLoc, (float) recognizedListResult.heading, intervalRef);
} else {
Log.d(TAG, "未使用缓存 id : " + uniqueKey);
marker.setRotateAngle(((float) recognizedListResult.heading));
marker.setPosition(recognizedListResult.lat, recognizedListResult.lon);
// Log.d(TAG, "使用缓存 id : " + uniqueKey);
long interval = 45;
if (lastPosition != null) {
interval = computeAnimDuration(lastPosition.satelliteTime, recognizedListResult.satelliteTime);
}
final MogoLatLng renderLoc = new MogoLatLng(recognizedListResult.lat, recognizedListResult.lon);
long cost = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start);
Log.d("ADAS动画数据","cost : " + cost);
final long intervalRef = interval - cost;
Log.d("ADAS动画数据", "最终赋值 : " + intervalRef + " 两帧间隔 : " + interval + " uuid : " + recognizedListResult.uuid);
marker.addDynamicAnchorPosition(renderLoc, (float) recognizedListResult.heading, intervalRef);
String carColor = recognizedListResult.color;
if (TextUtils.isEmpty(carColor)) {
carColor = getModelRenderColor(recognizedListResult.type, FROM_ADAS, recognizedListResult.speed, recognizedListResult.lon, recognizedListResult.lat, recognizedListResult.heading);
@@ -313,9 +286,18 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
newAdasRecognizedMarkersCaches.put(uniqueKey, marker);
// if (shouldShowSpeed(recognizedListResult.type)) {
// showSelfSpeed(marker, recognizedListResult.speed, recognizedListResult.uuid, recognizedListResult.type, recognizedListResult.heading, MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode());
// }
if (shouldShowSpeed(recognizedListResult.type)) {
Message msg = mRenderThreadHandler.obtainMessage();
msg.obj = new SpeedData(marker
, recognizedListResult.speed
, recognizedListResult.uuid
, recognizedListResult.type
, recognizedListResult.heading
, MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode());
msg.what = MSG_DISPLAY_SPEED;
msg.sendToTarget();
}
Log.d("ADAS数据延时", "render 刷新一台车 cost : " + TimeUnit.NANOSECONDS.toMillis((System.nanoTime() - start)));
}
/**
@@ -325,6 +307,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
* @return {@link IMogoMarker}
*/
private IMogoMarker drawAdasRecognizedDataMarker(ADASRecognizedResult recognizedListResult) {
long start = System.nanoTime();
if (recognizedListResult == null) {
return null;
}
@@ -349,6 +332,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
.position(new MogoLatLng(recognizedListResult.lat, recognizedListResult.lon));
IMogoMarker marker = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager(mContext).addMarker(DataTypes.TYPE_MARKER_ADAS, options);
cacheMarkerIconResMd5Val(resIdVal, marker);
Log.d("ADAS数据延时", "创建一个新 marker cost : " + TimeUnit.NANOSECONDS.toMillis((System.nanoTime() - start)));
return marker;
}

View File

@@ -15,18 +15,19 @@ import com.mogo.map.marker.IMogoMarker;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.R;
import com.mogo.module.common.constants.AdasRecognizedType;
import com.mogo.module.common.drawer.bean.SpeedData;
import com.mogo.module.common.uploadintime.SnapshotLocationController;
import com.mogo.utils.WorkThreadHandler;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import static com.mogo.cloud.socket.entity.SocketDownDataHelper.FROM_ADAS;
import static com.mogo.cloud.socket.entity.SocketDownDataHelper.FROM_MY_LOCATION;
import static com.mogo.cloud.socket.entity.SocketDownDataHelper.FROM_ROAD_UNIT;
import static com.mogo.module.common.constants.DataTypes.TYPE_MARKER_ADAS;
import static com.mogo.module.common.constants.DataTypes.TYPE_MARKER_CLOUD_DATA;
import static java.lang.Math.PI;
@@ -48,6 +49,11 @@ class BaseDrawer {
*/
public static final int MAP_RENDER_FRAME_FREQUENCY = 30;
/**
* 显示速度
*/
public static final int MSG_DISPLAY_SPEED = 11;
/**
* 移动点的时间间隔
*/
@@ -60,7 +66,7 @@ class BaseDrawer {
protected final Context mContext;
private TextView mSpeedView;
private static TextView mSpeedView;
public BaseDrawer() {
mContext = AbsMogoApplication.getApp();
@@ -79,6 +85,7 @@ class BaseDrawer {
}
private static Handler mWorkThreadHandler;
protected static Handler mRenderThreadHandler = null;
/**
* 处理 marker 移除的线程
@@ -107,6 +114,29 @@ class BaseDrawer {
}
};
}
if (mRenderThreadHandler == null) {
mRenderThreadHandler = new Handler(WorkThreadHandler.newInstance("render-thread-" + new Random().nextLong()).getLooper()) {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
if (msg.what == MSG_DISPLAY_SPEED) {
if (msg.obj instanceof SpeedData) {
showSpeed((SpeedData) msg.obj);
}
}
}
};
}
}
private static void showSpeed(SpeedData speedData) {
showSelfSpeed(speedData.getMarker()
, speedData.getSpeed()
, speedData.getUuid()
, speedData.getType()
, speedData.getHeading()
, speedData.getIsVrMode());
}
/**
@@ -179,7 +209,8 @@ class BaseDrawer {
public int getModelRes(int type) {
AdasRecognizedType recognizedType = AdasRecognizedType.valueFrom(type);
if (recognizedType == AdasRecognizedType.classIdCar) {
return R.raw.othercar;
// TODO 这里临时替换模型解决穿模现象
return R.raw.tachexiaoche;
} else if (recognizedType == AdasRecognizedType.classIdTrafficBus) {
return R.raw.bus;
} else if (recognizedType == AdasRecognizedType.classIdMoto) {
@@ -193,15 +224,16 @@ class BaseDrawer {
} else if (recognizedType == AdasRecognizedType.classIdBicycle) {
return R.raw.zixingche;
} else if (recognizedType == AdasRecognizedType.classIdTrafficTruck) {
return R.raw.kache;
// TODO 这里临时替换模型解决穿模现象
return R.raw.daba;
}
return R.raw.people;
}
/**
* 根据速度、经纬度计算距离判断车辆颜色
* 根据数据源判断车辆预警颜色
*
* @param speed 车速 TODO 这里很可能是adas的策略
* @param speed 车速
* @param lon 经度
* @param lat 纬度
* @return 实际车辆颜色
@@ -211,45 +243,8 @@ class BaseDrawer {
// AdasRecognizedType recognizedType = AdasRecognizedType.valueFrom(type);
// if (recognizedType == AdasRecognizedType.classIdUnKnow) {
// return Car3DModelColor.Normal.color;
// }
// 距离策略 todo 此处两种策略是临时方案
// double[] coordinates = getCurCoordinates();
// double distance = CoordinateUtils.calculateLineDistance(lon, lat, coordinates[0], coordinates[1]) * 100;
// if (distance < 15) {
// return Car3DModelColor.Dangerous.color; // todo 方案1
//// return Car3DTestModelColor.getTestModelColor(fromType, Waring_Dangerous); // todo 方案2
// } else if (distance < 50 && distance >= 15) {
// return Car3DModelColor.Warming.color; // todo 方案1
//// return Car3DTestModelColor.getTestModelColor(fromType, Waring_Close); // todo 方案2
// }
// 他车车速和自车车速对比速度策略
// 自车速度 >= 50% 危险
// 10% < 自车速度 < 50% 警告
// double curSpeed = getCurSpeed();
// if (curSpeed > 0 && speed > curSpeed) {
// double rate = ((speed - curSpeed) / curSpeed) * 100;
// if (rate >= 50) {
// return Car3DModelColor.Dangerous.color; // todo 方案1
//// return Car3DTestModelColor.getTestModelColor(fromType, Waring_Dangerous); // todo 方案2
// } else if (rate > 10 && rate < 50) {
// return Car3DModelColor.Warming.color; // todo 方案1
//// return Car3DTestModelColor.getTestModelColor(fromType, Waring_Close); // todo 方案2
// }
// }
// 默认颜色 // todo 方案1
// switch (fromType) {
// case FROM_ADAS:
// return Car3DModelColor.Normal_Visual.color;
// case FROM_ROAD_UNIT:
// return Car3DModelColor.Normal_Cloud.color;
// default:
// return Car3DModelColor.Normal.color;
// }
return Car3DModelColor.Normal.color;
// todo 方案2
// return Car3DTestModelColor.getTestModelColor(fromType, Waring_Normal);
}
/**
@@ -312,7 +307,6 @@ class BaseDrawer {
Dangerous_Visual("#FF91B7F1"),
Dangerous_Cloud("#FF260FEC");
private int fromType;
private final String color;
Car3DModelColor(String color) {
@@ -321,47 +315,6 @@ class BaseDrawer {
}
public static final int Waring_Normal = 0;
public static final int Waring_Close = 1;
public static final int Waring_Dangerous = 2;
/**
* 模型颜色
*/
public enum Car3DTestModelColor {
Normal_Type(FROM_MY_LOCATION, Waring_Normal, "#D8D8D8FF"),
Normal_Type_Visual(FROM_ADAS, Waring_Normal, "#D8CFF8BD"),
Normal_Type_Cloud(FROM_ROAD_UNIT, Waring_Normal, "#D8F83F94"),
Warming_Type(FROM_MY_LOCATION, Waring_Close, "#FFD53EFF"),
Warming_Type_Visual(FROM_ADAS, Waring_Close, "#FFC192F1"),
Warming_Type_Cloud(FROM_ROAD_UNIT, Waring_Close, "#FFEF09AD"),
Dangerous_Type(FROM_MY_LOCATION, Waring_Dangerous, "#FF3C45FF"),
Dangerous_Type_Visual(FROM_ADAS, Waring_Dangerous, "#FF91B7F1"),
Dangerous_Type_Cloud(FROM_ROAD_UNIT, Waring_Dangerous, "#FF260FEC");
private final int fromType;
private final int waringType;
private final String color;
Car3DTestModelColor(int fromType, int waringType, String color) {
this.fromType = fromType;
this.waringType = waringType;
this.color = color;
}
public static String getTestModelColor(int fromType, int waringType) {
for (Car3DTestModelColor value : Car3DTestModelColor.values()) {
if (value.fromType == fromType && value.waringType == waringType) {
return value.color;
}
}
return Normal_Type.color;
}
}
/**
* 展示车辆速度
*
@@ -369,7 +322,7 @@ class BaseDrawer {
* @param speed 是否显示速度
* @param isVrMode 是否是vrMode
*/
public void showSelfSpeed(IMogoMarker mogoMarker, double speed, String uuid, int type, double heading, boolean isVrMode) {
public static void showSelfSpeed(IMogoMarker mogoMarker, double speed, String uuid, int type, double heading, boolean isVrMode) {
Log.d("EmArrow", "showSelf uuid : " + uuid + " speed : " + speed);
if (mogoMarker == null || mogoMarker.isDestroyed()) {
return;
@@ -384,7 +337,8 @@ class BaseDrawer {
return;
}
mogoMarker.setInfoWindowOffset(0, 20);
String text = "speed : " + speedIntVal + "\n" + uuid + "\n" + "type : " + type + "\n" + "heading : " + heading;
// String text = "speed : " + speedIntVal + "\n" + uuid + "\n" + "type : " + type + "\n" + "heading : " + heading;
String text = uuid + " " + (int) heading;
mSpeedView.setText(text);
mogoMarker.updateInfoWindowView(mSpeedView);
}
@@ -461,16 +415,18 @@ class BaseDrawer {
/**
* 使用系统时间或卫星时间计算出动画的运动时间最小值45防止两个点距离过近设置的最小动画执行时间
*
* @param lastSystemTime 上一个点系统时间,误差值
* @param curSystemTime 当前点系统时间,误差值
* @param lastSatelliteTime 上一个点SNTP时间精确值
* @param curSatelliteTime 当前点SNTP时间精确值
* @return 动画运动时间
*/
public long computeAnimDuration(long lastSystemTime, long curSystemTime, long lastSatelliteTime, long curSatelliteTime) {
long systemTimeInterval = curSystemTime - lastSystemTime;
long satelliteTimeInterval = curSatelliteTime - lastSatelliteTime;
long interval = systemTimeInterval < satelliteTimeInterval || satelliteTimeInterval == 0 ? systemTimeInterval : satelliteTimeInterval;
public long computeAnimDuration(long lastSatelliteTime, long curSatelliteTime) {
if (lastSatelliteTime == 0 || curSatelliteTime == 0) {
Log.d("ADAS动画数据", "卫星时间存在错误");
return 45;
}
long interval = curSatelliteTime - lastSatelliteTime;
Log.d("ADAS动画数据", "lastSatelliteTime : " + lastSatelliteTime +
" ---- curSatelliteTime : " + curSatelliteTime + " ===== 插值 " + interval);
if (interval < 45) {
interval = 45;
}

View File

@@ -1,6 +1,7 @@
package com.mogo.module.common.drawer;
import android.os.Build;
import android.os.Message;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
@@ -19,6 +20,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.drawer.bean.SpeedData;
import com.mogo.module.common.utils.Trigonometric;
import com.mogo.service.adas.IMogoADASController;
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
@@ -263,7 +265,7 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
while (iterator.hasNext()) {
SocketDownData.CloudRoadDataProto result = iterator.next();
long internal = result.getSatelliteTime() - Long.parseLong(adasControllerApi.getSatelliteTime());
if (internal > 300) {
if (internal > 3000) {
iterator.remove();
}
}
@@ -318,7 +320,7 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
mLastPositions.put(uniqueKey, cloudRoadData);
if (useCache) {
long interval = computeAnimDuration(lastPosition.getSystemTime(), cloudRoadData.getSystemTime(), lastPosition.getSatelliteTime(), cloudRoadData.getSatelliteTime());
long interval = computeAnimDuration(lastPosition.getSatelliteTime(), cloudRoadData.getSatelliteTime());
final MogoLatLng point = new MogoLatLng(cloudRoadData.getWgslat(), cloudRoadData.getWgslon());
long cost = System.currentTimeMillis() - start;
@@ -328,12 +330,19 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
marker.setRotateAngle(((float) cloudRoadData.getHeading()));
marker.setPosition(cloudRoadData.getWgslat(), cloudRoadData.getWgslon());
}
marker.setAnchorColor(getModelRenderColor(cloudRoadData.getType(), cloudRoadData.getFromType(), cloudRoadData.getSpeed(), cloudRoadData.getWgslon(), cloudRoadData.getWgslat(), cloudRoadData.getHeading()));
newSnapshotCaches.put(uniqueKey, marker);
marker.setAnchorColor(getModelRenderColor(cloudRoadData.getType(), cloudRoadData.getFromType(), cloudRoadData.getSpeed(), cloudRoadData.getWgslon(), cloudRoadData.getWgslat(), cloudRoadData.getHeading()));
if (shouldShowSpeed(cloudRoadData.getType())) {
showSelfSpeed(marker, cloudRoadData.getSpeed(), cloudRoadData.getUuid(), cloudRoadData.getType(), cloudRoadData.getHeading(), MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode());
Message msg = mRenderThreadHandler.obtainMessage();
msg.obj = new SpeedData(marker
, cloudRoadData.getSpeed()
, cloudRoadData.getUuid()
, cloudRoadData.getType()
, cloudRoadData.getHeading()
, MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode());
msg.what = MSG_DISPLAY_SPEED;
msg.sendToTarget();
}
}

View File

@@ -80,17 +80,15 @@ public class V2XWarnDataDrawer extends BaseDrawer implements IMogoStatusChangedL
*/
public void renderWarnData(V2XWarningEntity data) {
MarkerLocation location = new MarkerLocation();
location.setLat(data.getDirection() == 1 ? data.getStopLines().get(0).lat : data.getLat());
location.setLon(data.getDirection() == 1 ? data.getStopLines().get(0).lon : data.getLon());
location.setLat(data.getLat());
location.setLon(data.getLon());
MarkerShowEntity markerShowEntity = new MarkerShowEntity();
markerShowEntity.setMarkerLocation(location);
markerShowEntity.setMarkerType(TYPE_MARKER_CLOUD_WARN_DATA);
IMogoMarker marker = drawMarker(markerShowEntity, modeResType(data.getType()));
//识别物
marker.addDynamicAnchorPosition(new MogoLatLng(
data.getDirection() == 1 ? data.getStopLines().get(1).lat : data.getCollisionLat(),
data.getDirection() == 1 ? data.getStopLines().get(1).lon : data.getCollisionLon()), (float) data.getHeading(), 5000);
marker.addDynamicAnchorPosition(new MogoLatLng(data.getCollisionLat(), data.getCollisionLon()), (float) data.getHeading(), 5000);
//移动完成以后3s后消失
UiThreadHandler.postDelayed(() -> {
marker.remove();
@@ -98,19 +96,16 @@ public class V2XWarnDataDrawer extends BaseDrawer implements IMogoStatusChangedL
}
//根据识别物类型 (行人0/自行车1/摩托车2/小汽车3/公交车4)获取3D模型(对应查看getModelRes)
//根据识别物类型 (行人1/自行车2/摩托车4/骑行车辆11)获取3D模型(对应查看getModelRes)
private int modeResType(int dataType) {
switch (dataType) {
case 0:
return 1;
case 1:
return 2;
case 11:
return 1;
case 2:
return 4;
case 3:
return 3;
return 2;
case 4:
return 6;
return 4;
}
return 1;
}

View File

@@ -0,0 +1,73 @@
package com.mogo.module.common.drawer.bean;
import com.mogo.map.marker.IMogoMarker;
/**
* 速度显示对象
*/
public class SpeedData {
public IMogoMarker marker;
public double speed;
public String uuid;
public int type;
public double heading;
public boolean isVrMode;
public SpeedData(IMogoMarker marker, double speed, String uuid, int type, double heading, boolean isVrMode) {
this.marker = marker;
this.speed = speed;
this.uuid = uuid;
this.type = type;
this.heading = heading;
this.isVrMode = isVrMode;
}
public IMogoMarker getMarker() {
return marker;
}
public void setMarker(IMogoMarker marker) {
this.marker = marker;
}
public double getSpeed() {
return speed;
}
public void setSpeed(double speed) {
this.speed = speed;
}
public String getUuid() {
return uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public double getHeading() {
return heading;
}
public void setHeading(double heading) {
this.heading = heading;
}
public boolean getIsVrMode() {
return isVrMode;
}
public void setIsVrMode(boolean isVrMode) {
this.isVrMode = isVrMode;
}
}

View File

@@ -12,7 +12,7 @@ import java.util.List;
*/
public class V2XWarningEntity implements Serializable {
//事件类型 行人0/自行车1/摩托车2/小汽车3/公交车4
//事件类型 行人1/自行车2/摩托车4/骑行车辆11
private int type;
//目标物位置
private double lat;

Binary file not shown.

View File

@@ -3,8 +3,8 @@
<dimen name="dp_32">42px</dimen>
<dimen name="module_v2n_tip_width">628px</dimen>
<dimen name="module_v2n_tip_height">188px</dimen>
<dimen name="module_v2n_tip_text_width">106px</dimen>
<dimen name="module_v2n_tip_text_margin_right">52px</dimen>
<dimen name="module_v2n_tip_text_width">120px</dimen>
<dimen name="module_v2n_tip_text_margin_right">26px</dimen>
<dimen name="module_v2n_image_margin_left">37px</dimen>
<dimen name="module_v2x_brake_tip_width">435px</dimen>
<dimen name="module_v2x_brake_tip_height">186px</dimen>

View File

@@ -49,6 +49,7 @@ import com.mogo.map.uicontroller.EnumMapUI;
import com.mogo.map.uicontroller.IMogoMapUIController;
import com.mogo.map.uicontroller.VisualAngleMode;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.constants.DataTypes;
import com.mogo.module.common.dialog.WMDialog;
import com.mogo.module.common.glide.SkinAbleBitmapTarget;
import com.mogo.module.common.map.CustomNaviInterrupter;
@@ -963,7 +964,7 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
}
}
private int[] heights = new int[]{100, 200, 300};
private final int[] heights = new int[]{100, 200, 300};
private int currentHeight;
private void debugTopView() {
@@ -1363,7 +1364,7 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
.getMapUIController().changeMapVisualAngle(VisualAngleMode.MODE_MEDIUM_SIGHT, null);
mSwitchText.setText(R.string.module_map_model_normal);
} else if (MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapUIController().getCurrentMapVisualAngle().isMediumSight()) {
MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager(AbsMogoApplication.getApp()).inVisibleAllMarkers();
MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager(AbsMogoApplication.getApp()).inVisibleWithoutMarkers(DataTypes.TYPE_MARKER_ADAS);
MogoApisHandler.getInstance().getApis().getMapServiceApi()
.getMapUIController().changeMapVisualAngle(VisualAngleMode.MODE_LONG_SIGHT, null);
mSwitchText.setText(R.string.module_map_model_faster);

View File

@@ -341,7 +341,7 @@ public class MockIntentHandler implements IntentHandler {
MarkerServiceHandler.getApis().getRefreshStrategyControllerApi().restartAutoRefreshAtTime(duration);
IMogoMarker marker = MarkerServiceHandler.getMarkerManager().addMarker(TAG, options);
MarkerServiceHandler.getMogoStatusManager().setUserInteractionStatus(TAG, true, false);
if(!MarkerServiceHandler.getApis().getStatusManagerApi().isVrMode()){
if (!MarkerServiceHandler.getApis().getStatusManagerApi().isVrMode()) {
MarkerServiceHandler.getMapUIController().moveToCenter(mogoLatLngs.get(0));
}
WorkThreadHandler.getInstance().post(() -> marker.startSmooth(mogoLatLngs, duration));
@@ -652,7 +652,7 @@ public class MockIntentHandler implements IntentHandler {
String carsLine = roadSizeBr.readLine();
SocketDownData.LauncherSnapshotProto.Builder data = SocketDownData.LauncherSnapshotProto.newBuilder();
List<SocketDownData.CloudRoadDataProto> allList = GsonUtil.arrayFromJson(carsLine, SocketDownData.CloudRoadDataProto.class);
if(allList == null || allList.size() == 0){
if (allList == null || allList.size() == 0) {
return;
}
for (SocketDownData.CloudRoadDataProto cloudRoadData : allList) {
@@ -854,7 +854,7 @@ public class MockIntentHandler implements IntentHandler {
Log.i("mock-timer-loc-map", "cost " + (System.currentTimeMillis() - start) + "ms");
SnapshotLocationController.getInstance().syncAdasLocationInfo(jo);
Log.i("mock-timer-loc", "cost " + (System.currentTimeMillis() - start) + "ms");
Log.i("mock-timer-loc-info",jo.toString());
Log.i("mock-timer-loc-info", jo.toString());
return true;
}
@@ -917,10 +917,7 @@ public class MockIntentHandler implements IntentHandler {
}
}
AdasRec adasRec = new AdasRec();
adasRec.models = allList;
MogoApisHandler.getInstance().getApis().getAdasControllerApi().mockAdasRecognized(GsonUtil.jsonFromObject(adasRec));
MogoApisHandler.getInstance().getApis().getAdasControllerApi().mockAdasRecognized(allList);
Log.i("mock-timer-adas", "cost " + (System.currentTimeMillis() - start) + "ms");
return true;
}
@@ -947,16 +944,9 @@ public class MockIntentHandler implements IntentHandler {
}
}
AdasRec adasRec = new AdasRec();
adasRec.models = allList;
MogoApisHandler.getInstance().getApis().getAdasControllerApi().mockAdasRecognized(GsonUtil.jsonFromObject(adasRec));
MogoApisHandler.getInstance().getApis().getAdasControllerApi().mockAdasRecognized(allList);
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

@@ -1,46 +1,39 @@
package com.mogo.module.small.map;
import android.content.Context;
import android.graphics.Color;
import android.graphics.BitmapFactory;
import android.location.Location;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.animation.LinearInterpolator;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import androidx.annotation.Nullable;
import com.alibaba.android.arouter.thread.CancelableCountDownLatch;
import com.amap.api.maps.AMap;
import com.amap.api.maps.CameraUpdate;
import com.amap.api.maps.CameraUpdateFactory;
import com.amap.api.maps.TextureMapView;
import com.amap.api.maps.UiSettings;
import com.amap.api.maps.model.BitmapDescriptorFactory;
import com.amap.api.maps.model.CameraPosition;
import com.amap.api.maps.model.CustomMapStyleOptions;
import com.amap.api.maps.model.LatLng;
import com.amap.api.maps.model.LatLngBounds;
import com.amap.api.maps.model.Marker;
import com.amap.api.maps.model.MarkerOptions;
import com.amap.api.maps.model.Polyline;
import com.amap.api.maps.model.PolylineOptions;
import com.mogo.cloud.commons.utils.CoordinateUtils;
import com.amap.api.navi.AMapNavi;
import com.amap.api.navi.AMapNaviView;
import com.amap.api.navi.AMapNaviViewOptions;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.map.MogoLatLng;
import com.mogo.map.navi.IMogoCarLocationChangedListener2;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.view.RoundLayout;
import com.mogo.module.small.map.animation.DirectionRotateAnimation;
import com.mogo.module.small.map.utils.MapAssetStyleUtils;
import com.mogo.module.small.map.view.ISmallMapDirectionView;
import com.mogo.utils.logger.Logger;
import java.util.ArrayList;
import java.util.List;
import ch.hsr.geohash.GeoHash;
/**
* 小地图的方向View
*
@@ -55,17 +48,14 @@ public class SmallMapDirectionView
public static final String MODULE_NAME = "SmallMap";
private RoundLayout rlSmallMapBorder;
private TextureMapView mAMapNaviView;
private AMap mAMap;
private Marker mCarMarker;
private Marker mStartMarker;
private Marker mEndMarker;
private ImageView mIvMapBorder;
private DirectionRotateAnimation mRotateAnimation;
private int lastAngle = 0;
private int zoomLevel = 13;
private List<LatLng> mCoordinatesLatLng = new ArrayList<>();
private List<MogoLatLng> mCoordinatesLatLngCurrent = new ArrayList<>();
private Polyline mPolyline;
private CameraUpdate mCameraUpdate;
private AMapNaviView mAMapNaviView;
private AMap mAMap;
private AMapNavi mAMapNavi;
private int zoomLevel = 15;
public SmallMapDirectionView(Context context) {
this(context, null);
@@ -85,11 +75,15 @@ public class SmallMapDirectionView
}
private void initView(Context context) {
mRotateAnimation = new DirectionRotateAnimation(context, null);
LayoutInflater.from(context).inflate(R.layout.module_small_map_view, this);
mAMapNaviView = AbsMogoApplication.getMapNaviView();
rlSmallMapBorder = findViewById(R.id.rlSmallMapBorder);
rlSmallMapBorder.addView(mAMapNaviView);
mIvMapBorder = findViewById(R.id.ivMapBorder);
initAMapView();
@@ -122,7 +116,10 @@ public class SmallMapDirectionView
}
private void initAMapView() {
mCameraUpdate = CameraUpdateFactory.zoomTo(zoomLevel);
// 车头朝上
mAMapNaviView.setNaviMode(AMapNaviView.CAR_UP_MODE);
// 设置电子眼所在路线的可见性
mAMapNaviView.setRouteOverlayVisible(false);
mAMap = mAMapNaviView.getMap();
// 关闭地图文字标注
mAMap.showMapText(false);
@@ -130,15 +127,26 @@ public class SmallMapDirectionView
mAMap.setMapType(AMap.MAP_TYPE_NIGHT);
// 关闭显示实时路况图层aMap是地图控制器对象。
mAMap.setTrafficEnabled(false);
mAMap.setOnCameraChangeListener(new AMap.OnCameraChangeListener() {
@Override
public void onCameraChange(CameraPosition cameraPosition) {
if (cameraPosition != null) {
//Log.w("onCameraChange", "cameraPosition=" + cameraPosition.bearing);
changeAngle((int) cameraPosition.bearing);
}
}
@Override
public void onCameraChangeFinish(CameraPosition cameraPosition) {
}
});
mAMapNavi = AMapNavi.getInstance(getContext());
//使用外部GPS数据
mAMapNavi.setIsUseExtraGPSData(true);
// 设置 锚点 图标
mCarMarker = mAMap.addMarker(new MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.module_small_map_view_my_location_logo))
.anchor(0.5f, 0.5f));
mStartMarker = mAMap.addMarker(new MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.module_small_map_view_dir_start)));
mEndMarker = mAMap.addMarker(new MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.module_small_map_view_dir_end)));
new Thread(() -> {
try {
@@ -154,7 +162,8 @@ public class SmallMapDirectionView
);
//设置希望展示的地图缩放级别
mAMap.moveCamera(mCameraUpdate);
CameraUpdate cameraUpdate = CameraUpdateFactory.zoomTo(zoomLevel);
mAMap.moveCamera(cameraUpdate);
}).start();
// 设置地图的样式
@@ -164,6 +173,70 @@ public class SmallMapDirectionView
uiSettings.setMyLocationButtonEnabled(false); // 显示默认的定位按钮
uiSettings.setLogoBottomMargin(-150); //设置Logo下边界距离屏幕底部的边距,设置为负值即可
// 导航地图
AMapNaviViewOptions options = mAMapNaviView.getViewOptions();
//设置导航界面UI是否显示。
if (options != null) {
// 设置是否开启自动黑夜模式切换默认为false不自动切换
options.setAutoNaviViewNightMode(false);
// 设置6秒后是否自动锁车
options.setAutoLockCar(true);
// 设置路线上的摄像头气泡是否显示
options.setCameraBubbleShow(false);
// 设置路线相关的配置属性,如:路线的路况颜色,路线上是否显示摄像头气泡等。
// options.setRouteOverlayOptions( MapStyleUtils.getRouteOverlayOptions() );
// 设置自车的图片对象
options.setCarBitmap(BitmapFactory.decodeResource(getContext().getResources(),
R.drawable.module_small_map_view_my_location_logo));
// 设置罗盘位图对象
options.setFourCornersBitmap(BitmapFactory.decodeResource(getContext().getResources(),
R.drawable.icon_module_small_map_four_corners));
// 设置指南针图标否在导航界面显示默认显示。true显示false隐藏。
options.setCompassEnabled(false);
//设置路况光柱条是否显示(只适用于驾车导航,需要联网)。
options.setTrafficBarEnabled(false);
// 设置[实时交通图层开关按钮]是否显示(只适用于驾车导航,需要联网)。
options.setTrafficLayerEnabled(false);
// 设置导航界面是否显示路线全览按钮。
options.setRouteListButtonShow(false);
// 设置屏幕是否常亮,默认开启
options.setScreenAlwaysBright(false);
// 设置交通播报是否打开(只适用于驾车导航,需要联网)。
options.setTrafficInfoUpdateEnabled(false);
// 设置摄像头播报是否打开(只适用于驾车导航)。
options.setCameraInfoUpdateEnabled(false);
// 设置菜单按钮是否在导航界面显示。
options.setSettingMenuEnabled(false);
// 设置是否绘制显示交通路况的线路(彩虹线),拥堵-红色,畅通-绿色,缓慢-黄色,未知-蓝色。默认不绘制彩虹线。
options.setTrafficLine(false);
// 设置是否绘制牵引线(当前位置到目的地的指引线)。默认不绘制牵引线。
options.setLeaderLineEnabled(-1);
// 设置导航界面UI是否显示。
options.setLayoutVisible(false);
// 设置是否自动画路
options.setAutoDrawRoute(false);
// 设置是否显示路口放大图(实景图)
options.setRealCrossDisplayShow(false);
// 设置是否显示路口放大图(路口模型图)
options.setModeCrossDisplayShow(false);
// 设置是否显示道路信息view
options.setLaneInfoShow(false);
// 设置是否自动改变缩放等级
options.setAutoChangeZoom(false);
// 设置是否自动全览模式,即在算路成功后自动进入全览模式
options.setAutoDisplayOverview(false);
// 设置路线转向箭头隐藏和显示
options.setNaviArrowVisible(false);
// 通过路线是否自动置灰,仅支持驾车导航
options.setAfterRouteAutoGray(false);
options.setZoom(((int) 10));
//options.setPointToCenter(0.7D, 0.5D);
// 2D模式
options.setTilt(0);
// 黑夜模式
options.setNaviNight(true);
mAMapNaviView.setViewOptions(options);
}
}
@@ -175,44 +248,8 @@ public class SmallMapDirectionView
@Override
public void onCarLocationChanged2(Location latLng) {
Logger.d(MODULE_NAME, "onCarLocationChanged2 latLng:" + latLng);
LatLng currentLatLng = new LatLng(latLng.getLatitude(), latLng.getLongitude());
if (mCarMarker != null) {
mCarMarker.setRotateAngle(360 - latLng.getBearing());
mCarMarker.setPosition(currentLatLng);
mCarMarker.setToTop();
}
if (mCoordinatesLatLng.size() > 1) {
mCoordinatesLatLngCurrent.clear();
for (LatLng lng : mCoordinatesLatLng) {
MogoLatLng mogoLatLng = new MogoLatLng(lng.latitude, lng.longitude);
mCoordinatesLatLngCurrent.add(mogoLatLng);
}
// 结束位置
LatLng endLatLng = mCoordinatesLatLng.get(mCoordinatesLatLng.size() - 1);
// 与结束位置进行 GeoHash 0-12
// GeoHash endGeoHash = GeoHash.withCharacterPrecision(endLatLng.latitude, endLatLng.longitude, 7);
// GeoHash currentGeoHash = GeoHash.withCharacterPrecision(currentLatLng.latitude, currentLatLng.longitude, 7);
// Log.d(MODULE_NAME, "currentGeoHash=" + currentGeoHash);
// Log.d(MODULE_NAME, "endGeoHash=" + endGeoHash);
float calculateDistance = CoordinateUtils.calculateLineDistance(
endLatLng.latitude, endLatLng.longitude,
currentLatLng.latitude, currentLatLng.longitude
);
Log.d(MODULE_NAME, "calculateDistance=" + calculateDistance);
if (calculateDistance <= 20) {
clearPolyline();
} else {
drawablePolyline(mCoordinatesLatLngCurrent);
}
} else {
//设置希望展示的地图缩放级别
mAMap.moveCamera(CameraUpdateFactory.newLatLngZoom(currentLatLng, zoomLevel));
if (mAMapNavi != null) {
mAMapNavi.setExtraGPSData(2, latLng);
}
}
@@ -223,57 +260,39 @@ public class SmallMapDirectionView
@Override
public void drawablePolyline(List<MogoLatLng> coordinates) {
clearPolyline();
mCoordinatesLatLng.clear();
for (MogoLatLng coordinate : coordinates) {
mCoordinatesLatLng.add(new LatLng(coordinate.getLat(), coordinate.getLon()));
}
if (mAMap != null) {
if (mCoordinatesLatLng.size() > 2) {
// 设置开始结束Marker位置
mStartMarker.setPosition(mCoordinatesLatLng.get(0));
mEndMarker.setPosition(mCoordinatesLatLng.get(mCoordinatesLatLng.size() - 1));
mStartMarker.setVisible(true);
mEndMarker.setVisible(true);
//存放所有点的经纬度
LatLngBounds.Builder boundsBuilder = new LatLngBounds.Builder();
for (int i = 0; i < mCoordinatesLatLng.size(); i++) {
//把所有点都include进去LatLng类型
boundsBuilder.include(mCoordinatesLatLng.get(i));
}
//第二个参数为四周留空宽度
mAMap.animateCamera(CameraUpdateFactory.newLatLngBoundsRect(boundsBuilder.build(), 65, 65, 65, 65));
// 绘制线
mPolyline = mAMap.addPolyline(
new PolylineOptions()
.addAll(mCoordinatesLatLng)
.color(Color.argb(255, 31, 127, 255))
.width(5));
} else {
//设置希望展示的地图缩放级别
mAMap.moveCamera(CameraUpdateFactory.newLatLngZoom(mCoordinatesLatLng.get(0), zoomLevel));
}
}
}
@Override
public void clearPolyline() {
mCoordinatesLatLng.clear();
if (mPolyline != null) {
mPolyline.remove();
}
if (mStartMarker != null) {
mStartMarker.setVisible(false);
}
if (mEndMarker != null) {
mEndMarker.setVisible(false);
}
}
/**
* 修改角度
*
* @param angle 角度 0 - 359度旋转,相对于自身中心位置
*/
public void changeAngle(int angle) {
int tempAngle = 360 - angle;
// if (tempAngle <= 180) {
// tempAngle = tempAngle;
// } else {
// tempAngle = -(360 - tempAngle);
// }
mRotateAnimation.setFromDegrees(lastAngle);
mRotateAnimation.setToDegrees(tempAngle);
//设置线性插值,可以解决旋转一圈后卡顿问题
mRotateAnimation.setInterpolator(new LinearInterpolator());
//设置旋转一圈时间
mRotateAnimation.setDuration(300);
//控件动画结束时是否保持动画最后的状态
mRotateAnimation.setFillAfter(true);
mIvMapBorder.startAnimation(mRotateAnimation);
// 刷新最后一次角度
lastAngle = tempAngle;
}
}

View File

@@ -10,7 +10,7 @@
android:layout_width="@dimen/module_small_map_view_border_width"
android:layout_height="@dimen/module_small_map_view_border_width"
android:layout_centerInParent="true"
android:background="@drawable/module_small_map_view_border_north" />
android:background="@drawable/module_small_map_view_border" />
<com.mogo.module.common.view.RoundLayout
android:id="@+id/rlSmallMapBorder"
@@ -30,4 +30,11 @@
android:layout_height="match_parent" />-->
</com.mogo.module.common.view.RoundLayout>
<ImageView
android:id="@+id/ivMapBorder"
android:layout_width="@dimen/module_small_map_border_view_width"
android:layout_height="@dimen/module_small_map_border_view_width"
android:layout_centerInParent="true"
android:src="@drawable/module_small_map_view_border_north" />
</merge>

View File

@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="module_small_map_padding">40px</dimen>
<dimen name="module_small_map_view_border_width">550px</dimen>
<dimen name="module_small_map_view_border_width">400px</dimen>
<dimen name="module_small_map_border_view_width">550px</dimen>
<dimen name="module_small_map_view_width">360px</dimen>
</resources>

View File

@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="module_small_map_padding">30px</dimen>
<dimen name="module_small_map_view_border_width">450px</dimen>
<dimen name="module_small_map_view_border_width">288px</dimen>
<dimen name="module_small_map_border_view_width">450px</dimen>
<dimen name="module_small_map_view_width">260px</dimen>
</resources>

View File

@@ -11,7 +11,6 @@ import com.mogo.map.uicontroller.IMogoMapUIController;
import com.mogo.module.v2x.alarm.V2XCalculateServer;
import com.mogo.module.v2x.manager.IMoGoPersonWarnPolylineManager;
import com.mogo.module.v2x.manager.IMoGoStopPolylineManager;
import com.mogo.module.v2x.manager.IMoGoV2XCloundDataManager;
import com.mogo.module.v2x.manager.IMoGoV2XMarkerManager;
import com.mogo.module.v2x.manager.IMoGoV2XPolylineManager;
import com.mogo.module.v2x.manager.IMoGoV2XStatusManager;
@@ -45,9 +44,6 @@ import com.mogo.service.windowview.IMogoWindowManager;
import com.zhidao.carchattingprovider.CallChattingProviderConstant;
import com.zhidao.carchattingprovider.ICarsChattingProvider;
import java.util.ArrayList;
import java.util.List;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
@@ -109,7 +105,6 @@ public class V2XServiceManager {
private static IMoGoWarnPolylineManager moGoWarnPolylineManager;
private static IMoGoPersonWarnPolylineManager moGoPersonWarnPolylineManager;
private static IMoGoStopPolylineManager moGoStopPolylineManager;
private static IMoGoV2XCloundDataManager moGoV2XCloundDataManager;
private V2XServiceManager() {
@@ -165,7 +160,6 @@ public class V2XServiceManager {
moGoV2XMarkerManager = (IMoGoV2XMarkerManager) ARouter.getInstance().build(MoGoV2XServicePaths.PATH_V2X_MARKER_MANAGER).navigation(context);
moGoV2XPolylineManager = (IMoGoV2XPolylineManager) ARouter.getInstance().build(MoGoV2XServicePaths.PATH_V2X_POLYLINE_MANAGER).navigation(context);
moGoWarnPolylineManager = (IMoGoWarnPolylineManager) ARouter.getInstance().build(MoGoV2XServicePaths.PATH_V2X_WARN_POLYLINE_MANAGER).navigation(context);
moGoV2XCloundDataManager = (IMoGoV2XCloundDataManager) ARouter.getInstance().build(MoGoV2XServicePaths.PATH_V2X_WARN_CLOUND_DATA_MANAGER).navigation(context);
moGoPersonWarnPolylineManager = (IMoGoPersonWarnPolylineManager) ARouter.getInstance().build(MoGoV2XServicePaths.PATH_V2X_PERSON_WARN_POLYLINE_MANAGER).navigation(context);
moGoStopPolylineManager = (IMoGoStopPolylineManager) ARouter.getInstance().build(MoGoV2XServicePaths.PATH_V2X_STOP_POLYLINE_MANAGER).navigation(context);
@@ -337,14 +331,6 @@ public class V2XServiceManager {
V2XServiceManager.mIMogoADASController = mIMogoADASController;
}
public static IMoGoV2XCloundDataManager getMoGoV2XCloundDataManager() {
return moGoV2XCloundDataManager;
}
public static void setMoGoV2XCloundDataManager(IMoGoV2XCloundDataManager moGoV2XCloundDataManager) {
V2XServiceManager.moGoV2XCloundDataManager = moGoV2XCloundDataManager;
}
public static IMoGoPersonWarnPolylineManager getMoGoPersonWarnPolylineManager() {
return moGoPersonWarnPolylineManager;
}

View File

@@ -1,21 +0,0 @@
package com.mogo.module.v2x.listener;
import com.mogo.module.common.entity.V2XWarningEntity;
import com.mogo.service.connection.IMogoOnMessageListener;
/**
* @author liujing
* @description 车路云—场景预警-云下发数据监听 前车/行人/摩托车/盲区碰撞预警
* @since: 2021/3/31
*/
public class V2XMessageListener_401013 implements IMogoOnMessageListener<V2XWarningEntity> {
@Override
public Class target() {
return null;
}
@Override
public void onMsgReceived(V2XWarningEntity obj) {
}
}

View File

@@ -1,21 +0,0 @@
package com.mogo.module.v2x.manager;
import com.alibaba.android.arouter.facade.template.IProvider;
import com.mogo.module.common.entity.V2XWarningEntity;
/**
* desc: V2X 处理云端预警消息
*/
public interface IMoGoV2XCloundDataManager extends IProvider {
/**
* 处理下发数据
*/
void analysisV2XCloundDataEvent(V2XWarningEntity cloundWarningInfo);
/**
* 清除 所有的 POI
*/
void clearALLPOI();
}

View File

@@ -1,367 +0,0 @@
package com.mogo.module.v2x.manager.impl;
import android.content.Context;
import android.location.Location;
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.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.V2XWarningEntity;
import com.mogo.module.common.utils.Trigonometric;
import com.mogo.module.service.MarkerServiceHandler;
import com.mogo.module.service.receiver.MogoReceiver;
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;
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.common.entity.V2XMessageEntity.V2XTypeEnum.ALERT_THE_FRONT_CRASH_WARNING_TOP;
import static com.mogo.module.v2x.V2XServiceManager.getContext;
/**
* desc : V2X 服务端下发数据处理 点的绘制
*/
@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 = true;//绘制线是否已被清除
private List fillPoints = new ArrayList();//停止线经纬度合集
private boolean isFirstLocation = false;
private MogoLatLng carLocation = new MogoLatLng(
MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLat(),
MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLon()
);
/*
* 自车前方的点,在停止线上--通过自车位置与距离停止线之间的距离计算
* */
private MogoLatLng middleLocationInStopLine;
private V2XFrontWarningScenario mV2XScenario;
private static long showTime = 4000;
private float bearing;
@Override
public void init(Context context) {
MogoApisHandler.getInstance().getApis().getRegisterCenterApi()
.registerCarLocationChangedListener(TAG, this);
}
@Override
public void analysisV2XCloundDataEvent(V2XWarningEntity cloundWarningInfo) {
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
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.getDirection(), MogoReceiver.ACTION_V2X_FRONT_WARNING);
isSelfLineClear = false;
isFirstLocation = false;
V2XServiceManager.getMarkerManager().removeMarkers(WARNING_ARROWS);
if (cloundWarningInfo.getDirection() == ALERT_THE_FRONT_CRASH_WARNING_TOP) { //前方 TODO
middleLocationInStopLine = getMiddleLocationInStopLine();
//如果是正前方类型,红色绘制区域从停止线向前绘制50米
MogoLatLng warningLocation = Trigonometric.getNewLocation(middleLocationInStopLine, 50, cloundWarningInfo.getAngle());
//停止线前方画线
WorkThreadHandler.getInstance().postDelayed(() -> {
//二轮车和行人的渲染和移动
V2XServiceManager.getMarkerManager().removeMarkers(TYPE_MARKER_CLOUD_WARN_DATA);
V2XWarnDataDrawer.getInstance().renderWarnData(cloundWarningInfo);
//绘制识别物与交汇点连线,并且更新连线数据
drawRedWarningLineFrontOfStopLine(cloundWarningInfo, middleLocationInStopLine, warningLocation);
//添加停止线marker
handleStopLine();
//自车画线
drawSelfCarLine(carLocation.lon, carLocation.lat, bearing);
}, 500);
UiThreadHandler.postDelayed(() -> {
V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine();
V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
V2XServiceManager.getMoGoStopPolylineManager().clearLine();
isSelfLineClear = true;
}, showTime);
} else { //左侧或者右侧
WorkThreadHandler.getInstance().postDelayed(() -> {
//绘制识别物与交汇点连线,并且更新连线数据
drawOtherObjectLine(cloundWarningInfo);
//二轮车和行人的渲染和移动
V2XServiceManager.getMarkerManager().removeMarkers(TYPE_MARKER_CLOUD_WARN_DATA);
V2XWarnDataDrawer.getInstance().renderWarnData(cloundWarningInfo);
//车辆静止的时候
drawSelfCarLine(carLocation.lon, carLocation.lat, bearing);
}, 500);
//延迟3秒清理线
UiThreadHandler.postDelayed(() -> {
V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine();
V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
isSelfLineClear = true;
}, showTime);
}
}
}
/**
* 自车为起点绘制(根据设计,前方行人/弱势交通参与者预警 getDirection() == ALERT_THE_FRONT_CRASH_WARNING_TOP自车与停止线之间为蓝色预警;其他侧方预警自车与预碰撞点之间显示红色预警)
*/
private void drawSelfCarLine(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) {
carLocation = getMogoLat(new MogoLatLng(lat, lon));
isFirstLocation = true;
}
//绘制线的终点(在停止线上或者预碰撞点上)
endLatlng = new MogoLatLng(mCloundWarningInfo.getDirection() == ALERT_THE_FRONT_CRASH_WARNING_TOP ? middleLocationInStopLine.lat : mCloundWarningInfo.getCollisionLat(),
mCloundWarningInfo.getDirection() == ALERT_THE_FRONT_CRASH_WARNING_TOP ? 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.lon + "," + startLatlng.lat +
"中间扩展点" + addMiddleLoc.lon + "," + addMiddleLoc.lat + "终点:" + endLatlng.lon + "," + endLatlng.lat);
if (mogoPolyline != null) {
mogoPolyline.setPoints(Arrays.asList(startLatlng, addMiddleLoc, endLatlng));
mogoPolyline.setTransparency(0.5f);
} else {
DrawLineInfo info = new DrawLineInfo(); // 对象
Log.d(TAG, "安全区域的画线点为" + "起点:" + startLatlng + "中间点:" + addMiddleLoc + "终点:" + endLatlng);
List locations = new ArrayList();
locations.add(startLatlng);
locations.add(addMiddleLoc);
locations.add(endLatlng);
info.setLocations(locations);
info.setHeading(bearing);
info.setWidth(mCloundWarningInfo.getRoadwidth() * 14 + 5);
info.setDirection(mCloundWarningInfo.getDirection());
V2XServiceManager.getMoGoWarnPolylineManager().drawWarnPolyline(getContext(), info);
}
} else {
V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
}
}
}
/*
* 停止线绘制
* */
private void handleStopLine() {
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.heading = mCloundWarningInfo.heading;
V2XWarnDataDrawer.getInstance().renderStopLineData(entity);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 场景如:车辆行驶正前方绘制红色区域(停止线继续前行的预警区域) TODO 需要实时给行人当前位置
*/
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(TAG, "红色区域起始点 = " + startLatLng.lon + "," + startLatLng.lat +
"中间点坐标:" + addMiddleLoc.lon + "," + addMiddleLoc.lat
+ "终点" + endLatlng.lon + "," + endLatlng.lat);
if (polyLine != null) {
Log.d(V2XConst.LOG_NAME_WARN, "drawStopLine polyLine != null");
polyLine.setPoints(Arrays.asList(startLatLng, addMiddleLoc, endLatlng));
polyLine.setTransparency(0.5f);
} else {
DrawLineInfo lineInfo = new DrawLineInfo();
List locations = new ArrayList();
locations.add(startLatLng);
locations.add(addMiddleLoc);
locations.add(endLatlng);
lineInfo.setLocations(locations);
lineInfo.setHeading(info.heading);
Log.d(V2XConst.LOG_NAME_WARN, "drawStopLine width = " + info.getRoadwidth());
lineInfo.setWidth(info.getRoadwidth() * 14 + 5);
V2XServiceManager.getMoGoStopPolylineManager().drawStopPolyline(getContext(), lineInfo);
}
} else {
V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine();
V2XServiceManager.getMoGoStopPolylineManager().clearLine();
}
}
/**
* 侧方目标物与预碰撞点连线,并且更新数据 TODO 需要实时给行人当前位置
*/
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,
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));
polyLine.setTransparency(0.5f);
} else {
DrawLineInfo lineInfo = new DrawLineInfo();
Log.d(TAG, "目标物与预碰撞点画线点为" + "起点:" + startLatlng + "中间点:" + addMiddleLoc + "终点:" + endLatlng);
List locations = new ArrayList();
locations.add(startLatlng);
locations.add(addMiddleLoc);
locations.add(endLatlng);
lineInfo.setLocations(locations);
lineInfo.setHeading(info.heading);
Log.d(V2XConst.LOG_NAME_WARN, "drawOtherObjectLine width = " + info.getRoadwidth());
lineInfo.setWidth(info.getRoadwidth() * 14 + 5);
V2XServiceManager.getMoGoPersonWarnPolylineManager().drawPersonWarnPolyline(getContext(), lineInfo);
//识别物到预碰撞点之间的箭头
addArrows(startLatlng, endLatlng);
}
} else {
Log.e(V2XConst.LOG_NAME_WARN, "info == null");
V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine();
}
}
//侧面目标物与碰撞点之间添加多个小箭头
private void addArrows(MogoLatLng startLatLng, MogoLatLng endLatLng) {
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 + 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
public void clearALLPOI() {
}
/**
* 自车定位 移动完成需要 3s消失,这里何时清理,应该是没有数据的时候
* 地图侧回调回的定位Location为高德坐标
*/
@Override
public void onCarLocationChanged2(Location latLng) {
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() && isSelfLineClear == false) {
//当行人经纬度交点 开始画线,否则清理
if (mCloundWarningInfo != null) {
mCloundWarningInfo.setCarLocation(new MogoLatLng(latLng.getLatitude(), latLng.getLongitude()));
}
drawSelfCarLine(latLng.getLongitude(), latLng.getLatitude(), latLng.getBearing());
}
carLocation = new MogoLatLng(latLng.getLatitude(), latLng.getLongitude());
Log.d("车行驶的轨迹---", String.valueOf(latLng.getLongitude()) + "," + String.valueOf(latLng.getLatitude()));
}
@Override
public void onCarLocationChanged(MogoLatLng latLng) {
}
/**
* 补点后的停止线经纬度合集
*/
public void pointsBetween() {
try {
fillPoints.clear();
List stopLines = mCloundWarningInfo.getStopLines();
if (stopLines.size() > 1) {
MogoLatLng x = mCloundWarningInfo.getStopLines().get(0);
MogoLatLng y = mCloundWarningInfo.getStopLines().get(1);
//两点间的距离
float distance = CoordinateUtils.calculateLineDistance(x.lon, x.lat, y.lon, y.lat);
float average = distance / 3;
//两点间的角度
double angle = Trigonometric.getAngle(x.lon, x.lat, y.lon, y.lat);
//根据距离和角度获取下个点的经纬度
fillPoints.add(x);
for (int i = 1; i < 3; i++) {
MogoLatLng newLocation = Trigonometric.getNewLocation(x, average * i, angle);
fillPoints.add(newLocation);
}
fillPoints.add(y);
}
} catch (Exception e) {
e.printStackTrace();
}
}
private MogoLatLng getMogoLat(MogoLatLng latlng) {
MogoLatLng newLocation = Trigonometric.getNewLocation(latlng, mCloundWarningInfo.getStopLineDistance(), mCloundWarningInfo.getAngle());
return newLocation;
}
/*
* 自车前方的点,在停止线上--通过自车位置与距离停止线之间的距离计算
* */
private MogoLatLng getMiddleLocationInStopLine() {
MogoLatLng newLocation = Trigonometric.getNewLocation(carLocation, mCloundWarningInfo.getStopLineDistance(), mCloundWarningInfo.getAngle());
return newLocation;
}
}

View File

@@ -58,7 +58,7 @@ public class V2XWarningMarker implements IV2XMarker {
/*
* 自车前方的点,在停止线上--通过自车位置与距离停止线之间的距离计算
* */
private MogoLatLng middleLocationInStopLine;
private MogoLatLng middleLocationInStopLine = new MogoLatLng(0,0);
private static long showTime = 5000;
private float bearing;
@@ -75,8 +75,8 @@ public class V2XWarningMarker implements IV2XMarker {
}
public void drawLineWithEntity() {
showTime = mCloundWarningInfo.getShowTime() > 0 ? mCloundWarningInfo.getShowTime() : 5000;
Log.d(TAG, "显示时间为++" + String.valueOf(showTime));
showTime = mCloundWarningInfo.getShowTime() > 0 ? mCloundWarningInfo.getShowTime()*1000 : 5000;
Log.d(TAG, "显示时间为++" + String.valueOf(showTime)+"识别物类型:"+String.valueOf(mCloundWarningInfo.getType()));
pointsBetween();
bearing = V2XLocationListener.getInstance().getLastCarLocation().getBearing();
isSelfLineClear = false;
@@ -95,8 +95,12 @@ public class V2XWarningMarker implements IV2XMarker {
drawRedWarningLineFrontOfStopLine(mCloundWarningInfo, middleLocationInStopLine, warningLocation);
//添加停止线marker
handleStopLine();
//自车画线
drawSelfCarLine(carLocation.lon, carLocation.lat, bearing);
if (carLocation.lat != 0 && carLocation.lon != 0){
//自车画线
drawSelfCarLine(carLocation.lon, carLocation.lat, bearing);
}else {
Log.d(TAG,"自车定位数据为空carLocation == null");
}
}, 0);
UiThreadHandler.postDelayed(() -> {
@@ -114,7 +118,11 @@ public class V2XWarningMarker implements IV2XMarker {
V2XServiceManager.getMarkerManager().removeMarkers(TYPE_MARKER_CLOUD_WARN_DATA);
V2XWarnDataDrawer.getInstance().renderWarnData(mCloundWarningInfo);
//车辆静止的时候
drawSelfCarLine(carLocation.lon, carLocation.lat, bearing);
if (carLocation.lat != 0 && carLocation.lon != 0){
drawSelfCarLine(carLocation.lon, carLocation.lat, bearing);
}else {
Log.d(TAG,"数据为空carLocation == null");
}
}, 0);
@@ -242,16 +250,15 @@ public class V2XWarningMarker implements IV2XMarker {
if (!isSelfLineClear) {
IMogoPolyline mogoPolyline = V2XServiceManager.getMoGoWarnPolylineManager().getMogoWarnPolyline();
if (mCloundWarningInfo != null) {
MogoLatLng startLatlng = null;
MogoLatLng endLatlng = null;
MogoLatLng addMiddleLoc = null;
MogoLatLng startLatlng = new MogoLatLng(0,0);
MogoLatLng endLatlng = new MogoLatLng(0,0);
MogoLatLng addMiddleLoc = new MogoLatLng(0,0);
if (!isFirstLocation) {
carLocation = getMogoLat(new MogoLatLng(lat, lon));
isFirstLocation = true;
}
//绘制线的终点(在停止线上或者预碰撞点上)
endLatlng = new MogoLatLng(mCloundWarningInfo.getDirection() == ALERT_THE_FRONT_CRASH_WARNING_TOP ? middleLocationInStopLine.lat : mCloundWarningInfo.getCollisionLat(),
mCloundWarningInfo.getDirection() == ALERT_THE_FRONT_CRASH_WARNING_TOP ? middleLocationInStopLine.lon : mCloundWarningInfo.getCollisionLon());
//自车位置

View File

@@ -11,7 +11,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/module_v2n_image_margin_left"
android:layout_marginTop="@dimen/dp_20"
android:layout_centerVertical="true"
android:src="@drawable/v2x_road_front_car_warning" />
<TextView
@@ -22,7 +22,7 @@
android:layout_centerVertical="true"
android:layout_marginRight="@dimen/dp_28"
android:maxWidth="@dimen/module_v2n_tip_text_width"
android:text="1.2米"
android:text="112米"
android:textColor="@color/v2x_FF3036"
android:textSize="@dimen/dp_32" />
@@ -32,7 +32,7 @@
android:layout_height="wrap_content"
android:layout_alignEnd="@+id/warning_distance"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/dp_20"
android:layout_marginLeft="@dimen/dp_30"
android:layout_marginRight="@dimen/module_v2n_tip_text_margin_right"
android:layout_toRightOf="@+id/warning_type_image"
android:text="前车碰撞预警"

View File

@@ -108,13 +108,6 @@ public interface IMogoADASController extends IProvider {
*/
void removeAdasWarnMessageCallback(IMogoAdasWarnMessageCallback callback);
/**
* 获取 adas 识别列表
*
* @return
*/
List<ADASRecognizedResult> getLastADASRecognizedResult();
/**
* 添加adas识别物体回调
*
@@ -213,5 +206,4 @@ public interface IMogoADASController extends IProvider {
void mockAdasRecognized(List<ADASRecognizedResult> recognizedResults);
void mockAdasRecognized(String json);
}

View File

@@ -1,16 +1,19 @@
package com.mogo.service.impl.adas;
import android.util.Log;
import com.alibaba.android.arouter.launcher.ARouter;
import com.mogo.commons.utils.MortonCode;
import com.mogo.map.uicontroller.IMogoMapUIController;
import com.mogo.service.IMogoServiceApis;
import com.mogo.service.adas.entity.ADASRecognizedResult;
import com.mogo.service.adas.entity.ADASWarnMessage;
import com.zhidao.autopilotservice.model.AdasAIDLOwnerCarRectModel;
import com.zhidao.support.adas.high.bean.RectInfo;
import com.zhidao.support.adas.high.bean.WarnMessageInfo;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
/*
@@ -37,12 +40,12 @@ public class AdasObjectUtils {
return warnMessage;
}
public static List<ADASRecognizedResult> regroupData(List<AdasAIDLOwnerCarRectModel> datums) {
public static List<ADASRecognizedResult> regroupData(List<RectInfo.RectBean> datums) {
if (datums == null || datums.isEmpty()) {
return null;
}
List<ADASRecognizedResult> recognizedListResults = new ArrayList<>();
for (AdasAIDLOwnerCarRectModel model : datums) {
for (RectInfo.RectBean model : datums) {
if (model == null) {
continue;
}
@@ -54,10 +57,11 @@ public class AdasObjectUtils {
return recognizedListResults;
}
public static ADASRecognizedResult fromAdasObject(AdasAIDLOwnerCarRectModel model) {
public static ADASRecognizedResult fromAdasObject(RectInfo.RectBean model) {
if (model == null) {
return null;
}
long start = System.nanoTime();
ADASRecognizedResult result = new ADASRecognizedResult();
result.uuid = model.getUuid();
result.lat = model.getLat();
@@ -73,11 +77,14 @@ public class AdasObjectUtils {
result.dataAccuracy = model.dataAccuracy;
result.distance = model.distance;
result.drawlevel = model.getDrawlevel();
result.mortonCode = MortonCode.wrapEncodeMorton(result.lon, result.lat);
IMogoMapUIController mogoMapUIController = ARouter.getInstance().navigation(IMogoServiceApis.class).getMapServiceApi().getMapUIController();
if (mogoMapUIController != null) {
result.tileId = String.valueOf(mogoMapUIController.getTileId(result.lon, result.lat));
}
// result.mortonCode = MortonCode.wrapEncodeMorton(result.lon, result.lat);
Log.d("ADAS数据延时","fromAdasObject cost : " + TimeUnit.NANOSECONDS.toMillis((System.nanoTime() - start)));
// IMogoMapUIController mogoMapUIController = ARouter.getInstance().navigation(IMogoServiceApis.class).getMapServiceApi().getMapUIController();
// if (mogoMapUIController != null) {
// long start = System.currentTimeMillis();
// result.tileId = String.valueOf(mogoMapUIController.getTileId(result.lon, result.lat));
// Log.d("ADAS数据延时", "getTileId 耗时 : " + (System.currentTimeMillis() - start) + "ms");
// }
return result;
}
}

View File

@@ -7,7 +7,6 @@ import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.util.Log;
import android.widget.Toast;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
@@ -18,8 +17,8 @@ import com.mogo.commons.network.SubscribeImpl;
import com.mogo.map.MogoLatLng;
import com.mogo.map.uicontroller.EnumMapUI;
import com.mogo.module.adas.AdasProvider;
import com.mogo.module.adas.AdasStatusListener;
import com.mogo.module.adas.IAdasDataListener;
import com.mogo.module.adas.IAdasStatusListener;
import com.mogo.service.MogoServicePaths;
import com.mogo.service.adas.IMogoADASController;
import com.mogo.service.adas.IMogoAdasCarDataCallback;
@@ -51,15 +50,11 @@ 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.autopilotservice.model.AdasAIDLOwnerCarStateModel;
import com.zhidao.support.adas.high.OnAdasListener;
import com.zhidao.support.adas.high.bean.AutopilotRoute;
import com.zhidao.support.adas.high.bean.AutopilotStatus;
import com.zhidao.support.adas.high.bean.RectInfo;
import com.zhidao.support.adas.high.bean.WarnMessageInfo;
import com.zhidao.support.adas.high.msg.MyMessageFactory;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
@@ -69,19 +64,8 @@ import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.TimeUnit;
import io.reactivex.Observable;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
import rx.android.schedulers.AndroidSchedulers;
import static rx.android.schedulers.AndroidSchedulers.mainThread;
/**
* @author congtaowang
* @since 2020-03-10
* <p>
* 描述
*/
@Route(path = MogoServicePaths.PATH_ADAS_CONTROLLER)
public class MogoADASController implements IMogoADASController {
@@ -101,10 +85,8 @@ public class MogoADASController implements IMogoADASController {
private boolean mIsReleased = true;
private IAdasDataListener mAdasDataListener;
private AdasProvider adasProvider;
/**
* 获取adas前车距离
*/
@@ -125,9 +107,33 @@ public class MogoADASController implements IMogoADASController {
*/
private final List<IMogoAdasRouteCallBack> mMogoAdasRouteCallBacks = new CopyOnWriteArrayList<>();
private IAdasDataListener mAdasDataListener;
private IMogoAdasCarDataCallback mMogoAdasCarDataCallback;
private List<AdasAIDLOwnerCarRectModel> mLastFrameDatums;
private IMogoAdasOCHCallback mAdasOCHCallback;
private double mLastLon;
private double mLastLat;
private double mSpeed;
private String satelliteTime;
@Override
public double getLastSpeed() {
return mSpeed;
}
public double getLastLat() {
return mLastLat;
}
public double getLastLon() {
return mLastLon;
}
public String getSatelliteTime() {
return satelliteTime;
}
/**
* 接收 adas 识别数据线程
@@ -137,9 +143,9 @@ public class MogoADASController implements IMogoADASController {
public void handleMessage(Message msg) {
super.handleMessage(msg);
if (msg.obj instanceof List) {
mAdasDataListener.notifyOwnerCarRect((List<AdasAIDLOwnerCarRectModel>) msg.obj);
handleAdasRecognizedData((List<RectInfo.RectBean>) msg.obj);
} else if (msg.obj == null) {
mAdasDataListener.notifyOwnerCarRect(null);
handleAdasRecognizedData(null);
}
}
};
@@ -167,8 +173,8 @@ public class MogoADASController implements IMogoADASController {
mLastLon = stateInfo.getValues().getLon();
mLastLat = stateInfo.getValues().getLat();
// satelliteTime = stateInfo.getValues().getSatelliteTime();
satelliteTime = stateInfo.getValues().getSystemTime();
mSpeed = stateInfo.getValues().getGnss_speed();
satelliteTime = stateInfo.getValues().getSatelliteTime();
if (mMogoAdasCarDataCallback != null) {
mMogoAdasCarDataCallback.onAdasCarDataCallback(stateInfo);
}
@@ -176,111 +182,12 @@ public class MogoADASController implements IMogoADASController {
}
};
private final OnAdasListener mOnAdasListener = new OnAdasListenerAdapter() {
@Override
public void onRectData(RectInfo rectInfo) {
List<AdasAIDLOwnerCarRectModel> data = new ArrayList<>();
if (rectInfo != null && rectInfo.getModels() != null && !rectInfo.getModels().isEmpty()) {
List<RectInfo.RectBean> beans = rectInfo.getModels();
for (RectInfo.RectBean bean : beans) {
if (bean == null) {
continue;
}
AdasAIDLOwnerCarRectModel model = new AdasAIDLOwnerCarRectModel();
model.setId(bean.getId());
model.setXl(bean.getXl());
model.setXr(bean.getXr());
model.setYb(bean.getYb());
model.setYt(bean.getYt());
model.setDistance_x(bean.getDistance_x());
model.setDistance_y(bean.getDistance_y());
String type;
if (TextUtils.isEmpty(bean.getType())) {
type = "100";
Logger.d(TAG, " === ADAS 返回结果出现 type 为 null情况 ====");
} else {
type = bean.getType();
}
model.setType(type);
model.setLat(bean.getLat());
model.setLon(bean.getLon());
model.setHeading(bean.getHeading());
model.setSystemTime(bean.getSystemTime());
model.setSatelliteTime(bean.getSystemTime());
model.setAlt(bean.getAlt());
model.setCarId(bean.getCarId());
model.setUuid(bean.getUuid());
model.setColor(bean.getColor());
model.setSpeed(bean.getSpeed());
model.setDataAccuracy(bean.getDataAccuracy());
model.setDistance(bean.getDistance());
model.setDrawlevel(bean.getDrawlevel()); //liyz
data.add(model);
Log.d("ADAS数据延时", "uuid : " + bean.getUuid() + " type : " + bean.getType() + "systemTime : " + System.currentTimeMillis() + " GPS time" + Long.parseLong(bean.getSystemTime())
+ " timeDelay : " + (System.currentTimeMillis() - Long.parseLong(bean.getSystemTime())));
// Log.d("ADAS原始数据", "uuid : " + bean.getUuid() + " type : " + bean.getType());
Logger.d(TAG, "识别距离x = %s, y = %s", model.getDistance_x(), model.getDistance_y());
}
}
if (mLastFrameDatums == null) {
mLastFrameDatums = new ArrayList<>();
}
try {
mLastFrameDatums.addAll(data);
} catch (Exception e) {
}
Message message = mAdasRecognizedRecHandler.obtainMessage();
message.obj = data;
message.sendToTarget();
DebugConfig.setStatus(DebugConfig.sAdasRecognized, true);
}
@Override
public void onAutopilotRoute(AutopilotRoute autopilotRoute) {
}
@Override
public void onWarnMessage(WarnMessageInfo warnMessageInfo) {
if (warnMessageInfo == null) {
return;
}
// 警告消息
Logger.d(TAG, "onWarnMessage = %s", warnMessageInfo.toString());
if (mMogoAdasWarnMessageCallbackList.isEmpty()) {
return;
}
final ADASWarnMessage warnMessage = AdasObjectUtils.fromAdasObject(warnMessageInfo);
if (warnMessage == null) {
return;
}
UiThreadHandler.post(() -> {
for (IMogoAdasWarnMessageCallback callback : mMogoAdasWarnMessageCallbackList) {
if (callback != null) {
callback.onReceiveData(warnMessage);
}
}
});
}
};
private IMogoAdasOCHCallback mAdasOCHCallback;
/**
* 处理数据
*
* @param models
*/
private void handleAdasRecognizedData(List<AdasAIDLOwnerCarRectModel> models) {
private void handleAdasRecognizedData(List<RectInfo.RectBean> models) {
if (models == null
|| models.isEmpty()) {
invokeCallbackPerSecond(null);
@@ -289,7 +196,7 @@ public class MogoADASController implements IMogoADASController {
invokeCallbackPerSecond(models);
}
private void invokeCallbackPerSecond(List<AdasAIDLOwnerCarRectModel> models) {
private void invokeCallbackPerSecond(List<RectInfo.RectBean> models) {
List<ADASRecognizedResult> recognizedListResults = AdasObjectUtils.regroupData(models);
if (!mMogoAdasRecognizedDataCallbacks.isEmpty()) {
for (IMogoAdasRecognizedDataCallback callback : mMogoAdasRecognizedDataCallbacks) {
@@ -301,8 +208,6 @@ public class MogoADASController implements IMogoADASController {
}
}
private MyMessageFactory mAdasMessageFactory;
@Override
public void openADAS() {
showADAS();
@@ -333,7 +238,7 @@ public class MogoADASController implements IMogoADASController {
// }
Logger.d(TAG, Log.getStackTraceString(new Throwable()));
init(AbsMogoApplication.getApp());
adasProvider.addAdasStatusListener(new AdasStatusListener() {
adasProvider.addAdasStatusListener(new IAdasStatusListener() {
@Override
public void onServiceConnected() {
Logger.d(TAG, "adas statusListener connected");
@@ -362,20 +267,54 @@ public class MogoADASController implements IMogoADASController {
}
@Override
public void cameraEyeDetectResult(String detectResult) {
Logger.d(TAG, "detectResult " + detectResult);
try {
JSONObject jsonObjectWs = new JSONObject(detectResult);
String action = jsonObjectWs.optString("action");
if (TextUtils.isEmpty(action)) {
Logger.w(TAG, "--->action is null");
return;
}
//识别的他车移动操作
mAdasMessageFactory.createMessage(action).handlerMsg(GsonUtil.getGson(), mOnAdasListener, detectResult);
} catch (JSONException e) {
e.printStackTrace();
public void onRectData(RectInfo rectInfo) {
// 仅在 vr 模式下显示 adas 识别车辆
if (!SingletonsHolder.get(IMogoStatusManager.class).isVrMode()) {
return;
}
if (!SingletonsHolder.get(IMogoStatusManager.class).isMainPageLaunched()) {
return;
}
if (rectInfo == null || TextUtils.isEmpty(rectInfo.getAction())) {
Logger.w(TAG, "--->action is null");
return;
}
final long start = System.nanoTime();
if (rectInfo.getModels() != null && !rectInfo.getModels().isEmpty()) {
List<RectInfo.RectBean> beans = rectInfo.getModels();
try {
Message message = mAdasRecognizedRecHandler.obtainMessage();
message.obj = beans;
message.sendToTarget();
Log.i("ADAS数据延时", "接收数据 -> 发出 cost :" + TimeUnit.NANOSECONDS.toMillis((System.nanoTime() - start)) + "ms");
} catch (Exception e) {
e.printStackTrace();
}
}
DebugConfig.setStatus(DebugConfig.sAdasRecognized, true);
}
@Override
public void onWarnMessage(WarnMessageInfo warnMessageInfo) {
if (warnMessageInfo == null) {
return;
}
// 警告消息
Logger.d(TAG, "onWarnMessage = %s", warnMessageInfo.toString());
if (mMogoAdasWarnMessageCallbackList.isEmpty()) {
return;
}
final ADASWarnMessage warnMessage = AdasObjectUtils.fromAdasObject(warnMessageInfo);
if (warnMessage == null) {
return;
}
UiThreadHandler.post(() -> {
for (IMogoAdasWarnMessageCallback callback : mMogoAdasWarnMessageCallbackList) {
if (callback != null) {
callback.onReceiveData(warnMessage);
}
}
});
}
@Override
@@ -457,31 +396,6 @@ public class MogoADASController implements IMogoADASController {
message.sendToTarget();
}
@Override
public void notifyOwnerCarState(AdasAIDLOwnerCarStateModel ownerCarStateModel) {
Logger.d(TAG, "AdasAIDLOwnerCarStateModel " + ownerCarStateModel);
ADASCarStateInfo stateInf = new ADASCarStateInfo();
stateInf.setAction("state");
ADASCarStateInfo.ValuesBean bean = new ADASCarStateInfo.ValuesBean();
bean.setSatelliteTime(ownerCarStateModel.getSatelliteTime());
bean.setAcceleration(ownerCarStateModel.getAcceleration());
bean.setAlt(ownerCarStateModel.getAlt());
bean.setGnss_speed(ownerCarStateModel.getGnss_speed());
bean.setHeading(ownerCarStateModel.getHeading());
bean.setLat(ownerCarStateModel.getLat());
bean.setLon(ownerCarStateModel.getLon());
bean.setReceiverDataTime(ownerCarStateModel.getReceiverDataTime());
bean.setSystemTime(ownerCarStateModel.getSystemTime());
bean.setYaw_rate(ownerCarStateModel.getYaw_rate());
stateInf.setValues(bean);
mLastLon = ownerCarStateModel.getLon();
mLastLat = ownerCarStateModel.getLat();
mSpeed = ownerCarStateModel.getGnss_speed();
if (mMogoAdasCarDataCallback != null) {
mMogoAdasCarDataCallback.onAdasCarDataCallback(stateInf);
}
}
@Override
public void notifyAutopilotState(AutopilotStatus autopilotStatus) {
Logger.d(TAG, "notifyAutopilotState: " + autopilotStatus);
@@ -490,53 +404,11 @@ public class MogoADASController implements IMogoADASController {
mAdasOCHCallback.onStateChanged(autopilotStatus.getValues().getState(), autopilotStatus.getValues().getReason());
}
}
@Override
public void notifyOwnerCarRect(List<AdasAIDLOwnerCarRectModel> ownerCarStateRectList) {
// 物体识别返回
Logger.d(TAG, "ADAS-REC-received data: size = %s", ownerCarStateRectList == null ? 0 : ownerCarStateRectList.size());
final long start = System.currentTimeMillis();
// 仅在 vr 模式下显示 adas 识别车辆
if (!SingletonsHolder.get(IMogoStatusManager.class).isVrMode()) {
return;
}
if (!SingletonsHolder.get(IMogoStatusManager.class).isMainPageLaunched()) {
return;
}
try {
handleAdasRecognizedData(ownerCarStateRectList);
} catch (Exception e) {
e.printStackTrace();
}
Logger.i("ADAS-REC-timer", "cost " + (System.currentTimeMillis() - start) + "ms");
}
};
adasProvider.addAdasEventListener(mAdasDataListener);
}
}
private double mLastLon;
private double mLastLat;
private double mSpeed;
private String satelliteTime;
@Override
public double getLastSpeed() {
return mSpeed;
}
public double getLastLat() {
return mLastLat;
}
public double getLastLon() {
return mLastLon;
}
public String getSatelliteTime() {
return satelliteTime;
}
private boolean useTestSn = false;
private void invokeShowADASOperation() {
@@ -609,7 +481,6 @@ public class MogoADASController implements IMogoADASController {
@Override
public void init(Context context) {
mIsReleased = false;
mAdasMessageFactory = new MyMessageFactory();
adasProvider = ARouter.getInstance().navigation(AdasProvider.class);
this.context = context;
}
@@ -629,7 +500,6 @@ public class MogoADASController implements IMogoADASController {
if (ui == null || !DebugConfig.isMapBased()) {
return;
}
Logger.d(TAG, "new Mode: " + ui.name());
switch (ui) {
case CarUp_2D:
@@ -779,25 +649,6 @@ public class MogoADASController implements IMogoADASController {
mMogoAdasWarnMessageCallbackList.remove(callback);
}
@Override
public List<ADASRecognizedResult> getLastADASRecognizedResult() {
if (mLastFrameDatums == null) {
return null;
}
if (!DebugConfig.isUseAdasRecognize()) {
return null;
}
try {
List<AdasAIDLOwnerCarRectModel> data = mLastFrameDatums;
mLastFrameDatums = null;
List<ADASRecognizedResult> recognizedResultList;
recognizedResultList = AdasObjectUtils.regroupData(data);
return recognizedResultList;
} catch (Exception e) {
return null;
}
}
@Override
public void addAdasRecognizedDataCallback(IMogoAdasRecognizedDataCallback callback) {
if (callback == null) {
@@ -923,27 +774,6 @@ public class MogoADASController implements IMogoADASController {
}
}
@Override
public void mockAdasRecognized(String json) {
mAdasDataListener.cameraEyeDetectResult(json);
}
//
// private static final int PERIOD = 5 * 1000;
// private static final int DELAY = 10000;
// private Disposable mDisposable;
//
// /**
// * 定时循环任务
// */
// private void timeLoop() {
// mDisposable = Observable.interval(DELAY, PERIOD, TimeUnit.MILLISECONDS)
// .map((aLong -> aLong + 1))
// .subscribeOn(Schedulers.io())
// .subscribe(aLong ->
// adasProvider.setBasicInfo()
// );//getUnreadCount()执行的任务
// }
}