Skip to content

Commit

Permalink
Apply clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
rajat2004 committed Jun 9, 2021
1 parent 9ef975c commit 763ea44
Show file tree
Hide file tree
Showing 14 changed files with 65 additions and 58 deletions.
8 changes: 4 additions & 4 deletions AirLib/include/api/WorldSimApiBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,20 @@ namespace airlib
virtual std::string getSettingsString() const = 0;

// Image APIs
virtual CameraInfo getCameraInfo(const std::string& camera_name, const std::string& vehicle_name = "", bool external=false) const = 0;
virtual CameraInfo getCameraInfo(const std::string& camera_name, const std::string& vehicle_name = "", bool external = false) const = 0;
virtual void setCameraPose(const std::string& camera_name, const msr::airlib::Pose& pose,
const std::string& vehicle_name = "", bool external = false) = 0;
virtual void setCameraFoV(const std::string& camera_name, float fov_degrees,
const std::string& vehicle_name = "", bool external = false) = 0;
virtual void setDistortionParam(const std::string& camera_name, const std::string& param_name, float value,
const std::string& vehicle_name = "", bool external = false) = 0;
virtual std::vector<float> getDistortionParams(const std::string& camera_name, const std::string& vehicle_name = "",
bool external = false) const = 0;
bool external = false) const = 0;

virtual std::vector<ImageCaptureBase::ImageResponse> getImages(const std::vector<ImageCaptureBase::ImageRequest>& requests,
const std::string& vehicle_name = "", bool external = false) const = 0;
const std::string& vehicle_name = "", bool external = false) const = 0;
virtual std::vector<uint8_t> getImage(const std::string& camera_name, ImageCaptureBase::ImageType image_type,
const std::string& vehicle_name = "", bool external = false) const = 0;
const std::string& vehicle_name = "", bool external = false) const = 0;
};
}
} //namespace
Expand Down
11 changes: 7 additions & 4 deletions AirLib/include/common/AirSimSettings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,13 @@ namespace airlib
bool external;

SubwindowSetting(int window_index_val = 0, ImageType image_type_val = ImageType::Scene, bool visible_val = false,
const std::string& camera_name_val = "", const std::string& vehicle_name_val = "", bool external_val = false)
: window_index(window_index_val), image_type(image_type_val), visible(visible_val),
camera_name(camera_name_val), vehicle_name(vehicle_name_val), external(external_val)
const std::string& camera_name_val = "", const std::string& vehicle_name_val = "", bool external_val = false)
: window_index(window_index_val)
, image_type(image_type_val)
, visible(visible_val)
, camera_name(camera_name_val)
, vehicle_name(vehicle_name_val)
, external(external_val)
{
}
};
Expand Down Expand Up @@ -1346,7 +1350,6 @@ namespace airlib
}
}
}

};
}
} //namespace
Expand Down
19 changes: 7 additions & 12 deletions AirLib/src/api/RpcLibServerBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,9 @@ namespace airlib
return getWorldSimApi()->runConsoleCommand(command);
});

pimpl_->server.bind("simGetImages", [&](const std::vector<RpcLibAdaptorsBase::ImageRequest>& request_adapter, const std::string& vehicle_name, bool external) ->
vector<RpcLibAdaptorsBase::ImageResponse> {
const auto& response = getWorldSimApi()->getImages(RpcLibAdaptorsBase::ImageRequest::to(request_adapter), vehicle_name, external);
return RpcLibAdaptorsBase::ImageResponse::from(response);
pimpl_->server.bind("simGetImages", [&](const std::vector<RpcLibAdaptorsBase::ImageRequest>& request_adapter, const std::string& vehicle_name, bool external) -> vector<RpcLibAdaptorsBase::ImageResponse> {
const auto& response = getWorldSimApi()->getImages(RpcLibAdaptorsBase::ImageRequest::to(request_adapter), vehicle_name, external);
return RpcLibAdaptorsBase::ImageResponse::from(response);
});

pimpl_->server.bind("simGetImage", [&](const std::string& camera_name, ImageCaptureBase::ImageType type, const std::string& vehicle_name, bool external) -> vector<uint8_t> {
Expand Down Expand Up @@ -258,23 +257,19 @@ namespace airlib
return RpcLibAdaptorsBase::CameraInfo(camera_info);
});

pimpl_->server.bind("simSetDistortionParam", [&](const std::string& camera_name, const std::string& param_name, float value,
const std::string& vehicle_name, bool external) -> void {
pimpl_->server.bind("simSetDistortionParam", [&](const std::string& camera_name, const std::string& param_name, float value, const std::string& vehicle_name, bool external) -> void {
getWorldSimApi()->setDistortionParam(camera_name, param_name, value, vehicle_name, external);
});

pimpl_->server.bind("simGetDistortionParams", [&](const std::string& camera_name, const std::string& vehicle_name,
bool external) -> std::vector<float> {
pimpl_->server.bind("simGetDistortionParams", [&](const std::string& camera_name, const std::string& vehicle_name, bool external) -> std::vector<float> {
return getWorldSimApi()->getDistortionParams(camera_name, vehicle_name, external);
});

pimpl_->server.bind("simSetCameraPose", [&](const std::string& camera_name, const RpcLibAdaptorsBase::Pose& pose,
const std::string& vehicle_name, bool external) -> void {
pimpl_->server.bind("simSetCameraPose", [&](const std::string& camera_name, const RpcLibAdaptorsBase::Pose& pose, const std::string& vehicle_name, bool external) -> void {
getWorldSimApi()->setCameraPose(camera_name, pose.to(), vehicle_name, external);
});

pimpl_->server.bind("simSetCameraFov", [&](const std::string& camera_name, float fov_degrees,
const std::string& vehicle_name, bool external) -> void {
pimpl_->server.bind("simSetCameraFov", [&](const std::string& camera_name, float fov_degrees, const std::string& vehicle_name, bool external) -> void {
getWorldSimApi()->setCameraFoV(camera_name, fov_degrees, vehicle_name, external);
});

Expand Down
2 changes: 0 additions & 2 deletions Unity/AirLibWrapper/AirsimWrapper/Source/PawnSimApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ const NedTransform& PawnSimApi::getNedTransform() const
return ned_transform_;
}


msr::airlib::RCData PawnSimApi::getRCData() const
{
AirSimRCData rcDataFromUnity = GetRCData(getVehicleName().c_str());
Expand Down Expand Up @@ -220,7 +219,6 @@ void PawnSimApi::allowPassthroughToggleInput()
PrintLogMessage("enable_passthrough_on_collisions: ", state_.passthrough_enabled ? "true" : "false", params_.vehicle_name.c_str(), ErrorLogSeverity::Information);
}


//parameters in NED frame
PawnSimApi::Pose PawnSimApi::getPose() const
{
Expand Down
6 changes: 3 additions & 3 deletions Unity/AirLibWrapper/AirsimWrapper/Source/WorldSimApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ msr::airlib::CameraInfo WorldSimApi::getCameraInfo(const std::string& camera_nam
}

void WorldSimApi::setCameraPose(const std::string& camera_name, const msr::airlib::Pose& pose,
const std::string& vehicle_name, bool external)
const std::string& vehicle_name, bool external)
{
if (external)
throw std::invalid_argument(common_utils::Utils::stringf("external field is not supported on Unity Image APIs").c_str());
Expand All @@ -274,7 +274,7 @@ void WorldSimApi::setCameraFoV(const std::string& camera_name, float fov_degrees
}

void WorldSimApi::setDistortionParam(const std::string& camera_name, const std::string& param_name, float value,
const std::string& vehicle_name, bool external)
const std::string& vehicle_name, bool external)
{
throw std::invalid_argument(common_utils::Utils::stringf("setDistortionParam is not supported on unity").c_str());
}
Expand All @@ -297,7 +297,7 @@ std::vector<WorldSimApi::ImageCaptureBase::ImageResponse> WorldSimApi::getImages
}

std::vector<uint8_t> WorldSimApi::getImage(const std::string& camera_name, ImageCaptureBase::ImageType image_type,
const std::string& vehicle_name, bool external) const
const std::string& vehicle_name, bool external) const
{
std::vector<ImageCaptureBase::ImageRequest> request{ ImageCaptureBase::ImageRequest(camera_name, image_type) };
const auto& response = getImages(request);
Expand Down
6 changes: 3 additions & 3 deletions Unity/AirLibWrapper/AirsimWrapper/Source/WorldSimApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ class WorldSimApi : public msr::airlib::WorldSimApiBase
virtual void setDistortionParam(const std::string& camera_name, const std::string& param_name, float value,
const std::string& vehicle_name = "", bool external = false) override;
virtual std::vector<float> getDistortionParams(const std::string& camera_name, const std::string& vehicle_name = "",
bool external = false) const override;
bool external = false) const override;

virtual std::vector<ImageCaptureBase::ImageResponse> getImages(const std::vector<ImageCaptureBase::ImageRequest>& requests,
const std::string& vehicle_name = "", bool external = false) const override;
const std::string& vehicle_name = "", bool external = false) const override;
virtual std::vector<uint8_t> getImage(const std::string& camera_name, msr::airlib::ImageCaptureBase::ImageType image_type,
const std::string& vehicle_name = "", bool external = false) const override;
const std::string& vehicle_name = "", bool external = false) const override;

private:
SimModeBase* simmode_;
Expand Down
2 changes: 1 addition & 1 deletion Unreal/Plugins/AirSim/Source/PIPCamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ std::vector<float> APIPCamera::getDistortionParams() const
{
std::vector<float> param_values(5, 0.0);

auto getParamValue = [this](const auto &name, float &val) {
auto getParamValue = [this](const auto& name, float& val) {
distortion_param_instance_->GetScalarParameterValue(FName(name), val);
};

Expand Down
8 changes: 5 additions & 3 deletions Unreal/Plugins/AirSim/Source/PIPCamera.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,12 @@ class AIRSIM_API APIPCamera : public ACameraActor
UDetectionComponent* getDetectionComponent(const ImageType type, bool if_active) const;

msr::airlib::Pose getPose() const;

private: //members
UPROPERTY() UMaterialParameterCollection* distortion_param_collection_;
UPROPERTY() UMaterialParameterCollectionInstance* distortion_param_instance_;
UPROPERTY()
UMaterialParameterCollection* distortion_param_collection_;
UPROPERTY()
UMaterialParameterCollectionInstance* distortion_param_instance_;

UPROPERTY()
TArray<USceneCaptureComponent2D*> captures_;
Expand Down
17 changes: 11 additions & 6 deletions Unreal/Plugins/AirSim/Source/PawnSimApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,17 @@ class PawnSimApi : public msr::airlib::VehicleSimApiBase
}

Params(APawn* pawn_val, const NedTransform* global_transform_val, PawnEvents* pawn_events_val,
const common_utils::UniqueValueMap<std::string, APIPCamera*>& cameras_val, UClass* pip_camera_class_val,
UParticleSystem* collision_display_template_val, const msr::airlib::GeoPoint& home_geopoint_val,
const std::string& vehicle_name_val)
: pawn(pawn_val), global_transform(global_transform_val), pawn_events(pawn_events_val), cameras(cameras_val),
pip_camera_class(pip_camera_class_val), collision_display_template(collision_display_template_val),
home_geopoint(home_geopoint_val), vehicle_name(vehicle_name_val)
const common_utils::UniqueValueMap<std::string, APIPCamera*>& cameras_val, UClass* pip_camera_class_val,
UParticleSystem* collision_display_template_val, const msr::airlib::GeoPoint& home_geopoint_val,
const std::string& vehicle_name_val)
: pawn(pawn_val)
, global_transform(global_transform_val)
, pawn_events(pawn_events_val)
, cameras(cameras_val)
, pip_camera_class(pip_camera_class_val)
, collision_display_template(collision_display_template_val)
, home_geopoint(home_geopoint_val)
, vehicle_name(vehicle_name_val)
{
}
};
Expand Down
3 changes: 2 additions & 1 deletion Unreal/Plugins/AirSim/Source/SimHUD/SimHUD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,8 @@ void ASimHUD::initializeSubWindows()
subwindow_cameras_[setting.window_index] = camera;
else
UAirBlueprintLib::LogMessageString("Invalid Camera settings in <SubWindows> element",
std::to_string(setting.window_index), LogDebugLevel::Failure);
std::to_string(setting.window_index),
LogDebugLevel::Failure);
}
}

Expand Down
9 changes: 4 additions & 5 deletions Unreal/Plugins/AirSim/Source/SimMode/SimModeBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,8 @@ void ASimModeBase::initializeExternalCameras()
//get pose
FVector position = transform.fromLocalNed(setting.position) - transform.fromLocalNed(Vector3r::Zero());
FTransform camera_transform(FRotator(setting.rotation.pitch, setting.rotation.yaw, setting.rotation.roll),
position, FVector(1., 1., 1.));
position,
FVector(1., 1., 1.));

//spawn and attach camera to pawn
camera_spawn_params.Name = FName(("external_" + camera_setting_pair.first).c_str());
Expand Down Expand Up @@ -512,14 +513,12 @@ bool ASimModeBase::isRecording() const

const APIPCamera* ASimModeBase::getCamera(const std::string& camera_name, const std::string& vehicle_name, bool external) const
{
return external ? getExternalCamera(camera_name) :
getVehicleSimApi(vehicle_name)->getCamera(camera_name);
return external ? getExternalCamera(camera_name) : getVehicleSimApi(vehicle_name)->getCamera(camera_name);
}

const UnrealImageCapture* ASimModeBase::getImageCapture(const std::string& vehicle_name, bool external) const
{
return external ? external_image_capture_.get() :
getVehicleSimApi(vehicle_name)->getImageCapture();
return external ? external_image_capture_.get() : getVehicleSimApi(vehicle_name)->getImageCapture();
}

//API server start/stop
Expand Down
2 changes: 1 addition & 1 deletion Unreal/Plugins/AirSim/Source/SimMode/SimModeBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class AIRSIM_API ASimModeBase : public AActor
return const_cast<APIPCamera*>(
static_cast<const ASimModeBase*>(this)->getExternalCamera(camera_name));
}

APIPCamera* getCamera(const std::string& camera_name, const std::string& vehicle_name = "", bool external = false)
{
return const_cast<APIPCamera*>(
Expand Down
22 changes: 13 additions & 9 deletions Unreal/Plugins/AirSim/Source/WorldSimApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -628,25 +628,26 @@ std::string WorldSimApi::getSettingsString() const
return msr::airlib::AirSimSettings::singleton().settings_text_;
}


msr::airlib::CameraInfo WorldSimApi::getCameraInfo(const std::string& camera_name, const std::string& vehicle_name, bool external) const
{
msr::airlib::CameraInfo info;
const auto* camera = simmode_->getCamera(camera_name, vehicle_name, external);
UAirBlueprintLib::RunCommandOnGameThread([camera, &info]() {
info = camera->getCameraInfo();
}, true);
},
true);

return info;
}

void WorldSimApi::setCameraPose(const std::string& camera_name, const msr::airlib::Pose& pose,
const std::string& vehicle_name, bool external)
const std::string& vehicle_name, bool external)
{
auto* camera = simmode_->getCamera(camera_name, vehicle_name, external);
UAirBlueprintLib::RunCommandOnGameThread([camera, &pose]() {
camera->setCameraPose(pose);
}, true);
},
true);
}

void WorldSimApi::setCameraFoV(const std::string& camera_name, float fov_degrees,
Expand All @@ -655,16 +656,18 @@ void WorldSimApi::setCameraFoV(const std::string& camera_name, float fov_degrees
auto* camera = simmode_->getCamera(camera_name, vehicle_name, external);
UAirBlueprintLib::RunCommandOnGameThread([camera, &fov_degrees]() {
camera->setCameraFoV(fov_degrees);
}, true);
},
true);
}

void WorldSimApi::setDistortionParam(const std::string& camera_name, const std::string& param_name, float value,
const std::string& vehicle_name, bool external)
const std::string& vehicle_name, bool external)
{
auto* camera = simmode_->getCamera(camera_name, vehicle_name, external);
UAirBlueprintLib::RunCommandOnGameThread([camera, &param_name, &value]() {
camera->setDistortionParam(param_name, value);
}, true);
},
true);
}

std::vector<float> WorldSimApi::getDistortionParams(const std::string& camera_name, const std::string& vehicle_name, bool external) const
Expand All @@ -673,7 +676,8 @@ std::vector<float> WorldSimApi::getDistortionParams(const std::string& camera_na
const auto* camera = simmode_->getCamera(camera_name, vehicle_name, external);
UAirBlueprintLib::RunCommandOnGameThread([camera, &param_values]() {
param_values = camera->getDistortionParams();
}, true);
},
true);

return param_values;
}
Expand All @@ -690,7 +694,7 @@ std::vector<WorldSimApi::ImageCaptureBase::ImageResponse> WorldSimApi::getImages
}

std::vector<uint8_t> WorldSimApi::getImage(const std::string& camera_name, ImageCaptureBase::ImageType image_type,
const std::string& vehicle_name, bool external) const
const std::string& vehicle_name, bool external) const
{
std::vector<ImageCaptureBase::ImageRequest> request{ ImageCaptureBase::ImageRequest(camera_name, image_type) };
const auto& response = getImages(request);
Expand Down
8 changes: 4 additions & 4 deletions Unreal/Plugins/AirSim/Source/WorldSimApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ class WorldSimApi : public msr::airlib::WorldSimApiBase
virtual void setDistortionParam(const std::string& camera_name, const std::string& param_name, float value,
const std::string& vehicle_name = "", bool external = false) override;
virtual std::vector<float> getDistortionParams(const std::string& camera_name, const std::string& vehicle_name = "",
bool external = false) const override;
bool external = false) const override;

virtual std::vector<ImageCaptureBase::ImageResponse> getImages(const std::vector<ImageCaptureBase::ImageRequest>& requests,
const std::string& vehicle_name = "", bool external = false) const override;
const std::string& vehicle_name = "", bool external = false) const override;
virtual std::vector<uint8_t> getImage(const std::string& camera_name, ImageCaptureBase::ImageType image_type,
const std::string& vehicle_name = "", bool external = false) const override;
const std::string& vehicle_name = "", bool external = false) const override;

private:
AActor* createNewActor(const FActorSpawnParameters& spawn_params, const FTransform& actor_transform, const Vector3r& scale, UStaticMesh* static_mesh);
Expand All @@ -99,4 +99,4 @@ class WorldSimApi : public msr::airlib::WorldSimApiBase
ASimModeBase* simmode_;
ULevelStreamingDynamic* current_level_;
std::vector<bool> voxel_grid_;
};
};

0 comments on commit 763ea44

Please sign in to comment.