Skip to content

Commit 07c4d4e

Browse files
committed
Add Vehicle option for Subwindow settings
1 parent b7a65bb commit 07c4d4e

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

AirLib/include/common/AirSimSettings.hpp

+9-5
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,12 @@ struct AirSimSettings {
4040
ImageType image_type;
4141
bool visible;
4242
std::string camera_name;
43+
std::string vehicle_name;
4344

44-
SubwindowSetting(int window_index_val = 0, ImageType image_type_val = ImageType::Scene, bool visible_val = false, const std::string& camera_name_val = "")
45-
: window_index(window_index_val), image_type(image_type_val), visible(visible_val), camera_name(camera_name_val)
45+
SubwindowSetting(int window_index_val = 0, ImageType image_type_val = ImageType::Scene,
46+
bool visible_val = false, const std::string& camera_name_val = "", const std::string& vehicle_name_val = "")
47+
: window_index(window_index_val), image_type(image_type_val),
48+
visible(visible_val), camera_name(camera_name_val), vehicle_name(vehicle_name_val)
4649
{
4750
}
4851
};
@@ -1002,6 +1005,7 @@ struct AirSimSettings {
10021005
json_settings_child.getInt("ImageType", 0));
10031006
subwindow_setting.visible = json_settings_child.getBool("Visible", false);
10041007
subwindow_setting.camera_name = getCameraName(json_settings_child);
1008+
subwindow_setting.vehicle_name = json_settings_child.getString("Vehicle", "");
10051009
}
10061010
}
10071011
}
@@ -1010,9 +1014,9 @@ struct AirSimSettings {
10101014
static void initializeSubwindowSettings(std::vector<SubwindowSetting>& subwindow_settings)
10111015
{
10121016
subwindow_settings.clear();
1013-
subwindow_settings.push_back(SubwindowSetting(0, ImageType::DepthVis, false, "")); //depth
1014-
subwindow_settings.push_back(SubwindowSetting(0, ImageType::Segmentation, false, "")); //seg
1015-
subwindow_settings.push_back(SubwindowSetting(0, ImageType::Scene, false, "")); //vis
1017+
subwindow_settings.push_back(SubwindowSetting(0, ImageType::DepthVis, false, "", "")); //depth
1018+
subwindow_settings.push_back(SubwindowSetting(0, ImageType::Segmentation, false, "", "")); //seg
1019+
subwindow_settings.push_back(SubwindowSetting(0, ImageType::Scene, false, "", "")); //vis
10161020
}
10171021

10181022
void loadOtherSettings(const Settings& settings_json)

Unreal/Plugins/AirSim/Source/SimHUD/SimHUD.cpp

+10-3
Original file line numberDiff line numberDiff line change
@@ -323,18 +323,25 @@ void ASimHUD::initializeSubWindows()
323323
}
324324
else
325325
subwindow_cameras_[0] = subwindow_cameras_[1] = subwindow_cameras_[2] = nullptr;
326+
}
326327

328+
// TODO: Set default cameras
329+
for (size_t window_index = 0; window_index < AirSimSettings::kSubwindowCount; ++window_index) {
327330

328-
for (size_t window_index = 0; window_index < AirSimSettings::kSubwindowCount; ++window_index) {
329-
330-
const auto& subwindow_setting = AirSimSettings::singleton().subwindow_settings.at(window_index);
331+
const auto& subwindow_setting = AirSimSettings::singleton().subwindow_settings.at(window_index);
332+
auto vehicle_sim_api = simmode_->getVehicleSimApi(subwindow_setting.vehicle_name);
331333

334+
if (vehicle_sim_api) {
332335
if (vehicle_sim_api->getCamera(subwindow_setting.camera_name) != nullptr)
333336
subwindow_cameras_[subwindow_setting.window_index] = vehicle_sim_api->getCamera(subwindow_setting.camera_name);
334337
else
335338
UAirBlueprintLib::LogMessageString("CameraID in <SubWindows> element in settings.json is invalid",
336339
std::to_string(window_index), LogDebugLevel::Failure);
337340
}
341+
else
342+
UAirBlueprintLib::LogMessageString("Vehicle in <SubWindows> element in settings.json is invalid",
343+
std::to_string(window_index), LogDebugLevel::Failure);
344+
338345
}
339346

340347

0 commit comments

Comments
 (0)