1. mock添加10辆车

2. 道路吸附同步到snapshot
This commit is contained in:
tongchenfei
2021-03-17 20:29:57 +08:00
parent f1b9f7481e
commit 29c0277921
9 changed files with 213 additions and 94 deletions

View File

@@ -197,76 +197,19 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
return;
}
final double lon = recognizedListResult.lon;
final double lat = recognizedListResult.lat;
final long start = System.currentTimeMillis();
double[] matchedPoint = SnapshotSetDataDrawer.getInstance().matchRoad( recognizedListResult.uuid, recognizedListResult.lon,
recognizedListResult.lat,
recognizedListResult.heading,
true
);
ADASRecognizedResult lastPosition = mLastPositions.remove( uniqueKey );
boolean match = false;
if ( matchedPoint != null ) {
Logger.d( TAG, "matchPoint %s distance = %s",lineCounter, matchedPoint[2] );
match = matchedPoint[2] < 1 && matchedPoint[2] > 0;
if ( lastPosition != null ) {
double clearAngle;
if (recognizedListResult.heading > 0 && recognizedListResult.heading <= 90) {
clearAngle = recognizedListResult.heading;
} else if (recognizedListResult.heading > 90 && recognizedListResult.heading <= 180) {
clearAngle = 180 - recognizedListResult.heading ;
} else if (recognizedListResult.heading > 180 && recognizedListResult.heading <= 270) {
clearAngle = recognizedListResult.heading - 180;
}else{
clearAngle = 360 - recognizedListResult.heading;
}
double _angle = Math.atan2(Math.abs(matchedPoint[0] - lastPosition.lon), Math.abs(matchedPoint[1] - lastPosition.lat)) * (180 / PI);
_angle = Math.abs(clearAngle - _angle);
Logger.d(TAG, "matchPoint %s angel = %s", lineCounter, _angle);
if ( _angle > 22.5 ) {
match = false;
}
}
// mIsMatchStatusCache.put( uniqueKey, match );
if ( match ) {
recognizedListResult.lon = matchedPoint[0];
recognizedListResult.lat = matchedPoint[1];
}
double lastLon = -1;
double lastLat = -1;
if (lastPosition != null) {
lastLon = lastPosition.lon;
lastLat = lastPosition.lat;
}
double[] matchLonLat = getMatchLonLat(recognizedListResult.uuid, recognizedListResult.lon, recognizedListResult.lat, recognizedListResult.heading, lastLon, lastLat);
recognizedListResult.lon = matchLonLat[0];
recognizedListResult.lat = matchLonLat[1];
// Boolean isMatch = mIsMatchStatusCache.get( uniqueKey );
// if ( matchedPoint != null ) {
// if ( ( isMatch == null || !isMatch ) ) {
// if ( matchedPoint[2] < 0.5 && matchedPoint[2] > 0 ) {
// isMatch = true;
// }
// } else {
// if ( matchedPoint[2] > 1 ) {
// isMatch = false;
// }
// }
// if ( isMatch == null ) {
// isMatch = false;
// }
// if (lastPosition != null) {
// double _angle = Math.atan2(Math.abs(matchedPoint[0] - lastPosition.lon), Math.abs(matchedPoint[1] - lastPosition.lat)) * (180 / PI);
// Logger.d(TAG, "matchPoint %s angel = %s", lineCounter, _angle);
// if (_angle > 22.5) {
// isMatch = false;
// }
// }
// mIsMatchStatusCache.put( uniqueKey, isMatch );
//
// if ( isMatch ) {
// recognizedListResult.lon = matchedPoint[0];
// recognizedListResult.lat = matchedPoint[1];
// }
// }
mLastPositions.put( uniqueKey, recognizedListResult );
Logger.d( "matchRoad", "cost = %s", System.currentTimeMillis() - start );
IMogoMarker marker = mAdasRecognizedMarkersCaches.remove( uniqueKey );

View File

@@ -16,8 +16,10 @@ 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.realtime.entity.ADASRecognizedResult;
import com.mogo.realtime.entity.CloudRoadData;
import com.mogo.utils.WorkThreadHandler;
import com.mogo.utils.logger.Logger;
import java.util.ArrayList;
import java.util.Collection;
@@ -384,4 +386,43 @@ class BaseDrawer {
}
}
}
protected double[] getMatchLonLat(String id,double lon,double lat,double heading,double lastLon,double lastLat){
double[] matchedPoint = SnapshotSetDataDrawer.getInstance().matchRoad( id, lon,
lat,
heading,
true
);
boolean match = false;
if ( matchedPoint != null ) {
// Logger.d( TAG, "matchPoint %s distance = %s",lineCounter, matchedPoint[2] );
match = matchedPoint[2] < 1 && matchedPoint[2] > 0;
if ( lastLon != -1 ) {
double clearAngle;
if (heading > 0 && heading <= 90) {
clearAngle = heading;
} else if (heading > 90 && heading <= 180) {
clearAngle = 180 - heading ;
} else if (heading > 180 && heading <= 270) {
clearAngle = heading - 180;
}else{
clearAngle = 360 - heading;
}
double _angle = Math.atan2(Math.abs(matchedPoint[0] - lastLon), Math.abs(matchedPoint[1] - lastLat)) * (180 / PI);
_angle = Math.abs(clearAngle - _angle);
// Logger.d(TAG, "matchPoint %s angel = %s", lineCounter, _angle);
if ( _angle > 22.5 ) {
match = false;
}
}
if ( match ) {
lon = matchedPoint[0];
lat = matchedPoint[1];
}
}
return new double[]{lon,lat};
}
}

View File

@@ -195,39 +195,22 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
return;
}
final long start = System.currentTimeMillis();
// double[] matchedPoint = SnapshotSetDataDrawer.getInstance().matchRoad( recognizedListResult.getUniqueKey(), recognizedListResult.getWgslon(),
// recognizedListResult.getWgslat(),
// recognizedListResult.getHeading(),
// true
// );
// Boolean isMatch = mIsMatchStatusCache.get( uniqueKey );
// if ( matchedPoint != null ) {
// if ( ( isMatch == null || !isMatch ) ) {
// if ( matchedPoint[2] < 0.5 ) {
// isMatch = true;
// }
// } else {
// if ( matchedPoint[2] > 1 ) {
// isMatch = false;
// }
// }
// if ( isMatch == null ) {
// isMatch = false;
// }
// mIsMatchStatusCache.put( uniqueKey, isMatch );
//
// if ( isMatch ) {
// recognizedListResult.setWgslon(matchedPoint[0]);
// recognizedListResult.setWgslat(matchedPoint[1]);
// }
// }
// Logger.d( "matchRoad", "cost = %s", System.currentTimeMillis() - start );
IMogoMarker marker = mAdasRecognizedMarkersCaches.remove( uniqueKey );
CloudRoadData lastPosition = mLastPositions.put( uniqueKey, recognizedListResult );
double lastLon = -1;
double lastLat = -1;
if (lastPosition != null) {
lastLon = lastPosition.getWgslon();
lastLat = lastPosition.getWgslat();
}
double[] matchLonLat = getMatchLonLat(recognizedListResult.getUniqueKey(), recognizedListResult.getWgslon(), recognizedListResult.getWgslat(), recognizedListResult.getHeading(), lastLon, lastLat);
recognizedListResult.setWgslon(matchLonLat[0]);
recognizedListResult.setWgslat(matchLonLat[1]);
if ( marker == null || marker.isDestroyed() ) {
marker = drawSnapshotDataMarker( recognizedListResult );
if ( marker == null ) {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -727,6 +727,11 @@ public class MockIntentHandler implements IntentHandler {
br32.close();
br33.close();
br34.close();
br35.close();
br36.close();
br37.close();
br38.close();
br39.close();
} catch ( IOException ex ) {
ex.printStackTrace();
}
@@ -735,6 +740,11 @@ public class MockIntentHandler implements IntentHandler {
br32 = null;
br33 = null;
br34 = null;
br35 = null;
br36 = null;
br37 = null;
br38 = null;
br39 = null;
}
} else if ( msg.what == 31 ) {
try {
@@ -861,7 +871,7 @@ public class MockIntentHandler implements IntentHandler {
private boolean handleMockSnapshotIntent() throws Exception {
if ( br2 == null ) {
br2 = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "snapshot.txt" ) ) );
br2 = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "adas6.txt" ) ) );
}
String line = br2.readLine();
if ( line == null ) {
@@ -886,7 +896,7 @@ public class MockIntentHandler implements IntentHandler {
delay = cloudRoadData.getSystemTime() - last;
}
last = cloudRoadData.getSystemTime();
mLocationMockHandler.sendEmptyMessageDelayed( 2, 100L );
mLocationMockHandler.sendEmptyMessageDelayed( 2, 50L );
return true;
}
@@ -937,6 +947,22 @@ public class MockIntentHandler implements IntentHandler {
if ( br34 == null ) {
br34 = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "adas6.txt" ) ) );
}
if ( br35 == null ) {
br35 = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "adas3-2.txt" ) ) );
}
if ( br36 == null ) {
br36 = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "adas4-2.txt" ) ) );
}
if ( br37 == null ) {
br37 = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "adas4-4.txt" ) ) );
}
if ( br38 == null ) {
br38 = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "adas5-2.txt" ) ) );
}
if ( br39 == null ) {
br39 = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "adas5-4.txt" ) ) );
}
String line = br3.readLine();
if ( line == null ) {
throw new Exception( "end of file 3." );
@@ -964,6 +990,27 @@ public class MockIntentHandler implements IntentHandler {
allList.add( next );
}
next = handleMockAdasIntent7();
if ( next != null ) {
allList.add( next );
}
next = handleMockAdasIntent8();
if ( next != null ) {
allList.add( next );
}
next = handleMockAdasIntent9();
if ( next != null ) {
allList.add( next );
}
next = handleMockAdasIntent10();
if ( next != null ) {
allList.add( next );
}
next = handleMockAdasIntent11();
if ( next != null ) {
allList.add( next );
}
AdasRecognizedResultDrawer.getInstance().renderAdasRecognizedResult( allList );
Log.i( "mock-timer-adas", "cost " + ( System.currentTimeMillis() - start ) + "ms" );
long delay = 100;
@@ -1054,4 +1101,104 @@ public class MockIntentHandler implements IntentHandler {
return adasRecognizedResult;
}
private BufferedReader br35;
private ADASRecognizedResult handleMockAdasIntent7() {
String line = null;
try {
line = br35.readLine();
} catch ( IOException e ) {
e.printStackTrace();
}
if ( line == null ) {
return null;
}
ADASRecognizedResult adasRecognizedResult = GsonUtil.objectFromJson( line, ADASRecognizedResult.class );
if ( adasRecognizedResult == null ) {
return null;
}
adasRecognizedResult.uuid = "2_6";
return adasRecognizedResult;
}
private BufferedReader br36;
private ADASRecognizedResult handleMockAdasIntent8() {
String line = null;
try {
line = br36.readLine();
} catch ( IOException e ) {
e.printStackTrace();
}
if ( line == null ) {
return null;
}
ADASRecognizedResult adasRecognizedResult = GsonUtil.objectFromJson( line, ADASRecognizedResult.class );
if ( adasRecognizedResult == null ) {
return null;
}
adasRecognizedResult.uuid = "2_7";
return adasRecognizedResult;
}
private BufferedReader br37;
private ADASRecognizedResult handleMockAdasIntent9() {
String line = null;
try {
line = br37.readLine();
} catch ( IOException e ) {
e.printStackTrace();
}
if ( line == null ) {
return null;
}
ADASRecognizedResult adasRecognizedResult = GsonUtil.objectFromJson( line, ADASRecognizedResult.class );
if ( adasRecognizedResult == null ) {
return null;
}
adasRecognizedResult.uuid = "2_8";
return adasRecognizedResult;
}
private BufferedReader br38;
private ADASRecognizedResult handleMockAdasIntent10() {
String line = null;
try {
line = br38.readLine();
} catch ( IOException e ) {
e.printStackTrace();
}
if ( line == null ) {
return null;
}
ADASRecognizedResult adasRecognizedResult = GsonUtil.objectFromJson( line, ADASRecognizedResult.class );
if ( adasRecognizedResult == null ) {
return null;
}
adasRecognizedResult.uuid = "2_9";
return adasRecognizedResult;
}
private BufferedReader br39;
private ADASRecognizedResult handleMockAdasIntent11() {
String line = null;
try {
line = br39.readLine();
} catch ( IOException e ) {
e.printStackTrace();
}
if ( line == null ) {
return null;
}
ADASRecognizedResult adasRecognizedResult = GsonUtil.objectFromJson( line, ADASRecognizedResult.class );
if ( adasRecognizedResult == null ) {
return null;
}
adasRecognizedResult.uuid = "2_10";
return adasRecognizedResult;
}
}