Skip to content

Commit

Permalink
Use NedTransform to transform airsim units to world units
Browse files Browse the repository at this point in the history
  • Loading branch information
aburgm committed Feb 19, 2018
1 parent 15ea8ca commit 2f7d781
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions Unreal/Plugins/AirSim/Source/NedTransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ float NedTransform::toNedMeters(float length)
return length / world_to_meters_;
}

float NedTransform::toNeuUU(float length)
{
return length * world_to_meters_;
}

NedTransform::Vector3r NedTransform::toNedMeters(const FVector& position, bool use_offset)
{
return NedTransform::toVector3r(position - (use_offset ? offset_ : FVector::ZeroVector), 1 / world_to_meters_, true);
Expand Down
1 change: 1 addition & 0 deletions Unreal/Plugins/AirSim/Source/NedTransform.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class NedTransform
static FQuat toFQuat(const Quaternionr& q, bool convert_from_ned);
static Quaternionr toQuaternionr(const FQuat& q, bool convert_to_ned);
static float toNedMeters(float length);
static float toNeuUU(float length);

//TODO: make below private
static FVector toFVector(const Vector3r& vec, float scale, bool convert_from_ned);
Expand Down
5 changes: 3 additions & 2 deletions Unreal/Plugins/AirSim/Source/PIPCamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "Materials/MaterialInstanceDynamic.h"
#include "AirBlueprintLib.h"
#include "ImageUtils.h"
#include "NedTransform.h"


APIPCamera::APIPCamera()
Expand Down Expand Up @@ -145,7 +146,7 @@ void APIPCamera::updateCaptureComponentSetting(USceneCaptureComponent2D* capture
if (!std::isnan(setting.fov_degrees))
capture->FOVAngle = setting.fov_degrees;
if (!std::isnan(setting.ortho_width))
capture->OrthoWidth = setting.ortho_width * 100.0f;
capture->OrthoWidth = NedTransform::toNeuUU(setting.ortho_width);

updateCameraPostProcessingSetting(capture->PostProcessSettings, setting);
}
Expand All @@ -160,7 +161,7 @@ void APIPCamera::updateCameraSetting(UCameraComponent* camera, const CaptureSett
if (!std::isnan(setting.fov_degrees))
camera->SetFieldOfView(setting.fov_degrees);
if (!std::isnan(setting.ortho_width))
camera->SetOrthoWidth(setting.ortho_width * 100.0f);
camera->SetOrthoWidth(NedTransform::toNeuUU(setting.ortho_width));

updateCameraPostProcessingSetting(camera->PostProcessSettings, setting);
}
Expand Down

0 comments on commit 2f7d781

Please sign in to comment.