Giter Site home page Giter Site logo

djitellopy's Introduction

DJITelloPy

DJI Tello drone python interface using the official Tello SDK and Tello EDU SDK. This library has the following features:

  • implementation of all tello commands
  • easily retrieve a video stream
  • receive and parse state packets
  • control a swarm of drones
  • support for python >= 3.6

Feel free to contribute!

Install using pip

pip install djitellopy

For Linux distributions with both python2 and python3 (e.g. Debian, Ubuntu, ...) you need to run

pip3 install djitellopy

Install in developer mode

Using the commands below you can install the repository in an editable way. This allows you to modify the library and use the modified version as if you had installed it regularly.

git clone https://github.com/damiafuentes/DJITelloPy.git
cd DJITelloPy
pip install -e .

Usage

API Reference

See djitellopy.readthedocs.io for a full reference of all classes and methods available.

Simple example

from djitellopy import Tello

tello = Tello()

tello.connect()
tello.takeoff()

tello.move_left(100)
tello.rotate_counter_clockwise(90)
tello.move_forward(100)

tello.land()

More examples

In the examples directory there are some code examples. Comments in the examples are mostly in both english and chinese.

Notes

  • If you are using the streamon command and the response is Unknown command means you have to update the Tello firmware. That can be done through the Tello app.
  • Mission pad detection and navigation is only supported by the Tello EDU.
  • Bright environment is necessary for successful use of mission pads.
  • Connecting to an existing wifi network is only supported by the Tello EDU.
  • When connected to an existing wifi network video streaming is not available (TODO: needs confirmation with the new SDK3 port commands)

DJITelloPy in the media and in the wild

Authors

  • Damià Fuentes Escoté
  • Jakob Löw
  • and more

License

This project is licensed under the MIT License - see the LICENSE.txt file for details

djitellopy's People

Contributors

c0dergeorge avatar damiafuentes avatar ehong-tl avatar hyansuper avatar i44p avatar koenigscode avatar leventarican avatar m4gnv5 avatar michalkormanik avatar mustafatokmak avatar oskarzyg avatar ovicus avatar parakh08 avatar tamakijunji avatar trevorm4x avatar walt-h avatar wouter-heerwegh 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

djitellopy's Issues

state fields not available

I have basic commands (connect, takeoff, land, moves) working in WinPython 3.8.2. However, if I do any state queries I get something like the following:

tello.get_battery()


Exception Traceback (most recent call last)
in
----> 1 tello.get_battery()

D:\Users\Dave\WPy64-3850\python-3.8.5.amd64\lib\site-packages\djitellopy\enforce_types.py in wrapper(*args, **kwargs)
43 def wrapper(*args, **kwargs):
44 check_types(spec, *args, **kwargs)
---> 45 return func(*args, **kwargs)
46
47 return wrapper

D:\Users\Dave\WPy64-3850\python-3.8.5.amd64\lib\site-packages\djitellopy\tello.py in get_battery(self)
374 int: 0-100
375 """
--> 376 return self.get_state_field('bat')
377
378 def get_udp_video_address(self) -> str:

D:\Users\Dave\WPy64-3850\python-3.8.5.amd64\lib\site-packages\djitellopy\enforce_types.py in wrapper(*args, **kwargs)
43 def wrapper(*args, **kwargs):
44 check_types(spec, *args, **kwargs)
---> 45 return func(*args, **kwargs)
46
47 return wrapper

D:\Users\Dave\WPy64-3850\python-3.8.5.amd64\lib\site-packages\djitellopy\tello.py in get_state_field(self, key)
219 return state[key]
220 else:
--> 221 raise Exception('Could not get state property ' + key)
222
223 def get_mission_pad_id(self) -> int:

Exception: Could not get state property bat

Thanks for your help!

Velocity giving wrong, accurate position

Tello using the command get_speed() publishes constantly a speed of 10 irrespective of motion. Also, how is possible to get its current position or distance it has travelled?

Increasing sampling rate of state

I'm using tello.get_acceleration_z() to get the acceleration, but I notice that the value that I receive is basically only updated at 10 Hz (even though I call the function more often). Is there a way to increase the sampling rate of the state?

Working in virtual machine

Hi @damiafuentes , i tried to run your code in virtual machine with ubuntu OS inside but it cannot stream the video, but it is able to do takeoff command. Do you have idea to resolve this?

OpenCV Error Video

tello.connect()
tello.streamon()
frame_read = tello.get_frame_read()
tello.takeoff()
tello.move_up(30)
while True:
    img = frame_read.frame
    cv2.imshow("drone", img)
    if cv2.waitKey(1) & 0xff == ord("q"):
        frame_read.stop()
        tello.streamoff()
        tello.land()
        break

The Error I get:

[h264 @ 000001ab71bba300] non-existing PPS 0 referenced
[h264 @ 000001ab71bba300] decode_slice_header error
[h264 @ 000001ab71bba300] no frame!
[h264 @ 000001ab71c17840] error while decoding MB 28 18, bytestream -20

I can see the video after i get enough errors but it causes problems with flight ( just auto-lands) and it is hard to read the console readout with the many errors.

System is windows 10 , i7 , GeForce GTX

In swarm scenario, how to give separate commands to tellos?

Hello,

Trying to give separate commands to tello UAVs in swarm. Want to implement following scenario
-1'st UAV Takes off
-1'st UAV Lands
-2'st UAV Takes off
-3'st UAV Takes off
-2'st UAV Lands
-3'st UAV Lands

Can you help?
Want to try further condition based scenarios (stop/land based on battery level/other UAV status, etc)

Following code gives an error, also tried customizing swarm.py, tello.py but no luck.

Code:

from djitellopy import TelloSwarm

swarm = TelloSwarm.fromIps([
"192.168.1.45",
"192.168.1.46",
"192.168.1.47"
])

swarm[0].connect()
swarm[1].connect()
swarm[2].connect()

swarm[0].takeoff()
swarm[0].land()

swarm[1].takeoff()
swarm[2].takeoff()

swarm[1].land()
swarm[2].land()

swarm[0].end()
swarm[1].end()
swarm[2].end()

name 'client socket' is not defined

Hello,
My script throws an error when I call me.Connect().

Code:

from djitellopy import Tello
import cv2
import threading
import time

# Image settings
useCamera = 1  # 0 for not using camera and 1 for streaming
width = 640  # width of the image
height = 480  # height of the image

# Flight settings
startCounter = 0  # 0 for testing and 1 for flying

# Thread settings
exitFlag = 0

# Connect to Tello drone
me = Tello()
me.connect()  # This is line 23, error starts here
me.for_back_velocity = 0
me.left_right_velocity = 0
me.up_down_velocity = 0
me.yaw_velocity = 0
me.speed = 0
...

Error:
[INFO] tello.py - 424 - Send command: command
Traceback (most recent call last):
File "C:\X\PycharmProjects\TelloProject\TelloDemo.py", line 23, in
me.connect()
File "C:\X\PycharmProjects\DJITelloPy\djitellopy\enforce_types.py", line 45, in wrapper
return func(*args, **kwargs)
File "C:\X\PycharmProjects\DJITelloPy\djitellopy\tello.py", line 518, in connect
self.send_control_command("command")
File "C:\X\PycharmProjects\DJITelloPy\djitellopy\enforce_types.py", line 45, in wrapper
return func(*args, **kwargs)
File "C:\X\PycharmProjects\DJITelloPy\djitellopy\tello.py", line 460, in send_control_command
response = self.send_command_with_return(command, timeout=timeout)
File "C:\X\PycharmProjects\DJITelloPy\djitellopy\enforce_types.py", line 45, in wrapper
return func(*args, **kwargs)
File "C:\X\PycharmProjects\DJITelloPy\djitellopy\tello.py", line 427, in send_command_with_return
client_socket.sendto(command.encode('utf-8'), self.address)
NameError: name 'client_socket' is not defined

I'm using PyCharm with Python 3.9 interpreter. As for packages I tried to install the required opencv-python and numpy versions, but I get the error:

ERROR: Could not find a version that satisfies the requirement opencv-python==3.4.3.18
ERROR: No matching distribution found for opencv-python==3.4.3.18

So currently I'm using the closest version I could install (3.4.13.47)

As for my setup I'm using Windows10, i7 and a GTX960. My computer is connected to the internet via LAN and I connect to the drone via WiFi. The drone is calibrated and its' software is up to date.
I've had this error for quite some time, but while i talked to a friend of mine via discord this error didn't appear at all.
Do I have to specify somewhere, which connection or socket PyCharm is supposed to use while executing my code? If yes, where can I do that?
And are the required versions for opencv-python and numpy mandatory or can I use the latest versions as well?

with kind regards

No Video after StreamOn

I have been able to successfully connect to the tello and see the camera feed using the app. I have also been able to connect and control the tello over my home network using both a raspberry pi & a macbook pro, however I have not been able to see the camera feed.

I've tried running the manual-control-pygame.py example, and while the window opens I see no camera feed at all.

This is the error message I get:OpenCV: Couldn't read video stream from file "udp://@0.0.0.0:11111"

Don't know how to get backgroundframeread to work.

First of all, great library! I am able to send commands and to get video capture going. However i want to capture every single frame and forward it to an external processing module (over http). Can you explain how i could use your library to achieve this?

I am trying to do the following (in short):
frame_read = self.tello.get_frame_read()
encodedFrame = cv2.imencode(".jpg", frame_read)[1].tostring()
response = self.sendFrameForProcessing(encodedFrame)

But i don't seem to get the current frame and i also don't want to block the main thread.
Thanks in advance!

PyPi Package

Hey,

the readme currently reads

The python package at PyPi library is not maintained anymore. I would recommend to install it through git clone.

In my opinion having the ability to install with pip is much easier and gives a lower hurdle for new people to try this library. I am willing to maintain the PyPi packet (push code updates, add a readme etc.).

If you agree @damiafuentes i can begin the process of transferring ownership :)

Video Stream does not work

Hi,

I was trying to get the example.py to work, but video stream does not seem to work. I am using python 3.6.9 on Mac OS.

This is my stdout:

pygame 1.9.4
Hello from the pygame community. https://www.pygame.org/contribute.html
Send command: command
Response: ok
Send command: speed 10
Response: ok
Send command: streamoff
Response: ok
Send command: streamon
Response: ok
[h264 @ 0x7f86968c6600] non-existing PPS 0 referenced
[h264 @ 0x7f86968c6600] non-existing PPS 0 referenced
[h264 @ 0x7f86968c6600] decode_slice_header error
[h264 @ 0x7f86968c6600] no frame!
[h264 @ 0x7f86968c6600] non-existing PPS 0 referenced
[h264 @ 0x7f86968c6600] non-existing PPS 0 referenced
[h264 @ 0x7f86968c6600] decode_slice_header error
[h264 @ 0x7f86968c6600] no frame!
[h264 @ 0x7f86968c6600] non-existing PPS 0 referenced
[h264 @ 0x7f86968c6600] non-existing PPS 0 referenced
[h264 @ 0x7f86968c6600] decode_slice_header error
[h264 @ 0x7f86968c6600] no frame!
[h264 @ 0x7f86968c6600] non-existing PPS 0 referenced
[h264 @ 0x7f86968c6600] non-existing PPS 0 referenced
[h264 @ 0x7f86968c6600] decode_slice_header error
[h264 @ 0x7f86968c6600] no frame!
[h264 @ 0x7f86968c6600] non-existing PPS 0 referenced
[h264 @ 0x7f86968c6600] non-existing PPS 0 referenced
[h264 @ 0x7f86968c6600] decode_slice_header error
[h264 @ 0x7f86968c6600] no frame!
[h264 @ 0x7f86968c6600] non-existing PPS 0 referenced
[h264 @ 0x7f86968c6600] non-existing PPS 0 referenced
[h264 @ 0x7f86968c6600] decode_slice_header error
[h264 @ 0x7f86968c6600] no frame!
[h264 @ 0x7f86968c6600] non-existing PPS 0 referenced
[h264 @ 0x7f86968c6600] non-existing PPS 0 referenced
[h264 @ 0x7f86968c6600] decode_slice_header error
[h264 @ 0x7f86968c6600] no frame!
[h264 @ 0x7f86968c6600] non-existing PPS 0 referenced
[h264 @ 0x7f86968c6600] non-existing PPS 0 referenced
[h264 @ 0x7f86968c6600] decode_slice_header error
[h264 @ 0x7f86968c6600] no frame!
[h264 @ 0x7f86968c6600] non-existing PPS 0 referenced
[h264 @ 0x7f86968c6600] non-existing PPS 0 referenced
[h264 @ 0x7f86968c6600] decode_slice_header error
[h264 @ 0x7f86968c6600] no frame!
[h264 @ 0x7f86968c6600] non-existing PPS 0 referenced
[h264 @ 0x7f86968c6600] non-existing PPS 0 referenced
[h264 @ 0x7f86968c6600] decode_slice_header error
[h264 @ 0x7f86968c6600] no frame!
[h264 @ 0x7f86968c6600] non-existing PPS 0 referenced
[h264 @ 0x7f86968c6600] non-existing PPS 0 referenced
[h264 @ 0x7f86968c6600] decode_slice_header error
[h264 @ 0x7f86968c6600] no frame!
[h264 @ 0x7f86968c6600] non-existing PPS 0 referenced
[h264 @ 0x7f86968c6600] non-existing PPS 0 referenced
[h264 @ 0x7f86968c6600] decode_slice_header error
[h264 @ 0x7f86968c6600] no frame!
[h264 @ 0x7f86968c6600] non-existing PPS 0 referenced
[h264 @ 0x7f86968c6600] non-existing PPS 0 referenced
[h264 @ 0x7f86968c6600] decode_slice_header error
[h264 @ 0x7f86968c6600] no frame!
[h264 @ 0x7f86968c6600] non-existing PPS 0 referenced
[h264 @ 0x7f86968c6600] non-existing PPS 0 referenced
[h264 @ 0x7f86968c6600] decode_slice_header error
[h264 @ 0x7f86968c6600] no frame!
[h264 @ 0x7f86968c6600] non-existing PPS 0 referenced
[h264 @ 0x7f86968c6600] non-existing PPS 0 referenced
[h264 @ 0x7f86968c6600] decode_slice_header error
[h264 @ 0x7f86968c6600] no frame!
[h264 @ 0x7f86968c6600] non-existing PPS 0 referenced
[h264 @ 0x7f86968c6600] non-existing PPS 0 referenced
[h264 @ 0x7f86968c6600] decode_slice_header error
[h264 @ 0x7f86968c6600] no frame!
[h264 @ 0x7f86968c6600] non-existing PPS 0 referenced
[h264 @ 0x7f86968c6600] non-existing PPS 0 referenced
[h264 @ 0x7f86968c6600] decode_slice_header error
[h264 @ 0x7f86968c6600] no frame!
[h264 @ 0x7f86968c6600] non-existing PPS 0 referenced
[h264 @ 0x7f86968c6600] non-existing PPS 0 referenced
[h264 @ 0x7f86968c6600] decode_slice_header error
[h264 @ 0x7f86968c6600] no frame!
[h264 @ 0x7f86968c6600] non-existing PPS 0 referenced
[h264 @ 0x7f86968c6600] non-existing PPS 0 referenced
[h264 @ 0x7f86968c6600] decode_slice_header error
[h264 @ 0x7f86968c6600] no frame!
[h264 @ 0x7f86968c6600] non-existing PPS 0 referenced
[h264 @ 0x7f86968c6600] non-existing PPS 0 referenced
[h264 @ 0x7f86968c6600] decode_slice_header error
[h264 @ 0x7f86968c6600] no frame!
[h264 @ 0x7f86968c6600] non-existing PPS 0 referenced
[h264 @ 0x7f86968c6600] non-existing PPS 0 referenced
[h264 @ 0x7f86968c6600] decode_slice_header error
[h264 @ 0x7f86968c6600] no frame!
[h264 @ 0x7f86968c6600] non-existing PPS 0 referenced
[h264 @ 0x7f86968c6600] non-existing PPS 0 referenced
[h264 @ 0x7f86968c6600] decode_slice_header error
[h264 @ 0x7f86968c6600] no frame!
[h264 @ 0x7f86968c6600] non-existing PPS 0 referenced
[h264 @ 0x7f86968c6600] non-existing PPS 0 referenced
[h264 @ 0x7f86968c6600] decode_slice_header error
[h264 @ 0x7f86968c6600] no frame!
[h264 @ 0x7f86968c6600] non-existing PPS 0 referenced
[h264 @ 0x7f86968c6600] non-existing PPS 0 referenced
[h264 @ 0x7f86968c6600] decode_slice_header error
[h264 @ 0x7f86968c6600] no frame!
[h264 @ 0x7f86968c6600] non-existing PPS 0 referenced
[h264 @ 0x7f86968c6600] non-existing PPS 0 referenced
[h264 @ 0x7f86968c6600] decode_slice_header error
[h264 @ 0x7f86968c6600] no frame!
[h264 @ 0x7f869801c800] error while decoding MB 48 23, bytestream -5
[h264 @ 0x7f869801fe00] error while decoding MB 30 41, bytestream -8

Thanks!

get tempreture

Hi there

Thanks for the awesome work.

Just need to fix the temperature get command. Should be temp? not temperature? as coded.

New Feature - Enhanced Navigation Maneuvers

Proposal for enhanced navigation features such as:

  • collision detection which would force the Tello to move in a safer direction
  • obstacle detection which would allow the Tello to prevent moving in its intended path if something obstructs its flight path
  • swarm coordination preventing two drones from colliding with one another
  • etc.

If anyone hasn't already started, I would be more than willing to start implementing some of these.

Is the swarm control for Tello edu only?

Hi, I am very interested in the swarm control, but the normal version of tello (not tello edu) require the computer to connect to the drone's own wifi at 192.168.10.1, so I wonder if your code can be used to control multiple tello drones at different IPs.

example.py

Thanks for you effort! but, Does this example allows me to take images or videos, and able to save it somewhere? Also, I managed to run the program but after awhile the pygame window just closes itself (managed to took off, then the window shuts) while the drone is flying and it auto lands after awhile...

go_xyz_speed need 7 parameters

When I try to use go_xyz_speed with x y z and speed he asked me 3 more parameters. When I check in definition it says x1,y1,z1,x2,y2,z2,speed
There should be a mistake

IMU error

Heyo. I'm running into an error regarding the imu when trying to control the drone using examply.py.
The drone is able to obtain the video feed and takeoff however it does not respond to any other commands. This is the output I am getting :

image

Somehow its not detecting the imu. I tried recallibrating the IMU and updating to latest firmware through the Tello app. I am able to fly it through the app.

No module named 'djitellopy.decorators'.

Hi! I am running into the following issue when I try running example.py.

Traceback (most recent call last):
  File "example.py", line 1, in <module>
    from djitellopy import Tello
  File "/mnt/c/Users/Anubhav/Documents/Tello/TelloSDKPy/djitellopy/__init__.py", line 1, in <module>
    from .tello import Tello, BackgroundFrameRead
  File "/mnt/c/Users/Anubhav/Documents/Tello/TelloSDKPy/djitellopy/tello.py", line 8, in <module>
    from .decorators import accepts
ModuleNotFoundError: No module named 'djitellopy.decorators'

Do you know what can be causing this? I am on python version 3.7.

No module named 'djitellopy' and 'cv2'

Hello guys,
I have already installed the module "djitellopy" with this command:
pip install -r requirements.txt
My code is:

from djitellopy import Tello
import cv2
import time

tello = Tello()

tello.connect()
tello.takeoff()

tello.move_left(100)
tello.rotate_counter_clockwise(45)

tello.land()
tello.end()

But the shell put in output this:

================ RESTART: /Volumes/HD750/TELLO PYTHON/test 3.py ================
Traceback (most recent call last):
  File "/Volumes/HD750/TELLO PYTHON/test 3.py", line 1, in <module>
    from djitellopy import Tello
ModuleNotFoundError: No module named 'djitellopy'

The same problem appears with cv2:

Traceback (most recent call last):
  File "/Volumes/HD750/TELLO PYTHON/test 3.py", line 2, in <module>
    import cv2
ModuleNotFoundError: No module named 'cv2'

For check the correct work of cv2 I have commented the first line:

#from djitellopy import Tello
import cv2
import time

I haven't any ideas about this problem. You can help me?
Thanks

Elia

Race Condition in swarm

when in a swarm of more than 6-8 drones a race condition arises between threads that are responsible for receiving telemetry and responses to commands. This bug can be fixed if you assign one thread to the swarm, which will receive telemetry and responses, and distribute them among the drones, depending on the ip address. Inside the swarm, you can also store the drones not in the list, but in the dictionary, with the key by ip address.

New Tello "Talent"

There seems to be a new Tello version called Tello "Talent". I assume it is coming out in the near future, as today an update for the Tello iOS App popped up, but i can't find the new model anywhere on the website. The mentioned URL does not seem to work either.

Screenshot of the version history of the iOS app:

related forum post: https://tellopilots.com/threads/ios-app-update-mentions-new-tello-talent-drone.5491/

We'll have to wait and see what is new, and whether we can support the new drone with this library.

All tello drone functions work perfectly except takeoff.

I just started using this library with my new tello drone and I'm quite happy with how well it's working. However, out of all the methods I can call for my tello drone, the only one that doesn't work properly is the drone.takeoff() method. Whenever I call this method, my drone takes off but then after 15-20 seconds it just lands back on the ground. This is the output I get when I call the method:

Timeout exceed on command takeoff
Command takeoff was unsuccessful. Message: False

This bug has occurred when my drone is fully charged and updated to the latest firmware. Is there a workaround/fix to this issue?

Oserror: [winerror 10048] only one usage of each socket address (protocol/network address/port) is normally permitted

Damià, great job! Thanks! I just observed one issue. I can only run my script on Spyder once. The second time I get the following error "Oserror: [winerror 10048] only one usage of each socket address (protocol/network address/port) is normally permitted". I thought tello.end() would close nicely the socket but no. There is a workaround (in cmd.exe, run "netstat -ano|findstr 8889" then "taskkill /F /PID [ProcessID]") but I have to do it manually every time which is not so convenient. DO you have the same issue?

New Feature - GUI

Proposal for GUI-based control of Tello where the user can perhaps select pre-made flight patterns (such as flying in a triangle, square, etc.) or create a new custom pattern for launch. More advanced patterns can be considered, along with buttons to safely land the Tello, etc. Video stream to GUI would also be great.

Can't install on windows10, Ubuntu

As of December 11, 2019, this package cannot be installed on any current platform mostly including Windows 10 and I have tried every solution as per google and still nothing works. I even tried copying and pasting the parts of your code I need in particular(procerssing UDP steam in opencv in a seperate thread) and still nothing works. I have tried experimenting with sections of your code and I cannot seem to get anything to work as far as processing UDP video. I can stream UDP through Opencv2 videocapture by itself and it works fine. When I do the same in a thread, it comes in choppy but still relevant. However, when I apply computer vision, it becomes unmanageable with an almost indefinite delay. I am assuming you have figured out the solution without being able to run your code. Could you shed some light on the process behind processing UDP via python and opencv. I am sure once I delve deep enough and study UDP and networking then the answer will become apparent. Until then, could you enlighten the issue? Why does UDP slow up the main thread and need to be processed in a seperate one? I have having trouble finding information about this. Thanks

get_frame_read() frame is None

Hi all,
I'm interested getting frames and video from Tello. Already at the first stages,
after frame_read = tello.get_frame_read() , frame_read.frame is None
What might be the problem?
Thanks,
Daniel

This is my code:

import time, cv2
from threading import Thread
from djitellopy import Tello

keepRecording = True

def videoRecorder():
# create a VideoWrite object, recoring to ./video.avi
height, width, _ = frame_read.frame.shape
video = cv2.VideoWriter('video.avi', cv2.VideoWriter_fourcc(*'XVID'), 30, (width, height))

while keepRecording:
    video.write(frame_read.frame)
    time.sleep(1 / 30)

video.release()

####################

tello = Tello()
tello.connect()
tello.streamon()

frame_read = tello.get_frame_read()
cv2.imshow('Live Video', frame_read.frame)

recorder = Thread(target=videoRecorder)
recorder.start()

tello.takeoff()
tello.move_up(100)
tello.rotate_counter_clockwise(360)
tello.land()

keepRecording = False

recorder.join() #join thread

Time Between Commands

Hi @damiafuentes .I working with Tello for object detection and I have some questions to you.Firstly ,your code has time between rc commands =0.5 .Is it necessary ?Has offical tello specs this time interval ? Can I send command 0.1 second???

curve_xyz_speed command not working

Our class is using the Tello Edu drones, with SDK 2.0. We use PyCharm to code, but the curve command is not functioning. Our teacher has tried sending direct packets to the drone as well. The return is an error.

Is it possible to obtain the states (vgx,vgy,vgz) of Tello without a mission pad?

Hi, I'm using an origin Tello, not an EDU. I installed djitellopy via Pycharm, then I found that the site package was actually different from the one shown in this repository (tello.py and other files). I'm trying to implement sensor fusion of camera and IMU, using Apriltags. I have successfully got the accelerations in XYZ and angular accelerations as well. It seems to be impossible to get the vgx, vgy, and vgz based the tello.py. However, since we can use some commands to set velocity and let the drone move a certain distance(cm) towards the desired direction, also based on the SDK file given by DJI, I believe all the states are actually available. So I'm wondering how to get vgx, vgy, and vgz without a mission pad.

Query about a few design decisions

I come from an academic background that does not involve robotics or embedded systems and I'm hoping to use your code as a basis for something to share with my students. When I write Python-based libraries to share with students, I do a lot more type checking and parameter validation than you do. Is this a performance issue or are you assuming the users of your code are less likely to do stupid stuff?

I know if I write code that I intend to use just myself, I am much less fanatical about that sort of thing, but when I turn code over to students I want to make sure they get a bit more feedback and never have to wade through stack dumps from errors thrown deep inside some library my code uses.

I see some folks run your code on devices like a Raspberry Pi and your code works with swarms. I'm running the code on a Windows laptop with an 8th gen Intel Core i7 and only working with a single drone, so I'm not seeing performance issues that may be real in other useage scenarios.

For example, you have your code annotated with types so "mypy" can do static type checks, but I don't trust my students to run "mypy" on the combo of their code that uses my library, so I do things like:

def foo(self, x: int):
   x = int(x)
   if x<0:
      ...
   ...

or even

def foo(self, x: int):
   try:
       x = int(x)
   except:
       raise ...
   finally:
      if x < 0: ...
   ...

I expect to file some pull requests and will be more than happy to add more bulletproofing, but before I submitted the PRs, I wanted to make sure I wasn't going to include things that you had purposely excluded because of the potential performance impact. I could make some the extra checking optional with code like so the extra checking was an opt-in thing:

def foo(self, x: int):
   if self.paranoid:
      x = int(x)
      try:
         ...
  ...

Commands all respond with error.

Hi
I cloned this repo and am running this small test script.

#!/usr/bin/env python

#include "ros/ros.h"
#include "std_msgs/String.h"
#include <sstream>

import rospy
from djitellopy import Tello
import cv2
import time

rospy.init_node('dji_tellopy', anonymous=False)

tello = Tello()

connected=tello.connect()
if(connected==True):
print("connected!")
if(connected==False):
print("Not connected!")

now = rospy.Time.now()
seconds=rospy.Time.now()

tello.takeoff()
print("took off")

tello.move_left(10)
print("moved left")

tello.rotate_counter_clockwise(45)
print("rotated")

tello.land()
tello.end()

My Output however, is an error return for all commands:

Screenshot from 2020-03-29 21-31-56

Why could that be? The connection seems to be established and the commands seem fairly simple?
Grateful for any help.
I do realise my code has some misleading outputs (e.g. the prints after the commands, which imply that the command was executed when in fact, it was not)

Best regards,

V

`

enforce_types has broken the package

When I am trying to connect to the drone I get the following error (on Ubuntu 18.04 and Python 3.6.9):

>>> from djitellopy import Tello
>>> tello = Tello()
>>> tello.connect()
Traceback (most recent call last):
File "<input>", line 1, in <module>
  tello.connect()
File "/home/mannykoum/Manos_repos/drone-env/dronenv/lib/python3.6/site-packages/djitellopy
  /enforce_types.py", line 42, in wrapper
  return func(*args, **kwargs)
File "/home/mannykoum/Manos_repos/drone-env/dronenv/lib/python3.6/site-packages/djitellopy
  /tello.py", line 517, in connect
  self.send_control_command("command")
File "/home/mannykoum/Manos_repos/drone-env/dronenv/lib/python3.6/site-packages/djitellopy
  /enforce_types.py", line 41, in wrapper
  check_types(spec, *args, **kwargs)
File "/home/mannykoum/Manos_repos/drone-env/dronenv/lib/python3.6/site-packages/djitellopy
  /enforce_types.py", line 19, in check_types
  if isinstance(type_hint, typing._SpecialForm):
AttributeError: module 'typing' has no attribute '_SpecialForm'

warning: Error opening file (/build/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:901)

I tried to run the script example.py, but the pygame window was none responsive. The flashing light from the tello turns from green to red. Further waiting results in warning messages (See below) to appear.

Printout after running the script:

pygame 1.9.4
Hello from the pygame community. https://www.pygame.org/contribute.html
Send command: command
Response: b'ok'
Send command: speed 10
Response: b'ok'
Send command: streamoff
Response: b'ok'
Send command: streamon
Response: b'ok'
warning: Error opening file (/build/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:901)
warning: udp://@0.0.0.0:11111 (/build/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:902)

Other information:

Windows 10 Home 1803, OS build 17134.523
Tello Firmware: 01.04.78.01
Numpy: 1.11.1+mkl
Opencv-python: 4.0.0.21
Pygame: 1.9.4

NB: The tello firmware was updated after encountering the "unknown command" error:

pygame 1.9.4
Hello from the pygame community. https://www.pygame.org/contribute.html
Send command: command
Response: b'OK'
Send command: speed 10
Response: b'OK'
Send command: streamoff
Response: b'Unkown Command!'
Command streamoff was unsuccessful. Message: Unkown Command!
Could not stop video stream

Update:
I went back to test the movement commands and encountered the following:

Send command: command
Response: b'ok'
Send command: takeoff
Timeout exceed on command takeoff
Command takeoff was unsuccessful. Message: False
Send command: left 100
Timeout exceed on command left 100
Command left 100 was unsuccessful. Message: False
Send command: ccw 45
Response: b'error Not joystick'
Command ccw 45 was unsuccessful. Message: error Not joystick
Send command: cw 45
Response: b'ok'
Send command: right 100
Response: b'ok'
Send command: land
Response: b'error Auto land'
Command land was unsuccessful. Message: error Auto land

I suspect it has to do with the firmware update...

Connection and takeoff error

Hello
Thank you for this amazing library. I have had this working successfully before but am having issues getting it to connect now. It's a new drone, using a new laptop (Windows 10) and a fresh install of Python (3.8.5) and library (whatever PyPi currently has).

I've reverted all the way to using code similar to the demo script

    tello = Tello()
    tello.connect()
    time.sleep(1)
    tello.takeoff()

The terminal output is as follows

tello.py - 186 - Send command: command
tello.py - 203 - Response command: ok
tello.py - 140 - invalid literal for int() with base 10: '-1,-1,-1'
tello.py - 141 - Response was is mid:-1;x:-100;y:-100;z:-100;mpry:-1,-1,-1;pitch:0;roll:0;yaw:0;vgx:0;vgy:0;vgz:0;templ:66;temph:68;tof:6553;h:0;bat:5;baro:118.26;time:0;agx:7.00;agy:0.00;agz:-997.00;

tello.py - 186 - Send command: takeoff
tello.py - 203 - Response takeoff: error
tello.py - 186 - Send command: takeoff
tello.py - 203 - Response takeoff: error
tello.py - 186 - Send command: takeoff
tello.py - 203 - Response takeoff: error
Traceback (most recent call last):
  File "c:/repos/tello-drone-experimenting/demo2-programmed-flight.py", line 44, in <module>
    demo()
  File "c:/repos/tello-drone-experimenting/demo2-programmed-flight.py", line 22, in demo
    tello.takeoff()
  File "c:\repos\tello-drone-experimenting\djitellopy\tello.py", line 334, in takeoff
    if self.send_control_command("takeoff", timeout=20):
  File "c:\repos\tello-drone-experimenting\djitellopy\decorators.py", line 35, in new_f
    return f(*args, **kwds)
  File "c:\repos\tello-drone-experimenting\djitellopy\tello.py", line 273, in send_control_command
    return self.return_error_on_send_command(command, response, self.enable_exceptions)
  File "c:\repos\tello-drone-experimenting\djitellopy\tello.py", line 315, in return_error_on_send_command
    raise Exception(msg)
Exception: Command takeoff was unsuccessful. Message: error

I notice that before the exception generated by the takeoff command, there is an "invalid literal" occurring on the connect command. Any advice on what I am missing would be much appreciated.

Regards

Process finished with exit code -1073741819 (0xC0000005)

Hello,
example.py worked fine and nothing happened, but when I pressed Esc key to stop the program, the program returned the message "Process finished with exit code -1073741819 (0xC0000005)", and I can't understand why this occured.
I'm trying to record a video with opencv using this code, but this problem happened. Can you explain for me?
Thank you and best regards.

Image is reversed

Hello
Thank's for this python interface, it works great !
Only problem I had was the image that was reversed in the example.py, I added a fliplr line 91 before rotating the image and that did the trick.

        frame = np.fliplr(frame)
        frame = np.rot90(frame)

Cheers

The flight status of drone.

I am not sure if the problem appeared because of my drone's hardware.

Compared to use the official app to control the drone, the drone flew lower after taking off when used this package for controlling. And the flight status was also not stable, the drone would fly to an unexpectable direction when hovering after taking off, even though no command was given. But the problem seems not existed when using the official app.

What's more, I noticed a firmware update was pushed by the official app, and I updated it before the test mentioned above. The flight control by this package worked well when Dec 2019, and I finished my experiment smoothly. But today, it did not work well as before. Is this firmware update has changed something internal and caused this problem?

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.