Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UE4] simGetSegmentationObjectID will always return -1 #2854

Closed
LSBOSS opened this issue Jul 15, 2020 · 1 comment · Fixed by #2855
Closed

[UE4] simGetSegmentationObjectID will always return -1 #2854

LSBOSS opened this issue Jul 15, 2020 · 1 comment · Fixed by #2855

Comments

@LSBOSS
Copy link
Contributor

LSBOSS commented Jul 15, 2020

Intro

Depending on the MeshNamingMethod in SegmentationSettings in AirSim's settings.json custom IDs will be assigned either based on a name of a StaticMesh/SkelletalMesh or the name of its owner.

For that reason UAirBlueprintLib::GetMeshName is being used during initialization of IDs to find out the correct name and also taking the different nature of above MeshComponents into account.

Problem

However, calling simGetSegmentationObjectID from Python ultimately leads to the call of UAirBlueprintLib::GetMeshStencilID which is NOT using above GetMeshName method but rather is just comparing the actual name of a MeshComponent (e.g. "StaticMeshComponent0") with the passed search parameter (e.g. "ground") . This ultimately fails and thus this function is returning -1.

Example

I added two log outputs. One in UAirBlueprintLib::GetMeshStencilID to output every name this function is comparing to the passed search parameter + corresponding custom ID. A second log has been inserted into UAirBlueprintLib::InitializeObjectStencilID to output its name handling + corresponding custom IDs

From the Block environment I chose 4 objects for comparison and then called print(client.simGetSegmentationObjectID("ground")) from Python which returns -1.

UAirBlueprintLib::InitializeObjectStencilID:

LogTemp: [name --> id]
LogTemp: cylinder2 --> 95
LogTemp: ground --> 148
LogTemp: templatecube_rounded_10 --> 241
LogTemp: orangeball --> 28

UAirBlueprintLib::GetMeshStencilID:

LogTemp: [name --> id]
LogTemp: StaticMeshComponent0 --> 95
LogTemp: StaticMeshComponent0 --> 148
LogTemp: StaticMeshComponent0 --> 241
LogTemp: StaticMeshComponent0 --> 28

GetMeshStencilID is comparing the passed parameter "ground" with all the StaticMeshComponent0 it can find which in the end fails.

Fix proposal

  • In UAirBlueprintLib::GetMeshStencilID:
    • Make use of GetMeshName instead of the component name
    • Iterate over StaticMeshComponents and SkinnedMeshComponents separately as done in InitializeMeshStencilIDs

Sofware and Versions

Unreal Engine: 4.24.2
AirSim Plugin build from commit: Mon Jun 1 10:30:23 2020 +0530
AirSim Python library: 1.2.8
Python: 3.7.2 32bit

@chongjeelee
Copy link

chongjeelee commented Jan 24, 2022

hi,everyone,i found a helpful method to set or get segmentation id.the mesh name you can find it in the GUI details(Static Mesh),like below:
screenshot-20220124-162412

you can use client.simSetSegmentationObjectID("Air_Balloon_Set[\w]*",0,True) to set air_ballon_set object color,also you can use client.simSetSegmentationObjectID("SM_hang_glider[\w]*",255,True).
Be careful with [\w]*,this is regex.
if you want to set what you want to set ,pls set all objectID the same color before,like this,client.simSetSegmentationObjectID("[\w]*",0,True).
when you find objectID always return -1,this is a good idea!
hahaha ,i think so.

above useful,but you must set MeshNamingMethod is StaticMeshName on settings.json.
when you set MeshNamingMethod is "",above objectID all determin on indivual label name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants