Improved GPS heading compensation

Change-Id: I63324db2649fd557a244c6133d38e72ce8988929
Signed-off-by: Ricky Barrette <rickbarrette@gmail.com>
This commit is contained in:
2012-03-14 13:40:42 -04:00
parent 500c7162e3
commit 57d885c3fc

View File

@@ -88,7 +88,6 @@ public class NavigationActivity extends FragmentActivity implements CompassListe
+"\nDrive: "+mIOIOManager.getDriveValue() +"\nDrive: "+mIOIOManager.getDriveValue()
+"\nSteering: "+mIOIOManager.getSteerValue() +"\nSteering: "+mIOIOManager.getSteerValue()
+"\nBearing: "+mBearing +"\nBearing: "+mBearing
+"\nHeadinging: "+mHeading
+"\nisRunning: "+isRunning); +"\nisRunning: "+isRunning);
if(mPoints != null) if(mPoints != null)
updateLog("Point = "+mIndex +" of "+ mPoints.size()); updateLog("Point = "+mIndex +" of "+ mPoints.size());
@@ -140,6 +139,7 @@ public class NavigationActivity extends FragmentActivity implements CompassListe
private ArrayList<PathOverlay> mWayPoints; private ArrayList<PathOverlay> mWayPoints;
private GeoPoint mLastReportedLocation; private GeoPoint mLastReportedLocation;
private float mHeading = 0; private float mHeading = 0;
private long mLastReportedTime;
/** /**
* Called when the scrolling switch is checked * Called when the scrolling switch is checked
@@ -197,11 +197,18 @@ public class NavigationActivity extends FragmentActivity implements CompassListe
public void onCompassUpdate(float bearing) { public void onCompassUpdate(float bearing) {
mBearing = bearing; mBearing = bearing;
if(Debug.DEBUG)
Log.v(TAG, "Bearing ="+bearing);
/* /*
* used calculated bearing if the last location was updated less than a x ago * used calculated bearing if the last location was updated less than a x ago
*/ */
if(mHeading > 0 && (System.currentTimeMillis() - mLast) < 500) if((System.currentTimeMillis() - mLastReportedTime) < 500)
bearing = mHeading; mHeading = bearing;
if(Debug.DEBUG)
Log.v(TAG, "Heading ="+mHeading);
bearing = GeoUtils.calculateBearing(mMap.getUserLocation(), mMap.getDestination(), bearing); bearing = GeoUtils.calculateBearing(mMap.getUserLocation(), mMap.getDestination(), bearing);
@@ -309,9 +316,13 @@ public class NavigationActivity extends FragmentActivity implements CompassListe
if(point != null) if(point != null)
if(mLastReportedLocation != null){ if(mLastReportedLocation != null){
mHeading = new Float(GeoUtils.bearing(mLastReportedLocation, point)); if(!point.equals(mLastReportedLocation)){
mLastReportedTime = mLast;
float heading = new Float(GeoUtils.bearing(mLastReportedLocation, point));
mHeading = heading > 180 ? heading -360 : heading;
if(Debug.DEBUG) if(Debug.DEBUG)
Log.d(TAG, "Heading = "+ mHeading); updateLog("Heading = "+ mHeading);
}
} }
mLastReportedLocation = point; mLastReportedLocation = point;
if(currentDest != null) if(currentDest != null)