Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
5edcad6
Update README.md
The1only Jan 5, 2020
0a35f57
First step in uppgrade... NOT working...
The1only Feb 4, 2020
e2afddd
nano
The1only Feb 7, 2020
eca7309
nano
The1only Feb 7, 2020
38af6e9
Noved to DJI SDK 4.11.1, also moved to Androidx
The1only Feb 8, 2020
c81a1a5
Text Updated...
The1only Feb 8, 2020
e6b1497
Got the updated Login screen to work...
The1only Feb 9, 2020
ab3687d
A fix after chrash....
The1only Feb 10, 2020
705c17d
V4.11.1 ´WORKING with video and telemetry...
The1only Feb 10, 2020
41e0011
Working version, still some issues, but it works.
The1only Feb 10, 2020
5e30fb8
just small fixes in credit.
The1only Feb 10, 2020
8a65dff
cleaning up UI
The1only Feb 14, 2020
f181f3f
Added Landscape mode
The1only Feb 21, 2020
3902dc0
Added Landscape mode...
The1only Feb 21, 2020
d9b6be4
Added all new Mavlink 2 commands
The1only Feb 21, 2020
7024adf
Fixed a mavlink error.
The1only Feb 21, 2020
e52db13
Added a built in DJI Simulator, but not working yet, also fixed Mavli…
The1only Feb 21, 2020
3486b79
Added a Simulator for easier development, unstable code.
The1only Feb 25, 2020
a4f4a8e
Added comment
The1only Feb 25, 2020
3262dd6
Initial version with Simulator, got velocity working, and video in ba…
The1only Feb 26, 2020
aa326c0
Added support for pan & tilt on camera using RC channel 8 and 9...
The1only Feb 27, 2020
d6be672
Added comments...
The1only Feb 27, 2020
66821e4
Fixed comment
The1only Feb 27, 2020
b2c9bec
Flying with a joystick from QGroundcontrol now works. But takeoff has…
The1only Feb 27, 2020
2c64f38
Added comments about using joystick
The1only Feb 27, 2020
2c1e862
Fixed layout and work on Mision plan
The1only Feb 28, 2020
49732f0
Work on GUI and added test mode for easier GUI work with no drone.
The1only Feb 28, 2020
0bff13a
Added immage for test...
The1only Feb 28, 2020
2f6b1eb
Testing images
The1only Feb 28, 2020
4112abc
Added a new image...
The1only Feb 28, 2020
c144c11
New image...
The1only Feb 28, 2020
04ba03d
New immage..
The1only Feb 28, 2020
01bc2bb
More text to reame...
The1only Feb 28, 2020
0d46e95
More text fix...
The1only Feb 28, 2020
33ec794
Text layout work....
The1only Feb 28, 2020
9f89b26
Text fix
The1only Feb 28, 2020
fab1d21
Added Comment...
The1only Feb 28, 2020
4aa6bf1
Text fix
The1only Feb 28, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 58 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,40 @@
# Rosetta Drone
# Rosetta Drone for **DJI Mavic 2** series
## Supports Android 8.0 and newer, with DJI SDK 4.11.1 and Androidx

## The project now works on DJI Mavic 2 Pro/Zoom/Enterprise, and got live H.264 video stream out , tested on QGroundcontrol.

## **Please do create issues or create PR on this fork.**

![Image of Opening screen](images/popen.png)
Opening screen, requires DJI login first time...


This version has implemented the new video stream method in DJI SDK that require quite a few modifications. It also includes all the latest libraries, and Androidx.
In the unstable code there is also the DJI simulator, to enable testing in the lab. Android Studio is now updated to 3.6

Rosetta Drone is a Mavlink wrapper for the DJI SDK, which allows users to fly DJI drones using Mavlink-speaking ground control stations. In theory it should work with any Mavlink GCS, but all testing so far has been done with QGroundControl.

*** IMPORTANT SAFETY NOTE *** Due to imperfect translation between DJI and Mavlink, props may begin spinning at unexpected times. Always treat props as if they are live. Use Rosetta Drone's "safety" feature, which *should* prevent the drone from acknowledging unexpected GCS arm or takeoff commands.

The user assumes all responsibility for prevention of harm or damage. This is an evolving, experimental app. See "Known issues" below before use.

![Image of Opening screen](images/Screenshot.png)
Main screen, with live video...


# Features

* Report telemetry in QGC like position, attitude, relative altitude, heading, and battery remaining
* Command Return-to-Launch from QGC
* View drone video feeds in QGC or forward RTP to an IP address of your choice (currently Mavic Pro only)
* View drone video feeds in QGC or forward RTP to an IP address of your choice (currently Mavic Pro 2 only)
* Create and fly waypoint missions
* Fly by joystick and QGS
* Fly from Python in DroneKit
* Use Mavproxy to connect both QGC and DroneKit at the same time
* Use Gstreamer/OpenCV/FFMPEG and DroneKit to create complex AI functions





# Usage
Expand Down Expand Up @@ -39,6 +62,29 @@ Note that if you are using QGroundControl on the same device as RosettaDrone, th

7. After flight, ensure the safety is enabled before approaching props.

8. Support is added for Pan and Tilt of camera gimbal by using RC channel 8 and 9.

###Add this to you're Dronekit python script:

def set_servo(servo,val):
msg = vehicle.message_factory.command_long_encode(
0, # time_boot_ms (not used)
0, # target system, target component
mavutil.mavlink.MAV_CMD_DO_SET_SERVO,
0,
servo, # RC channel...
1500+(val*5.5), # RC value
0, 0, 0, 0, 0)
vehicle.send_mavlink(msg)
vehicle.flush()

And then use: set_servo(8,-45.0) to set the gimbal....


9. Support for **joystick** is added and tested with QGroundcontrol, using the now built in simulator.

10. By taping on the drone icon 5 times, you enable test mode and can open the software with no drone connected. For GUI work.


# Building from source

Expand Down Expand Up @@ -66,7 +112,7 @@ Anyone who speaks multiple languages knows that translations are rarely perfect.

- DJI reports heading in True, which RosettaDrone passes along in vfr_hud.hdg. The mavlink protocol does not specify magnetic or true.

- DJI and Mavlink use different scales to characterize GPS accuracy. DJI also does not report hdop or vdop.
- DJI and Mavlink use different scales to characterise GPS accuracy. DJI also does not report hdop or vdop.

- Radio signal strength is not yet implemented

Expand All @@ -78,19 +124,25 @@ Anyone who speaks multiple languages knows that translations are rarely perfect.

# Known Issues for Users

- Occassionally RosettaDrone will loop through repeated "Connecting to drone..." messages upon plugging in a drone. We believe this is a bug in the DJI SDK. Try restarting the drone, killing RosettaDrone, and restarting it. If that doesn't work, reinstalling the app clears caches and usually solves the problem.

- If you change the UDP port while QGC is running, you may need to restart QGC

- If you change the video UDP port while QGC is running, you may need to restart Rosettadrone

- Some times the Rosetta drone stopps and restarts, work are in progress to eliminate this. Seems to be related to the Mavlik layer.

- If you takeoff using the QGC, and then sett a point and hit goto, the Rosettadrone enters an error state. Work are in progress.

# Known Issues for Developers

RosettaDrone uses MAVLink code generated by the MAVLink code generator, using the ArduPilot dialect. The Java code generator contains errors (see issues [#805](https://github.com/mavlink/mavlink/issues/805) and [#806](https://github.com/mavlink/mavlink/issues/806)), and the code required manual tweaking after generation. This means that simply dropping in updated auto-generated files will likely produce errors.
RosettaDrone uses MAVLink code generated by the MAVLink code generator, using the ArduPilot dialect. The Java code generator contains errors (see issues [#805](https://github.com/mavlink/mavlink/issues/805) and [#806](https://github.com/mavlink/mavlink/issues/806)), and the code required manual tweaking after generation. This means that simply dropping in updated auto-generated files will likely produce errors. At the moment this seems only to apply for setting and getting double that is missing. It is quite easy to copy the float function and modify it to double. The only usage for this is for ROV wheel distance, so someone should fix that in Mavlink.

The use of an ArduPilot dialect over PX4 is not intended to be a statement of preference. The author believes strongly in the importance of maintaining maximum compatibility across both projects.

# Acknowledgements

Rosetta Drone was brought to you by developers from Rogue Squadron, a UAS/C-UAS red team at the Defense Innovation Unit Experimental.
The updated version was brought to you by eSmartSystems in cooperation with the Defense Drone depatment at 9Tek.

## Icons
Icons made by Pixel Perfect & Freepik at flaticon
Expand All @@ -103,3 +155,4 @@ Rosetta Drone uses a modified version of DJI's [Android Video Stream Decoding Sa

Video RTP packing uses code modified from the [libstreamer](https://github.com/fyhertz/libstreaming) library, licensed under Apache 2.


82 changes: 66 additions & 16 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 27
compileSdkVersion 28
defaultConfig {
applicationId "sq.rogue.rosettadrone"
minSdkVersion 23
targetSdkVersion 27
minSdkVersion 25
targetSdkVersion 28
versionCode 1
versionName "1.2.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
versionName "5.0.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}

dexOptions {
javaMaxHeapSize "4g"
}

buildTypes {
release {
minifyEnabled false
Expand All @@ -28,6 +32,13 @@ android {
}
}

sourceSets {
main {
jni.srcDirs=[]
jniLibs.srcDirs=['../libs']
}
}

packagingOptions {
doNotStrip "*/*/libdjivideo.so"
doNotStrip "*/*/libSDKRelativeJNI.so"
Expand All @@ -38,6 +49,18 @@ android {
doNotStrip "*/*/libFRCorkscrew.so"
doNotStrip "*/*/libUpgradeVerify.so"
doNotStrip "*/*/libFR.so"

// Add the new so
doNotStrip "*/*/libDJIFlySafeCore.so"
doNotStrip "*/*/libdjifs_jni.so"
doNotStrip "*/*/libsfjni.so"

doNotStrip "*/*/libDJICommonJNI.so"
doNotStrip "*/*/libDJICSDKCommon.so"
doNotStrip "*/*/libDJIUpgradeCore.so"
doNotStrip "*/*/libDJIUpgradeJNI.so"

exclude 'META-INF/rxjava.properties'
}
externalNativeBuild {
cmake {
Expand All @@ -46,27 +69,54 @@ android {
}
defaultConfig {
ndk {
abiFilters 'armeabi-v7a' // more could be added
abiFilters 'armeabi-v7a', 'x86', 'arm64-v8a'
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

}
dependencies {
// debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.4'
// releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4'



// classpath 'com.android.tools.build:gradle:6.2.1'

implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
androidTestImplementation('androidx.test.espresso:espresso-core:3.2.0', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:preference-v7:27.1.1'
implementation 'com.android.support:preference-v14:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:design:27.1.1'
testImplementation 'junit:junit:4.12'
implementation 'com.squareup:otto:1.3.8'
implementation('com.dji:dji-sdk:4.11.1', {
/**
* Uncomment the "library-anti-distortion" if your app does not need Anti Distortion for Mavic 2 Pro and Mavic 2 Zoom.
* Uncomment the "fly-safe-database" if you need database for release, or we will download it when DJISDKManager.getInstance().registerApp
* is called.
* Both will greatly reducing the size of the APK.
*/
exclude module: 'library-anti-distortion'
//exclude module: 'fly-safe-database'
})
compileOnly 'com.dji:dji-sdk-provided:4.11.1'

implementation 'androidx.annotation:annotation:1.1.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.preference:preference:1.1.0'
implementation 'androidx.legacy:legacy-preference-v14:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.1.0'
testImplementation 'junit:junit:4.13'
testImplementation 'org.mockito:mockito-core:2.7.22'
testImplementation 'org.mockito:mockito-android:2.7.22'
implementation 'com.dji:dji-sdk:4.6'
compileOnly 'com.dji:dji-sdk-provided:4.6'
implementation 'com.android.support:multidex:1.0.3'
implementation 'androidx.multidex:multidex:2.0.1'

implementation 'androidx.core:core:1.2.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package sq.rogue.rosettadrone;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down
56 changes: 44 additions & 12 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,23 @@
package="sq.rogue.rosettadrone">

<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />

<uses-feature android:name="android.hardware.camera"/>
<uses-feature android:name="android.hardware.camera.autofocus"/>

<uses-feature
android:name="android.hardware.usb.host"
Expand All @@ -32,34 +36,62 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name="sq.rogue.rosettadrone.MainActivity"
android:launchMode="singleInstance">

<activity
android:name="sq.rogue.rosettadrone.ConnectionActivity"
android:launchMode="singleTop">
<!-- android:screenOrientation="portrait"> -->
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<action android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" />

<category android:name="android.intent.category.LAUNCHER"/>
<action android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED"/>
</intent-filter>
<meta-data
android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED"
android:resource="@xml/accessory_filter" />
android:resource="@xml/accessory_filter"/>
</activity>

<activity android:name="sq.rogue.rosettadrone.MainActivity">
<!-- android:screenOrientation="portrait"> -->
<!-- android:launchMode="singleInstance"> -->
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<action android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" />

<!-- <category android:name="android.intent.category.LAUNCHER"/> -->
</intent-filter>
<!-- <meta-data
android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED"
android:resource="@xml/accessory_filter" />
-->
</activity>

<uses-library android:name="org.apache.http.legacy" android:required="false" />

<activity android:name="sq.rogue.rosettadrone.settings.SettingsActivity"
android:theme="@style/AppTheme.Settings"
android:label="Settings">
</activity>

<activity android:name="sq.rogue.rosettadrone.settings.HelpActivity"
android:theme="@style/AppTheme.Settings"
android:label="Settings">
</activity>

<!-- DJI SDK -->
<uses-library android:name="com.android.future.usb.accessory"/>

<meta-data
android:name="com.dji.sdk.API_KEY"
android:value="@string/dji_key"/>

<service android:name="dji.sdk.sdkmanager.DJIGlobalService">
</service>
<service android:name=".video.VideoService">
</service>

<!--
<service android:name="sq.rogue.rosettadrone.video.VideoService">
</service>
-->
<!-- DJI SDK -->
</application>

</manifest>
</manifest>
Loading