Skip to content

Commit 66288ce

Browse files
committedNov 23, 2021
Port optical flow and domain randomization PRs
1 parent 95dda12 commit 66288ce

21 files changed

+143
-107
lines changed
 

‎AirLib/include/api/RpcLibClientBase.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ namespace airlib
131131
msr::airlib::Kinematics::State simGetGroundTruthKinematics(const std::string& vehicle_name = "") const;
132132
msr::airlib::Environment::State simGetGroundTruthEnvironment(const std::string& vehicle_name = "") const;
133133
std::vector<std::string> simSwapTextures(const std::string& tags, int tex_id = 0, int component_id = 0, int material_id = 0);
134-
bool simSetMeshMaterial(const std::string& object_name = "", const std::string& material_name = "");
135-
bool simSetMeshMaterialFromTexture(const std::string& object_name = "", const std::string& texture_path = "");
134+
bool simSetObjectMaterial(const std::string& object_name, const std::string& material_name);
135+
bool simSetObjectMaterialFromTexture(const std::string& object_name, const std::string& texture_path);
136136

137137
// Recording APIs
138138
void startRecording();

‎AirLib/include/api/WorldSimApiBase.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ namespace airlib
106106
virtual bool getDisqualified(const std::string& racer_name) = 0;
107107
virtual int getLastGatePassed(const std::string& racer_name) = 0;
108108
virtual bool setTextureFromUrl(std::string& object_name, std::string& url) = 0;
109-
virtual bool setMeshMaterial(const std::string& object_name, const std::string& material_name) = 0;
110-
virtual bool setMeshMaterialFromTexture(const std::string& object_name, const std::string& texture_path) = 0;
109+
virtual bool setObjectMaterial(const std::string& object_name, const std::string& material_name) = 0;
110+
virtual bool setObjectMaterialFromTexture(const std::string& object_name, const std::string& texture_path) = 0;
111111
};
112112
}
113113
} //namespace

‎AirLib/include/common/ImageCaptureBase.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ namespace airlib
2626
Segmentation,
2727
SurfaceNormals,
2828
Infrared,
29+
OpticalFlow,
30+
OpticalFlowVis,
2931
Count //must be last
3032
};
3133

‎AirLib/src/api/RpcLibClientBase.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -410,14 +410,14 @@ __pragma(warning(disable : 4239))
410410
return pimpl_->client.call("simSwapTextures", tags, tex_id, component_id, material_id).as<vector<string>>();
411411
}
412412

413-
bool RpcLibClientBase::simSetMeshMaterial(const std::string& object_name, const std::string& material_name)
413+
bool RpcLibClientBase::simSetObjectMaterial(const std::string& object_name, const std::string& material_name)
414414
{
415-
return pimpl_->client.call("simSetMeshMaterial", object_name, material_name).as<bool>();
415+
return pimpl_->client.call("simSetObjectMaterial", object_name, material_name).as<bool>();
416416
}
417417

418-
bool RpcLibClientBase::simSetMeshMaterialFromTexture(const std::string& object_name, const std::string& texture_path)
418+
bool RpcLibClientBase::simSetObjectMaterialFromTexture(const std::string& object_name, const std::string& texture_path)
419419
{
420-
return pimpl_->client.call("simSetMeshMaterialFromTexture", object_name, texture_path).as<bool>();
420+
return pimpl_->client.call("simSetObjectMaterialFromTexture", object_name, texture_path).as<bool>();
421421
}
422422

423423
bool RpcLibClientBase::simLoadLevel(const string& level_name)

‎AirLib/src/api/RpcLibServerBase.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -444,12 +444,12 @@ namespace airlib
444444
return *getWorldSimApi()->swapTextures(tag, tex_id, component_id, material_id);
445445
});
446446

447-
pimpl_->server.bind("simSetMeshMaterial", [&](const std::string& object_name, const std::string& material_name) -> bool {
448-
return getWorldSimApi()->setMeshMaterial(object_name, material_name);
447+
pimpl_->server.bind("simSetObjectMaterial", [&](const std::string& object_name, const std::string& material_name) -> bool {
448+
return getWorldSimApi()->setObjectMaterial(object_name, material_name);
449449
});
450450

451-
pimpl_->server.bind("simSetMeshMaterialFromTexture", [&](const std::string& object_name, const std::string& texture_path) -> bool {
452-
return getWorldSimApi()->setMeshMaterialFromTexture(object_name, texture_path);
451+
pimpl_->server.bind("simSetObjectMaterialFromTexture", [&](const std::string& object_name, const std::string& texture_path) -> bool {
452+
return getWorldSimApi()->setObjectMaterialFromTexture(object_name, texture_path);
453453
});
454454

455455
pimpl_->server.bind("startRecording", [&]() -> void {

‎PythonClient/airsimdroneracinglab/types.py

+32-16
Original file line numberDiff line numberDiff line change
@@ -54,29 +54,45 @@ def from_msgpack(cls, encoded):
5454
return obj
5555

5656

57-
class ImageType:
58-
59-
"""
60-
61-
Attributes:
62-
DepthPerspective (int): Description
63-
DepthPlanner (int): Description
64-
DepthVis (int): Description
65-
DisparityNormalized (int): Description
66-
Infrared (int): Description
67-
Scene (int): Description
68-
Segmentation (int): Description
69-
SurfaceNormals (int): Description
70-
"""
71-
57+
class _ImageType(type):
58+
@property
59+
def Scene(cls):
60+
return 0
61+
def DepthPlanar(cls):
62+
return 1
63+
def DepthPerspective(cls):
64+
return 2
65+
def DepthVis(cls):
66+
return 3
67+
def DisparityNormalized(cls):
68+
return 4
69+
def Segmentation(cls):
70+
return 5
71+
def SurfaceNormals(cls):
72+
return 6
73+
def Infrared(cls):
74+
return 7
75+
def OpticalFlow(cls):
76+
return 8
77+
def OpticalFlowVis(cls):
78+
return 9
79+
80+
def __getattr__(self, key):
81+
if key == 'DepthPlanner':
82+
print('\033[31m'+"DepthPlanner has been (correctly) renamed to DepthPlanar. Please use ImageType.DepthPlanar instead."+'\033[0m')
83+
raise AttributeError
84+
85+
class ImageType(metaclass=_ImageType):
7286
Scene = 0
73-
DepthPlanner = 1
87+
DepthPlanar = 1
7488
DepthPerspective = 2
7589
DepthVis = 3
7690
DisparityNormalized = 4
7791
Segmentation = 5
7892
SurfaceNormals = 6
7993
Infrared = 7
94+
OpticalFlow = 8
95+
OpticalFlowVis = 9
8096

8197

8298
class DrivetrainType:

‎Unity/AirLibWrapper/AirsimWrapper/Source/WorldSimApi.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,22 @@ std::unique_ptr<std::vector<std::string>> WorldSimApi::swapTextures(const std::s
6767
return result;
6868
}
6969

70+
bool WorldSimApi::setObjectMaterialFromTexture(const std::string& object_name, const std::string& texture_path)
71+
{
72+
throw std::invalid_argument(common_utils::Utils::stringf(
73+
"setObjectMaterialFromTexture is not supported on unity")
74+
.c_str());
75+
return false;
76+
}
77+
78+
bool WorldSimApi::setObjectMaterial(const std::string& object_name, const std::string& material_name)
79+
{
80+
throw std::invalid_argument(common_utils::Utils::stringf(
81+
"setObjectMaterial is not supported on unity")
82+
.c_str());
83+
return false;
84+
}
85+
7086
std::vector<std::string> WorldSimApi::listSceneObjects(const std::string& name_regex) const
7187
{
7288
std::vector<std::string> result;

‎Unity/AirLibWrapper/AirsimWrapper/Source/WorldSimApi.h

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ class WorldSimApi : public msr::airlib::WorldSimApiBase
3636
const std::string& message_param = "", unsigned char severity = 0) override;
3737

3838
virtual std::unique_ptr<std::vector<std::string>> swapTextures(const std::string& tag, int tex_id = 0, int component_id = 0, int material_id = 0) override;
39+
virtual bool setObjectMaterial(const std::string& object_name, const std::string& material_name) override;
40+
virtual bool setObjectMaterialFromTexture(const std::string& object_name, const std::string& texture_path) override;
3941
virtual std::vector<std::string> listSceneObjects(const std::string& name_regex) const override;
4042
virtual Pose getObjectPose(const std::string& object_name) const override;
4143

‎Unreal/ADRL.sln

+37-33
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Engine", "Engine", "{94A6C6
77
EndProject
88
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Games", "Games", "{8E2F6A87-1826-34F4-940C-CC23A48F9FE4}"
99
EndProject
10-
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UE4", "Intermediate\ProjectFiles\UE4.vcxproj", "{2B964CE8-D9F3-4E3A-B2D0-5F09B3F4D312}"
10+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ADRL", "Intermediate\ProjectFiles\ADRL.vcxproj", "{3C2C2D46-E808-48EA-9F36-ADBBAAFAC148}"
1111
EndProject
12-
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ADRL", "Intermediate\ProjectFiles\ADRL.vcxproj", "{3E37CEDE-5ADA-4D2F-BB6A-2B492CB1FA21}"
12+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UE4", "Intermediate\ProjectFiles\UE4.vcxproj", "{E3166709-6D22-49CB-99CC-CC3890E10D0F}"
1313
EndProject
1414
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Visualizers", "Visualizers", "{1CCEC849-CC72-4C59-8C36-2F7C38706D4C}"
1515
ProjectSection(SolutionItems) = preProject
16-
..\..\..\..\..\Program Files\Epic Games\UE_4.26\Engine\Extras\VisualStudioDebugging\UE4.natvis = ..\..\..\..\..\Program Files\Epic Games\UE_4.26\Engine\Extras\VisualStudioDebugging\UE4.natvis
16+
..\..\..\UE\UE_4.27\Engine\Extras\VisualStudioDebugging\UE4.natvis = ..\..\..\UE\UE_4.27\Engine\Extras\VisualStudioDebugging\UE4.natvis
1717
EndProjectSection
1818
EndProject
1919
Global
@@ -29,41 +29,45 @@ Global
2929
Shipping|Win32 = Shipping|Win32
3030
Shipping|Win64 = Shipping|Win64
3131
EndGlobalSection
32+
# Visual Assist Section
33+
GlobalSection(44630d46-96b5-488c-8df926e21db8c1a3) = preSolution
34+
ueSolution=true
35+
EndGlobalSection
3236
GlobalSection(ProjectConfigurationPlatforms) = postSolution
33-
{2B964CE8-D9F3-4E3A-B2D0-5F09B3F4D312}.DebugGame Editor|Win32.ActiveCfg = BuiltWithUnrealBuildTool|Win32
34-
{2B964CE8-D9F3-4E3A-B2D0-5F09B3F4D312}.DebugGame Editor|Win64.ActiveCfg = BuiltWithUnrealBuildTool|Win32
35-
{2B964CE8-D9F3-4E3A-B2D0-5F09B3F4D312}.DebugGame|Win32.ActiveCfg = BuiltWithUnrealBuildTool|Win32
36-
{2B964CE8-D9F3-4E3A-B2D0-5F09B3F4D312}.DebugGame|Win64.ActiveCfg = BuiltWithUnrealBuildTool|Win32
37-
{2B964CE8-D9F3-4E3A-B2D0-5F09B3F4D312}.Development Editor|Win32.ActiveCfg = BuiltWithUnrealBuildTool|Win32
38-
{2B964CE8-D9F3-4E3A-B2D0-5F09B3F4D312}.Development Editor|Win64.ActiveCfg = BuiltWithUnrealBuildTool|Win32
39-
{2B964CE8-D9F3-4E3A-B2D0-5F09B3F4D312}.Development|Win32.ActiveCfg = BuiltWithUnrealBuildTool|Win32
40-
{2B964CE8-D9F3-4E3A-B2D0-5F09B3F4D312}.Development|Win64.ActiveCfg = BuiltWithUnrealBuildTool|Win32
41-
{2B964CE8-D9F3-4E3A-B2D0-5F09B3F4D312}.Shipping|Win32.ActiveCfg = BuiltWithUnrealBuildTool|Win32
42-
{2B964CE8-D9F3-4E3A-B2D0-5F09B3F4D312}.Shipping|Win64.ActiveCfg = BuiltWithUnrealBuildTool|Win32
43-
{3E37CEDE-5ADA-4D2F-BB6A-2B492CB1FA21}.DebugGame Editor|Win32.ActiveCfg = Invalid|Win32
44-
{3E37CEDE-5ADA-4D2F-BB6A-2B492CB1FA21}.DebugGame Editor|Win64.ActiveCfg = DebugGame_Editor|x64
45-
{3E37CEDE-5ADA-4D2F-BB6A-2B492CB1FA21}.DebugGame Editor|Win64.Build.0 = DebugGame_Editor|x64
46-
{3E37CEDE-5ADA-4D2F-BB6A-2B492CB1FA21}.DebugGame|Win32.ActiveCfg = DebugGame|Win32
47-
{3E37CEDE-5ADA-4D2F-BB6A-2B492CB1FA21}.DebugGame|Win32.Build.0 = DebugGame|Win32
48-
{3E37CEDE-5ADA-4D2F-BB6A-2B492CB1FA21}.DebugGame|Win64.ActiveCfg = DebugGame|x64
49-
{3E37CEDE-5ADA-4D2F-BB6A-2B492CB1FA21}.DebugGame|Win64.Build.0 = DebugGame|x64
50-
{3E37CEDE-5ADA-4D2F-BB6A-2B492CB1FA21}.Development Editor|Win32.ActiveCfg = Invalid|Win32
51-
{3E37CEDE-5ADA-4D2F-BB6A-2B492CB1FA21}.Development Editor|Win64.ActiveCfg = Development_Editor|x64
52-
{3E37CEDE-5ADA-4D2F-BB6A-2B492CB1FA21}.Development Editor|Win64.Build.0 = Development_Editor|x64
53-
{3E37CEDE-5ADA-4D2F-BB6A-2B492CB1FA21}.Development|Win32.ActiveCfg = Development|Win32
54-
{3E37CEDE-5ADA-4D2F-BB6A-2B492CB1FA21}.Development|Win32.Build.0 = Development|Win32
55-
{3E37CEDE-5ADA-4D2F-BB6A-2B492CB1FA21}.Development|Win64.ActiveCfg = Development|x64
56-
{3E37CEDE-5ADA-4D2F-BB6A-2B492CB1FA21}.Development|Win64.Build.0 = Development|x64
57-
{3E37CEDE-5ADA-4D2F-BB6A-2B492CB1FA21}.Shipping|Win32.ActiveCfg = Shipping|Win32
58-
{3E37CEDE-5ADA-4D2F-BB6A-2B492CB1FA21}.Shipping|Win32.Build.0 = Shipping|Win32
59-
{3E37CEDE-5ADA-4D2F-BB6A-2B492CB1FA21}.Shipping|Win64.ActiveCfg = Shipping|x64
60-
{3E37CEDE-5ADA-4D2F-BB6A-2B492CB1FA21}.Shipping|Win64.Build.0 = Shipping|x64
37+
{3C2C2D46-E808-48EA-9F36-ADBBAAFAC148}.DebugGame Editor|Win32.ActiveCfg = Invalid|Win32
38+
{3C2C2D46-E808-48EA-9F36-ADBBAAFAC148}.DebugGame Editor|Win64.ActiveCfg = DebugGame_Editor|x64
39+
{3C2C2D46-E808-48EA-9F36-ADBBAAFAC148}.DebugGame Editor|Win64.Build.0 = DebugGame_Editor|x64
40+
{3C2C2D46-E808-48EA-9F36-ADBBAAFAC148}.DebugGame|Win32.ActiveCfg = DebugGame|Win32
41+
{3C2C2D46-E808-48EA-9F36-ADBBAAFAC148}.DebugGame|Win32.Build.0 = DebugGame|Win32
42+
{3C2C2D46-E808-48EA-9F36-ADBBAAFAC148}.DebugGame|Win64.ActiveCfg = DebugGame|x64
43+
{3C2C2D46-E808-48EA-9F36-ADBBAAFAC148}.DebugGame|Win64.Build.0 = DebugGame|x64
44+
{3C2C2D46-E808-48EA-9F36-ADBBAAFAC148}.Development Editor|Win32.ActiveCfg = Invalid|Win32
45+
{3C2C2D46-E808-48EA-9F36-ADBBAAFAC148}.Development Editor|Win64.ActiveCfg = Development_Editor|x64
46+
{3C2C2D46-E808-48EA-9F36-ADBBAAFAC148}.Development Editor|Win64.Build.0 = Development_Editor|x64
47+
{3C2C2D46-E808-48EA-9F36-ADBBAAFAC148}.Development|Win32.ActiveCfg = Development|Win32
48+
{3C2C2D46-E808-48EA-9F36-ADBBAAFAC148}.Development|Win32.Build.0 = Development|Win32
49+
{3C2C2D46-E808-48EA-9F36-ADBBAAFAC148}.Development|Win64.ActiveCfg = Development|x64
50+
{3C2C2D46-E808-48EA-9F36-ADBBAAFAC148}.Development|Win64.Build.0 = Development|x64
51+
{3C2C2D46-E808-48EA-9F36-ADBBAAFAC148}.Shipping|Win32.ActiveCfg = Shipping|Win32
52+
{3C2C2D46-E808-48EA-9F36-ADBBAAFAC148}.Shipping|Win32.Build.0 = Shipping|Win32
53+
{3C2C2D46-E808-48EA-9F36-ADBBAAFAC148}.Shipping|Win64.ActiveCfg = Shipping|x64
54+
{3C2C2D46-E808-48EA-9F36-ADBBAAFAC148}.Shipping|Win64.Build.0 = Shipping|x64
55+
{E3166709-6D22-49CB-99CC-CC3890E10D0F}.DebugGame Editor|Win32.ActiveCfg = BuiltWithUnrealBuildTool|Win32
56+
{E3166709-6D22-49CB-99CC-CC3890E10D0F}.DebugGame Editor|Win64.ActiveCfg = BuiltWithUnrealBuildTool|Win32
57+
{E3166709-6D22-49CB-99CC-CC3890E10D0F}.DebugGame|Win32.ActiveCfg = BuiltWithUnrealBuildTool|Win32
58+
{E3166709-6D22-49CB-99CC-CC3890E10D0F}.DebugGame|Win64.ActiveCfg = BuiltWithUnrealBuildTool|Win32
59+
{E3166709-6D22-49CB-99CC-CC3890E10D0F}.Development Editor|Win32.ActiveCfg = BuiltWithUnrealBuildTool|Win32
60+
{E3166709-6D22-49CB-99CC-CC3890E10D0F}.Development Editor|Win64.ActiveCfg = BuiltWithUnrealBuildTool|Win32
61+
{E3166709-6D22-49CB-99CC-CC3890E10D0F}.Development|Win32.ActiveCfg = BuiltWithUnrealBuildTool|Win32
62+
{E3166709-6D22-49CB-99CC-CC3890E10D0F}.Development|Win64.ActiveCfg = BuiltWithUnrealBuildTool|Win32
63+
{E3166709-6D22-49CB-99CC-CC3890E10D0F}.Shipping|Win32.ActiveCfg = BuiltWithUnrealBuildTool|Win32
64+
{E3166709-6D22-49CB-99CC-CC3890E10D0F}.Shipping|Win64.ActiveCfg = BuiltWithUnrealBuildTool|Win32
6165
EndGlobalSection
6266
GlobalSection(SolutionProperties) = preSolution
6367
HideSolutionNode = FALSE
6468
EndGlobalSection
6569
GlobalSection(NestedProjects) = preSolution
66-
{2B964CE8-D9F3-4E3A-B2D0-5F09B3F4D312} = {94A6C6F3-99B3-346E-9557-ABF9D4064DBD}
67-
{3E37CEDE-5ADA-4D2F-BB6A-2B492CB1FA21} = {8E2F6A87-1826-34F4-940C-CC23A48F9FE4}
70+
{E3166709-6D22-49CB-99CC-CC3890E10D0F} = {94A6C6F3-99B3-346E-9557-ABF9D4064DBD}
71+
{3C2C2D46-E808-48EA-9F36-ADBBAAFAC148} = {8E2F6A87-1826-34F4-940C-CC23A48F9FE4}
6872
EndGlobalSection
6973
EndGlobal
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Binary file not shown.

‎Unreal/Plugins/AirSim/Source/PIPCamera.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ APIPCamera::APIPCamera()
4141
image_type_to_pixel_format_map_.Add(5, EPixelFormat::PF_B8G8R8A8);
4242
image_type_to_pixel_format_map_.Add(6, EPixelFormat::PF_B8G8R8A8);
4343
image_type_to_pixel_format_map_.Add(7, EPixelFormat::PF_B8G8R8A8);
44+
image_type_to_pixel_format_map_.Add(8, EPixelFormat::PF_B8G8R8A8);
45+
image_type_to_pixel_format_map_.Add(9, EPixelFormat::PF_B8G8R8A8);
4446

4547
object_filter_ = FObjectFilter();
4648
}
@@ -70,6 +72,10 @@ void APIPCamera::PostInitializeComponents()
7072
UAirBlueprintLib::GetActorComponent<USceneCaptureComponent2D>(this, TEXT("InfraredCaptureComponent"));
7173
captures_[Utils::toNumeric(ImageType::SurfaceNormals)] =
7274
UAirBlueprintLib::GetActorComponent<USceneCaptureComponent2D>(this, TEXT("NormalsCaptureComponent"));
75+
captures_[Utils::toNumeric(ImageType::OpticalFlow)] =
76+
UAirBlueprintLib::GetActorComponent<USceneCaptureComponent2D>(this, TEXT("OpticalFlowCaptureComponent"));
77+
captures_[Utils::toNumeric(ImageType::OpticalFlowVis)] =
78+
UAirBlueprintLib::GetActorComponent<USceneCaptureComponent2D>(this, TEXT("OpticalFlowVisCaptureComponent"));
7379

7480
detections_[Utils::toNumeric(ImageType::Scene)] =
7581
UAirBlueprintLib::GetActorComponent<UDetectionComponent>(this, TEXT("DetectionComponent"));

‎Unreal/Plugins/AirSim/Source/SimMode/SimModeBase.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ ASimModeBase::ASimModeBase()
6464
}
6565
else
6666
loading_screen_widget_ = nullptr;
67-
67+
6868
static ConstructorHelpers::FObjectFinder<UMaterial> domain_rand_mat_finder(TEXT("Material'/AirSim/HUDAssets/DomainRandomizationMaterial.DomainRandomizationMaterial'"));
6969
if (domain_rand_mat_finder.Succeeded()) {
7070
domain_rand_material_ = domain_rand_mat_finder.Object;

‎Unreal/Plugins/AirSim/Source/SimMode/SimModeBase.h

-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ class AIRSIM_API ASimModeBase : public AActor
124124

125125
TMap<FString, FAssetData> asset_map;
126126
TMap<FString, AActor*> scene_object_map;
127-
128127
UMaterial* domain_rand_material_;
129128

130129
protected: //must overrides

0 commit comments

Comments
 (0)
Please sign in to comment.