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

void Tello::init() #4

Open
TobiasFrahm opened this issue Nov 15, 2020 · 4 comments
Open

void Tello::init() #4

TobiasFrahm opened this issue Nov 15, 2020 · 4 comments

Comments

@TobiasFrahm
Copy link
Contributor

Hello, am I right, that the drone is always initialised? Even if the response.compare("ok") is not true?
Is this intended?

void Tello::init()
{
	udpclient = new WiFiUDP();
	//This initializes udp and transfer buffer
	udpclient->begin(COMMAND_PORT);
	isInitialised = true;
	string response = sendCommand("command");
	//if response is other than "ok" then we consider as error 
	if(response.compare("ok"))
	{
		isInitialised = true;
	}
}

Greetings
Tobi

@akshayvernekar
Copy link
Owner

Hi Tobi,
Good find , I had originally set it to FALSE but since the response to "command" is sent via UDP the response is sometimes lost, this is the reason I had set the isInitialised flag to TRUE when I carried out my tests . I should probably add a comment there .

Also could you check with your tello and let me know if you are able to get the response consistently ? If yes I will change the flag to False.

@TobiasFrahm
Copy link
Contributor Author

TobiasFrahm commented Nov 21, 2020

Hello,
thank you for the Reply. I see your point here, I think the loss of Information due to the UDP is a general problem with this tello API... I think something Asynchronous would be needed here, but we are talking about an controlling API of a flying device...
We cannot block and wait for the response, but it would be great to be sure that the command was processed by the tello.

But anyways, in this certain case, since this is a init-function, I think it would be OK to do something blocking like this:

string Tello::init()
{
	udpclient = new WiFiUDP();
	//This initializes udp and transfer buffer
	udpclient->begin(COMMAND_PORT);
	string response = "nok":
	u_int8_t cnt = 0;
	while (response.compare("ok")){
		response = sendCommand("command");
		delay(500);
		cnt++;
		if (cnt > 10){
			// just don't block forever
			return "error";
		}
	}
		
	//if response is other than "ok" then we consider as error 
	if(response.compare("ok"))
	{
		isInitialised = true;
	}
}

@TobiasFrahm
Copy link
Contributor Author

I observed strange behavior with this. It nearly always works, If i just use it as it was.
If I try my approach, it does not even get in the SDK-Mode with or without response...
I will play around a bit, maybe I will find an answer!

@akshayvernekar
Copy link
Owner

I guess I have faced this issue earlier, if you have already sent the command to enter the SDK mode the drone doesn't send Acknowledgement if the command is sent again for the second time . I don't have my Tello currently to verify but i remember facing this issue.

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