Skip to content

Commit

Permalink
Add Vehicle option for Subwindow settings
Browse files Browse the repository at this point in the history
  • Loading branch information
rajat2004 committed Jul 8, 2020
1 parent b7a65bb commit 07c4d4e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
14 changes: 9 additions & 5 deletions AirLib/include/common/AirSimSettings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}
};
Expand Down Expand Up @@ -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", "");
}
}
}
Expand All @@ -1010,9 +1014,9 @@ struct AirSimSettings {
static void initializeSubwindowSettings(std::vector<SubwindowSetting>& 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)
Expand Down
13 changes: 10 additions & 3 deletions Unreal/Plugins/AirSim/Source/SimHUD/SimHUD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <SubWindows> element in settings.json is invalid",
std::to_string(window_index), LogDebugLevel::Failure);
}
else
UAirBlueprintLib::LogMessageString("Vehicle in <SubWindows> element in settings.json is invalid",
std::to_string(window_index), LogDebugLevel::Failure);

}


Expand Down

0 comments on commit 07c4d4e

Please sign in to comment.