marklauter / TelloAPI-SDK-2.0

Flight Controller for Ryze/DJI Tello Drone in C#
MIT License
28 stars 8 forks source link

Looks nice đź‘Ť #1

Closed ElektroKill closed 5 years ago

ElektroKill commented 5 years ago

Could I have a little tutorial on how to use the video feature? I want to display the video in a winforms picturebox if that’s possible ;)

marklauter commented 5 years ago

Hi. If you're in a hurry, I think you'll find something useful in my fork of TelloLib. I abandoned this fork because the 2.0 version of the text based Tello SDK coupled with the latest firmware on the Tello made the SDK actually reliable. I will be building some video processing into this repo, but based on my current workload it could be a month or two away. Once you look at my fork of TelloLib, I'd be happy to answer any specific questions you have.

This sample is a bit clunk because I was just working out the details of how video worked at the time. The UWP project with the specific example is here: https://github.com/marklauter/TelloLib/tree/master/src/NetStandard/Tello.Video.UWP

The solution file is in the root of the project. Tello.sln (not aTello.sln). Find that here: https://github.com/marklauter/TelloLib

If you unload the two projects under cpp/Interop I think the whole solution will build. Set the UWP project as startup project. All the video code is in the MainPage.xaml.cs file. Important methods to look at are Mss_SampleRequested() and InitializeVideo(). I've gone to a lot of trouble to identify and consolidate frames from the UDP sample stream, but this is unnecessary for just showing the video. I'm hoping to tie it to machine learning at some point, so creating frames seemed to make sense at the time. Every video sample that comes from Tello via UDP could just as easily be fed directly to the Mss_SampleRequested() event and you could skip setting args.Request.Sample.Duration.

This is hacked up sample is based on the info I found here: https://docs.microsoft.com/en-us/windows/uwp/audio-video-camera/process-media-frames-with-mediaframereader

ElektroKill commented 5 years ago

Thanks for the quick response. I noticed that this project is for sdk version 2.0. I have the normal Tello which comes with SDK 1.3 and as far as I am aware there is no way of updating to sdk 2.0 which comes with the Tello EDU. Which project should I use for my drone this one or you fork of TelloLib ?

marklauter commented 5 years ago

I also have the normal Tello. If you upgrade the firmware, most of SDK 2.0 will work. The core features haven't changed, there's just some extras for the mission pad, which I haven't bothered to support anyway. Everything in my API appears to work with the normal Tello, but I don't have 100% code coverage in the tests. For sure I can take off, fly around, receive video, and state, so the basics are solid.

To update the firmware you have to run the DJI Tello App on your phone or tablet. There's an option there to do the update. Make sure your drone battery is fully charged first. Wouldn't want the battery to poop out in the middle of a firmware update. Before I installed the update in December the Tello didn't respond reliably to the text based commands, but the latest firmware seems very solid.

You can see the similarities between 1.3 and 2.0 by checking the SDK docs.

Here's the link to SDK 2.0 https://dl-cdn.ryzerobotics.com/downloads/Tello/Tello%20SDK%202.0%20User%20Guide.pdf

Here's the link to SDK 1.3 https://dl-cdn.ryzerobotics.com/downloads/tello/20180910/Tello%20SDK%20Documentation%20EN_1.3.pdf

ElektroKill commented 5 years ago

Yes I have noticed the commands on my tello sometimes respond with garbage data instead of OK when I wrote my own c# api for version 1.0 of the tello sdk. Hope that the update fixes it.

marklauter commented 5 years ago

For sure the communication got better with the firmware update. There's still a problem where the first call to "command" to enter the SDK mode can return garbage. This requires a reboot of the drone and then reconnect to the network to resolve. I usually close my app too. I added information to the README for the repo last night and talked about that a bit.