Skip to content

Commit

Permalink
Merge pull request dronekit#22 from DroidPlanner/enhanced_follow_me
Browse files Browse the repository at this point in the history
Enhanced follow me
  • Loading branch information
m4gr3d committed Jan 7, 2015
2 parents dcbff9e + cbf02b3 commit 2cfecab
Show file tree
Hide file tree
Showing 39 changed files with 871 additions and 257 deletions.
4 changes: 2 additions & 2 deletions AidlLib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
defaultConfig {
minSdkVersion 14
targetSdkVersion 21
versionCode 20023
versionName '2.0.23'
versionCode 20025
versionName '2.0.25'
}

defaultPublishConfig "release"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import android.os.Parcel;
import android.os.Parcelable;

import java.util.ArrayList;
import java.util.List;

/**
* Created by fhuya on 11/5/14.
*/
Expand All @@ -13,7 +16,9 @@ public enum FollowType implements Parcelable {
RIGHT("Right"),
LEFT("Left"),
CIRCLE("Circle"),
ABOVE("Above");
ABOVE("Above"),
SPLINE_LEASH("Spline Leash"),
SPLINE_ABOVE("Spline Above");

private final String typeLabel;

Expand All @@ -25,6 +30,11 @@ public String getTypeLabel() {
return typeLabel;
}

@Override
public String toString(){
return getTypeLabel();
}

@Override
public int describeContents() {
return 0;
Expand All @@ -35,6 +45,23 @@ public void writeToParcel(Parcel dest, int flags) {
dest.writeString(name());
}

public static List<FollowType> getFollowTypes(boolean includeAdvanced){
List<FollowType> followTypes = new ArrayList<>();
followTypes.add(LEASH);
followTypes.add(LEAD);
followTypes.add(RIGHT);
followTypes.add(LEFT);
followTypes.add(CIRCLE);
followTypes.add(ABOVE);

if(includeAdvanced){
followTypes.add(SPLINE_LEASH);
followTypes.add(SPLINE_ABOVE);
}

return followTypes;
}

public static final Parcelable.Creator<FollowType> CREATOR = new Parcelable.Creator<FollowType>() {
public FollowType createFromParcel(Parcel source) {
return FollowType.valueOf(source.readString());
Expand Down
4 changes: 2 additions & 2 deletions ClientLib/mobile/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'com.android.library'

ext {
PUBLISH_ARTIFACT_ID = '3dr-services-lib'
PUBLISH_VERSION = '2.1.33'
PUBLISH_VERSION = '2.1.35'
PROJECT_DESCRIPTION = "3DR Services Client Library"
PROJECT_LABELS = ['3DR', '3DR Services', 'DroneAPI', 'Android']
PROJECT_LICENSES = ['Apache-2.0']
Expand All @@ -15,7 +15,7 @@ android {
defaultConfig {
minSdkVersion 14
targetSdkVersion 21
versionCode 20133
versionCode 20135
versionName PUBLISH_VERSION
}

Expand Down
Binary file modified ClientLib/mobile/libs/AidlLib.jar
Binary file not shown.
8 changes: 8 additions & 0 deletions ServiceApp/assets/CameraInfo/GoPro_Hero_3_Silver.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<cameraInfo>
<Name>GoPro Hero 3 Silver (Wide)</Name>
<SensorWidth>5.76</SensorWidth>
<SensorHeight>4.29</SensorHeight>
<SensorResolution>11</SensorResolution>
<FocalLength>2.5</FocalLength>
</cameraInfo>
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package org.droidplanner.services.android.api;

import android.annotation.SuppressLint;
import android.app.Notification;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
Expand All @@ -18,12 +22,14 @@

import org.droidplanner.core.MAVLink.connection.MavLinkConnection;
import org.droidplanner.core.MAVLink.connection.MavLinkConnectionListener;
import org.droidplanner.services.android.R;
import org.droidplanner.services.android.communication.connection.AndroidMavLinkConnection;
import org.droidplanner.services.android.communication.connection.AndroidTcpConnection;
import org.droidplanner.services.android.communication.connection.AndroidUdpConnection;
import org.droidplanner.services.android.communication.connection.BluetoothConnection;
import org.droidplanner.services.android.communication.connection.usb.UsbConnection;
import org.droidplanner.services.android.communication.service.UploaderService;
import org.droidplanner.services.android.ui.activity.MainActivity;
import org.droidplanner.services.android.utils.analytics.GAUtils;

import java.util.ArrayList;
Expand All @@ -39,6 +45,8 @@ public class DroidPlannerService extends Service {
private static final String CLAZZ_NAME = DroidPlannerService.class.getName();
private static final String TAG = DroidPlannerService.class.getSimpleName();

private static final int FOREGROUND_ID = 101;

public static final String ACTION_DRONE_CREATED = CLAZZ_NAME + ".ACTION_DRONE_CREATED";
public static final String ACTION_DRONE_DESTROYED = CLAZZ_NAME + ".ACTION_DRONE_DESTROYED";
public static final String ACTION_KICK_START_DRONESHARE_UPLOADS = CLAZZ_NAME + ".ACTION_KICK_START_DRONESHARE_UPLOADS";
Expand Down Expand Up @@ -177,19 +185,36 @@ public IBinder onBind(Intent intent) {
}
}

@SuppressLint("NewApi")
@Override
public void onCreate() {
super.onCreate();
Log.d(TAG, "Creating 3DR Services.");

final Context context = getApplicationContext();

mavlinkApi = new MavLinkServiceApi(this);
droneAccess = new DroneAccess(this);
dpServices = new DPServices(this);
lbm = LocalBroadcastManager.getInstance(getApplicationContext());
lbm = LocalBroadcastManager.getInstance(context);

//Put the service in the foreground
final Notification.Builder notifBuilder = new Notification.Builder(context)
.setContentTitle("3DR Services")
.setSmallIcon(R.drawable.ic_launcher)
.setContentIntent(PendingIntent.getActivity(context, 0, new Intent(context,
MainActivity.class).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK), 0));

final Notification notification = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN
? notifBuilder.build()
: notifBuilder.getNotification();
startForeground(FOREGROUND_ID, notification);
}

@Override
public void onDestroy() {
super.onDestroy();
Log.d(TAG, "Destroying 3DR Services.");

for (DroneApi droneApi : droneApiStore) {
droneApi.destroy();
Expand All @@ -202,6 +227,8 @@ public void onDestroy() {
}

mavConnections.clear();

stopForeground(true);
}

@Override
Expand All @@ -222,7 +249,8 @@ public int onStartCommand(Intent intent, int flags, int startId) {
}
}

return START_REDELIVER_INTENT;
stopSelf();
return START_NOT_STICKY;
}

}
79 changes: 49 additions & 30 deletions ServiceApp/src/org/droidplanner/services/android/api/DroneApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -657,36 +657,7 @@ public void setGuidedVelocity(double xVel, double yVel, double zVel) throws Remo

@Override
public void enableFollowMe(FollowType followType) throws RemoteException {
final FollowAlgorithm.FollowModes selectedMode;
switch (followType) {
case ABOVE:
selectedMode = FollowAlgorithm.FollowModes.ABOVE;
break;

case LEAD:
selectedMode = FollowAlgorithm.FollowModes.LEAD;
break;

case LEASH:
selectedMode = FollowAlgorithm.FollowModes.LEASH;
break;

case CIRCLE:
selectedMode = FollowAlgorithm.FollowModes.CIRCLE;
break;

case LEFT:
selectedMode = FollowAlgorithm.FollowModes.LEFT;
break;

case RIGHT:
selectedMode = FollowAlgorithm.FollowModes.RIGHT;
break;

default:
selectedMode = null;
break;
}
final FollowAlgorithm.FollowModes selectedMode = followTypeToMode(followType);

if (selectedMode != null) {
final Follow followMe = this.droneMgr.getFollowMe();
Expand Down Expand Up @@ -907,6 +878,46 @@ public void onReceivedMavLinkMessage(MAVLinkMessage msg) {
}
}

private static FollowAlgorithm.FollowModes followTypeToMode(FollowType followType){
final FollowAlgorithm.FollowModes followMode;

switch (followType) {
case ABOVE:
followMode = FollowAlgorithm.FollowModes.ABOVE;
break;

case LEAD:
followMode = FollowAlgorithm.FollowModes.LEAD;
break;

default:
case LEASH:
followMode = FollowAlgorithm.FollowModes.LEASH;
break;

case CIRCLE:
followMode = FollowAlgorithm.FollowModes.CIRCLE;
break;

case LEFT:
followMode = FollowAlgorithm.FollowModes.LEFT;
break;

case RIGHT:
followMode = FollowAlgorithm.FollowModes.RIGHT;
break;

case SPLINE_LEASH:
followMode = FollowAlgorithm.FollowModes.SPLINE_LEASH;
break;

case SPLINE_ABOVE:
followMode = FollowAlgorithm.FollowModes.SPLINE_ABOVE;
break;
}
return followMode;
}

private static FollowType followModeToType(FollowAlgorithm.FollowModes followMode) {
final FollowType followType;

Expand Down Expand Up @@ -935,6 +946,14 @@ private static FollowType followModeToType(FollowAlgorithm.FollowModes followMod
case ABOVE:
followType = FollowType.ABOVE;
break;

case SPLINE_LEASH:
followType = FollowType.SPLINE_LEASH;
break;

case SPLINE_ABOVE:
followType = FollowType.SPLINE_ABOVE;
break;
}

return followType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,7 @@ static public Intent createIntent(Context context, DroneSharePrefs droneSharePre
}

public static void kickStart(Context context, DroneSharePrefs droneSharePrefs){
if(droneSharePrefs != null && droneSharePrefs.areLoginCredentialsSet() && droneSharePrefs
.isEnabled()) {
if(droneSharePrefs != null && droneSharePrefs.areLoginCredentialsSet() && droneSharePrefs.isEnabled()) {
context.startService(UploaderService.createIntent(context, droneSharePrefs));
}
}
Expand Down
Loading

0 comments on commit 2cfecab

Please sign in to comment.