Skip to content

Commit

Permalink
fix empty vector case.
Browse files Browse the repository at this point in the history
  • Loading branch information
lovettchris committed Jun 5, 2017
1 parent 0672569 commit 7d16c4f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 6 additions & 1 deletion AirLib/src/rpc/RpcLibClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,12 @@ std::string RpcLibClient::getDebugInfo()
//get/set image
vector<uint8_t> RpcLibClient::getImageForCamera(int camera_id, DroneControllerBase::ImageType type)
{
return pimpl_->client.call("getImageForCamera", camera_id, type).as<vector<uint8_t>>();
vector<uint8_t> result = pimpl_->client.call("getImageForCamera", camera_id, type).as<vector<uint8_t>>();
if (result.size() == 1) {
// rpclib has a bug with serializing empty vectors, so we return a 1 byte vector instead.
result.clear();
}
return result;
}


Expand Down
3 changes: 1 addition & 2 deletions DroneShell/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1167,8 +1167,7 @@ class GetImageCommand : public DroneCommand {

auto image = context->client.getImageForCamera(0, imageType);

// size 1 is a trick we had to do to keep RPCLIB happy...
if (image.size() <= 1) {
if (image.size() == 0) {
std::cout << "error getting image, check sim for error messages" << endl;
return;
}
Expand Down

0 comments on commit 7d16c4f

Please sign in to comment.