diff --git a/AirLib/include/common/AirSimSettings.hpp b/AirLib/include/common/AirSimSettings.hpp index ce9fd75f5d..8380aeacc0 100644 --- a/AirLib/include/common/AirSimSettings.hpp +++ b/AirLib/include/common/AirSimSettings.hpp @@ -40,9 +40,12 @@ struct AirSimSettings { ImageType image_type; bool visible; std::string camera_name; + std::string vehicle_name; - SubwindowSetting(int window_index_val = 0, ImageType image_type_val = ImageType::Scene, bool visible_val = false, const std::string& camera_name_val = "") - : window_index(window_index_val), image_type(image_type_val), visible(visible_val), camera_name(camera_name_val) + SubwindowSetting(int window_index_val = 0, ImageType image_type_val = ImageType::Scene, + bool visible_val = false, const std::string& camera_name_val = "", const std::string& vehicle_name_val = "") + : window_index(window_index_val), image_type(image_type_val), + visible(visible_val), camera_name(camera_name_val), vehicle_name(vehicle_name_val) { } }; @@ -1002,6 +1005,7 @@ struct AirSimSettings { json_settings_child.getInt("ImageType", 0)); subwindow_setting.visible = json_settings_child.getBool("Visible", false); subwindow_setting.camera_name = getCameraName(json_settings_child); + subwindow_setting.vehicle_name = json_settings_child.getString("Vehicle", ""); } } } @@ -1010,9 +1014,9 @@ struct AirSimSettings { static void initializeSubwindowSettings(std::vector& subwindow_settings) { subwindow_settings.clear(); - subwindow_settings.push_back(SubwindowSetting(0, ImageType::DepthVis, false, "")); //depth - subwindow_settings.push_back(SubwindowSetting(0, ImageType::Segmentation, false, "")); //seg - subwindow_settings.push_back(SubwindowSetting(0, ImageType::Scene, false, "")); //vis + subwindow_settings.push_back(SubwindowSetting(0, ImageType::DepthVis, false, "", "")); //depth + subwindow_settings.push_back(SubwindowSetting(0, ImageType::Segmentation, false, "", "")); //seg + subwindow_settings.push_back(SubwindowSetting(0, ImageType::Scene, false, "", "")); //vis } void loadOtherSettings(const Settings& settings_json) diff --git a/Unreal/Plugins/AirSim/Source/SimHUD/SimHUD.cpp b/Unreal/Plugins/AirSim/Source/SimHUD/SimHUD.cpp index 77a56954d5..efe74f2870 100644 --- a/Unreal/Plugins/AirSim/Source/SimHUD/SimHUD.cpp +++ b/Unreal/Plugins/AirSim/Source/SimHUD/SimHUD.cpp @@ -323,18 +323,25 @@ void ASimHUD::initializeSubWindows() } else subwindow_cameras_[0] = subwindow_cameras_[1] = subwindow_cameras_[2] = nullptr; + } + // TODO: Set default cameras + for (size_t window_index = 0; window_index < AirSimSettings::kSubwindowCount; ++window_index) { - for (size_t window_index = 0; window_index < AirSimSettings::kSubwindowCount; ++window_index) { - - const auto& subwindow_setting = AirSimSettings::singleton().subwindow_settings.at(window_index); + const auto& subwindow_setting = AirSimSettings::singleton().subwindow_settings.at(window_index); + auto vehicle_sim_api = simmode_->getVehicleSimApi(subwindow_setting.vehicle_name); + if (vehicle_sim_api) { if (vehicle_sim_api->getCamera(subwindow_setting.camera_name) != nullptr) subwindow_cameras_[subwindow_setting.window_index] = vehicle_sim_api->getCamera(subwindow_setting.camera_name); else UAirBlueprintLib::LogMessageString("CameraID in element in settings.json is invalid", std::to_string(window_index), LogDebugLevel::Failure); } + else + UAirBlueprintLib::LogMessageString("Vehicle in element in settings.json is invalid", + std::to_string(window_index), LogDebugLevel::Failure); + }