Git Product home page Git Product logo

windows-sdk's Introduction

DJI Windows SDK

What Is This?

The DJI Windows SDK enables you to automate your DJI Product on a PC. You can control flight, and many subsystems of the product including the camera and gimbal. Using the DJI Windows SDK, create a customized UWP (Universal Windows Platform) app to unlock the full potential of your DJI aerial platform.

The Latest Version

The latest SDK version is Public Beta 0.3.2.

Get Started Immediately

Prerequisites

To use DJI Windows SDK, the following environments are required:

  • A PC or a laptop.
  • Windows 10.
  • Visual Studio 2017.
  • Windows 10 SDK, version 1803.

Supported Products

The supported DJI products include Mavic 2 Enterprise, Mavic 2 Enterprise Dual, Mavic 2 Pro/Zoom, Phantom 4 Pro V2.0+ (remote controller with screen), Mavic Air and Phantom 4 Pro V2.

For Mavic Air, only WiFi connection is supported. Therefore, the PC or the laptop should have a WiFi adapter.

For Phantom 4 Pro V2, USB connection is supported. Setup the connection with the following steps:

  • Install DJI Assistant 2 on the PC.
  • Ensure the remote controller has firmware version 01.00.200 or above. Use DJI GO 4 or DJI Assistant 2 to upgrade the remote controller if the firmware is old.
  • Make sure the remote controller is powered off.
  • Use a USB cable to connect PC with the remote controller. CAUTION: Use the mini-USB port of the remote controller instead of the Type A port.
  • Power on the remote controller.
  • Go to Device Manager of Windows. If the remote controller is connected successfully, you should see two devices in the list: Remote NDIS based Internet Sharing Device #1 and DJI USB Virtual COM (COM1). The number and the COM index may show differently across PC machines.

Insert the following XML code to Package.appxmanifest of your application:

<DeviceCapability Name="serialcommunication">
    <Device Id="vidpid:2ca3 001f">
	    <Function Type="name:serialPort" />
    </Device>
</DeviceCapability>

This can enable the permission to access to the COM port in your UWP application. This step is done in the sample code already.

CAUTION: It is necessary to power off the remote controller first and connect it to PC after. The remote controller will determine whether to enable PC mode during booting. If the remote controller disconnects from the PC, it has to be powered off before re-connecting to the PC.

Generate APP Key

To enable DJI Windows SDK, developers will need to register applications with an APP key. This is also required to run the sample in this repository. Follow the steps to create the APP key:

Go to the DJI Developer Center

  • Select the "Apps" tab on the left.
  • Select the "Create App" button on the right.
  • Enter the name, platform, UWP package name, category and description of the application.
  • An application activation email will be sent to complete App Key generation.
  • The App Key will appear in the user center, and can be copied and pasted into the application.

Run Sample Code

Git clone this repository. Open DJIWindowsSDKSample.sln. Because the dependencies and the video parser has been configured in this sample, just compile and run it using x86 as the architecture.

To start browsing all the features in the sample, you have to input the APP key. Following the previous section and use "com.wsdk.sample" as the package name to generate an APP key.

After SDK registers successfully, you should see the full list of features.

SDK API Reference

DJI Windows SDK API Documentation

FFmpeg Customization

We have forked the original FFmpeg and added customized features to provide more video frame information including the frame's width and height, frame rate number, etc. These features will help to implement video hardware decoding.

The sample is dynamically linked with modified libraries of FFmpeg licensed under the LGPLv2.1. The source code of these FFmpeg libraries, the compilation instructions, and the LGPL v2.1 license are provided in Github.

Support

You can get support from [email protected]

windows-sdk's People

Contributors

dji-dev avatar djilucas avatar oliverou avatar talobin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

windows-sdk's Issues

Where can I get the <djiwindowssdk/sdkmanager.h>?

already download winsdows sdk Public beta 0.2.0
but ....i can't find these file.
#include <djiwindowssdk/sdkmanager.h>
#include <djiwindowssdk/videofeed.h>
#include <djiwindowssdk/videofeeder.h>
#include <djiwindowssdk/virtualremotecontroller.h>

mavic air remote control connect windows pc issue

Hi all

Currently, I am trying to use a Mavic Air to get pictures taken by the drone. But I follow the steps to connect remote control with windows pc, always failure. My environment is:
*Windows 10 x64 pro.
*Visual Studio 2017.
*DJI Assistant 2 Installed.
If anyone knows how to check or solve the connection issue? it would be greatly appreciated!

Thanks and cheers!

Problem in "Integrate WSDK into Application" Tutorial

Hi, I follow this tutorial https://developer.dji.com/windows-sdk/documentation/application-development-workflow/workflow-integrate.html

I have this error:
Severity Code Description Project File Line Suppression State
Error CS7069 Reference to type 'Task<>' claims it is defined in 'System.Runtime', but it could not be found DJIWSDKDemo C:\Users\almendro.avellano\source\repos\DJIWSDKDemo\DJIWSDKDemo\MainPage.xaml.cs 61 Active

image

If I comment that lines and run it, show me the next error:
System.Reflection.TargetInvocationException
HResult=0x80131604
Message=Exception has been thrown by the target of an invocation.
Source=
StackTrace:

Inner Exception 1:
FileLoadException: Could not load file or assembly 'System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

image

I am using VS 2019.. Thanks for your help

Mavic 2 enterprise video feed not working

Hi! I'm trying to get a sample application working displaying a live video feed but none of the sample applications I have tried so far has worked. I have:

  • updated both the drone (V01.01.0640) and the controller (V01.01.0410) to the latest version through DJI Assistant 2 For Mavic
  • have the latest version of windows-sdk (0.3.2)
  • completed all the steps of installing the correct usb drivers to the controller from here
  • made sure to connect the controller through the micro-usb cable to the computer before turning the controller on but the live video still wont play.
  • I have read #32 and I'm not using the smart controller

This is how my device manager looks:
image Basic things like getting the name of the drone works fine:
image but the video stream wont work:
image
I got the sample application from here
I have also tried running both examples in this tutorial but it also had the same problem. Thanks for any help!

How to continuously handle ReceiveDecodeData

Hi, I plan to feed each frames of video took by FPV camera to opencv in real time to do some analysis. I found that the ReceiveDecodedData is handled by SetSurfaceAndVideoCallback, so I assume there is a loop inside this function to continuously capture the incoming data. My question is, how do I handle ReceiveDecodedData by loop(while or for). Or if you can provide sample code that meet my goal then that will be awesome. Thanks.

Virtual Remote Controller Issue

Hi, I am trying to use the virtual joystick to operate my mavic air, but there is no response after I call the method. The following is how I call it:
private void forward(object sender, RoutedEventArgs e) { DJI.WindowsSDK.DJISDKManager.Instance.VirtualRemoteController.UpdateJoystickValue(0,0, 1,0); }
to have the drone fly forward, and this function will be called by set the Click of a xaml button points to this function. Can you help me with this issue?

DJI Windows SDK Sample - cannot view FPV mode

I've cloned Windows SDK repo, open the sample solution with latest visual studio, fixed the dll ref for Windows SDK x86, build the solution on x86 and activated the sample app with my key.

I've turned on WiFi mode on my DJI Mavic Air and connected my laptop to its WiFi, but nothing get displayed on the FPV screen:
image

posted as well on stackoverflow.

Can't move gimbal in yaw or roll - mavic 2 enterprise dual

So I have this code:

            Task<ResultValue<GimbalAttitudeRange?>> tskGimbalGet = DJISDKManager.Instance.ComponentManager.GetGimbalHandler(0, 0).GetGimbalAttitudeRangeAsync();
            await tskGimbalGet;
            System.Diagnostics.Debug.WriteLine("Gimbal range max yaw: " + tskGimbalGet.Result.value.Value.yaw.max.ToString());
            System.Diagnostics.Debug.WriteLine("Gimbal range min yaw: " + tskGimbalGet.Result.value.Value.yaw.min.ToString());

            System.Diagnostics.Debug.WriteLine("Gimbal range max roll: " + tskGimbalGet.Result.value.Value.roll.max.ToString());
            System.Diagnostics.Debug.WriteLine("Gimbal range min roll: " + tskGimbalGet.Result.value.Value.roll.min.ToString());

            System.Diagnostics.Debug.WriteLine("Gimbal range max pitch: " + tskGimbalGet.Result.value.Value.pitch.max.ToString());
            System.Diagnostics.Debug.WriteLine("Gimbal range min pitch: " + tskGimbalGet.Result.value.Value.pitch.min.ToString());

but it returns this:

Gimbal range max yaw: 0
Gimbal range min yaw: 0
Gimbal range max roll: 0
Gimbal range min roll: 0
Gimbal range max pitch: 0
Gimbal range min pitch: -90

which suggests that the gimbal can only change pitch. I tried rotating on the yaw axis anyways and got a PARAM_OUT_OF_RANGE error. Am I doing something wrong? Does this work on the android SDK?

What should be value of ProductIndex?

HI,

I am using following function. What should be value of parameter ProductIndex?

VideoFeeder.GetPrimeryVideoFeed(int ProductIndex)

Thanks,
Savan

Cannot install USB driver on remote controller

I tried installing the WinUSB driver for my Mavic 2 enterprise remote controller using Zadig, but the controller was not detected in the COM ports of my computer. Attached is a screenshot of Zadig showing no devices found.
zadigScreenshot
Has anyone ran into this before?

Unable to init sdk for side-loaded UWP app

64bit Build failed

The DJIVideo-Parser has some 3rdParty Libs that are not 64 bit (e.g. avcodec.lib,avformat.lib,swscale.lib,avutil.lib)

List of supported drones

Any chance of of having additional DJI drones supported (e.g. M series or P4 pro)?

Thanks
Niki

Set thermal resolution to 336 x 256

Hi! The Mavic 2 enterprise dual is supposed to support the resolution 336 x 256 but the enum VideoResolution doesn't contain that resolution and I can't find any thermal specific resolution setter.

Sample Flight Plan

Hello Fellow Enthusiasts!

I may be simply overlooking the documentation and the sample code, but, I was unable to find a simple example of a flight path for the drone. I was wondering what the proper procedures are for taking off, moving, pausing, and landing (particularly auto landing). I have some code already, it runs, the drone executes, but it appears the drone does something different every time. I figured it's how I'm attempting to use the provided functions. So if there is any possibility to look at a sample flight plan, it would be greatly appreciated!

Cheers!

DJIWindowsSDKSample_x86 does not compile

I encountered with an error Cannot resolve Assembly or Windows Metadata file 'Windows-SDK-master\Sample Code\Debug\DJIVideoParser\DJIVideoParser.winmd' while compiling DJIWindowsSDKSample_x86.

I downloaded the SDK and followed the instruction on README.md, but it didn't work.
It seemed that DJIVideoParser haven't been compiled (even it is included in the dependencies of the sample project), and no files are generated.

This didn't help. I tried the x64 version, and I also reinstalled Visual Studio 2017, and neither of them did work.

UpdateJoystickValue is not working

I tried to control the drone with the virtual remote controller. But nothing happens (no Exception is thrown, the drone's (DJI Phantom 4 V2 Pro) position does not change). As mentioned in the API: the drone is flying while I send the UpdateJoystick command.

E.g. :for changing the drones altitude I use the following code: DJISDKManager.Instance.VirtualRemoteController.UpdateJoystickValue(0.5f, 0.0f 0.0f 0.0f);

'DJI.WindowsSDK.DJISDKManager' threw an exception.

Fellow Developers,

I downloaded the most recent release in hopes to update my DLLs and be able to move forward with the new SDK. I can build the project but when I try to execute my app, it errors with the following:

'DJI.WindowsSDK.DJISDKManager' threw an exception. - Inner Exception.
FileNotFoundException: The specified module could not be found. (Exception from HRESULT: 0x8007007E)

I've re-pulled the repo, using both Visual Studio 2017 and the 2019 Preview, I then tried the sample SDK and got the same error. I'm currently on Windows Build 17763.292. Is there something I'm missing?

Thanks!

Failed SDK registration.

When I try to activate the SDK I get:

SDK_REGISTRATION_PACKAGE_ID_DOES_NOT_MATCH

Any suggestions?

I did have to generate a new package certificate to get things to build.

GetIsFlyingAsync() BoolMsg Result

Hello Fellow Pilots!

I'm currently trying to take off and then get the current state of the drone. I have three buttons, one for takeoff, one for landing, and one to check the state of the drone. The launch and land work perfect, but when I try to get the state of the drone, it crashes every time. Here's my code:

private void BtnGetStatus_Click(object sender, RoutedEventArgs e)
        {
            var isFlying = flightController.GetIsFlyingAsync();
            status.Text = isFlying.Result.value.ToString();
        }

I'm all ears! Cheers!

At Waypoint mission, Upload Mission is finished incompletely.

I want to execute Waypoint Mission.

So I'm running the method and checking the error message in the following order.
Init Mission -> SetGroundStationMode -> LoadMission -> GetLoadedMission -> UploadMission -> StartMission

There was no problem until LoadMission, but there was a problem with UploadMission.

The waypoint is uploaded one by one, uploaded to the last mission and returned to the "READY_TO_UPLOAD" state, or the "UPLOADING" state is maintained.

The code used is the one that successfully executed Waypoint Mission in MAVIC 2 ENTERPRISE.

code:

private async void Mission_execute(object sender, RoutedEventArgs a)
        {
            BoolMsg yn = new BoolMsg();
            yn.value = true;
            SDKError err = await DJISDKManager.Instance.ComponentManager.GetFlightControllerHandler(0, 0).SetGroundStationModeEnabledAsync(yn);
            Debug.WriteLine("GSM err : " + err.ToString());
            DJISDKManager.Instance.WaypointMissionManager.GetWaypointMissionHandler(0).StateChanged += Waypoint_Mission_State;

            err = DJISDKManager.Instance.WaypointMissionManager.GetWaypointMissionHandler(0).LoadMission(this.WaypointMission);
            if (err != SDKError.NO_ERROR)
            {
                String dialogMsg = "Failed to Load => " + err.ToString();
                Debug.WriteLine(dialogMsg);
                return;
            }
            else Debug.WriteLine("Success to Load");

            err = await DJISDKManager.Instance.WaypointMissionManager.GetWaypointMissionHandler(0).UploadMission();
            if (err != SDKError.NO_ERROR)
            {
                String dialogMsg = "Failed to upload => " + err.ToString();
                Debug.WriteLine(dialogMsg);
                return;
            }
            else
            {
                Debug.WriteLine("Success to Upload");
                DJISDKManager.Instance.WaypointMissionManager.GetWaypointMissionHandler(0).UploadStateChanged += Upload_State;
            }

            err = await DJISDKManager.Instance.WaypointMissionManager.GetWaypointMissionHandler(0).StartMission();
            if (err != SDKError.NO_ERROR)
            {
                String dialogMsg = "Failed to start mission => " + err.ToString();
                Debug.WriteLine(dialogMsg);
                return;
            }
            else Debug.WriteLine("Success to Start");

        }

My development environment is like this:
OS : Windows 10
IDE : Visual Studio 2019
Development Language: C#
Drone: MAVIC 2 ZOOM (Firmware: V01.00.0510(latest firware)) & MAVIC AIR
SDK Version: 0.3.1

Support for Enterprise Dual?

Hey Team,

Currently trying to create applications utilizing the Mavic Enterprise Dual via Windows SDK, and cannot get any video feed via the two sample applications provided or through other attempts to configure and obtain the feed.

The SDK states that it supports the Mavic Dual, but through some forum information from other members and the difficulties we have had, its seeming like that is not the case.

I've only found bits and pieces of those developing for the dual, none of which were success stories.

Could the dev team or others confirm if the M2ED is supported in the Windows SDK, or any help/direction in obtaining the feed in the sample applications or custom applications?

Thanks!

Get the thermal camera feed on the mavic mavic 2 enterprise dual

Hi! I'm trying to get the live feed from the thermal camera. I'm currently running the code that's under the section "Implementing the First Person View" in this article and have added this:

public MainPage()
{
    ...
    Task.Run(enableThermal);
}

private async void enableThermal()
{
    // Wait until camera has booted
    await Task.Delay(TimeSpan.FromSeconds(5));

    CameraDisplayModeMsg msg = new CameraDisplayModeMsg
    {
        value = CameraDisplayMode.THERMAL_ONLY
    };
    DJISDKManager.Instance.ComponentManager.GetCameraHandler(0, 0).SetCameraDisplayModeAsync(msg);
}

But nothing happens when I run it. To get the reason why it failed I ran this:

Task<SDKError> tsk = DJISDKManager.Instance.ComponentManager.GetCameraHandler(0, 0).SetCameraDisplayModeAsync(msg);
await Task.Delay(TimeSpan.FromSeconds(1));

System.Diagnostics.Debug.WriteLine("Tsk status: " + tsk.Result.ToString());

Then I got: Tsk status: REQUEST_HANDLER_NOT_FOUND
I also tried running this:

Task<SDKError> tsk = DJISDKManager.Instance.ComponentManager.GetCameraHandler(0, 0).SetVideoResolutionFrameRateAsync(new VideoResolutionFrameRate { resolution = VideoResolution.RESOLUTION_1920x1080 });
await Task.Delay(TimeSpan.FromSeconds(1));

System.Diagnostics.Debug.WriteLine("Tsk status: " + tsk.Result.ToString());

But then I got: Tsk status: SYSTEM_ERROR. So maybe this is a problem with async tasks in general?

Programmatic Access to SD/On-board Storage

Hello Mavic friends!

Currently, I am trying to use a Mavic Air in a production environment. To be able to maximize performance and productivity, I need to be able to get pictures taken by the drone on to the computer that is controlling it. I almost have the programmatic flight down, but I need to be able to get the pictures off. I don't believe that there is anything currently in the SDK for making a connection the storage, but it would be a nice feature (especially considering it is in the mobile SDK).

If anyone knows how to make any sort of connection (SSH, FPT, SFTP, TELNET, etc) it would be greatly appreciated!

Thanks and cheers!

Could you provide simple example for VirtualRemoteController

Hello. I used to use the bebop. It supports the various language.
I want to move to DJI. It seems like it is very complex rather than Bebop python sdk.
Could you provide any simple example using by Virtual Remote controller?
I usually use the vision based approach rather than GPS.
Thank you.

Connection Guide for DJI Mavic 2 Enterprise

I noticed on the latest release notes that the Mavic 2 Enterprise was now supported for the Windows SDK. Where can I find the USB authority configuration for this product?

Unit and Coordinate system of SDK

Hi,
I was wondering the exact meaning of unit of latitude and longitude used in this SDK. As I know, 1 degree is about 69 miles when we talk about geology, it will be unreasonable if we apply this unit. So I was wondering what does the degree here means, like 1 degree = ?. In addition, I also want to know the start point of the coordinate system. Is it a ego-centric coordinates system or it starts from where the drone taking off? Thanks!

Video feed over WIFI with Mavic Air

The sample application will not display the video from my Mavic Air over wifi. Is this supported? I can't get the video feed to display in my own UWP application either following the integration instructions exactly.

Onvideopush recieves a populated byte array but it wont display on my SwapChainPanel.

DJISDKManager.Instance.VideoFeeder.GetPrimaryVideoFeed(0).VideoDataUpdated += OnVideoPush;

Also for some reason this is never called. The converted RGBA frame is what I'm most interested in. Is there some way to get this callback to work?

//Decode data. Do nothing here. This function would return a bytes array with image data in RGBA format.
private static void ReceiveDecodedData(byte[] data, int width, int height){}

Multiple drone suppory

Is there a support for multiple drone connections? in example, making multiple flight plans and ordering different drones against each flight plan. gz#24427

FlightController events like AttitudeChanged and VelocutyChanged only fire once

After the drone connects I do the following:

fc = DJISDKManager.Instance.ComponentManager.GetFlightControllerHandler(0, 0);
fc.AltitudeChanged += Instance_AircraftAltitudeEvent;
fc.VelocityChanged += Instance_VelocityEvent;

and the event handlers look like this:

        private void Instance_AircraftAttitudeEvent(object sender, Attitude? value)
        {
            if(value.HasValue)
            {
                Attitude att = value.Value;
                System.Diagnostics.Debug.WriteLine("Attitude event: " + att.pitch + " " + att.roll + " " + att.yaw);
            }
        }

        private void Instance_VelocityEvent(object sender, Velocity3D? value)
        {
            if (value.HasValue)
            {
                Velocity3D velocity = value.Value;
                System.Diagnostics.Debug.WriteLine("Velocity event: " + velocity.x + " " + velocity.y + " " + velocity.z);
            }
        }

But the output I get is only this:

Velocity event: 0 0 0
Attitude event: 7.5 -0.2 -13.2

Regardless of how much I fly around.

DJIVideoParser: H264_Decoder should use PIX_FMT_RGB24

The current FFMPEG pixel format used by the video parser is PIX_FMT_RGBA, which is 4 bytes per pixel. Since the alpha byte is always 0xff, you can save 25% of your buffer space by using PIX_FMT_RGB24 instead. You will need to change all the "* 4" to "* 3" (or define BYTES_PER_PIXEL and use that instead), plus change the VideoFeedRenderer::HandleImageTexture to use GL_RGB instead of GL_RGBA.

Bug in UpdateJoystickValue() API

Hi, I'm testing Windows SDK 0.3.1. I noticed there's a bug in api.

in class VirtualRemoteController,
the method
void UpdateJoystickValue(float throttle, float roll, float pitch, float yaw)

parameters roll and yaw are misplaced.
for example, doing UpdateJoystickValue(0,1,0,0) makes mavic air rotate about Z-axis(yaw).
and UpdateJoystickValue(0,0,0,1) makes mavic air rotate about longitudinal (X, roll) axis.

I think it is unintended result. wish to be fixed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.