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 Mar 18, 2021
1 parent 0a76444 commit 1f53fa9
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 34 deletions.
7 changes: 3 additions & 4 deletions AirLib/include/api/WorldSimApiBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
#define air_WorldSimApiBase_hpp

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

#include "common/ImageCaptureBase.hpp"

namespace msr { namespace airlib {

Expand Down Expand Up @@ -82,7 +81,7 @@ class WorldSimApiBase {

// Image APIs
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,
virtual void setCameraPose(const std::string& camera_name, const 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;
Expand All @@ -91,7 +90,7 @@ class WorldSimApiBase {
virtual std::vector<float> getDistortionParams(const std::string& camera_name, const std::string& vehicle_name = "",
bool external = false) const = 0;

virtual std::vector<ImageCaptureBase::ImageResponse> getImages(const std::vector<ImageCaptureBase::ImageRequest>& requests,
virtual std::vector<ImageCaptureBase::ImageResponse> getImages(const std::vector<ImageCaptureBase::ImageRequest>& requests,
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;
Expand Down
1 change: 0 additions & 1 deletion PythonClient/airsim/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,6 @@ def simSetDistortionParams(self, camera_name, distortion_params, vehicle_name =
"""

for param_name, value in distortion_params.items():
# self.client.call('simSetDistortionParam', str(camera_name), param_name, value, vehicle_name, external)
self.simSetDistortionParam(camera_name, param_name, value, vehicle_name, external)

def simSetDistortionParam(self, camera_name, param_name, value, vehicle_name = '', external = False):
Expand Down
4 changes: 2 additions & 2 deletions Unreal/Plugins/AirSim/Source/PIPCamera.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ class AIRSIM_API APIPCamera : public ACameraActor

void setCameraTypeEnabled(ImageType type, bool enabled);
bool getCameraTypeEnabled(ImageType type) const;
void setupCameraFromSettings(const APIPCamera::CameraSetting& camera_setting, const NedTransform& ned_transform);
void setupCameraFromSettings(const CameraSetting& camera_setting, const NedTransform& ned_transform);
void setCameraPose(const msr::airlib::Pose& relative_pose);
void setCameraFoV(float fov_degrees);
msr::airlib::CameraInfo getCameraInfo() const;
std::vector<float> getDistortionParams() const;
void setDistortionParam(const std::string& param_name, float value);

msr::airlib::ProjectionMatrix getProjectionMatrix(const APIPCamera::ImageType image_type) const;
msr::airlib::ProjectionMatrix getProjectionMatrix(const ImageType image_type) const;


USceneCaptureComponent2D* getCaptureComponent(const ImageType type, bool if_active);
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 @@ -509,18 +509,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 @@ -151,7 +151,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 @@ -574,11 +574,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 @@ -588,36 +588,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 @@ -82,10 +82,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 1f53fa9

Please sign in to comment.