Skip to content

Commit

Permalink
rename VehicleCameraBase -> ImageCaptureBase
Browse files Browse the repository at this point in the history
  • Loading branch information
sytelus committed Dec 6, 2017
1 parent 6a8f22c commit 547dff4
Show file tree
Hide file tree
Showing 27 changed files with 75 additions and 75 deletions.
2 changes: 1 addition & 1 deletion AirLib/AirLib.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<ClInclude Include="include\common\UpdatableObject.hpp" />
<ClInclude Include="include\common\VectorMath.hpp" />
<ClInclude Include="include\common\common_utils\AsyncTasker.hpp" />
<ClInclude Include="include\controllers\VehicleCameraBase.hpp" />
<ClInclude Include="include\controllers\ImageCaptureBase.hpp" />
<ClInclude Include="include\controllers\VehicleConnectorBase.hpp" />
<ClInclude Include="include\vehicles\car\api\CarApiBase.hpp" />
<ClInclude Include="include\vehicles\multirotor\api\MultirotorRpcLibAdapators.hpp" />
Expand Down
6 changes: 3 additions & 3 deletions AirLib/AirLib.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,6 @@
<ClInclude Include="include\physics\DebugPhysicsBody.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\controllers\VehicleCameraBase.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\api\ControlServerBase.hpp">
<Filter>Header Files</Filter>
</ClInclude>
Expand Down Expand Up @@ -468,6 +465,9 @@
<ClInclude Include="include\vehicles\multirotor\controllers\RealMultirotorConnector.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\controllers\ImageCaptureBase.hpp">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\safety\ObstacleMap.cpp">
Expand Down
32 changes: 16 additions & 16 deletions AirLib/include/api/RpcLibAdapatorsBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include "common/Common.hpp"
#include "common/CommonStructs.hpp"
#include "controllers/VehicleCameraBase.hpp"
#include "controllers/ImageCaptureBase.hpp"
#include "safety/SafetyEval.hpp"
#include "rpc/msgpack.hpp"

Expand Down Expand Up @@ -199,7 +199,7 @@ class RpcLibAdapatorsBase {

struct ImageRequest {
uint8_t camera_id;
msr::airlib::VehicleCameraBase::ImageType image_type;
msr::airlib::ImageCaptureBase::ImageType image_type;
bool pixels_as_float;
bool compress;

Expand All @@ -208,17 +208,17 @@ class RpcLibAdapatorsBase {
ImageRequest()
{}

ImageRequest(const msr::airlib::VehicleCameraBase::ImageRequest& s)
ImageRequest(const msr::airlib::ImageCaptureBase::ImageRequest& s)
{
camera_id = s.camera_id;
image_type = s.image_type;
pixels_as_float = s.pixels_as_float;
compress = s.compress;
}

msr::airlib::VehicleCameraBase::ImageRequest to() const
msr::airlib::ImageCaptureBase::ImageRequest to() const
{
msr::airlib::VehicleCameraBase::ImageRequest d;
msr::airlib::ImageCaptureBase::ImageRequest d;
d.camera_id = camera_id;
d.image_type = image_type;
d.pixels_as_float = pixels_as_float;
Expand All @@ -228,18 +228,18 @@ class RpcLibAdapatorsBase {
}

static std::vector<ImageRequest> from(
const std::vector<msr::airlib::VehicleCameraBase::ImageRequest>& request
const std::vector<msr::airlib::ImageCaptureBase::ImageRequest>& request
) {
std::vector<ImageRequest> request_adaptor;
for (const auto& item : request)
request_adaptor.push_back(ImageRequest(item));

return request_adaptor;
}
static std::vector<msr::airlib::VehicleCameraBase::ImageRequest> to(
static std::vector<msr::airlib::ImageCaptureBase::ImageRequest> to(
const std::vector<ImageRequest>& request_adapter
) {
std::vector<msr::airlib::VehicleCameraBase::ImageRequest> request;
std::vector<msr::airlib::ImageCaptureBase::ImageRequest> request;
for (const auto& item : request_adapter)
request.push_back(item.to());

Expand All @@ -258,15 +258,15 @@ class RpcLibAdapatorsBase {
bool pixels_as_float;
bool compress;
int width, height;
msr::airlib::VehicleCameraBase::ImageType image_type;
msr::airlib::ImageCaptureBase::ImageType image_type;

MSGPACK_DEFINE_MAP(image_data_uint8, image_data_float, camera_position,
camera_orientation, time_stamp, message, pixels_as_float, compress, width, height, image_type);

ImageResponse()
{}

ImageResponse(const msr::airlib::VehicleCameraBase::ImageResponse& s)
ImageResponse(const msr::airlib::ImageCaptureBase::ImageResponse& s)
{
pixels_as_float = s.pixels_as_float;

Expand All @@ -289,9 +289,9 @@ class RpcLibAdapatorsBase {
image_type = s.image_type;
}

msr::airlib::VehicleCameraBase::ImageResponse to() const
msr::airlib::ImageCaptureBase::ImageResponse to() const
{
msr::airlib::VehicleCameraBase::ImageResponse d;
msr::airlib::ImageCaptureBase::ImageResponse d;

d.pixels_as_float = pixels_as_float;

Expand All @@ -312,17 +312,17 @@ class RpcLibAdapatorsBase {
return d;
}

static std::vector<msr::airlib::VehicleCameraBase::ImageResponse> to(
static std::vector<msr::airlib::ImageCaptureBase::ImageResponse> to(
const std::vector<ImageResponse>& response_adapter
) {
std::vector<msr::airlib::VehicleCameraBase::ImageResponse> response;
std::vector<msr::airlib::ImageCaptureBase::ImageResponse> response;
for (const auto& item : response_adapter)
response.push_back(item.to());

return response;
}
static std::vector<ImageResponse> from(
const std::vector<msr::airlib::VehicleCameraBase::ImageResponse>& response
const std::vector<msr::airlib::ImageCaptureBase::ImageResponse>& response
) {
std::vector<ImageResponse> response_adapter;
for (const auto& item : response)
Expand All @@ -337,7 +337,7 @@ class RpcLibAdapatorsBase {

MSGPACK_ADD_ENUM(msr::airlib::SafetyEval::SafetyViolationType_);
MSGPACK_ADD_ENUM(msr::airlib::SafetyEval::ObsAvoidanceStrategy);
MSGPACK_ADD_ENUM(msr::airlib::VehicleCameraBase::ImageType);
MSGPACK_ADD_ENUM(msr::airlib::ImageCaptureBase::ImageType);


#endif
6 changes: 3 additions & 3 deletions AirLib/include/api/RpcLibClientBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include "common/Common.hpp"
#include "common/CommonStructs.hpp"
#include "controllers/VehicleCameraBase.hpp"
#include "controllers/ImageCaptureBase.hpp"


namespace msr { namespace airlib {
Expand All @@ -21,8 +21,8 @@ class RpcLibClientBase {
ConnectionState getConnectionState();
bool ping();

vector<VehicleCameraBase::ImageResponse> simGetImages(vector<VehicleCameraBase::ImageRequest> request);
vector<uint8_t> simGetImage(int camera_id, VehicleCameraBase::ImageType type);
vector<ImageCaptureBase::ImageResponse> simGetImages(vector<ImageCaptureBase::ImageRequest> request);
vector<uint8_t> simGetImage(int camera_id, ImageCaptureBase::ImageType type);
msr::airlib::GeoPoint getHomeGeoPoint();

void simSetPose(const Pose& pose, bool ignore_collision);
Expand Down
6 changes: 3 additions & 3 deletions AirLib/include/api/VehicleApiBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#define air_VehicleApiBase_hpp

#include "common/CommonStructs.hpp"
#include "controllers/VehicleCameraBase.hpp"
#include "controllers/ImageCaptureBase.hpp"

namespace msr { namespace airlib {

Expand All @@ -17,8 +17,8 @@ class VehicleApiBase {
virtual bool isApiControlEnabled() const = 0;
virtual void reset() = 0;

virtual vector<VehicleCameraBase::ImageResponse> simGetImages(const vector<VehicleCameraBase::ImageRequest>& request) = 0;
virtual vector<uint8_t> simGetImage(uint8_t camera_id, VehicleCameraBase::ImageType image_type) = 0;
virtual vector<ImageCaptureBase::ImageResponse> simGetImages(const vector<ImageCaptureBase::ImageRequest>& request) = 0;
virtual vector<uint8_t> simGetImage(uint8_t camera_id, ImageCaptureBase::ImageType image_type) = 0;

virtual void simSetPose(const Pose& pose, bool ignore_collision) = 0;
virtual Pose simGetPose() = 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

#ifndef air_VehicleCameraBase_hpp
#define air_VehicleCameraBase_hpp
#ifndef air_ImageCaptureBase_hpp
#define air_ImageCaptureBase_hpp

#include "common/Common.hpp"
#include "common/common_utils/EnumFlags.hpp"

namespace msr { namespace airlib {

// This is an abstraction for cameras associated with a vehicle. Each camera has a unique id.
class VehicleCameraBase
class ImageCaptureBase
{
public: //types
enum class ImageType : uint { //this indexes to array
Expand All @@ -26,14 +26,14 @@ class VehicleCameraBase

struct ImageRequest {
uint8_t camera_id;
VehicleCameraBase::ImageType image_type;
ImageCaptureBase::ImageType image_type;
bool pixels_as_float;
bool compress;

ImageRequest()
{}

ImageRequest(uint8_t camera_id_val, VehicleCameraBase::ImageType image_type_val, bool pixels_as_float_val = false, bool compress_val = true)
ImageRequest(uint8_t camera_id_val, ImageCaptureBase::ImageType image_type_val, bool pixels_as_float_val = false, bool compress_val = true)
{
camera_id = camera_id_val;
image_type = image_type_val;
Expand Down
4 changes: 2 additions & 2 deletions AirLib/include/controllers/VehicleConnectorBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#define air_VehicleConnectorBase_hpp

#include "VehicleControllerBase.hpp"
#include "VehicleCameraBase.hpp"
#include "ImageCaptureBase.hpp"
#include "common/UpdatableObject.hpp"

namespace msr { namespace airlib {
Expand All @@ -25,7 +25,7 @@ class VehicleConnectorBase : public UpdatableObject
virtual void stopApiServer() = 0;
virtual bool isApiServerStarted() = 0;
virtual VehicleControllerBase* getController() = 0;
virtual VehicleCameraBase* getCamera(unsigned int index) = 0;
virtual ImageCaptureBase* getCamera(unsigned int index) = 0;
virtual void setPose(const Pose& pose, bool ignore_collision) = 0;
virtual Pose getPose() = 0;
virtual bool setSegmentationObjectID(const std::string& mesh_name, int object_id,
Expand Down
2 changes: 1 addition & 1 deletion AirLib/include/vehicles/car/api/CarApiBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#ifndef air_CarApiBase_hpp
#define air_CarApiBase_hpp

#include "controllers/VehicleCameraBase.hpp"
#include "controllers/ImageCaptureBase.hpp"
#include "common/VectorMath.hpp"
#include "common/CommonStructs.hpp"
#include "api/VehicleApiBase.hpp"
Expand Down
2 changes: 1 addition & 1 deletion AirLib/include/vehicles/car/api/CarRpcLibAdapators.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "common/Common.hpp"
#include "common/CommonStructs.hpp"
#include "api/RpcLibAdapatorsBase.hpp"
#include "controllers/VehicleCameraBase.hpp"
#include "controllers/ImageCaptureBase.hpp"
#include "vehicles/car/api/CarApiBase.hpp"
#include "rpc/msgpack.hpp"

Expand Down
2 changes: 1 addition & 1 deletion AirLib/include/vehicles/car/api/CarRpcLibClient.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "common/CommonStructs.hpp"
#include "vehicles/car/api/CarApiBase.hpp"
#include "api/RpcLibClientBase.hpp"
#include "controllers/VehicleCameraBase.hpp"
#include "controllers/ImageCaptureBase.hpp"


namespace msr { namespace airlib {
Expand Down
12 changes: 6 additions & 6 deletions AirLib/include/vehicles/multirotor/api/DroneApi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,22 +251,22 @@ class DroneApi : public VehicleApiBase {
controller_->enableApiControl(is_enabled);
}

virtual vector<VehicleCameraBase::ImageResponse> simGetImages(const vector<VehicleCameraBase::ImageRequest>& request) override
virtual vector<ImageCaptureBase::ImageResponse> simGetImages(const vector<ImageCaptureBase::ImageRequest>& request) override
{
vector<VehicleCameraBase::ImageResponse> response;
vector<ImageCaptureBase::ImageResponse> response;

for (const auto& item : request) {
VehicleCameraBase* camera = vehicle_->getCamera(item.camera_id);
ImageCaptureBase* camera = vehicle_->getCamera(item.camera_id);
const auto& item_response = camera->getImage(item.image_type, item.pixels_as_float, item.compress);
response.push_back(item_response);
}

return response;
}
virtual vector<uint8_t> simGetImage(uint8_t camera_id, VehicleCameraBase::ImageType image_type) override
virtual vector<uint8_t> simGetImage(uint8_t camera_id, ImageCaptureBase::ImageType image_type) override
{
vector<VehicleCameraBase::ImageRequest> request = { VehicleCameraBase::ImageRequest(camera_id, image_type)};
const vector<VehicleCameraBase::ImageResponse>& response = simGetImages(request);
vector<ImageCaptureBase::ImageRequest> request = { ImageCaptureBase::ImageRequest(camera_id, image_type)};
const vector<ImageCaptureBase::ImageResponse>& response = simGetImages(request);
if (response.size() > 0)
return response.at(0).image_data_uint8;
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "api/RpcLibAdapatorsBase.hpp"
#include "vehicles/multirotor/controllers/DroneCommon.hpp"
#include "vehicles/multirotor/controllers/DroneControllerBase.hpp"
#include "controllers/VehicleCameraBase.hpp"
#include "controllers/ImageCaptureBase.hpp"
#include "safety/SafetyEval.hpp"
#include "rpc/msgpack.hpp"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "common/Common.hpp"
#include <functional>
#include "common/CommonStructs.hpp"
#include "controllers/VehicleCameraBase.hpp"
#include "controllers/ImageCaptureBase.hpp"
#include "vehicles/multirotor/controllers/DroneControllerBase.hpp"
#include "api/RpcLibClientBase.hpp"
#include "vehicles/multirotor/controllers/DroneCommon.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class RealMultirotorConnector : public VehicleConnectorBase
return controller_;
}

virtual VehicleCameraBase* getCamera(unsigned int index) override
virtual ImageCaptureBase* getCamera(unsigned int index) override
{
//TODO: we need to support this but with only scene image type
throw std::logic_error("getCamera() call is only supported for simulation");
Expand Down
4 changes: 2 additions & 2 deletions AirLib/src/api/RpcLibClientBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ Pose RpcLibClientBase::simGetPose()
{
return pimpl_->client.call("simGetPose").as<RpcLibAdapatorsBase::Pose>().to();
}
vector<VehicleCameraBase::ImageResponse> RpcLibClientBase::simGetImages(vector<VehicleCameraBase::ImageRequest> request)
vector<ImageCaptureBase::ImageResponse> RpcLibClientBase::simGetImages(vector<ImageCaptureBase::ImageRequest> request)
{
const auto& response_adaptor = pimpl_->client.call("simGetImages",
RpcLibAdapatorsBase::ImageRequest::from(request))
.as<vector<RpcLibAdapatorsBase::ImageResponse>>();

return RpcLibAdapatorsBase::ImageResponse::to(response_adaptor);
}
vector<uint8_t> RpcLibClientBase::simGetImage(int camera_id, VehicleCameraBase::ImageType type)
vector<uint8_t> RpcLibClientBase::simGetImage(int camera_id, ImageCaptureBase::ImageType type)
{
vector<uint8_t> result = pimpl_->client.call("simGetImage", camera_id, type).as<vector<uint8_t>>();
if (result.size() == 1) {
Expand Down
2 changes: 1 addition & 1 deletion AirLib/src/api/RpcLibServerBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ RpcLibServerBase::RpcLibServerBase(VehicleApiBase* vehicle, string server_addres
const auto& response = vehicle_->simGetImages(RpcLibAdapatorsBase::ImageRequest::to(request_adapter));
return RpcLibAdapatorsBase::ImageResponse::from(response);
});
pimpl_->server.bind("simGetImage", [&](uint8_t camera_id, VehicleCameraBase::ImageType type) -> vector<uint8_t> {
pimpl_->server.bind("simGetImage", [&](uint8_t camera_id, ImageCaptureBase::ImageType type) -> vector<uint8_t> {
auto result = vehicle_->simGetImage(camera_id, type);
if (result.size() == 0) {
// rpclib has a bug with serializing empty vectors, so we return a 1 byte vector instead.
Expand Down
14 changes: 7 additions & 7 deletions Unreal/Plugins/AirSim/Source/Car/CarPawnApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ CarPawnApi::CarPawnApi(VehiclePawnWrapper* pawn, UWheeledVehicleMovementComponen
{
}

std::vector<VehicleCameraBase::ImageResponse> CarPawnApi::simGetImages(
const std::vector<VehicleCameraBase::ImageRequest>& request)
std::vector<ImageCaptureBase::ImageResponse> CarPawnApi::simGetImages(
const std::vector<ImageCaptureBase::ImageRequest>& request)
{
std::vector<VehicleCameraBase::ImageResponse> response;
std::vector<ImageCaptureBase::ImageResponse> response;

for (const auto& item : request) {
VehicleCameraBase* camera = pawn_->getCameraConnector(item.camera_id);
ImageCaptureBase* camera = pawn_->getCameraConnector(item.camera_id);
const auto& item_response = camera->getImage(item.image_type, item.pixels_as_float, item.compress);
response.push_back(item_response);
}
Expand Down Expand Up @@ -48,10 +48,10 @@ msr::airlib::CollisionInfo CarPawnApi::getCollisionInfo()
return pawn_->getCollisionInfo();
}

std::vector<uint8_t> CarPawnApi::simGetImage(uint8_t camera_id, VehicleCameraBase::ImageType image_type)
std::vector<uint8_t> CarPawnApi::simGetImage(uint8_t camera_id, ImageCaptureBase::ImageType image_type)
{
std::vector<VehicleCameraBase::ImageRequest> request = { VehicleCameraBase::ImageRequest(camera_id, image_type) };
const std::vector<VehicleCameraBase::ImageResponse>& response = simGetImages(request);
std::vector<ImageCaptureBase::ImageRequest> request = { ImageCaptureBase::ImageRequest(camera_id, image_type) };
const std::vector<ImageCaptureBase::ImageResponse>& response = simGetImages(request);
if (response.size() > 0)
return response.at(0).image_data_uint8;
else
Expand Down
Loading

0 comments on commit 547dff4

Please sign in to comment.