Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot control the Tello using keystrokes #1

Open
mhered opened this issue Jul 11, 2023 · 1 comment
Open

Cannot control the Tello using keystrokes #1

mhered opened this issue Jul 11, 2023 · 1 comment

Comments

@mhered
Copy link

mhered commented Jul 11, 2023

Hello,

first, thank you for taking to the time to publish such a nice library to play with the Tello using C++.

I am not sure this is an issue or it's my improper use of the library, but I figured it may happen to other people so I decided to ask here.

I cannot get the Tello to respond to keystrokes using tello.move(), I keep getting error messages:

[Tello] Failed to send command 'rc 0.000000 0.000000 0.000000 0.000000': Timeout waiting for response
[Tello] Failed to send command 'rc 0.000000 0.000000 -5.000000 0.000000': Timeout waiting for response
[Tello] Failed to send command 'rc 0.000000 0.000000 0.000000 0.000000': Timeout waiting for response

Comms seem fine, because I do get the Tello to take off, send video stream, move around e.g. using turn_right() / turn_left() and land. The problem is with controlling it in real time with the keyboard using move().

I assume it is to do with an incorrect configuration of delays and/or not capturing properly the keystrokes.

I tried two different approaches:

I also played with different values of delays using tello.sleep() to speed up or slow down the control loop

... but all attempts failed similarly.

Any idea of what I am doing wrong?

Thanks for your help!

@HerrNamenlos123
Copy link
Owner

Hi! Thank you for opening this issue!

Unfortunately I do not have a tello with me to test anything. I took a look at the code at https://github.com/mhered/cpp_100daysofcode/tree/main/code/Day053_18-05-23/Tello, but I can't spot a major mistake. Given the error message you are seeing, it seems like the response is not working. Are you sure everything else is working properly? Do all other commands work? What if you simply call takeoff, turn_left() and move() in a row with hardcoded values (preferrably zero), does it work in itself?

I modified the execute_command function to print the command instead of sending it and always return ok. This way, it seems like everything is working, when i press the keys in the window, the value changes. I tried it in Ubuntu/WSL because I don't have OpenCV on Windows.

You can take a look at send_request() in tello.hpp, it is responsible for actually sending and receiving the commands. Also, there is a #define TELLO_DEFAULT_COMMAND_TIMEOUT which you can alter. send_request() works in a way that it sends the command via one UDP Client and then waits for a response on another UDP Server. As soon as data arrives, this is the response, the function returns, and the response is evaluated. That means, if no data arrives, you will have the timeout you are seeing, or if it is somehow missed.

Please check yourself what the response for the rc command is or what it should be, you can also modify the function to simply print the response before returning. Maybe I just never tested the rc command and it does not actually send any response. Please check that.

I hope you can do a bit more investigation, I cannot help you directly because I have no tello for testing. PRINTF_DEBUG is your friend :)
Things you should check:

  • Does the move() command work at all or just not in this context?
  • Modify some functions in tello.hpp (especially send_request()):
    • What command is really being sent?
    • What response is sent back?
    • If at all, how long does it take?
    • There is a difference between 'commands' and 'actions'
    • Modify TELLO_DEFAULT_COMMAND_TIMEOUT (or action timeout) for testing only, no command should ever take longer than 1 sec
  • Use Wireshark to sniff what packets are actually being sent, to check if the UDP server misses it

Let me know if you know more!

mhered added a commit to mhered/cpp_100daysofcode that referenced this issue Jul 17, 2023
- `main.cpp`:
   - activate `tello.hpp` instead of `tello_dummy.hpp`
   - move `#include "tello.hpp"` before `#include "oldPixelGameEngine.h"`
     otherwise it does not compile
- `tello_dummy.hpp`:
   - redefine `sleep()` to receive milliseconds instead of seconds
- open issue #1 in original repo: HerrNamenlos123/tello#1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants