From 9082e403baaa76712df8342832d5175d0a3c7d21 Mon Sep 17 00:00:00 2001 From: Wouter Jansen Date: Tue, 1 Jul 2025 10:33:30 +0200 Subject: [PATCH 01/10] Fixed duplicate indexes for annotation system causing meshes to not show up in annotation masks. --- .../Source/Annotation/AnnotationComponent.cpp | 2 +- .../Source/Annotation/ObjectAnnotator.cpp | 70 ++++++++++++++++--- 2 files changed, 61 insertions(+), 11 deletions(-) diff --git a/Unreal/Plugins/AirSim/Source/Annotation/AnnotationComponent.cpp b/Unreal/Plugins/AirSim/Source/Annotation/AnnotationComponent.cpp index d7c99b759..897b44d18 100644 --- a/Unreal/Plugins/AirSim/Source/Annotation/AnnotationComponent.cpp +++ b/Unreal/Plugins/AirSim/Source/Annotation/AnnotationComponent.cpp @@ -432,7 +432,7 @@ FPrimitiveSceneProxy* UAnnotationComponent::CreateSceneProxy() // } else { - UE_LOG(LogTemp, Warning, TEXT("AirSim Annotation: The type of ParentMeshComponent : %s can not be supported."), *ParentComponent->GetClass()->GetName()); + //UE_LOG(LogTemp, Warning, TEXT("AirSim Annotation: The type of ParentMeshComponent : %s can not be supported."), *ParentComponent->GetClass()->GetName()); return nullptr; } // return nullptr; diff --git a/Unreal/Plugins/AirSim/Source/Annotation/ObjectAnnotator.cpp b/Unreal/Plugins/AirSim/Source/Annotation/ObjectAnnotator.cpp index db41e4f4b..3aeacd2b0 100644 --- a/Unreal/Plugins/AirSim/Source/Annotation/ObjectAnnotator.cpp +++ b/Unreal/Plugins/AirSim/Source/Annotation/ObjectAnnotator.cpp @@ -3,6 +3,8 @@ // Licensed under the MIT License. #include "ObjectAnnotator.h" #include "Runtime/Engine/Public/EngineUtils.h" +#include "SceneInterface.h" +#include "../Private/ScenePrivate.h" #include "Runtime/Launch/Resources/Version.h" #include "AnnotationComponent.h" #include "AirBlueprintLib.h" @@ -72,6 +74,16 @@ void FObjectAnnotator::getPaintableComponentMeshes(AActor* actor, TMapGetUniqueID(); + if (const UPrimitiveComponent* PrimitiveComp = Cast(component)) + { + if (const FPrimitiveSceneProxy* SceneProxy = PrimitiveComp->SceneProxy) + { + int32 PersistentPrimitiveIndexTemp = SceneProxy->GetPrimitiveSceneInfo()->GetPersistentIndex().Index; + if (PersistentPrimitiveIndexTemp != -1) + PersistentPrimitiveIndex = PersistentPrimitiveIndexTemp; + } + } if (paintable_components.Num() == 1) { if (UStaticMeshComponent* staticmesh_component = Cast(component)) { if (actor->GetParentActor()) { @@ -84,7 +96,9 @@ void FObjectAnnotator::getPaintableComponentMeshes(AActor* actor, TMapGetRootComponent()->GetAttachParent()->GetName()); component_name.Append("_"); } - component_name.Append(actor->GetParentActor()->GetName()); + component_name.Append(actor->GetParentActor()->GetName()); + component_name.Append("_"); + component_name.Append(FString::FromInt(PersistentPrimitiveIndex)); paintable_components_meshes->Emplace(component_name, component); } } @@ -99,15 +113,23 @@ void FObjectAnnotator::getPaintableComponentMeshes(AActor* actor, TMapGetName()); + component_name.Append("_"); + component_name.Append(FString::FromInt(PersistentPrimitiveIndex)); paintable_components_meshes->Emplace(component_name, component); } - else { - paintable_components_meshes->Emplace(actor->GetName(), component); + else { + FString component_name = actor->GetName(); + component_name.Append("_"); + component_name.Append(FString::FromInt(PersistentPrimitiveIndex)); + paintable_components_meshes->Emplace(component_name, component); } } } if (USkinnedMeshComponent* SkinnedMeshComponent = Cast(component)) { - paintable_components_meshes->Emplace(actor->GetName(), component); + FString component_name = actor->GetName(); + component_name.Append("_"); + component_name.Append(FString::FromInt(PersistentPrimitiveIndex)); + paintable_components_meshes->Emplace(component_name, component); } } else { @@ -128,10 +150,14 @@ void FObjectAnnotator::getPaintableComponentMeshes(AActor* actor, TMapGetName()); } + component_name.Append("_"); + component_name.Append(FString::FromInt(PersistentPrimitiveIndex)); } } if (USkinnedMeshComponent* skinnedmesh_component = Cast(component)) { component_name = actor->GetName(); + component_name.Append("_"); + component_name.Append(FString::FromInt(PersistentPrimitiveIndex)); } paintable_components_meshes->Emplace(component_name, component); index++; @@ -146,6 +172,16 @@ void FObjectAnnotator::getPaintableComponentMeshesAndTags(AActor* actor, TMapGetUniqueID(); + if (const UPrimitiveComponent* PrimitiveComp = Cast(component)) + { + if (const FPrimitiveSceneProxy* SceneProxy = PrimitiveComp->SceneProxy) + { + int32 PersistentPrimitiveIndexTemp = SceneProxy->GetPrimitiveSceneInfo()->GetPersistentIndex().Index; + if (PersistentPrimitiveIndexTemp != -1) + PersistentPrimitiveIndex = PersistentPrimitiveIndexTemp; + } + } if (paintable_components.Num() == 1) { if (UStaticMeshComponent* staticmesh_component = Cast(component)) { if (actor->GetParentActor()) { @@ -159,6 +195,8 @@ void FObjectAnnotator::getPaintableComponentMeshesAndTags(AActor* actor, TMapGetParentActor()->GetName()); + component_name.Append("_"); + component_name.Append(FString::FromInt(PersistentPrimitiveIndex)); paintable_components_meshes->Emplace(component_name, component); paintable_components_tags->Emplace(component_name, staticmesh_component->ComponentTags); } @@ -174,6 +212,8 @@ void FObjectAnnotator::getPaintableComponentMeshesAndTags(AActor* actor, TMapGetName()); + component_name.Append("_"); + component_name.Append(FString::FromInt(PersistentPrimitiveIndex)); paintable_components_meshes->Emplace(component_name, component); if (actor->Tags.Num() > 0) paintable_components_tags->Emplace(component_name, actor->Tags); @@ -181,21 +221,27 @@ void FObjectAnnotator::getPaintableComponentMeshesAndTags(AActor* actor, TMapEmplace(component_name, staticmesh_component->ComponentTags); } else { - paintable_components_meshes->Emplace(actor->GetName(), component); + FString component_name = actor->GetName(); + component_name.Append("_"); + component_name.Append(FString::FromInt(PersistentPrimitiveIndex)); + paintable_components_meshes->Emplace(component_name, component); if (actor->Tags.Num() > 0) - paintable_components_tags->Emplace(actor->GetName(), actor->Tags); + paintable_components_tags->Emplace(component_name, actor->Tags); else - paintable_components_tags->Emplace(actor->GetName(), staticmesh_component->ComponentTags); + paintable_components_tags->Emplace(component_name, staticmesh_component->ComponentTags); } } } if (USkinnedMeshComponent* SkinnedMeshComponent = Cast(component)) { + FString component_name = actor->GetName(); + component_name.Append("_"); + component_name.Append(FString::FromInt(PersistentPrimitiveIndex)); if (actor->Tags.Num() > 0) - paintable_components_tags->Emplace(actor->GetName(), actor->Tags); + paintable_components_tags->Emplace(component_name, actor->Tags); else - paintable_components_tags->Emplace(actor->GetName(), SkinnedMeshComponent->ComponentTags); - paintable_components_meshes->Emplace(actor->GetName(), component); + paintable_components_tags->Emplace(component_name, SkinnedMeshComponent->ComponentTags); + paintable_components_meshes->Emplace(component_name, component); } } else { @@ -217,10 +263,14 @@ void FObjectAnnotator::getPaintableComponentMeshesAndTags(AActor* actor, TMapGetName()); } } + component_name.Append("_"); + component_name.Append(FString::FromInt(PersistentPrimitiveIndex)); paintable_components_tags->Emplace(component_name, staticmesh_component->ComponentTags); } if (USkinnedMeshComponent* skinnedmesh_component = Cast(component)) { component_name = actor->GetName(); + component_name.Append("_"); + component_name.Append(FString::FromInt(PersistentPrimitiveIndex)); paintable_components_tags->Emplace(component_name, skinnedmesh_component->ComponentTags); } paintable_components_meshes->Emplace(component_name, component); From d5031c4a21fc1b921525f8bdc265d99c3be37cbe Mon Sep 17 00:00:00 2001 From: Wouter Jansen Date: Tue, 1 Jul 2025 10:35:25 +0200 Subject: [PATCH 02/10] Updated for WIP changes --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bee313dc3..ce44caf28 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +### Development (version 3.4) +* Fixed duplicate indexes for annotation system causing meshes to not show up in annotation masks. + ### April 2025 (version 3.3) * The latest available stable Unreal Engine version that is now targeted for release is 5.5. This means 5.4 will no longer be actively maintained. * The documentation now is placed on a sub-URL page here: https://cosys-lab.github.io/Cosys-AirSim From 26c6160d4ca744689372f85cbc92d36b98067206 Mon Sep 17 00:00:00 2001 From: Wouter Jansen Date: Tue, 1 Jul 2025 10:35:44 +0200 Subject: [PATCH 03/10] updated version numbering to match changelog and other versioning systems --- Unreal/Plugins/AirSim/AirSim.uplugin | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Unreal/Plugins/AirSim/AirSim.uplugin b/Unreal/Plugins/AirSim/AirSim.uplugin index ae5bf2c5a..3d7119897 100644 --- a/Unreal/Plugins/AirSim/AirSim.uplugin +++ b/Unreal/Plugins/AirSim/AirSim.uplugin @@ -1,7 +1,7 @@ { "FileVersion" : 3, - "Version" : "2.0.0", - "VersionName": "2.0.0", + "Version" : "3.4.0", + "VersionName": "3.4.0", "FriendlyName": "Cosys-AirSim", "Description": "Cosys-AirSim - Simulator Plugin", "Category" : "Science", From c22956a8dea406ae4e2fd171034a32eba58ba394 Mon Sep 17 00:00:00 2001 From: Wouter Jansen Date: Tue, 1 Jul 2025 10:42:42 +0200 Subject: [PATCH 04/10] WIP 5.6 documentation --- CHANGELOG.md | 1 + README.md | 2 +- docs/docker_ubuntu.md | 6 +++--- docs/install_linux.md | 6 +++--- docs/install_windows.md | 4 ++-- docs/packaging.md | 2 +- docs/run_packaged.md | 2 +- docs/skid_steer_vehicle.md | 2 +- 8 files changed, 13 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ce44caf28..f9740f484 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ ### Development (version 3.4) +* Added support for Unreal 5.6. This will become the next targeted stable Unreal Engine replacing 5.5 when Cosys-AirSim 3.4 releases. * Fixed duplicate indexes for annotation system causing meshes to not show up in annotation masks. ### April 2025 (version 3.3) diff --git a/README.md b/README.md index 875137a61..e42568b66 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Please note that we use that same [MIT license](https://github.com/Cosys-Lab/Cos Do note that this repository is provided as is, will not be actively updated and comes without warranty or support. Please contact a Cosys-Lab researcher to get more in depth information on which branch or version is best for your work. -This [5.5 dev branch](https://github.com/Cosys-Lab/Cosys-AirSim/tree/5.5dev) is for the development of Cosys-AirSim on Unreal Engine v5.5.0. The documentation is best read from [source](https://github.com/Cosys-Lab/Cosys-AirSim/tree/5.5dev/docs). +This [5.6 dev branch](https://github.com/Cosys-Lab/Cosys-AirSim/tree/5.6dev) is for the development of Cosys-AirSim on Unreal Engine v5.6.0. The documentation is best read from [source](https://github.com/Cosys-Lab/Cosys-AirSim/tree/5.6dev/docs). For the latest stable and maintained build for a recent Unreal Engine see the [main branch](https://github.com/Cosys-Lab/Cosys-AirSim/tree/main) and associated builds in the [releases](https://github.com/Cosys-Lab/Cosys-AirSim/releases). Unreal [5.2.1](https://github.com/Cosys-Lab/Cosys-AirSim/tree/5.2.1) is also available for long term support builds. diff --git a/docs/docker_ubuntu.md b/docs/docker_ubuntu.md index bacf6b729..6e80657b8 100644 --- a/docs/docker_ubuntu.md +++ b/docs/docker_ubuntu.md @@ -69,8 +69,8 @@ xhost +local:docker $ cd Airsim/docker; $ python build_airsim_image.py \ --source \ - ----base_image ghcr.io/epicgames/unreal-engine:dev-5.5.X \ - --target_image=airsim_source:dev-5.5.X + ----base_image ghcr.io/epicgames/unreal-engine:dev-5.6.X \ + --target_image=airsim_source:dev-5.6.X ``` #### Running Cosys-AirSim container @@ -78,7 +78,7 @@ $ python build_airsim_image.py \ ```bash xhost +local:docker -./run_airsim_image_source.sh airsim_source:dev-5.5.X +./run_airsim_image_source.sh airsim_source:dev-5.6.X ``` Syntax is `./run_airsim_image_source.sh DOCKER_IMAGE_NAME` diff --git a/docs/install_linux.md b/docs/install_linux.md index 49bcf8d30..447840639 100755 --- a/docs/install_linux.md +++ b/docs/install_linux.md @@ -12,10 +12,10 @@ sudo ./llvm.sh ``` ## Install Unreal Engine -Download the latest version of Unreal Engine 5.5 from the [official download page](https://www.unrealengine.com/en-US/linux). +Download the latest version of Unreal Engine 5.6 from the [official download page](https://www.unrealengine.com/en-US/linux). This will require an Epic Games account. Once the zip archive is downloaded you can extract it to where you want to install the Unreal Engine. ```bash -unzip Linux_Unreal_Engine_5.5.X.zip -d destination_folder +unzip Linux_Unreal_Engine_5.6.X.zip -d destination_folder ``` If you chose a folder such as for example `/opt/UnrealEngine` make sure to provide permissions and to set the owner, otherwise you might run into issues: ```bash @@ -23,7 +23,7 @@ sudo chmod -R 777 /opt/UnrealEngine sudo chown -r yourusername /opt/UnrealEngine ``` From where you install Unreal Engine, you can run `Engine/Binaries/Linux/UnrealEditor` from the terminal to launch Unreal Engine. -For more information you can read the [quick start guide](https://dev.epicgames.com/documentation/en-us/unreal-engine/linux-development-quickstart-for-unreal-engine?application_version=5.5). +For more information you can read the [quick start guide](https://dev.epicgames.com/documentation/en-us/unreal-engine/linux-development-quickstart-for-unreal-engine?application_version=5.6). You can alternatively install Unreal Engine from source if you do not use a Ubuntu distribution, see the documentation linked above for more information. diff --git a/docs/install_windows.md b/docs/install_windows.md index e50201005..611e6080b 100644 --- a/docs/install_windows.md +++ b/docs/install_windows.md @@ -3,12 +3,12 @@ ## Install Unreal Engine 1. [Download](https://www.unrealengine.com/download) the Epic Games Launcher. While the Unreal Engine is open source and free to download, registration is still required. 2. Run the Epic Games Launcher, open the `Unreal Engine` tab on the left pane. -Click on the `Install` button on the top right, which should show the option to download **Unreal Engine 5.5.X**. Chose the install location to suit your needs, as shown in the images below. If you have multiple versions of Unreal installed then **make sure the version you are using is set to `current`** by clicking down arrow next to the Launch button for the version. +Click on the `Install` button on the top right, which should show the option to download **Unreal Engine 5.6.X**. Chose the install location to suit your needs, as shown in the images below. If you have multiple versions of Unreal installed then **make sure the version you are using is set to `current`** by clicking down arrow next to the Launch button for the version. ![Unreal Engine Tab UI Screenshot](images/ue_install.png) ![Unreal Engine Install Location UI Screenshot](images/ue_install_location.png) ## Build Cosys-AirSim -* Install Visual Studio 2022. Make sure to select Desktop Development with C++ and Windows 10/11 SDK **10.0.X (choose latest)** and select the latest .NET Framework SDK under the 'Individual Components' tab while installing VS 2022. More info [here](https://dev.epicgames.com/documentation/en-us/unreal-engine/setting-up-visual-studio-development-environment-for-cplusplus-projects-in-unreal-engine?application_version=5.5). +* Install Visual Studio 2022. Make sure to select Desktop Development with C++ and Windows 10/11 SDK **10.0.X (choose latest)** and select the latest .NET Framework SDK under the 'Individual Components' tab while installing VS 2022. More info [here](https://dev.epicgames.com/documentation/en-us/unreal-engine/setting-up-visual-studio-development-environment-for-cplusplus-projects-in-unreal-engine?application_version=5.6). * Start `Developer Command Prompt for VS 2022`. * Clone the repo: `git clone https://github.com/Cosys-Lab/Cosys-AirSim.git`, and go the AirSim directory by `cd Cosys-AirSim`. * Run `build.cmd` from the command line. This will create ready to use plugin bits in the `Unreal\Plugins` folder that can be dropped into any Unreal project. diff --git a/docs/packaging.md b/docs/packaging.md index ae9641135..ca5b624db 100644 --- a/docs/packaging.md +++ b/docs/packaging.md @@ -9,7 +9,7 @@ packaging an entire project including the plugin. First you need to build the library. On Windows: -* Install Visual Studio 2022. Make sure to select Desktop Development with C++ and Windows 10/11 SDK **10.0.X (choose latest)** and select the latest .NET Framework SDK under the 'Individual Components' tab while installing VS 2022. More info [here](https://dev.epicgames.com/documentation/en-us/unreal-engine/setting-up-visual-studio-development-environment-for-cplusplus-projects-in-unreal-engine?application_version=5.5). +* Install Visual Studio 2022. Make sure to select Desktop Development with C++ and Windows 10/11 SDK **10.0.X (choose latest)** and select the latest .NET Framework SDK under the 'Individual Components' tab while installing VS 2022. More info [here](https://dev.epicgames.com/documentation/en-us/unreal-engine/setting-up-visual-studio-development-environment-for-cplusplus-projects-in-unreal-engine?application_version=5.6). * Start `Developer Command Prompt for VS 2022`. * Clone the repo: `git clone https://github.com/Cosys-Lab/Cosys-AirSim.git`, and go the AirSim directory by `cd Cosys-AirSim`. * Run `build.cmd` from the command line. This will create ready to use plugin bits in the `Unreal\Plugins` folder. diff --git a/docs/run_packaged.md b/docs/run_packaged.md index 49bfb748c..b48765bba 100644 --- a/docs/run_packaged.md +++ b/docs/run_packaged.md @@ -1,7 +1,7 @@ # Download and run Packaged Binary If you wish to test the Cosys-AirSim plugin a simple environment without having to install Unreal Engine, you can download the prepackaged binary for the Blocks test environment from the [releases page](https://github.com/Cosys-Lab/Cosys-AirSim/releases) and run it as a binary executable on Windows (_Blocks.exe_) or start it with a shell script (_./Blocks.sh_) on Linux systems. -They support multiple launch arguments. More info can be found [here](https://dev.epicgames.com/documentation/en-us/unreal-engine/command-line-arguments-in-unreal-engine?application_version=5.5). +They support multiple launch arguments. More info can be found [here](https://dev.epicgames.com/documentation/en-us/unreal-engine/command-line-arguments-in-unreal-engine?application_version=5.6). The releases page also comes with additional downloads and links to the several API implementations for ROS(2) and the Python and Matlab API clients for that specific version of the Cosys-AirSim plugin. diff --git a/docs/skid_steer_vehicle.md b/docs/skid_steer_vehicle.md index 5ad19da90..548fd6e76 100644 --- a/docs/skid_steer_vehicle.md +++ b/docs/skid_steer_vehicle.md @@ -9,7 +9,7 @@ It is build using the Chaos engine of Unreal which does not support this vehicle ## Creating a new skid steer vehicle The steps to setup the vehicle are largely the same as a WheeledVehiclePawn with some slight adjustments. -1. Follow [this guide](https://dev.epicgames.com/documentation/en-us/unreal-engine/how-to-set-up-vehicles-in-unreal-engine?application_version=5.5) to create the skeletal mesh and physics asset. +1. Follow [this guide](https://dev.epicgames.com/documentation/en-us/unreal-engine/how-to-set-up-vehicles-in-unreal-engine?application_version=5.6) to create the skeletal mesh and physics asset. 2. For the wheels setup, the vehicle should have 4 wheels, 2 for the left side and 2 for the right side. Please use SkidWheel as the wheel class. 3. For the vehicle blueprint to create the pawn it is also largely the same as in that tutorial however as class one should use the *SkidVehiclePawn* sub-class. The vehicle setup parameters are more simplified. 4. To have animated wheels, proper physics and correct steering behavior, please take a look at how the CPHusky is configured in the AirSim plugin. The Husky is a skid steer vehicle and can be used as a reference. From ab3f2bc3e0eb45a7300177390243adad6e753d96 Mon Sep 17 00:00:00 2001 From: Wouter Jansen Date: Tue, 1 Jul 2025 11:26:43 +0200 Subject: [PATCH 05/10] Fixes for Unreal 5.6 --- Unreal/Environments/Blocks/Blocks.uproject | 2 +- Unreal/Plugins/AirSim/Source/AirBlueprintLib.cpp | 15 ++++++++++++++- Unreal/Plugins/AirSim/Source/PawnSimApi.cpp | 4 ++-- Unreal/Plugins/AirSim/Source/SimHUD/SimHUD.cpp | 2 +- Unreal/Plugins/AirSim/Source/WorldSimApi.cpp | 3 +-- 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/Unreal/Environments/Blocks/Blocks.uproject b/Unreal/Environments/Blocks/Blocks.uproject index b4aef6c07..818254649 100644 --- a/Unreal/Environments/Blocks/Blocks.uproject +++ b/Unreal/Environments/Blocks/Blocks.uproject @@ -1,6 +1,6 @@ { "FileVersion": 3, - "EngineAssociation": "5.5", + "EngineAssociation": "5.6", "Category": "", "Description": "", "Modules": [ diff --git a/Unreal/Plugins/AirSim/Source/AirBlueprintLib.cpp b/Unreal/Plugins/AirSim/Source/AirBlueprintLib.cpp index 93b4f43fd..89346e6b5 100644 --- a/Unreal/Plugins/AirSim/Source/AirBlueprintLib.cpp +++ b/Unreal/Plugins/AirSim/Source/AirBlueprintLib.cpp @@ -58,7 +58,20 @@ EAppReturnType::Type UAirBlueprintLib::ShowMessage(EAppMsgType::Type message_typ ULineBatchComponent* GetLineBatcher(const UWorld* InWorld, bool bPersistentLines, float LifeTime, bool bDepthIsForeground) { - return (InWorld ? (bDepthIsForeground ? InWorld->ForegroundLineBatcher : ((bPersistentLines || (LifeTime > 0.f)) ? InWorld->PersistentLineBatcher : InWorld->LineBatcher)) : NULL); + + if (InWorld) + { + if (bPersistentLines || LifeTime > 0.f) + { + return bDepthIsForeground ? InWorld->GetLineBatcher(UWorld::ELineBatcherType::ForegroundPersistent) : InWorld->GetLineBatcher(UWorld::ELineBatcherType::WorldPersistent); + } + else + { + return bDepthIsForeground ? InWorld->GetLineBatcher(UWorld::ELineBatcherType::Foreground) : InWorld->GetLineBatcher(UWorld::ELineBatcherType::World); + } + } + return nullptr; + //return (InWorld ? (bDepthIsForeground ? InWorld->ForegroundLineBatcher : ((bPersistentLines || (LifeTime > 0.f)) ? InWorld->PersistentLineBatcher : InWorld->LineBatcher)) : NULL); } static float GetLineLifeTime(ULineBatchComponent* LineBatcher, float LifeTime, bool bPersistent) diff --git a/Unreal/Plugins/AirSim/Source/PawnSimApi.cpp b/Unreal/Plugins/AirSim/Source/PawnSimApi.cpp index 508062eb1..f0d23b50b 100755 --- a/Unreal/Plugins/AirSim/Source/PawnSimApi.cpp +++ b/Unreal/Plugins/AirSim/Source/PawnSimApi.cpp @@ -438,12 +438,12 @@ bool PawnSimApi::testLineOfSightToPoint(const msr::airlib::GeoPoint& lla) const if (hit) { // No LOS, so draw red line FLinearColor color{ 1.0f, 0, 0, 0.4f }; - params_.pawn->GetWorld()->LineBatcher->DrawLine(params_.pawn->GetActorLocation(), target_location, color, SDPG_World, 10, -1); + UAirBlueprintLib::DrawLine(params_.pawn->GetWorld(), params_.pawn->GetActorLocation(), target_location, color.ToFColor(false), SDPG_World, 10, -1); } else { // Yes LOS, so draw green line FLinearColor color{ 0, 1.0f, 0, 0.4f }; - params_.pawn->GetWorld()->LineBatcher->DrawLine(params_.pawn->GetActorLocation(), target_location, color, SDPG_World, 10, -1); + UAirBlueprintLib::DrawLine(params_.pawn->GetWorld(), params_.pawn->GetActorLocation(), target_location, color.ToFColor(false), SDPG_World, 10, -1); } } }, diff --git a/Unreal/Plugins/AirSim/Source/SimHUD/SimHUD.cpp b/Unreal/Plugins/AirSim/Source/SimHUD/SimHUD.cpp index c82ecae77..c808f737a 100644 --- a/Unreal/Plugins/AirSim/Source/SimHUD/SimHUD.cpp +++ b/Unreal/Plugins/AirSim/Source/SimHUD/SimHUD.cpp @@ -171,7 +171,7 @@ void ASimHUD::createMainWidget() //create main widget if (widget_class_ != nullptr) { APlayerController* player_controller = this->GetWorld()->GetFirstPlayerController(); - auto* pawn = player_controller->GetPawn(); + TObjectPtr pawn = player_controller->GetPawn(); if (pawn) { std::string pawn_name = std::string(TCHAR_TO_ANSI(*pawn->GetName())); Utils::log(pawn_name); diff --git a/Unreal/Plugins/AirSim/Source/WorldSimApi.cpp b/Unreal/Plugins/AirSim/Source/WorldSimApi.cpp index bffd69967..1df0dea0d 100644 --- a/Unreal/Plugins/AirSim/Source/WorldSimApi.cpp +++ b/Unreal/Plugins/AirSim/Source/WorldSimApi.cpp @@ -856,8 +856,7 @@ bool WorldSimApi::testLineOfSightBetweenPoints(const msr::airlib::GeoPoint& lla1 // Yes LOS, so draw green line color = FLinearColor{ 0, 1.0f, 0, 0.4f }; } - - simmode_->GetWorld()->PersistentLineBatcher->DrawLine(point1, point2, color, SDPG_World, 4, 999999); + UAirBlueprintLib::DrawLine(simmode_->GetWorld(), point1, point2, color.ToFColor(false), SDPG_World, 10, -1); } }, true); From d44edf26fc2eab39199c33d044f4a8bb84bb86a0 Mon Sep 17 00:00:00 2001 From: Wouter Jansen Date: Tue, 1 Jul 2025 11:54:26 +0200 Subject: [PATCH 06/10] workaround for build issue on 5.6 --- Unreal/Plugins/AirSim/Source/AirSim.Build.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Unreal/Plugins/AirSim/Source/AirSim.Build.cs b/Unreal/Plugins/AirSim/Source/AirSim.Build.cs index 6109d172d..cd9a0b70f 100644 --- a/Unreal/Plugins/AirSim/Source/AirSim.Build.cs +++ b/Unreal/Plugins/AirSim/Source/AirSim.Build.cs @@ -93,6 +93,13 @@ public AirSim(ReadOnlyTargetRules Target) : base(Target) PublicIncludePaths.Add(Path.Combine(AirLibPath, "deps", "eigen3")); AddOSLibDependencies(Target); + PrivateIncludePaths.AddRange( + new string[] { + Path.Combine(GetModuleDirectory("Renderer"), "Private"), + Path.Combine(GetModuleDirectory("Renderer"), "Internal"), + } + ); + SetupCompileMode(CompileMode.HeaderOnlyWithRpc, Target); } From e4bad64c78cff993536690409a9cebe623b25eaa Mon Sep 17 00:00:00 2001 From: Wouter Jansen Date: Tue, 1 Jul 2025 16:02:21 +0200 Subject: [PATCH 07/10] fixed crash on endplay --- Unreal/Plugins/AirSim/Config/FilterPlugin.ini | 8 ++++++++ Unreal/Plugins/AirSim/Source/AirSimCameraDirector.cpp | 2 ++ Unreal/Plugins/AirSim/Source/LidarCamera.cpp | 1 + Unreal/Plugins/AirSim/Source/PIPCamera.cpp | 3 +++ Unreal/Plugins/AirSim/Source/Vehicles/Car/CarPawn.cpp | 2 ++ .../Source/Vehicles/ComputerVision/ComputerVisionPawn.cpp | 3 +++ .../AirSim/Source/Vehicles/SkidSteer/SkidVehiclePawn.cpp | 3 +++ 7 files changed, 22 insertions(+) create mode 100644 Unreal/Plugins/AirSim/Config/FilterPlugin.ini diff --git a/Unreal/Plugins/AirSim/Config/FilterPlugin.ini b/Unreal/Plugins/AirSim/Config/FilterPlugin.ini new file mode 100644 index 000000000..ccebca2f3 --- /dev/null +++ b/Unreal/Plugins/AirSim/Config/FilterPlugin.ini @@ -0,0 +1,8 @@ +[FilterPlugin] +; This section lists additional files which will be packaged along with your plugin. Paths should be listed relative to the root plugin directory, and +; may include "...", "*", and "?" wildcards to match directories, files, and individual characters respectively. +; +; Examples: +; /README.txt +; /Extras/... +; /Binaries/ThirdParty/*.dll diff --git a/Unreal/Plugins/AirSim/Source/AirSimCameraDirector.cpp b/Unreal/Plugins/AirSim/Source/AirSimCameraDirector.cpp index 9881b9f17..17f0b8c9b 100644 --- a/Unreal/Plugins/AirSim/Source/AirSimCameraDirector.cpp +++ b/Unreal/Plugins/AirSim/Source/AirSimCameraDirector.cpp @@ -207,6 +207,8 @@ void AAirSimCameraDirector::EndPlay(const EEndPlayReason::Type EndPlayReason) backup_camera_ = nullptr; front_camera_ = nullptr; follow_actor_ = nullptr; + + Super::EndPlay(EndPlayReason); } APIPCamera* AAirSimCameraDirector::getFpvCamera() const diff --git a/Unreal/Plugins/AirSim/Source/LidarCamera.cpp b/Unreal/Plugins/AirSim/Source/LidarCamera.cpp index 0f0bf5274..01ef33e4e 100755 --- a/Unreal/Plugins/AirSim/Source/LidarCamera.cpp +++ b/Unreal/Plugins/AirSim/Source/LidarCamera.cpp @@ -142,6 +142,7 @@ void ALidarCamera::EndPlay(const EEndPlayReason::Type EndPlayReason) render_target_2D_segmentation_ = nullptr; capture_2D_intensity_ = nullptr; render_target_2D_intensity_ = nullptr; + Super::EndPlay(EndPlayReason); } // Get all the settings from AirSim diff --git a/Unreal/Plugins/AirSim/Source/PIPCamera.cpp b/Unreal/Plugins/AirSim/Source/PIPCamera.cpp index df94876ce..e7ae455a8 100644 --- a/Unreal/Plugins/AirSim/Source/PIPCamera.cpp +++ b/Unreal/Plugins/AirSim/Source/PIPCamera.cpp @@ -399,6 +399,9 @@ void APIPCamera::EndPlay(const EEndPlayReason::Type EndPlayReason) captures_.Empty(); render_targets_.Empty(); detections_.Empty(); + + + Super::EndPlay(EndPlayReason); } unsigned int APIPCamera::imageTypeCount() diff --git a/Unreal/Plugins/AirSim/Source/Vehicles/Car/CarPawn.cpp b/Unreal/Plugins/AirSim/Source/Vehicles/Car/CarPawn.cpp index 952683e41..ccf326da2 100644 --- a/Unreal/Plugins/AirSim/Source/Vehicles/Car/CarPawn.cpp +++ b/Unreal/Plugins/AirSim/Source/Vehicles/Car/CarPawn.cpp @@ -236,6 +236,8 @@ void ACarPawn::EndPlay(const EEndPlayReason::Type EndPlayReason) camera_front_right_base_ = nullptr; camera_driver_base_ = nullptr; camera_back_center_base_ = nullptr; + + Super::EndPlay(EndPlayReason); } void ACarPawn::Tick(float Delta) diff --git a/Unreal/Plugins/AirSim/Source/Vehicles/ComputerVision/ComputerVisionPawn.cpp b/Unreal/Plugins/AirSim/Source/Vehicles/ComputerVision/ComputerVisionPawn.cpp index 1855cd5e8..0b02082bd 100644 --- a/Unreal/Plugins/AirSim/Source/Vehicles/ComputerVision/ComputerVisionPawn.cpp +++ b/Unreal/Plugins/AirSim/Source/Vehicles/ComputerVision/ComputerVisionPawn.cpp @@ -105,6 +105,9 @@ void AComputerVisionPawn::EndPlay(const EEndPlayReason::Type EndPlayReason) camera_back_center_base_ = nullptr; manual_pose_controller_ = nullptr; + + + Super::EndPlay(EndPlayReason); } void AComputerVisionPawn::Tick(float Delta) diff --git a/Unreal/Plugins/AirSim/Source/Vehicles/SkidSteer/SkidVehiclePawn.cpp b/Unreal/Plugins/AirSim/Source/Vehicles/SkidSteer/SkidVehiclePawn.cpp index 209d43ca0..917a9b768 100755 --- a/Unreal/Plugins/AirSim/Source/Vehicles/SkidSteer/SkidVehiclePawn.cpp +++ b/Unreal/Plugins/AirSim/Source/Vehicles/SkidSteer/SkidVehiclePawn.cpp @@ -239,6 +239,9 @@ void ASkidVehiclePawn::EndPlay(const EEndPlayReason::Type EndPlayReason) camera_front_right_base_ = nullptr; camera_driver_base_ = nullptr; camera_back_center_base_ = nullptr; + + + Super::EndPlay(EndPlayReason); } void ASkidVehiclePawn::Tick(float Delta) From 57e77a382b6a1637242d69cb2356292ea15e4e26 Mon Sep 17 00:00:00 2001 From: Wouter Jansen Date: Tue, 1 Jul 2025 16:06:07 +0200 Subject: [PATCH 08/10] updated for crashfix --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f9740f484..c3896e57b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ### Development (version 3.4) * Added support for Unreal 5.6. This will become the next targeted stable Unreal Engine replacing 5.5 when Cosys-AirSim 3.4 releases. * Fixed duplicate indexes for annotation system causing meshes to not show up in annotation masks. +* Fixed common crash on ending play. ### April 2025 (version 3.3) * The latest available stable Unreal Engine version that is now targeted for release is 5.5. This means 5.4 will no longer be actively maintained. From ff7d7025f9696130eb02b60581ea4acd2325495b Mon Sep 17 00:00:00 2001 From: Wouter Jansen Date: Tue, 8 Jul 2025 12:48:24 +0200 Subject: [PATCH 09/10] Fixed several edge-cases and crashes in annotation system --- CHANGELOG.md | 3 + .../Source/Annotation/ObjectAnnotator.cpp | 109 +++--------------- .../Source/Annotation/ObjectAnnotator.h | 3 - 3 files changed, 18 insertions(+), 97 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c3896e57b..39d155fca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,11 @@ ### Development (version 3.4) * Added support for Unreal 5.6. This will become the next targeted stable Unreal Engine replacing 5.5 when Cosys-AirSim 3.4 releases. +* Added unique index to each object name in the annotation system to avoid duplicate name overrides. * Fixed duplicate indexes for annotation system causing meshes to not show up in annotation masks. +* Fixed several edge-cases and crashes in annotation system. * Fixed common crash on ending play. + ### April 2025 (version 3.3) * The latest available stable Unreal Engine version that is now targeted for release is 5.5. This means 5.4 will no longer be actively maintained. * The documentation now is placed on a sub-URL page here: https://cosys-lab.github.io/Cosys-AirSim diff --git a/Unreal/Plugins/AirSim/Source/Annotation/ObjectAnnotator.cpp b/Unreal/Plugins/AirSim/Source/Annotation/ObjectAnnotator.cpp index 3aeacd2b0..ae09b04e2 100644 --- a/Unreal/Plugins/AirSim/Source/Annotation/ObjectAnnotator.cpp +++ b/Unreal/Plugins/AirSim/Source/Annotation/ObjectAnnotator.cpp @@ -152,15 +152,17 @@ void FObjectAnnotator::getPaintableComponentMeshes(AActor* actor, TMapEmplace(component_name, component); + index++; } } if (USkinnedMeshComponent* skinnedmesh_component = Cast(component)) { component_name = actor->GetName(); component_name.Append("_"); component_name.Append(FString::FromInt(PersistentPrimitiveIndex)); + paintable_components_meshes->Emplace(component_name, component); + index++; } - paintable_components_meshes->Emplace(component_name, component); - index++; } } } @@ -262,19 +264,21 @@ void FObjectAnnotator::getPaintableComponentMeshesAndTags(AActor* actor, TMapGetName()); } + component_name.Append("_"); + component_name.Append(FString::FromInt(PersistentPrimitiveIndex)); + paintable_components_tags->Emplace(component_name, staticmesh_component->ComponentTags); + paintable_components_meshes->Emplace(component_name, component); + index++; } - component_name.Append("_"); - component_name.Append(FString::FromInt(PersistentPrimitiveIndex)); - paintable_components_tags->Emplace(component_name, staticmesh_component->ComponentTags); } if (USkinnedMeshComponent* skinnedmesh_component = Cast(component)) { component_name = actor->GetName(); component_name.Append("_"); component_name.Append(FString::FromInt(PersistentPrimitiveIndex)); paintable_components_tags->Emplace(component_name, skinnedmesh_component->ComponentTags); + paintable_components_meshes->Emplace(component_name, component); + index++; } - paintable_components_meshes->Emplace(component_name, component); - index++; } } } @@ -289,18 +293,6 @@ bool FObjectAnnotator::SetComponentRGBColorByIndex(FString component_id, uint32 { FString color_string = FString::FromInt(color.R) + "," + FString::FromInt(color.G) + "," + FString::FromInt(color.B); FString color_string_gammacorrected = FString::FromInt(ColorGenerator_.GetGammaCorrectedColor(color.R)) + "," + FString::FromInt(ColorGenerator_.GetGammaCorrectedColor(color.G)) + "," + FString::FromInt(ColorGenerator_.GetGammaCorrectedColor(color.B)); - const FString* found_index_color = color_to_name_map_.FindKey(component_id); - - if (found_index_color != nullptr) { - color_to_name_map_.Remove(*found_index_color); - } - color_to_name_map_.Emplace(color_string, component_id); - const FString* found_index_color_gamma = gammacorrected_color_to_name_map_.FindKey(component_id); - if (found_index_color != nullptr) { - gammacorrected_color_to_name_map_.Remove(*found_index_color_gamma); - } - color_to_name_map_.Emplace(color_string, component_id); - gammacorrected_color_to_name_map_.Emplace(color_string_gammacorrected, component_id); name_to_color_index_map_[component_id] = color_index; name_to_gammacorrected_color_map_[component_id] = color_string_gammacorrected; UE_LOG(LogTemp, Log, TEXT("AirSim Annotation [%s]: Adjusted RGB annotation of object %s to new ID # %s (RGB: %s)"), *name_, *component_id, *FString::FromInt(color_index), *color_string_gammacorrected); @@ -328,18 +320,6 @@ bool FObjectAnnotator::SetComponentRGBColorByColor(FString component_id, FColor { FString color_string = FString::FromInt(color.R) + "," + FString::FromInt(color.G) + "," + FString::FromInt(color.B); FString color_string_gammacorrected = FString::FromInt(ColorGenerator_.GetGammaCorrectedColor(color.R)) + "," + FString::FromInt(ColorGenerator_.GetGammaCorrectedColor(color.G)) + "," + FString::FromInt(ColorGenerator_.GetGammaCorrectedColor(color.B)); - const FString* found_index_color = color_to_name_map_.FindKey(component_id); - - if (found_index_color != nullptr) { - color_to_name_map_.Remove(*found_index_color); - } - color_to_name_map_.Emplace(color_string, component_id); - const FString* found_index_color_gamma = gammacorrected_color_to_name_map_.FindKey(component_id); - if (found_index_color != nullptr) { - gammacorrected_color_to_name_map_.Remove(*found_index_color_gamma); - } - color_to_name_map_.Emplace(color_string, component_id); - gammacorrected_color_to_name_map_.Emplace(color_string_gammacorrected, component_id); name_to_color_index_map_[component_id] = color_index; name_to_gammacorrected_color_map_[component_id] = color_string_gammacorrected; UE_LOG(LogTemp, Log, TEXT("AirSim Annotation [%s]: Adjusted RGB annotation of object %s to new RGB color: %s (ID # %s)"), *name_, *component_id, *color_string_gammacorrected , *FString::FromInt(color_index)); @@ -373,18 +353,6 @@ bool FObjectAnnotator::SetComponentGreyScaleColorByValue(FString component_id, f { FString color_string = FString::FromInt(color.R) + "," + FString::FromInt(color.G) + "," + FString::FromInt(color.B); FString color_string_gammacorrected = color_string; - const FString* found_index_color = color_to_name_map_.FindKey(component_id); - - if (found_index_color != nullptr) { - color_to_name_map_.Remove(*found_index_color); - } - color_to_name_map_.Emplace(color_string, component_id); - const FString* found_index_color_gamma = gammacorrected_color_to_name_map_.FindKey(component_id); - if (found_index_color != nullptr) { - gammacorrected_color_to_name_map_.Remove(*found_index_color_gamma); - } - color_to_name_map_.Emplace(color_string, component_id); - gammacorrected_color_to_name_map_.Emplace(color_string_gammacorrected, component_id); name_to_gammacorrected_color_map_[component_id] = color_string_gammacorrected; name_to_value_map_[component_id] = greyscale_value; UE_LOG(LogTemp, Log, TEXT("AirSim Annotation [%s]: Adjusted greyscale annotation of object %s to new value %f (RGB: %s)"), *name_, *component_id, greyscale_value, *color_string_gammacorrected); @@ -515,8 +483,6 @@ bool FObjectAnnotator::AnnotateNewActorInstanceSegmentation(AActor* actor) { FString color_string = FString::FromInt(new_color.R) + "," + FString::FromInt(new_color.G) + "," + FString::FromInt(new_color.B); FString color_string_gammacorrected = FString::FromInt(ColorGenerator_.GetGammaCorrectedColor(new_color.R)) + "," + FString::FromInt(ColorGenerator_.GetGammaCorrectedColor(new_color.G)) + "," + FString::FromInt(ColorGenerator_.GetGammaCorrectedColor(new_color.B)); name_to_gammacorrected_color_map_.Emplace(it.Key(), color_string_gammacorrected); - color_to_name_map_.Emplace(color_string, it.Key()); - gammacorrected_color_to_name_map_.Emplace(color_string_gammacorrected, it.Key()); check(PaintRGBComponent(it.Value(), new_color, it.Key())); UE_LOG(LogTemp, Log, TEXT("AirSim Annotation [%s]: Added new object %s with ID # %s (RGB: %s)"), *name_, *it.Key(), *FString::FromInt(ObjectIndex), *color_string_gammacorrected); }else{ @@ -565,20 +531,10 @@ bool FObjectAnnotator::AnnotateNewActorRGB(AActor* actor) { if (name_to_component_map_.Contains(it.Key())) { name_to_color_index_map_[it.Key()] = color_index; - const FString* found_index_color = color_to_name_map_.FindKey(it.Key()); - if (found_index_color != nullptr) { - color_to_name_map_.Remove(*found_index_color); - } - color_to_name_map_.Emplace(color_string, it.Key()); - const FString* found_index_color_gamma = gammacorrected_color_to_name_map_.FindKey(it.Key()); - if (found_index_color != nullptr) { - gammacorrected_color_to_name_map_.Remove(*found_index_color_gamma); - } - gammacorrected_color_to_name_map_.Emplace(color_string_gammacorrected, it.Key()); name_to_gammacorrected_color_map_.Emplace(it.Key(), color_string_gammacorrected); check(UpdatePaintRGBComponent(it.Value(), new_color, it.Key())); if (set_direct_) { - UE_LOG(LogTemp, Log, TEXT("AirSim Annotation [%s]: Updated RGB annotated object %s with direct RGB color: %s (ID # %s)"), *name_, *it.Key(), *color_string_gammacorrected, *FString::FromInt(color_index)); + UE_LOG(LogTemp, Log, TEXT("AirSim Annotation [%s]: Updated RGB annotated object %s with direct RGB color: %s"), *name_, *it.Key(), *color_string_gammacorrected); } else { @@ -589,12 +545,10 @@ bool FObjectAnnotator::AnnotateNewActorRGB(AActor* actor) { name_to_component_map_.Emplace(it.Key(), it.Value()); component_to_name_map_.Emplace(it.Value(), it.Key()); name_to_color_index_map_.Emplace(it.Key(), color_index); - color_to_name_map_.Emplace(color_string, it.Key()); - gammacorrected_color_to_name_map_.Emplace(color_string_gammacorrected, it.Key()); name_to_gammacorrected_color_map_.Emplace(it.Key(), color_string_gammacorrected); check(PaintRGBComponent(it.Value(), new_color, it.Key())); if (set_direct_) { - UE_LOG(LogTemp, Log, TEXT("AirSim Annotation [%s]: Added new RGB annotated object %s with direct RGB color: %s (ID # %s)"), *name_, *it.Key(), *color_string_gammacorrected, *FString::FromInt(color_index)); + UE_LOG(LogTemp, Log, TEXT("AirSim Annotation [%s]: Added new RGB annotated object %s with direct RGB color: %s"), *name_, *it.Key(), *color_string_gammacorrected); } else { @@ -608,8 +562,6 @@ bool FObjectAnnotator::AnnotateNewActorRGB(AActor* actor) { name_to_color_index_map_.Emplace(it.Key(), 2744000 - 1); FString color_string = FString::FromInt(new_color.R) + "," + FString::FromInt(new_color.G) + "," + FString::FromInt(new_color.B); FString color_string_gammacorrected = FString::FromInt(ColorGenerator_.GetGammaCorrectedColor(new_color.R)) + "," + FString::FromInt(ColorGenerator_.GetGammaCorrectedColor(new_color.G)) + "," + FString::FromInt(ColorGenerator_.GetGammaCorrectedColor(new_color.B)); - color_to_name_map_.Emplace(color_string, it.Key()); - gammacorrected_color_to_name_map_.Emplace(color_string_gammacorrected, it.Key()); name_to_gammacorrected_color_map_.Emplace(it.Key(), color_string_gammacorrected); check(PaintRGBComponent(it.Value(), new_color, it.Key())); UE_LOG(LogTemp, Log, TEXT("AirSim Annotation [%s]: Added untagged RGB annotated object %s with default color (RGB: %s)"), *name_, *it.Key(), *color_string_gammacorrected); @@ -653,17 +605,7 @@ bool FObjectAnnotator::AnnotateNewActorGreyscale(AActor* actor) { if (name_to_component_map_.Contains(it.Key())) { - const FString* found_index_color = color_to_name_map_.FindKey(it.Key()); - if (found_index_color != nullptr) { - color_to_name_map_.Remove(*found_index_color); - } - color_to_name_map_.Emplace(color_string, it.Key()); - const FString* found_index_color_gamma = gammacorrected_color_to_name_map_.FindKey(it.Key()); - if (found_index_color != nullptr) { - gammacorrected_color_to_name_map_.Remove(*found_index_color_gamma); - } name_to_value_map_[it.Key()] = greyscale_value; - gammacorrected_color_to_name_map_.Emplace(color_string_gammacorrected, it.Key()); name_to_gammacorrected_color_map_[it.Key()] = color_string_gammacorrected; check(UpdatePaintRGBComponent(it.Value(), new_color, it.Key())); @@ -671,9 +613,7 @@ bool FObjectAnnotator::AnnotateNewActorGreyscale(AActor* actor) { } else { name_to_component_map_.Emplace(it.Key(), it.Value()); - component_to_name_map_.Emplace(it.Value(), it.Key()); - color_to_name_map_.Emplace(color_string, it.Key()); - gammacorrected_color_to_name_map_.Emplace(color_string_gammacorrected, it.Key()); + component_to_name_map_.Emplace(it.Value(), it.Key()); name_to_gammacorrected_color_map_.Emplace(it.Key(), color_string_gammacorrected); name_to_value_map_.Emplace(it.Key(), greyscale_value); check(PaintRGBComponent(it.Value(), new_color, it.Key())); @@ -685,8 +625,6 @@ bool FObjectAnnotator::AnnotateNewActorGreyscale(AActor* actor) { FColor new_color = FColor(0, 0, 0); FString color_string = FString::FromInt(new_color.R) + "," + FString::FromInt(new_color.G) + "," + FString::FromInt(new_color.B); FString color_string_gammacorrected = color_string; - color_to_name_map_.Emplace(color_string, it.Key()); - gammacorrected_color_to_name_map_.Emplace(color_string_gammacorrected, it.Key()); name_to_gammacorrected_color_map_.Emplace(it.Key(), color_string_gammacorrected); name_to_value_map_.Emplace(it.Key(), 0); check(PaintRGBComponent(it.Value(), new_color, it.Key())); @@ -884,8 +822,6 @@ void FObjectAnnotator::InitializeInstanceSegmentation(ULevel* InLevel) name_to_color_index_map_.Emplace(it.Key(), color_index); FString color_string = FString::FromInt(new_color.R) + "," + FString::FromInt(new_color.G) + "," + FString::FromInt(new_color.B); FString color_string_gammacorrected = FString::FromInt(ColorGenerator_.GetGammaCorrectedColor(new_color.R)) + "," + FString::FromInt(ColorGenerator_.GetGammaCorrectedColor(new_color.G)) + "," + FString::FromInt(ColorGenerator_.GetGammaCorrectedColor(new_color.B)); - color_to_name_map_.Emplace(color_string, it.Key()); - gammacorrected_color_to_name_map_.Emplace(color_string_gammacorrected, it.Key()); name_to_gammacorrected_color_map_.Emplace(it.Key(), color_string_gammacorrected); check(PaintRGBComponent(it.Value(), new_color, it.Key())); UE_LOG(LogTemp, Log, TEXT("AirSim Annotation [%s]: Added new object %s with ID # %s (RGB: %s)"), *name_, *it.Key(), *FString::FromInt(color_index), *color_string_gammacorrected); @@ -935,12 +871,10 @@ void FObjectAnnotator::InitializeRGB(ULevel* InLevel) name_to_color_index_map_.Emplace(it.Key(), color_index); FString color_string = FString::FromInt(new_color.R) + "," + FString::FromInt(new_color.G) + "," + FString::FromInt(new_color.B); FString color_string_gammacorrected = FString::FromInt(ColorGenerator_.GetGammaCorrectedColor(new_color.R)) + "," + FString::FromInt(ColorGenerator_.GetGammaCorrectedColor(new_color.G)) + "," + FString::FromInt(ColorGenerator_.GetGammaCorrectedColor(new_color.B)); - color_to_name_map_.Emplace(color_string, it.Key()); - gammacorrected_color_to_name_map_.Emplace(color_string_gammacorrected, it.Key()); name_to_gammacorrected_color_map_.Emplace(it.Key(), color_string_gammacorrected); check(PaintRGBComponent(it.Value(), new_color, it.Key())); if (set_direct_) { - UE_LOG(LogTemp, Log, TEXT("AirSim Annotation [%s]: Added new RGB annotated object %s with direct RGB color: %s (ID # %s)"), *name_, *it.Key(), *color_string_gammacorrected, *FString::FromInt(color_index)); + UE_LOG(LogTemp, Log, TEXT("AirSim Annotation [%s]: Added new RGB annotated object %s with direct RGB color: %s"), *name_, *it.Key(), *color_string_gammacorrected); } else { @@ -954,8 +888,6 @@ void FObjectAnnotator::InitializeRGB(ULevel* InLevel) name_to_color_index_map_.Emplace(it.Key(), 2744000 - 1); FString color_string = FString::FromInt(new_color.R) + "," + FString::FromInt(new_color.G) + "," + FString::FromInt(new_color.B); FString color_string_gammacorrected = FString::FromInt(ColorGenerator_.GetGammaCorrectedColor(new_color.R)) + "," + FString::FromInt(ColorGenerator_.GetGammaCorrectedColor(new_color.G)) + "," + FString::FromInt(ColorGenerator_.GetGammaCorrectedColor(new_color.B)); - color_to_name_map_.Emplace(color_string, it.Key()); - gammacorrected_color_to_name_map_.Emplace(color_string_gammacorrected, it.Key()); name_to_gammacorrected_color_map_.Emplace(it.Key(), color_string_gammacorrected); check(PaintRGBComponent(it.Value(), new_color, it.Key())); UE_LOG(LogTemp, Log, TEXT("AirSim Annotation [%s]: Added untagged RGB annotated object %s with default color (RGB: %s)"), *name_, *it.Key(), *color_string_gammacorrected); @@ -1004,8 +936,6 @@ void FObjectAnnotator::InitializeGreyscale(ULevel* InLevel) FString color_string = FString::FromInt(new_color.R) + "," + FString::FromInt(new_color.G) + "," + FString::FromInt(new_color.B); FString color_string_gammacorrected = color_string; - color_to_name_map_.Emplace(color_string, it.Key()); - gammacorrected_color_to_name_map_.Emplace(color_string_gammacorrected, it.Key()); name_to_gammacorrected_color_map_.Emplace(it.Key(), color_string_gammacorrected); name_to_value_map_.Emplace(it.Key(), greyscale_value); check(PaintRGBComponent(it.Value(), new_color, it.Key())); @@ -1017,8 +947,6 @@ void FObjectAnnotator::InitializeGreyscale(ULevel* InLevel) FColor new_color = FColor(0, 0, 0); FString color_string = FString::FromInt(new_color.R) + "," + FString::FromInt(new_color.G) + "," + FString::FromInt(new_color.B); FString color_string_gammacorrected = color_string; - color_to_name_map_.Emplace(color_string, it.Key()); - gammacorrected_color_to_name_map_.Emplace(color_string_gammacorrected, it.Key()); name_to_gammacorrected_color_map_.Emplace(it.Key(), color_string_gammacorrected); name_to_value_map_.Emplace(it.Key(), 0); check(PaintRGBComponent(it.Value(), new_color, it.Key())); @@ -1303,11 +1231,6 @@ TMap FObjectAnnotator::GetComponentToNameMap() { return component_to_name_map_; } - -TMap FObjectAnnotator::GetColorToComponentNameMap() { - return gammacorrected_color_to_name_map_; -} - TMap FObjectAnnotator::GetComponentToValueMap() { return name_to_value_map_; } @@ -1337,8 +1260,6 @@ void FObjectAnnotator::EndPlay() { } name_to_color_index_map_.Empty(); - color_to_name_map_.Empty(); - gammacorrected_color_to_name_map_.Empty(); name_to_component_map_.Empty(); annotation_component_list_.Empty(); name_to_gammacorrected_color_map_.Empty(); diff --git a/Unreal/Plugins/AirSim/Source/Annotation/ObjectAnnotator.h b/Unreal/Plugins/AirSim/Source/Annotation/ObjectAnnotator.h index b74527332..0990ca8a9 100644 --- a/Unreal/Plugins/AirSim/Source/Annotation/ObjectAnnotator.h +++ b/Unreal/Plugins/AirSim/Source/Annotation/ObjectAnnotator.h @@ -88,7 +88,6 @@ class AIRSIM_API FObjectAnnotator std::vector GetAllComponentNames(); TMap GetNameToComponentMap(); - TMap GetColorToComponentNameMap(); TMap GetComponentToValueMap(); TMap GetComponentToNameMap(); @@ -120,8 +119,6 @@ class AIRSIM_API FObjectAnnotator TMap name_to_gammacorrected_color_map_; TMap name_to_value_map_; TMap name_to_texture_path_map_; - TMap color_to_name_map_; - TMap gammacorrected_color_to_name_map_; TMap name_to_component_map_; TMap component_to_name_map_; TArray> annotation_component_list_; From a27bb1157f347ede22c5d87ffde862951c64fd7e Mon Sep 17 00:00:00 2001 From: Wouter Jansen Date: Wed, 30 Jul 2025 18:37:04 +0200 Subject: [PATCH 10/10] Updated annotation system to add both actor and component tags to the annotation system for checking if both exist instead of old behaviour where actor tags took priority and component tags would be ignored if both existed. --- CHANGELOG.md | 1 + .../Plugins/AirSim/Source/Annotation/ObjectAnnotator.cpp | 9 +++------ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 39d155fca..9c1b9094c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ### Development (version 3.4) * Added support for Unreal 5.6. This will become the next targeted stable Unreal Engine replacing 5.5 when Cosys-AirSim 3.4 releases. * Added unique index to each object name in the annotation system to avoid duplicate name overrides. +* Updated annotation system to add both actor and component tags to the annotation system for checking if both exist instead of old behaviour where actor tags took priority and component tags would be ignored if both existed. * Fixed duplicate indexes for annotation system causing meshes to not show up in annotation masks. * Fixed several edge-cases and crashes in annotation system. * Fixed common crash on ending play. diff --git a/Unreal/Plugins/AirSim/Source/Annotation/ObjectAnnotator.cpp b/Unreal/Plugins/AirSim/Source/Annotation/ObjectAnnotator.cpp index ae09b04e2..628fe0e41 100644 --- a/Unreal/Plugins/AirSim/Source/Annotation/ObjectAnnotator.cpp +++ b/Unreal/Plugins/AirSim/Source/Annotation/ObjectAnnotator.cpp @@ -219,8 +219,7 @@ void FObjectAnnotator::getPaintableComponentMeshesAndTags(AActor* actor, TMapEmplace(component_name, component); if (actor->Tags.Num() > 0) paintable_components_tags->Emplace(component_name, actor->Tags); - else - paintable_components_tags->Emplace(component_name, staticmesh_component->ComponentTags); + paintable_components_tags->Emplace(component_name, staticmesh_component->ComponentTags); } else { FString component_name = actor->GetName(); @@ -229,8 +228,7 @@ void FObjectAnnotator::getPaintableComponentMeshesAndTags(AActor* actor, TMapEmplace(component_name, component); if (actor->Tags.Num() > 0) paintable_components_tags->Emplace(component_name, actor->Tags); - else - paintable_components_tags->Emplace(component_name, staticmesh_component->ComponentTags); + paintable_components_tags->Emplace(component_name, staticmesh_component->ComponentTags); } } @@ -241,8 +239,7 @@ void FObjectAnnotator::getPaintableComponentMeshesAndTags(AActor* actor, TMapTags.Num() > 0) paintable_components_tags->Emplace(component_name, actor->Tags); - else - paintable_components_tags->Emplace(component_name, SkinnedMeshComponent->ComponentTags); + paintable_components_tags->Emplace(component_name, SkinnedMeshComponent->ComponentTags); paintable_components_meshes->Emplace(component_name, component); } }