damiafuentes / DJITelloPy

DJI Tello drone python interface using the official Tello SDK. Feel free to contribute!
MIT License
1.26k stars 493 forks source link

Commands all respond with error. #37

Closed vec123 closed 4 years ago

vec123 commented 4 years ago

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

`

M4GNV5 commented 4 years ago

takeoff usually fails when the battery is low. You could try to add a

print(tello.get_battery())

right after your call to tello.connect

vec123 commented 4 years ago

Hi, thanks for your response. I tried that out, and indeed, it seems my battery was not high enough for a take-off. After loading my drone, it takes off. However all messages still respond with an error and the move_left command is not executed.... here is my console output.

Screenshot from 2020-03-30 14-41-39

The drone takes off (eventhough the Message corresponding to this command states a False), stays in the air (a bit shaky) and eventually lands. It sais: "out of range" at some point, but the distance isn't more than 2 meters (probably even less than 1). Why could that be? Why isn't my left command executed and all other commands respond with an error? Additionally, my drone is very unstable in the air and drifts backwards during and after the take_off. Is that normal and something that needs to be handled by me or should the drone control its position itself, so that it doesn't drift around after a take_off?

Thank you again for any help. Best regards, V

M4GNV5 commented 4 years ago

The drone should control its position itself, but it sounds like your drone needs calibration. You can calibrate it using the official app (it asks you to remove all propellers and put the drone on each side for a few seconds). Aditionally as the drone flight stability is mainly based on camera it might help to turn on the light in your room.

How long does the takeoff command take until the error appears? Usually when the tello cant orient itself to a stable flight position the takeoff command takes longer to complete. The djitellopy library has a command timeout of 7 seconds which might not be enough for the takeoff command, especially in dark environments and/or bad calibration.

it seems like you are calling tello.move_left(10) for 10cm, the minimal allowed distance is 20cm, thus it is out of range. Try tello.move_left(20).

The ccw 45 command returns ok, so apart from the above everything looks fine.

smorad commented 4 years ago

Great library, thanks for releasing this!

I'm also seeing an issue with rotation commands failing in the same way. Do you know what causes these failures? They're intermittent in that they succeed maybe 20% of the time. This is with a fully charged battery.

tello.py - 186 - Send command: ccw 30
I0428 15:20:42.096289 140313620674304 tello.py:186] Send command: ccw 30
tello.py - 203 - Response ccw 30: error Auto land
I0428 15:20:42.162065 140313620674304 tello.py:203] Response ccw 30: error Auto land
tello.py - 186 - Send command: ccw 30
I0428 15:20:42.171342 140313620674304 tello.py:186] Send command: ccw 30
tello.py - 203 - Response ccw 30: error Auto land
I0428 15:20:42.204935 140313620674304 tello.py:203] Response ccw 30: error Auto land
tello.py - 186 - Send command: ccw 30
I0428 15:20:42.214517 140313620674304 tello.py:186] Send command: ccw 30
tello.py - 203 - Response ccw 30: error Auto land

Could this be caused by bad lighting/calibration? Or would that only cause instability/wandering?

lucasg1 commented 4 years ago

I also had these problems, I had to do some simple steps that we sometimes forget, make sure to check these every time you're starting a new flight:

Obs: I think these observations should be in the main page, should save a lot of time for new pilots...