Merge branch 'qa_merge_shunyi_vr_map' into dev2

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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