diff --git a/src/autopilot/KI/KIAutoInit.cpp b/src/autopilot/KI/KIAutoInit.cpp index db22715..e7d78ab 100644 --- a/src/autopilot/KI/KIAutoInit.cpp +++ b/src/autopilot/KI/KIAutoInit.cpp @@ -104,9 +104,16 @@ bool KIAutoInit::update(const tum_ardrone::filter_stateConstPtr statePtr) case STARTED: // wait 6s to reach hight. if(getMS() - stageStarted > reachHeightMS) - { - stageStarted = getMS(); - stage = WAIT_FOR_FIRST; + { + // check that the drone is actually flying + + if (statePtr->droneState >=3 && statePtr->droneState <= 7 ) { + stageStarted = getMS(); + stage = WAIT_FOR_FIRST; + } else { + // something went wrong, try again + stage = NONE; + } } node->sendControlToDrone(node->hoverCommand); return false; diff --git a/src/stateestimation/PTAMWrapper.cpp b/src/stateestimation/PTAMWrapper.cpp index 30fb118..ed39eee 100644 --- a/src/stateestimation/PTAMWrapper.cpp +++ b/src/stateestimation/PTAMWrapper.cpp @@ -1000,7 +1000,11 @@ void PTAMWrapper::on_key_down(int key) bool PTAMWrapper::handleCommand(std::string s) { if(s.length() == 5 && s.substr(0,5) == "space") - { + { + if (mpTracker == 0) { + ROS_INFO("Haven't received the first video frame yet, can't start the tracker"); + return true; + } mpTracker->pressSpacebar(); }