From ebfbb3f96a06f63f8e863684ecc6bc224c488e97 Mon Sep 17 00:00:00 2001 From: Rajat Singhal Date: Tue, 4 Jan 2022 07:39:06 +0530 Subject: [PATCH 1/3] Fix trace toggling for multiple vehicles --- Unreal/Plugins/AirSim/Source/SimHUD/SimHUD.cpp | 4 ++-- Unreal/Plugins/AirSim/Source/SimMode/SimModeBase.cpp | 8 ++++++++ Unreal/Plugins/AirSim/Source/SimMode/SimModeBase.h | 2 ++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Unreal/Plugins/AirSim/Source/SimHUD/SimHUD.cpp b/Unreal/Plugins/AirSim/Source/SimHUD/SimHUD.cpp index bffda000ff..968f41d28e 100644 --- a/Unreal/Plugins/AirSim/Source/SimHUD/SimHUD.cpp +++ b/Unreal/Plugins/AirSim/Source/SimHUD/SimHUD.cpp @@ -88,7 +88,7 @@ void ASimHUD::inputEventToggleHelp() void ASimHUD::inputEventToggleTrace() { - simmode_->getVehicleSimApi()->toggleTrace(); + simmode_->toggleTraceAll(); } ASimHUD::ImageType ASimHUD::getSubwindowCameraType(int window_index) @@ -135,7 +135,7 @@ void ASimHUD::updateWidgetSubwindowVisibility() if (camera != nullptr) { camera->setCameraTypeEnabled(camera_type, is_visible); - //sub-window captures don’t count as a request, set bCaptureEveryFrame and bCaptureOnMovement to display so we can show correctly the subwindow + //sub-window captures don't count as a request, set bCaptureEveryFrame and bCaptureOnMovement to display so we can show correctly the subwindow camera->setCameraTypeUpdate(camera_type, false); } diff --git a/Unreal/Plugins/AirSim/Source/SimMode/SimModeBase.cpp b/Unreal/Plugins/AirSim/Source/SimMode/SimModeBase.cpp index 4e755a2d8e..6edb123860 100644 --- a/Unreal/Plugins/AirSim/Source/SimMode/SimModeBase.cpp +++ b/Unreal/Plugins/AirSim/Source/SimMode/SimModeBase.cpp @@ -513,6 +513,14 @@ bool ASimModeBase::isRecording() const return FRecordingThread::isRecording(); } +void ASimModeBase::toggleTraceAll() +{ + for (auto sim_api : getApiProvider()->getVehicleSimApis()) { + auto* pawn_sim_api = static_cast(sim_api); + pawn_sim_api->toggleTrace(); + } +} + const APIPCamera* ASimModeBase::getCamera(const msr::airlib::CameraDetails& camera_details) const { return camera_details.external ? getExternalCamera(camera_details.camera_name) diff --git a/Unreal/Plugins/AirSim/Source/SimMode/SimModeBase.h b/Unreal/Plugins/AirSim/Source/SimMode/SimModeBase.h index 3b867d57a6..943cece855 100644 --- a/Unreal/Plugins/AirSim/Source/SimMode/SimModeBase.h +++ b/Unreal/Plugins/AirSim/Source/SimMode/SimModeBase.h @@ -71,6 +71,8 @@ class AIRSIM_API ASimModeBase : public AActor virtual void stopRecording(); virtual bool isRecording() const; + virtual void toggleTraceAll(); + void startApiServer(); void stopApiServer(); bool isApiServerStarted(); From a22f947dd15784cbd1a4da5165b50b78d95e5b6d Mon Sep 17 00:00:00 2001 From: Rajat Singhal Date: Tue, 4 Jan 2022 09:05:57 +0530 Subject: [PATCH 2/3] Cleanup SimHUD, remove some unused methods --- .../Plugins/AirSim/Source/SimHUD/SimHUD.cpp | 49 ++++--------------- Unreal/Plugins/AirSim/Source/SimHUD/SimHUD.h | 8 +-- 2 files changed, 10 insertions(+), 47 deletions(-) diff --git a/Unreal/Plugins/AirSim/Source/SimHUD/SimHUD.cpp b/Unreal/Plugins/AirSim/Source/SimHUD/SimHUD.cpp index 968f41d28e..283109e398 100644 --- a/Unreal/Plugins/AirSim/Source/SimHUD/SimHUD.cpp +++ b/Unreal/Plugins/AirSim/Source/SimHUD/SimHUD.cpp @@ -91,40 +91,6 @@ void ASimHUD::inputEventToggleTrace() simmode_->toggleTraceAll(); } -ASimHUD::ImageType ASimHUD::getSubwindowCameraType(int window_index) -{ - //TODO: index check - return getSubWindowSettings().at(window_index).image_type; -} - -void ASimHUD::setSubwindowCameraType(int window_index, ImageType type) -{ - getSubWindowSettings().at(window_index).image_type = type; - updateWidgetSubwindowVisibility(); -} - -APIPCamera* ASimHUD::getSubwindowCamera(int window_index) -{ - return subwindow_cameras_[window_index]; //TODO: index check -} - -void ASimHUD::setSubwindowCamera(int window_index, APIPCamera* camera) -{ - subwindow_cameras_[window_index] = camera; //TODO: index check - updateWidgetSubwindowVisibility(); -} - -bool ASimHUD::getSubwindowVisible(int window_index) -{ - return getSubWindowSettings().at(window_index).visible; -} - -void ASimHUD::setSubwindowVisible(int window_index, bool is_visible) -{ - getSubWindowSettings().at(window_index).visible = is_visible; - updateWidgetSubwindowVisibility(); -} - void ASimHUD::updateWidgetSubwindowVisibility() { for (int window_index = 0; window_index < AirSimSettings::kSubwindowCount; ++window_index) { @@ -150,22 +116,25 @@ bool ASimHUD::isWidgetSubwindowVisible(int window_index) return widget_->getSubwindowVisibility(window_index) != 0; } -void ASimHUD::inputEventToggleSubwindow0() +void ASimHUD::toggleSubwindowVisibility(int window_index) { - getSubWindowSettings().at(0).visible = !getSubWindowSettings().at(0).visible; + getSubWindowSettings().at(window_index).visible = !getSubWindowSettings().at(window_index).visible; updateWidgetSubwindowVisibility(); } +void ASimHUD::inputEventToggleSubwindow0() +{ + toggleSubwindowVisibility(0); +} + void ASimHUD::inputEventToggleSubwindow1() { - getSubWindowSettings().at(1).visible = !getSubWindowSettings().at(1).visible; - updateWidgetSubwindowVisibility(); + toggleSubwindowVisibility(1); } void ASimHUD::inputEventToggleSubwindow2() { - getSubWindowSettings().at(2).visible = !getSubWindowSettings().at(2).visible; - updateWidgetSubwindowVisibility(); + toggleSubwindowVisibility(2); } void ASimHUD::inputEventToggleAll() diff --git a/Unreal/Plugins/AirSim/Source/SimHUD/SimHUD.h b/Unreal/Plugins/AirSim/Source/SimHUD/SimHUD.h index 98ebaaa502..cc4df14f7b 100644 --- a/Unreal/Plugins/AirSim/Source/SimHUD/SimHUD.h +++ b/Unreal/Plugins/AirSim/Source/SimHUD/SimHUD.h @@ -34,13 +34,6 @@ class AIRSIM_API ASimHUD : public AHUD void inputEventToggleSubwindow2(); void inputEventToggleAll(); - ImageType getSubwindowCameraType(int window_index); - void setSubwindowCameraType(int window_index, ImageType type); - APIPCamera* getSubwindowCamera(int window_index); - void setSubwindowCamera(int window_index, APIPCamera* camera); - bool getSubwindowVisible(int window_index); - void setSubwindowVisible(int window_index, bool is_visible); - ASimHUD(); virtual void BeginPlay() override; virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override; @@ -51,6 +44,7 @@ class AIRSIM_API ASimHUD : public AHUD void toggleRecordHandler(); void updateWidgetSubwindowVisibility(); bool isWidgetSubwindowVisible(int window_index); + void toggleSubwindowVisibility(int window_index); private: void initializeSubWindows(); From d90a5a1939336672b736b6c36878080a24b97e91 Mon Sep 17 00:00:00 2001 From: zimmy87 Date: Tue, 11 Jan 2022 23:04:33 -0800 Subject: [PATCH 3/3] clean up AirLibWrapper remove unnecessary subwindow helper functions --- .../AirsimWrapper/Source/SimHUD/SimHUD.cpp | 21 ------------------- .../AirsimWrapper/Source/SimHUD/SimHUD.h | 4 ---- 2 files changed, 25 deletions(-) diff --git a/Unity/AirLibWrapper/AirsimWrapper/Source/SimHUD/SimHUD.cpp b/Unity/AirLibWrapper/AirsimWrapper/Source/SimHUD/SimHUD.cpp index 3e3e46d4f4..3f77dc0838 100644 --- a/Unity/AirLibWrapper/AirsimWrapper/Source/SimHUD/SimHUD.cpp +++ b/Unity/AirLibWrapper/AirsimWrapper/Source/SimHUD/SimHUD.cpp @@ -43,27 +43,6 @@ void SimHUD::EndPlay() } } -SimHUD::ImageType SimHUD::getSubwindowCameraType(int window_index) -{ - //TODO: index check - return getSubWindowSettings().at(window_index).image_type; -} - -void SimHUD::setSubwindowCameraType(int window_index, ImageType type) -{ - getSubWindowSettings().at(window_index).image_type = type; -} - -bool SimHUD::getSubwindowVisible(int window_index) -{ - return getSubWindowSettings().at(window_index).visible; -} - -void SimHUD::setSubwindowVisible(int window_index, bool is_visible) -{ - getSubWindowSettings().at(window_index).visible = is_visible; -} - void SimHUD::initializeSettings() { std::string settingsText; diff --git a/Unity/AirLibWrapper/AirsimWrapper/Source/SimHUD/SimHUD.h b/Unity/AirLibWrapper/AirsimWrapper/Source/SimHUD/SimHUD.h index b6178273ae..b65879f2b2 100644 --- a/Unity/AirLibWrapper/AirsimWrapper/Source/SimHUD/SimHUD.h +++ b/Unity/AirLibWrapper/AirsimWrapper/Source/SimHUD/SimHUD.h @@ -20,10 +20,6 @@ class SimHUD public: SimHUD(std::string sime_mode_name, int port_number); SimModeBase* GetSimMode(); - ImageType getSubwindowCameraType(int window_index); - void setSubwindowCameraType(int window_index, ImageType type); - bool getSubwindowVisible(int window_index); - void setSubwindowVisible(int window_index, bool is_visible); virtual void BeginPlay(); virtual void EndPlay(); virtual void Tick(float DeltaSeconds);