Skip to content

Commit 5eba3e5

Browse files
authored
Merge pull request #457 from dronekit/version_3.0.2
Version 3.0.2
2 parents a01f25b + bb8bd90 commit 5eba3e5

File tree

14 files changed

+61
-25
lines changed

14 files changed

+61
-25
lines changed

ClientLib/build.gradle

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ apply plugin: 'com.getkeepsafe.dexcount'
44
ext {
55
VERSION_MAJOR = 3
66
VERSION_MINOR = 0
7-
VERSION_PATCH = 1
7+
VERSION_PATCH = 2
88
VERSION_SUFFIX = "release"
99

1010
PUBLISH_ARTIFACT_ID = 'dronekit-android'
@@ -94,6 +94,7 @@ android {
9494
testOptions {
9595
unitTests.returnDefaultValues = true
9696
}
97+
buildToolsVersion '24.0.1'
9798
}
9899

99100
dependencies {

ClientLib/src/main/java/org/droidplanner/services/android/impl/core/MAVLink/MavLinkStreamRates.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
public class MavLinkStreamRates {
99

10-
public static void setupStreamRates(DataLinkProvider MAVClient, byte sysid, byte compid,
10+
public static void setupStreamRates(DataLinkProvider MAVClient, short sysid, short compid,
1111
int extendedStatus, int extra1, int extra2, int extra3, int position, int rcChannels,
1212
int rawSensors, int rawControler) {
1313
requestMavlinkDataStream(MAVClient, sysid, compid, MAV_DATA_STREAM.MAV_DATA_STREAM_EXTENDED_STATUS,
@@ -22,8 +22,8 @@ public static void setupStreamRates(DataLinkProvider MAVClient, byte sysid, byte
2222
requestMavlinkDataStream(MAVClient, sysid, compid, MAV_DATA_STREAM.MAV_DATA_STREAM_RC_CHANNELS, rcChannels);
2323
}
2424

25-
private static void requestMavlinkDataStream(DataLinkProvider mAVClient, byte sysid,
26-
byte compid, int stream_id, int rate) {
25+
private static void requestMavlinkDataStream(DataLinkProvider mAVClient, short sysid,
26+
short compid, int stream_id, int rate) {
2727
msg_request_data_stream msg = new msg_request_data_stream();
2828
msg.target_system = sysid;
2929
msg.target_component = compid;

ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/DroneVariable.java

+13
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
import timber.log.Timber;
1010

1111
public class DroneVariable<T extends MavLinkDrone> {
12+
13+
static int UNSIGNED_BYTE_MIN_VALUE = 0;
14+
static int UNSIGNED_BYTE_MAX_VALUE = 255;
15+
1216
protected T myDrone;
1317

1418
public DroneVariable(T myDrone) {
@@ -75,4 +79,13 @@ public void run() {
7579
});
7680
}
7781
}
82+
83+
public static short validateToUnsignedByteRange(int id){
84+
if(id < UNSIGNED_BYTE_MIN_VALUE || id > UNSIGNED_BYTE_MAX_VALUE){
85+
throw new IllegalArgumentException("Value is outside of the range of an sysid/compid byte: " + id);
86+
}
87+
return (short)id;
88+
}
89+
90+
7891
}

ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/autopilot/MavLinkDrone.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ public interface MavLinkDrone extends Drone {
2727

2828
void onMavLinkMessageReceived(MAVLinkMessage message);
2929

30-
public byte getSysid();
30+
public short getSysid();
3131

32-
public byte getCompid();
32+
public short getCompid();
3333

3434
public State getState();
3535

ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/autopilot/apm/ArduPilot.java

+6
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,12 @@ protected boolean performTakeoff(Bundle data, ICommandListener listener) {
385385

386386
@Override
387387
public void onMavLinkMessageReceived(MAVLinkMessage message) {
388+
389+
if (message.sysid != this.getSysid()) {
390+
// Reject Messages that are not for the system id
391+
return;
392+
}
393+
388394
int compId = message.compid;
389395
if (compId != AUTOPILOT_COMPONENT_ID
390396
&& compId != ARTOO_COMPONENT_ID

ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/autopilot/generic/GenericMavLinkDrone.java

+8-2
Original file line numberDiff line numberDiff line change
@@ -237,12 +237,13 @@ public boolean isConnectionAlive() {
237237
}
238238

239239
@Override
240-
public byte getSysid() {
240+
public short getSysid() {
241+
241242
return heartbeat.getSysid();
242243
}
243244

244245
@Override
245-
public byte getCompid() {
246+
public short getCompid() {
246247
return heartbeat.getCompid();
247248
}
248249

@@ -574,6 +575,11 @@ private void onHeartbeat(MAVLinkMessage msg) {
574575
@Override
575576
public void onMavLinkMessageReceived(MAVLinkMessage message) {
576577

578+
if (message.sysid != this.getSysid()) {
579+
// Reject Messages that are not for the system id
580+
return;
581+
}
582+
577583
onHeartbeat(message);
578584

579585
switch (message.msgid) {

ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/variables/HeartBeat.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ public class HeartBeat extends DroneVariable implements OnDroneListener<MavLinkD
2424
protected static final int NORMAL_HEARTBEAT = 2;
2525

2626
protected int heartbeatState = FIRST_HEARTBEAT;
27-
private byte sysid = 1;
28-
private byte compid = 1;
27+
private short sysid = 1;
28+
private short compid = 1;
2929

3030
/**
3131
* Stores the version of the mavlink protocol.
@@ -46,11 +46,11 @@ public HeartBeat(MavLinkDrone myDrone, Handler handler) {
4646
myDrone.addDroneListener(this);
4747
}
4848

49-
public byte getSysid() {
49+
public short getSysid() {
5050
return sysid;
5151
}
5252

53-
public byte getCompid() {
53+
public short getCompid() {
5454
return compid;
5555
}
5656

@@ -64,8 +64,8 @@ public short getMavlinkVersion() {
6464
public void onHeartbeat(MAVLinkMessage msg) {
6565
msg_heartbeat heartBeatMsg = msg instanceof msg_heartbeat ? (msg_heartbeat) msg : null;
6666
if(heartBeatMsg != null){
67-
sysid = (byte) msg.sysid;
68-
compid = (byte) msg.compid;
67+
sysid = validateToUnsignedByteRange(msg.sysid);
68+
compid = validateToUnsignedByteRange(msg.compid);
6969
mMavlinkVersion = heartBeatMsg.mavlink_version;
7070
}
7171

ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/waypoints/StructureScannerImpl.java

+8-6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import com.MAVLink.common.msg_mission_item;
44
import com.MAVLink.enums.MAV_CMD;
5+
import com.o3dr.services.android.lib.coordinate.LatLong;
6+
import com.o3dr.services.android.lib.coordinate.LatLongAlt;
57

68
import org.droidplanner.services.android.impl.core.helpers.geoTools.GeoTools;
79
import org.droidplanner.services.android.impl.core.mission.MissionImpl;
@@ -12,15 +14,13 @@
1214
import org.droidplanner.services.android.impl.core.survey.CameraInfo;
1315
import org.droidplanner.services.android.impl.core.survey.SurveyData;
1416
import org.droidplanner.services.android.impl.core.survey.grid.GridBuilder;
15-
import com.o3dr.services.android.lib.coordinate.LatLong;
16-
import com.o3dr.services.android.lib.coordinate.LatLongAlt;
1717

1818
import java.util.ArrayList;
1919
import java.util.List;
2020

2121
public class StructureScannerImpl extends SpatialCoordItem {
22-
private double radius = (10.0);
23-
private double heightStep = (5);
22+
private double radius = 10.0;
23+
private double heightStep = 5;
2424
private int numberOfSteps = 2;
2525
private boolean crossHatch = false;
2626
SurveyData survey = new SurveyData();
@@ -50,10 +50,12 @@ private void packROI(List<msg_mission_item> list) {
5050
}
5151

5252
private void packCircles(List<msg_mission_item> list) {
53-
for (double altitude = coordinate.getAltitude(); altitude <= getTopHeight(); altitude += heightStep) {
54-
CircleImpl circleImpl = new CircleImpl(missionImpl, new LatLongAlt(coordinate, (altitude)));
53+
double altitude = coordinate.getAltitude();
54+
for (int iSteps = 0; iSteps < numberOfSteps; iSteps++) {
55+
CircleImpl circleImpl = new CircleImpl(missionImpl, new LatLongAlt(coordinate, altitude));
5556
circleImpl.setRadius(radius);
5657
list.addAll(circleImpl.packMissionItem());
58+
altitude+= heightStep;
5759
}
5860
}
5961

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
3-
<integer name="core_lib_version">30000</integer>
3+
<integer name="core_lib_version">30200</integer>
44
</resources>

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ DroneKit-Android helps you create powerful Android apps for UAVs.
1414

1515
[DroneKit-Android](http://android.dronekit.io/) is the implementation of [DroneKit](http://dronekit.io/) on Android.
1616

17-
The API provides interfaces that apps can use to control copters, planes, and ground vehicles. It is compatible with vehicles that communicate using the MAVLink protocol (including most vehicles made by 3DR and other members of the DroneCode foundation), and is validated against the open-source [ArduPilot flight control platform](ardupilot.com).
17+
The API provides interfaces that apps can use to control copters, planes, and ground vehicles. It is compatible with vehicles that communicate using the MAVLink protocol (including most vehicles made by 3DR and other members of the DroneCode foundation), and is validated against the open-source [ArduPilot flight control platform](http://ardupilot.com).
1818

1919
This project implements the [DroneKit-Android Client library](http://android.dronekit.io) which allows developers to leverage the DroneKit API.
2020

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ buildscript {
1515
}
1616

1717
dependencies {
18-
classpath 'com.android.tools.build:gradle:1.5.0'
18+
classpath 'com.android.tools.build:gradle:2.2.0'
1919

2020
//Dexcount gradle plugin
2121
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.4.4'

dependencyLibs/Mavlink/build.gradle

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
apply plugin: 'java'
2+
sourceCompatibility = JavaVersion.VERSION_1_7
3+
targetCompatibility = JavaVersion.VERSION_1_7
24

35
sourceSets {
46
main {
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Sun Nov 30 09:39:49 PST 2014
1+
#Sun Oct 09 17:42:15 PDT 2016
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip

samples/StarterApp/build.gradle

+6
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ android {
2222
abortOnError false
2323
}
2424

25+
compileOptions {
26+
sourceCompatibility JavaVersion.VERSION_1_7
27+
targetCompatibility JavaVersion.VERSION_1_7
28+
}
29+
30+
buildToolsVersion '24.0.1'
2531
}
2632

2733
dependencies {

0 commit comments

Comments
 (0)