Skip to content

Commit

Permalink
Wait for valid GPS position at beginning of DroneShell.
Browse files Browse the repository at this point in the history
  • Loading branch information
lovettchris committed Apr 8, 2017
1 parent 23fd080 commit 8ca70ca
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion DroneShell/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1140,7 +1140,7 @@ int main(int argc, const char *argv[]) {
return -1;
}

CommandContext command_context{ /*RpcClient*/{server_address}, /*AsyncTasker*/ {} };
CommandContext command_context{ /*RpcClient*/{server_address}, /*AsyncTasker*/ {} };

command_context.tasker.setErrorHandler([](std::exception& e) {
try {
Expand All @@ -1160,6 +1160,21 @@ int main(int argc, const char *argv[]) {
Microsoft Research (c) 2016.
)");


std::cout << "Waiting for drone to report a valid GPS location...";
const float pause_time = 1;
auto gps = command_context.client.getGpsLocation();
while (gps.latitude == 0 && gps.longitude == 0 && gps.altitude == 0)
{
std::cout << ".";
std::this_thread::sleep_for(std::chrono::duration<double>(pause_time));
gps = command_context.client.getGpsLocation();
}

cout << std::endl;
cout << "Global position: lat=" << gps.latitude << ", lon=" << gps.longitude << ", alt=" << gps.altitude << std::endl;


//Shell callbacks
// shell.beforeScriptStartCallback(std::bind(&beforeScriptStartCallback, std::placeholders::_1, std::placeholders::_2));
// shell.afterScriptEndCallback(std::bind(&afterScriptEndCallback, std::placeholders::_1, std::placeholders::_2));
Expand Down

0 comments on commit 8ca70ca

Please sign in to comment.