Skip to content

Commit

Permalink
Fix some warnings, cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
rajat2004 committed Feb 27, 2021
1 parent eba40f6 commit 68bb0c8
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 27 deletions.
1 change: 1 addition & 0 deletions AirLib/include/api/WorldSimApiBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#define air_WorldSimApiBase_hpp

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

namespace msr { namespace airlib {

Expand Down
1 change: 0 additions & 1 deletion Unreal/Plugins/AirSim/Source/PawnSimApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class PawnSimApi : public msr::airlib::VehicleSimApiBase {
typedef msr::airlib::real_T real_T;
typedef msr::airlib::Utils Utils;
typedef msr::airlib::AirSimSettings::VehicleSetting VehicleSetting;
typedef msr::airlib::ImageCaptureBase ImageCaptureBase;

struct Params {
APawn* pawn;
Expand Down
12 changes: 4 additions & 8 deletions Unreal/Plugins/AirSim/Source/SimMode/SimModeBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -508,18 +508,14 @@ bool ASimModeBase::isRecording() const

const APIPCamera* ASimModeBase::getCamera(const std::string& camera_name, const std::string& vehicle_name, bool external) const
{
if (external)
return getExternalCamera(camera_name);
else
return 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
{
if (external)
return external_image_capture_.get();
else
return 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 @@ -145,7 +145,7 @@ class AIRSIM_API ASimModeBase : public AActor
virtual void initializeExternalCameras();

protected: //Utility methods for derived classes
virtual const msr::airlib::AirSimSettings& getSettings() const;
virtual const AirSimSettings& getSettings() const;
FRotator toFRotator(const AirSimSettings::Rotation& rotation, const FRotator& default_val);


Expand Down
25 changes: 12 additions & 13 deletions Unreal/Plugins/AirSim/Source/WorldSimApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -564,11 +564,11 @@ void WorldSimApi::setWind(const Vector3r& wind) const
simmode_->setWind(wind);
}

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

Expand All @@ -578,36 +578,35 @@ CameraInfo WorldSimApi::getCameraInfo(const std::string& camera_name, const std:
void WorldSimApi::setCameraPose(const std::string& camera_name, const msr::airlib::Pose& pose,
const std::string& vehicle_name, bool external)
{
UAirBlueprintLib::RunCommandOnGameThread([this, &camera_name, &vehicle_name, &external, &pose]() {
auto camera = simmode_->getCamera(camera_name, vehicle_name, external);
auto* camera = simmode_->getCamera(camera_name, vehicle_name, external);
UAirBlueprintLib::RunCommandOnGameThread([camera, &pose]() {
camera->setCameraPose(pose);
}, true);
}

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

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

std::vector<float> WorldSimApi::getDistortionParams(const std::string& camera_name, const std::string& vehicle_name, bool external) const
{
std::vector<float> param_values;
UAirBlueprintLib::RunCommandOnGameThread([this, &camera_name, &vehicle_name, &external, &param_values]() {
auto camera = simmode_->getCamera(camera_name, vehicle_name, external);
const auto* camera = simmode_->getCamera(camera_name, vehicle_name, external);
UAirBlueprintLib::RunCommandOnGameThread([camera, &param_values]() {
param_values = camera->getDistortionParams();
}, true);

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 @@ -80,10 +80,10 @@ class WorldSimApi : public msr::airlib::WorldSimApiBase {
virtual std::vector<float> getDistortionParams(const std::string& camera_name, const std::string& vehicle_name = "",
bool external = false) const override;

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

private:
AActor* createNewActor(const FActorSpawnParameters& spawn_params, const FTransform& actor_transform, const Vector3r& scale, UStaticMesh* static_mesh);
Expand Down

0 comments on commit 68bb0c8

Please sign in to comment.