Inital Commit of my mulitiple point navigation changes
Change-Id: I33996d4aaf6200b25cd46e95aba78330494c09a9 Signed-off-by: Ricky Barrette <rickbarrette@gmail.com>
This commit is contained in:
@@ -13,7 +13,7 @@
|
|||||||
# get is the path to your json retrieval script
|
# get is the path to your json retrieval script
|
||||||
# app is the redmine project name
|
# app is the redmine project name
|
||||||
# tracker is the redmine tracker
|
# tracker is the redmine tracker
|
||||||
server = http://rickbarrette.dyndns.org:8080/redmine/exceptionhandler
|
server = http://rickbarrette.dyndns.org:8888
|
||||||
app = IOIO Truck
|
app = IOIO Truck
|
||||||
tracker = Development Bug
|
tracker = Development Bug
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,8 @@ public class Main extends Activity implements OnClickListener {
|
|||||||
Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler(this));
|
Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler(this));
|
||||||
setContentView(R.layout.main);
|
setContentView(R.layout.main);
|
||||||
|
|
||||||
|
// Integer.parseInt("poop");
|
||||||
|
|
||||||
findViewById(R.id.test_activity_button).setOnClickListener(this);
|
findViewById(R.id.test_activity_button).setOnClickListener(this);
|
||||||
findViewById(R.id.nav_activity_button).setOnClickListener(this);
|
findViewById(R.id.nav_activity_button).setOnClickListener(this);
|
||||||
findViewById(R.id.camera_activity_button).setOnClickListener(this);
|
findViewById(R.id.camera_activity_button).setOnClickListener(this);
|
||||||
|
|||||||
@@ -21,12 +21,19 @@
|
|||||||
*/
|
*/
|
||||||
package com.TwentyCodes.android.IOIOTruck;
|
package com.TwentyCodes.android.IOIOTruck;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import org.apache.http.client.ClientProtocolException;
|
||||||
|
import org.json.JSONException;
|
||||||
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.TwentyCodes.android.location.LocationSelectedListener;
|
import com.TwentyCodes.android.fragments.UserOverlayMapFragment;
|
||||||
import com.TwentyCodes.android.location.MapView;
|
import com.TwentyCodes.android.location.MapView;
|
||||||
import com.TwentyCodes.android.location.RadiusOverlay;
|
import com.TwentyCodes.android.location.OnLocationSelectedListener;
|
||||||
import com.TwentyCodes.android.location.UserOverlayMapFragment;
|
import com.TwentyCodes.android.overlays.DirectionsOverlay;
|
||||||
|
import com.TwentyCodes.android.overlays.DirectionsOverlay.OnDirectionsCompleteListener;
|
||||||
|
import com.TwentyCodes.android.overlays.RadiusOverlay;
|
||||||
import com.google.android.maps.GeoPoint;
|
import com.google.android.maps.GeoPoint;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -35,12 +42,16 @@ import com.google.android.maps.GeoPoint;
|
|||||||
* Specifically this map view will allow user to select a point on the map via RadiusOverlay
|
* Specifically this map view will allow user to select a point on the map via RadiusOverlay
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
public class MapFragment extends UserOverlayMapFragment implements LocationSelectedListener {
|
public class MapFragment extends UserOverlayMapFragment implements OnLocationSelectedListener, OnDirectionsCompleteListener {
|
||||||
|
|
||||||
private final String TAG = "MapFragment";
|
private final String TAG = "MapFragment";
|
||||||
|
|
||||||
private RadiusOverlay mRadiusOverlay;
|
private RadiusOverlay mRadiusOverlay;
|
||||||
private LocationSelectedListener mLocationSelectedListener;
|
private OnLocationSelectedListener mLocationSelectedListener;
|
||||||
|
|
||||||
|
private OnDirectionsCompleteListener mDirectionsCompleteListener;
|
||||||
|
|
||||||
|
private DirectionsOverlay mDirectionsOverlay;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new MapFragment
|
* Creates a new MapFragment
|
||||||
@@ -50,6 +61,18 @@ public class MapFragment extends UserOverlayMapFragment implements LocationSelec
|
|||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called whrn the directions overlay is finished getting the directions.
|
||||||
|
* (non-Javadoc)
|
||||||
|
* @see com.TwentyCodes.android.overlays.DirectionsOverlay.OnDirectionsCompleteListener#onDirectionsComplete(com.TwentyCodes.android.overlays.DirectionsOverlay)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void onDirectionsComplete(DirectionsOverlay directionsOverlay) {
|
||||||
|
mDirectionsOverlay = directionsOverlay;
|
||||||
|
if(mDirectionsCompleteListener != null)
|
||||||
|
mDirectionsCompleteListener.onDirectionsComplete(directionsOverlay);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a point is selected on the map
|
* Called when a point is selected on the map
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
@@ -73,7 +96,7 @@ public class MapFragment extends UserOverlayMapFragment implements LocationSelec
|
|||||||
} else if(Debug.DEBUG)
|
} else if(Debug.DEBUG)
|
||||||
Log.d(TAG, "onLocationSelected() Location was null");
|
Log.d(TAG, "onLocationSelected() Location was null");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
* @see com.TwentyCodes.android.location.UserOverlayMapFragment#onMapViewCreate(com.TwentyCodes.android.location.MapView)
|
* @see com.TwentyCodes.android.location.UserOverlayMapFragment#onMapViewCreate(com.TwentyCodes.android.location.MapView)
|
||||||
@@ -88,13 +111,55 @@ public class MapFragment extends UserOverlayMapFragment implements LocationSelec
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* (non-Javadoc)
|
||||||
|
* @see com.TwentyCodes.android.fragments.UserOverlayMapFragment#setDestination(com.google.android.maps.GeoPoint)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setDestination(final GeoPoint destination) {
|
||||||
|
if(mDirectionsOverlay != null)
|
||||||
|
mDirectionsOverlay.removePath();
|
||||||
|
|
||||||
|
if(mDirectionsCompleteListener != null)
|
||||||
|
new Thread( new Runnable(){
|
||||||
|
@Override
|
||||||
|
public void run(){
|
||||||
|
try {
|
||||||
|
new DirectionsOverlay(getMap(), getUserLocation(), destination, MapFragment.this);
|
||||||
|
} catch (IllegalStateException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (ClientProtocolException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IOException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (JSONException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
super.setDestination(destination);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sets the distener for the directions overlay
|
||||||
* @param listener
|
* @param listener
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
public void setLocationSelectedListener(LocationSelectedListener listener){
|
public void setDirectionsCompleteListener(OnDirectionsCompleteListener listener){
|
||||||
mLocationSelectedListener = listener;
|
mDirectionsCompleteListener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param listener
|
||||||
|
* @author ricky barrette
|
||||||
|
*/
|
||||||
|
public void setLocationSelectedListener(OnLocationSelectedListener listener){
|
||||||
|
mLocationSelectedListener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param radius meters
|
* @param radius meters
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
|
|||||||
@@ -21,6 +21,8 @@
|
|||||||
*/
|
*/
|
||||||
package com.TwentyCodes.android.IOIOTruck;
|
package com.TwentyCodes.android.IOIOTruck;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
@@ -42,7 +44,10 @@ import com.TwentyCodes.android.IOIOTruck.IOIOTruckManager.IOIOTruckThreadListene
|
|||||||
import com.TwentyCodes.android.location.CompassListener;
|
import com.TwentyCodes.android.location.CompassListener;
|
||||||
import com.TwentyCodes.android.location.GeoPointLocationListener;
|
import com.TwentyCodes.android.location.GeoPointLocationListener;
|
||||||
import com.TwentyCodes.android.location.GeoUtils;
|
import com.TwentyCodes.android.location.GeoUtils;
|
||||||
import com.TwentyCodes.android.location.LocationSelectedListener;
|
import com.TwentyCodes.android.location.OnLocationSelectedListener;
|
||||||
|
import com.TwentyCodes.android.overlays.DirectionsOverlay;
|
||||||
|
import com.TwentyCodes.android.overlays.DirectionsOverlay.OnDirectionsCompleteListener;
|
||||||
|
import com.TwentyCodes.android.overlays.PathOverlay;
|
||||||
import com.google.android.maps.GeoPoint;
|
import com.google.android.maps.GeoPoint;
|
||||||
|
|
||||||
|
|
||||||
@@ -57,7 +62,7 @@ import com.google.android.maps.GeoPoint;
|
|||||||
* + drive the truck forward or reverse to best navigate to the selected point
|
* + drive the truck forward or reverse to best navigate to the selected point
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
public class NavigationActivity extends FragmentActivity implements CompassListener, GeoPointLocationListener, LocationSelectedListener, OnClickListener, OnCheckedChangeListener, IOIOTruckThreadListener {
|
public class NavigationActivity extends FragmentActivity implements CompassListener, GeoPointLocationListener, OnLocationSelectedListener, OnClickListener, OnCheckedChangeListener, IOIOTruckThreadListener, OnDirectionsCompleteListener {
|
||||||
|
|
||||||
private static final String TAG = "NavigationActivity";
|
private static final String TAG = "NavigationActivity";
|
||||||
private IOIOTruckManager mIOIOManager;
|
private IOIOTruckManager mIOIOManager;
|
||||||
@@ -79,6 +84,9 @@ public class NavigationActivity extends FragmentActivity implements CompassListe
|
|||||||
private long mLast;
|
private long mLast;
|
||||||
private WakeLock mWakeLock;
|
private WakeLock mWakeLock;
|
||||||
private int mCount;
|
private int mCount;
|
||||||
|
private ArrayList<GeoPoint> mPoints;
|
||||||
|
private int mIndex = 0;
|
||||||
|
private GeoPoint mDestPoint;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This thread will be used to update all the informational displays
|
* This thread will be used to update all the informational displays
|
||||||
@@ -106,6 +114,8 @@ public class NavigationActivity extends FragmentActivity implements CompassListe
|
|||||||
+"\nSteering: "+mIOIOManager.getSteerValue()
|
+"\nSteering: "+mIOIOManager.getSteerValue()
|
||||||
+"\nBearing: "+mBearing
|
+"\nBearing: "+mBearing
|
||||||
+"\nisRunning: "+isRunning);
|
+"\nisRunning: "+isRunning);
|
||||||
|
if(mPoints != null)
|
||||||
|
updateLog("Point = "+mIndex +" of "+ mPoints.size());
|
||||||
|
|
||||||
updateLastUpdateTextView();
|
updateLastUpdateTextView();
|
||||||
|
|
||||||
@@ -282,19 +292,35 @@ public class NavigationActivity extends FragmentActivity implements CompassListe
|
|||||||
mDistance = updateProgress(point);
|
mDistance = updateProgress(point);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* here we will update the progress bar
|
* if we have a destination, check to see if we are there yet
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
if(mPoint != null)
|
if(mPoint != null)
|
||||||
if(GeoUtils.isIntersecting(point, (float) (accuracy / 1E3), mPoint, Debug.RADIUS, Debug.FUDGE_FACTOR)) {
|
if(GeoUtils.isIntersecting(point, (float) (accuracy / 1E3), mPoint, Debug.RADIUS, Debug.FUDGE_FACTOR)) {
|
||||||
|
|
||||||
mCount++;
|
mCount++;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* if we get 5 positives, we are at our waypoint/dest
|
||||||
|
*/
|
||||||
if(mCount > 5){
|
if(mCount > 5){
|
||||||
Log.v(TAG, "Dest Reached, Stopping");
|
|
||||||
mIOIOManager.setDriveValue(IOIOTruckValues.DRIVE_STOP);
|
/*
|
||||||
updateGoButton(true);
|
* if ther points list is null, or there are no more points
|
||||||
updateLog(R.string.dest_reached);
|
*/
|
||||||
|
if(mPoints == null || mIndex == mPoints.size()+1){
|
||||||
|
mIOIOManager.setDriveValue(IOIOTruckValues.DRIVE_STOP);
|
||||||
|
updateGoButton(true);
|
||||||
|
updateLog(R.string.dest_reached);
|
||||||
|
} else {
|
||||||
|
mIndex ++;
|
||||||
|
|
||||||
|
if(mIndex <= mPoints.size()+1) {
|
||||||
|
updateLog("last Waypoint reached, moving to dest");
|
||||||
|
mPoint = mPoints.get(mIndex);
|
||||||
|
} else {
|
||||||
|
updateLog("Waypoint reached, moving to next");
|
||||||
|
mPoint = mDestPoint;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.v(TAG, "Driving Forward");
|
Log.v(TAG, "Driving Forward");
|
||||||
@@ -315,9 +341,11 @@ public class NavigationActivity extends FragmentActivity implements CompassListe
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onLocationSelected(GeoPoint point) {
|
public void onLocationSelected(GeoPoint point) {
|
||||||
mPoint = point;
|
mDestPoint = point;
|
||||||
mDistance = updateProgress(mMap.getUserLocation());
|
mDistance = updateProgress(mMap.getUserLocation());
|
||||||
updateLog(getString(R.string.point_selected)+point.toString());
|
updateLog(getString(R.string.point_selected)+point.toString());
|
||||||
|
mIndex = 0;
|
||||||
|
mCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -353,7 +381,9 @@ public class NavigationActivity extends FragmentActivity implements CompassListe
|
|||||||
mMap.setCompassListener(this);
|
mMap.setCompassListener(this);
|
||||||
mMap.setGeoPointLocationListener(this);
|
mMap.setGeoPointLocationListener(this);
|
||||||
mMap.setLocationSelectedListener(this);
|
mMap.setLocationSelectedListener(this);
|
||||||
|
mMap.setDirectionsCompleteListener(this);
|
||||||
mMap.setRadius((int) (Debug.RADIUS * 1E3));
|
mMap.setRadius((int) (Debug.RADIUS * 1E3));
|
||||||
|
mMap.enableGPSProgess();
|
||||||
mIOIOManager = new IOIOTruckManager(this, this);
|
mIOIOManager = new IOIOTruckManager(this, this);
|
||||||
mIOIOManager.start();
|
mIOIOManager.start();
|
||||||
|
|
||||||
@@ -421,5 +451,25 @@ public class NavigationActivity extends FragmentActivity implements CompassListe
|
|||||||
public void onLogUpdate(String log) {
|
public void onLogUpdate(String log) {
|
||||||
updateLog(log);
|
updateLog(log);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* called when the directions overlay is generated
|
||||||
|
* (non-Javadoc)
|
||||||
|
* @see com.TwentyCodes.android.overlays.DirectionsOverlay.OnDirectionsCompleteListener#onDirectionsComplete(com.TwentyCodes.android.overlays.DirectionsOverlay)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void onDirectionsComplete(DirectionsOverlay directionsOverlay) {
|
||||||
|
ArrayList<GeoPoint> points = new ArrayList<GeoPoint>();
|
||||||
|
for(PathOverlay item : directionsOverlay.getPath())
|
||||||
|
if(item.getEndPoint() != null)
|
||||||
|
points.add(item.getEndPoint());
|
||||||
|
mPoints = points;
|
||||||
|
mPoint = points.get(points.size()-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFirstFix(boolean isFirstFix) {
|
||||||
|
mMap.disableGPSProgess();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user