telloArduino icon indicating copy to clipboard operation
telloArduino copied to clipboard

void Tello::init()

Open TobiasFrahm opened this issue 3 years ago • 4 comments

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

TobiasFrahm avatar Nov 15 '20 09:11 TobiasFrahm

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.

akshayvernekar avatar Nov 16 '20 13:11 akshayvernekar

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 avatar Nov 21 '20 13:11 TobiasFrahm

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!

TobiasFrahm avatar Nov 21 '20 17:11 TobiasFrahm

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.

akshayvernekar avatar Nov 22 '20 05:11 akshayvernekar