Unit 8, Exercise 8.6: I am trying to make the drone takeoff, move, and land at a set interval while the action is happening. I am not quite understanding the behavior of the drone in response to the following code that I wrote. First, if I put the nested For loops as shown, the drone will repeatedly takeoff, move around, and land, but at the end although the print statement executes and says landed, the drone remains moving around no matter what goal time sent. What is happening here?
Second, if I comment out the nest For loops and leave the inside statements as they are, the drone will not do anything the first iteration of the while loop, but will execute the remaining iterations except for the last one where again, it does not land although the output says it landed. Why doesn’t it do anything the first iteration?
Lastly, I can make the drone takeoff, move, and land from the command line by publishing once each to the respective topics. The only restriction seems to be that the drone has to have taken off before I can move or land it which makes sense. Since it takes just one command from the command line to, say, takeoff, why does it take a loop in the cpp and constantly publishing a few times to do the same thing? I am not talking about only getstatus() loop which I understand is needed to do things in parallel to an action. It seems even if I make the drone takeoff before the action goes active, I need to put it in a loop. Why so?