Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ClientLib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apply plugin: 'com.android.library'
ext {
VERSION_MAJOR = 2
VERSION_MINOR = 9
VERSION_PATCH = 0
VERSION_PATCH = 1
VERSION_SUFFIX = "release"

PUBLISH_ARTIFACT_ID = 'dronekit-android'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@ public abstract class SoloMessageShot extends TLVPacket {
public static final int SHOT_SELFIE = 0;
public static final int SHOT_ORBIT = 1;
public static final int SHOT_CABLECAM = 2;
public static final int SHOT_ZIPLINE = 3;
public static final int SHOT_FOLLOW = 5;
public static final int SHOT_MPCC = 6;
public static final int SHOT_PANO = 7;
public static final int SHOT_REWIND = 8;
public static final int SHOT_TRANSECT = 9;
public static final int SHOT_RETURN_HOME = 10;

/*
Site Scan shots
Expand Down Expand Up @@ -78,6 +83,21 @@ public static CharSequence getShotLabel(Context context, int shotType) {
case SHOT_SCAN:
return context.getString(R.string.label_scan);

case SHOT_ZIPLINE:
return context.getString(R.string.label_zipline);

case SHOT_PANO:
return context.getString(R.string.label_pano);

case SHOT_REWIND:
return context.getString(R.string.label_rewind);

case SHOT_RETURN_HOME:
return context.getString(R.string.label_return_home);

case SHOT_TRANSECT:
return context.getString(R.string.label_transect);

default:
return null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
package com.o3dr.services.android.lib.drone.companion.solo.tlv;

import android.os.Parcel;
import android.support.annotation.IntDef;

import java.nio.ByteBuffer;

/**
* Created by phu on 6/24/16.
*/
public class SoloPanoOptions extends TLVPacket {

public static final int MESSAGE_LENGTH = 12;

/**
* Pano can automatically run, is it running?
*/
private static final int PANO_ON_VALUE = 1;
private static final int PANO_OFF_VALUE = 0;

private boolean isRunning;

/**
* Pano has multiple sub modes
*/
@IntDef({
PANO_PREFERENCE_CYLINDRICAL,
PANO_PREFERENCE_SPHERICAL,
PANO_PREFERENCE_VIDEO
})
public @interface PanoPreference{}

public static final int PANO_PREFERENCE_CYLINDRICAL = 0;
public static final int PANO_PREFERENCE_SPHERICAL = 1;
public static final int PANO_PREFERENCE_VIDEO = 2;
@PanoPreference
private int panoPreference;

/**
* Pan angle (used in cylindrical)
*/
private short panAngle;

/**
* Yaw speed (used in video)
*/
private float degreesPerSecondYawSpeed;

/**
* Camera FOV
*/
private float cameraFOV;

public boolean isRunning() {
return isRunning;
}

public void setRunning(boolean running) {
isRunning = running;
}

@PanoPreference
public int getPanoPreference() {
return panoPreference;
}

public void setPanoPreference(@PanoPreference int panoPreference) {
this.panoPreference = panoPreference;
}

public short getPanAngle() {
return panAngle;
}

public void setPanAngle(short panAngle) {
this.panAngle = panAngle;
}

public float getDegreesPerSecondYawSpeed() {
return degreesPerSecondYawSpeed;
}

public void setDegreesPerSecondYawSpeed(float degreesPerSecondYawSpeed) {
this.degreesPerSecondYawSpeed = degreesPerSecondYawSpeed;
}

public float getCameraFOV() {
return cameraFOV;
}

public void setCameraFOV(float cameraFOV) {
this.cameraFOV = cameraFOV;
}

public SoloPanoOptions(int panoPreference, boolean isRunning, short panAngle, float degreesPerSecondYawSpeed, float cameraFOV) {
super(TLVMessageTypes.TYPE_SOLO_PANO_OPTIONS, MESSAGE_LENGTH);
this.panoPreference = panoPreference;
this.isRunning = isRunning;
this.panAngle = panAngle;
this.degreesPerSecondYawSpeed = degreesPerSecondYawSpeed;
this.cameraFOV = cameraFOV;
}

SoloPanoOptions(ByteBuffer buffer) {
this(buffer.get(), buffer.get() == PANO_ON_VALUE, (short) buffer.getShort(), buffer.getFloat(), buffer.getFloat());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@phmagic the first parameter is an int, so buffer.getInt() should be used instead.
buffer.getShort() doesn't need a cast as well.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@phmagic nevermind, I see below you're storing the panoPreference as a byte.

}

@Override
protected void getMessageValue(ByteBuffer valueCarrier) {
valueCarrier.put((byte) panoPreference);
valueCarrier.put((byte) (isRunning ? 1 : 0));
valueCarrier.putShort(panAngle);
valueCarrier.putFloat(degreesPerSecondYawSpeed);
valueCarrier.putFloat(cameraFOV);
}

@Override
public void writeToParcel(Parcel dest, int flags) {
super.writeToParcel(dest, flags);
dest.writeByte((byte) panoPreference);
dest.writeByte(isRunning ? (byte) 1 : (byte) 0);
dest.writeInt(panAngle);
dest.writeFloat(degreesPerSecondYawSpeed);
dest.writeFloat(cameraFOV);
}

protected SoloPanoOptions(Parcel in) {
super(in);
@PanoPreference int panoPreference = (int)in.readByte();
this.panoPreference = panoPreference;
this.isRunning = in.readByte() != 0;
this.panAngle = (short) in.readInt();
this.degreesPerSecondYawSpeed = in.readFloat();
this.cameraFOV = in.readFloat();
}

public static final Creator<SoloPanoOptions> CREATOR = new Creator<SoloPanoOptions>() {
public SoloPanoOptions createFromParcel(Parcel source) {
return new SoloPanoOptions(source);
}

public SoloPanoOptions[] newArray(int size) {
return new SoloPanoOptions[size];
}
};

@Override
public String toString() {
return "SoloPanoOptions{" +
"panoPreference=" + panoPreference +
"isRunning=" + isRunning +
"panAngle=" + panAngle +
"degreesPerSecondYawSpeed=" + degreesPerSecondYawSpeed +
"cameraFOV=" + cameraFOV +
'}';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package com.o3dr.services.android.lib.drone.companion.solo.tlv;

import android.os.Parcel;

import java.nio.ByteBuffer;

/**
* Created by phu on 7/17/16.
*/
public class SoloPanoStatus extends TLVPacket {

public static final int MESSAGE_LENGTH = 2;

private byte currentStep;
private byte totalSteps;

public SoloPanoStatus(byte currentStep, byte totalSteps) {
super(TLVMessageTypes.TYPE_SOLO_PANO_STATUS, MESSAGE_LENGTH);
this.currentStep = currentStep;
this.totalSteps = totalSteps;
}

SoloPanoStatus(ByteBuffer buffer) {
this(buffer.get(), buffer.get());
}

@Override
protected void getMessageValue(ByteBuffer valueCarrier) {
valueCarrier.put(currentStep);
valueCarrier.put(totalSteps);
}

@Override
public void writeToParcel(Parcel dest, int flags) {
super.writeToParcel(dest, flags);
dest.writeByte(currentStep);
dest.writeByte(totalSteps);
}

protected SoloPanoStatus(Parcel in) {
super(in);
this.currentStep = in.readByte();
this.totalSteps = in.readByte();
}

public static final Creator<SoloPanoStatus> CREATOR = new Creator<SoloPanoStatus>() {
public SoloPanoStatus createFromParcel(Parcel source) {
return new SoloPanoStatus(source);
}
public SoloPanoStatus[] newArray(int size) {
return new SoloPanoStatus[size];
}
};

@Override
public String toString() {
return "SoloPanoStatus{" +
"currentStep=" + currentStep +
"totalSteps=" + totalSteps +
'}';
}

public int getCurrentStep() {
return currentStep;
}

public int getTotalSteps() {
return totalSteps;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package com.o3dr.services.android.lib.drone.companion.solo.tlv;

import android.os.Parcel;

import com.o3dr.services.android.lib.coordinate.LatLongAlt;

import java.nio.ByteBuffer;

/**
* Created by phu on 7/21/16.
*/
public class SoloReturnHomeLocationMessage extends TLVPacket {

private LatLongAlt coordinate;

public SoloReturnHomeLocationMessage(double latitude, double longitude, float altitudeInMeters) {
super(TLVMessageTypes.TYPE_RTL_HOME_POINT, 20);
this.coordinate = new LatLongAlt(latitude, longitude, altitudeInMeters);
}

public SoloReturnHomeLocationMessage(LatLongAlt coordinate){
super(TLVMessageTypes.TYPE_RTL_HOME_POINT, 20);
this.coordinate = coordinate;
}

public LatLongAlt getCoordinate() {
return coordinate;
}

public void setCoordinate(LatLongAlt coordinate) {
this.coordinate = coordinate;
}

@Override
protected void getMessageValue(ByteBuffer valueCarrier) {
valueCarrier.putDouble(coordinate.getLatitude());
valueCarrier.putDouble(coordinate.getLongitude());
valueCarrier.putFloat((float) coordinate.getAltitude());
}

@Override
public void writeToParcel(Parcel dest, int flags) {
super.writeToParcel(dest, flags);
dest.writeParcelable(this.coordinate, flags);
}

protected SoloReturnHomeLocationMessage(Parcel in) {
super(in);
this.coordinate = in.readParcelable(LatLongAlt.class.getClassLoader());
}

public static final Creator<SoloReturnHomeLocationMessage> CREATOR = new Creator<SoloReturnHomeLocationMessage>() {
public SoloReturnHomeLocationMessage createFromParcel(Parcel source) {
return new SoloReturnHomeLocationMessage(source);
}

public SoloReturnHomeLocationMessage[] newArray(int size) {
return new SoloReturnHomeLocationMessage[size];
}
};
}
Loading