damiafuentes / DJITelloPy

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

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

Closed yorklyb closed 3 years ago

yorklyb commented 3 years ago

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.

M4GNV5 commented 3 years ago

Hey,

yes the vgx, vgy, vgz state values are available on regular tellos. Please make sure you have the newest djitellopy installed. The version on pip is outdated. Try installing it using pip install https://github.com/damiafuentes/DJITelloPy/archive/master.zip

The speed values are availble through the tello.get_speed_x, tello.get_speed_y and tello.get_speed_z functions

yorklyb commented 3 years ago

Hey,

yes the vgx, vgy, vgz state values are available on regular tellos. Please make sure you have the newest djitellopy installed. The version on pip is outdated. Try installing it using pip install https://github.com/damiafuentes/DJITelloPy/archive/master.zip

The speed values are availble through the tello.get_speed_x, tello.get_speed_y and tello.get_speed_z functions

Thank you so much for your reply. I tried to use pip install https://github.com/damiafuentes/DJITelloPy/archive/master.zip and functions like tello.get_speed_x are available but I feel like they are not working.

I tested the functions on my Apriltag tracking demo, then I got this '[INFO] tello.py -450 - Send command (no expect response) : rc 0 10 0 7', which means I was sending forward velocity and yaw velocity to the drone and it worked. But the return I got from get_speed_x,y,z were all zero. However, I'm pretty sure that the drone had a non-zero velocity because I could see the drone moving forward towards my tag.

M4GNV5 commented 3 years ago

Im not sure wether vgx/vgy/vgz work when using send_rc_control. Can you try calling calling get_speed_x while performing a regular control command? Something like the following might shine some light on the problem (based on the record-video.py example):

import time
from threading import Thread
from djitellopy import Tello

tello = Tello()
tello.connect()

keepRunning = True
def statsWriter():
    while keepRunning:
        print("Speeds: ", tello.get_speed_x(), tello.get_speed_y(), tello.get_speed_z())
        time.sleep(0.1)

runner = Thread(target=statsWriter)
runner.start()

printf("Regular controls")
tello.takeoff()
time.sleep(0.5)
tello.move_up(100)
time.sleep(0.5)

print("Switching to RC control")
tello.send_rc_control(50, 0, 0, 0)
time.sleep(0.5)
tello.send_rc_control(-50, 0, 0, 0)
time.sleep(0.5)

tello.land()

keepRecording = False
runner.join()
yorklyb commented 3 years ago

Im not sure wether vgx/vgy/vgz work when using send_rc_control. Can you try calling calling get_speed_x while performing a regular control command? Something like the following might shine some light on the problem (based on the record-video.py example):

import time
from threading import Thread
from djitellopy import Tello

tello = Tello()
tello.connect()

keepRunning = True
def statsWriter():
    while keepRunning:
        print("Speeds: ", tello.get_speed_x(), tello.get_speed_y(), tello.get_speed_z())
        time.sleep(0.1)

runner = Thread(target=statsWriter)
runner.start()

printf("Regular controls")
tello.takeoff()
time.sleep(0.5)
tello.move_up(100)
time.sleep(0.5)

print("Switching to RC control")
tello.send_rc_control(50, 0, 0, 0)
time.sleep(0.5)
tello.send_rc_control(-50, 0, 0, 0)
time.sleep(0.5)

tello.land()

keepRecording = False
runner.join()

Ok, thanks a lot. I will do it recently.

yorklyb commented 3 years ago

Im not sure wether vgx/vgy/vgz work when using send_rc_control. Can you try calling calling get_speed_x while performing a regular control command? Something like the following might shine some light on the problem (based on the record-video.py example):

import time
from threading import Thread
from djitellopy import Tello

tello = Tello()
tello.connect()

keepRunning = True
def statsWriter():
    while keepRunning:
        print("Speeds: ", tello.get_speed_x(), tello.get_speed_y(), tello.get_speed_z())
        time.sleep(0.1)

runner = Thread(target=statsWriter)
runner.start()

printf("Regular controls")
tello.takeoff()
time.sleep(0.5)
tello.move_up(100)
time.sleep(0.5)

print("Switching to RC control")
tello.send_rc_control(50, 0, 0, 0)
time.sleep(0.5)
tello.send_rc_control(-50, 0, 0, 0)
time.sleep(0.5)

tello.land()

keepRecording = False
runner.join()

Ok, thanks a lot. I will do it recently.

Hi,I finally know the reason now. The output of get_speed_x has to be type int and if the velocity is not big enough (for example, 0.5cm/s), the output shall be zero. However, the unit of output of acceleration is in -0.001g so that it is more is precise even if it is also typed int. Thanks again for your help!