Skip to content

Commit

Permalink
move common code to check connection to client, enable show all files…
Browse files Browse the repository at this point in the history
… in projects
  • Loading branch information
sytelus committed Jul 4, 2017
1 parent 6aa2a1f commit f3371e1
Show file tree
Hide file tree
Showing 12 changed files with 154 additions and 123 deletions.
3 changes: 3 additions & 0 deletions AirLib/AirLib.vcxproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ShowAllFiles>true</ShowAllFiles>
</PropertyGroup>
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
Expand Down
2 changes: 2 additions & 0 deletions AirLib/include/rpc/RpcLibClient.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ class RpcLibClient {
bool isOffboardMode();
bool isSimulationMode();
std::string getDebugInfo();
void confirmConnection();


//request image
vector<uint8_t> getImageForCamera(int camera_id, VehicleCamera::ImageType type);
Expand Down
31 changes: 31 additions & 0 deletions AirLib/src/rpc/RpcLibClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,37 @@ std::string RpcLibClient::getDebugInfo()
return pimpl_->client.call("getDebugInfo").as<std::string>();
}

void RpcLibClient::confirmConnection()
{
ClockBase* clock = ClockFactory::get();

// make sure we can talk to the DroneServer
//std::cout << "Contacting DroneServer..." << std::flush;
//command_context.client.ping();
//std::cout << "DroneServer is responding." << std::endl;

std::cout << "Waiting for connection - " << std::flush;
const TTimeDelta pause_time = 1;
while (getConnectionState() != RpcLibClient::ConnectionState::Connected)
{
std::cout << "X" << std::flush;
clock->sleep_for(pause_time);
}
std::cout << "Connected!" << std::endl;

std::cout << "Waiting for drone to report a valid GPS location..." << std::flush;
auto gps = getGpsLocation();
int count = 0;
while (gps.latitude == 0 && gps.longitude == 0 && gps.altitude == 0 && count++ < 10)
{
std::cout << "." << std::flush;
clock->sleep_for(pause_time);
gps = getGpsLocation();
}
std::cout << std::endl;
std::cout << "Global position: lat=" << gps.latitude << ", lon=" << gps.longitude << ", alt=" << gps.altitude << std::endl;
}

//get/set image
vector<uint8_t> RpcLibClient::getImageForCamera(int camera_id, VehicleCamera::ImageType type)
{
Expand Down
3 changes: 3 additions & 0 deletions AirLibUnitTests/AirLibUnitTests.vcxproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ShowAllFiles>true</ShowAllFiles>
</PropertyGroup>
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
Expand Down
3 changes: 3 additions & 0 deletions DroneServer/DroneServer.vcxproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ShowAllFiles>true</ShowAllFiles>
</PropertyGroup>
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
Expand Down
3 changes: 3 additions & 0 deletions DroneShell/DroneShell.vcxproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ShowAllFiles>true</ShowAllFiles>
</PropertyGroup>
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
Expand Down
Loading

0 comments on commit f3371e1

Please sign in to comment.