Template Mismatch during attachment. Attaching instanced component to template component

I’m trying to use this plugin (ROSIntegrationVision) in order to stream video out of Unreal into ROS and ran into an issue.

When attempting to create a new vision component through C++ as stated in the readme and then creating a blueprint from that C++ class, the editor crashes with this error message:
[2024.05.20-01.36.42:358][658]LogOutputDevice: Error: Ensure condition failed: false [File:D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Private\Components\SceneComponent.cpp] [Line: 2012]
[2024.05.20-01.36.42:358][658]LogOutputDevice: Error: Template Mismatch during attachment. Attaching instanced component to template component. Parent ‘Vision’ (Owner ‘Default__RosActorBP_C’) Self ‘ColorCapture’ (Owner ‘RosActorBP_C_UAID_AC91A10E68F324F701_1254467327’).

The VisionComponent sets up subcomponents in its Constructor:

UVisionComponent::UVisionComponent() :
Width(960),
Height(540),
Framerate(1),
UseEngineFramerate(false),
ServerPort(10000),
FrameTime(1.0f / Framerate),
TimePassed(0),
ColorsUsed(0)
{
    Priv = new PrivateData();
    FieldOfView = 90.0;
    PrimaryComponentTick.bCanEverTick = true;
    PrimaryComponentTick.bStartWithTickEnabled = true;

    auto owner = GetOwner();
    if (owner)
    {
        Color = CreateDefaultSubobject<USceneCaptureComponent2D>(TEXT("ColorCapture"));
        Color->SetupAttachment(this);
        Color->CaptureSource = ESceneCaptureSource::SCS_FinalColorLDR;
        Color->TextureTarget = CreateDefaultSubobject<UTextureRenderTarget2D>(TEXT("ColorTarget"));
        Color->TextureTarget->InitAutoFormat(Width, Height);
        Color->FOVAngle = FieldOfView;

        Depth = CreateDefaultSubobject<USceneCaptureComponent2D>(TEXT("DepthCapture"));
        Depth->SetupAttachment(this);
        Depth->CaptureSource = ESceneCaptureSource::SCS_SceneDepth;
        Depth->TextureTarget = CreateDefaultSubobject<UTextureRenderTarget2D>(TEXT("DepthTarget"));
        Depth->TextureTarget->RenderTargetFormat = ETextureRenderTargetFormat::RTF_RGBA16f;
        Depth->TextureTarget->InitAutoFormat(Width, Height);
        Depth->FOVAngle = FieldOfView;

        Object = CreateDefaultSubobject<USceneCaptureComponent2D>(TEXT("ObjectCapture"));
        Object->SetupAttachment(this);
        Object->CaptureSource = ESceneCaptureSource::SCS_FinalColorLDR;
        Object->TextureTarget = CreateDefaultSubobject<UTextureRenderTarget2D>(TEXT("ObjectTarget"));
        Object->TextureTarget->InitAutoFormat(Width, Height);
        Object->FOVAngle = FieldOfView;
    }
    else {
        UE_LOG(LogTemp, Warning, TEXT("No owner!"));
    }

    CameraInfoPublisher = NewObject<UTopic>(UTopic::StaticClass());
    DepthPublisher = NewObject<UTopic>(UTopic::StaticClass());
    ImagePublisher = NewObject<UTopic>(UTopic::StaticClass());
    TFPublisher = NewObject<UTopic>(UTopic::StaticClass());
}

I’ve created a C++ class inheriting from the AActor class to so some things with the base ROSIntegration plugin and when I tried to attach the vision component to it from C++ in the constructor like:

UVisionComponent * vision = CreateDefaultSubobject<UVisionComponent>(TEXT("Vision"));
vision->SetupAttachment(RootComponent);

It compiles but when I try to update the derived blueprint class the editor crashes with the above mentioned error.

If any more information would be helpful let me know, I’m fairly new to Unreal Engine so any help is appreciated!

Try this: https://forums.unrealengine.com/t/ue5-template-mismatch-during-attaching-of-instanced-component/1510733/2

I had a custom SceneComponent that would break when a Blueprint inherited from a Blueprint that had my component. I was able to fix it by following that thread.

I wanted to attach a couple StaticMeshComponent to my custom SceneComponent.

Constructor:
StaticMeshComponent1->SetupAttachment(this);
StaticMeshComponent0->SetupAttachment(this);

OnRegister:
Super::OnRegister();
this->StaticMesh1->AttachToComponent(this, FAttachmentRules::KeepRelativeTransform);
this->StaticMesh0->AttachToComponent(this, FAttachmentRules::KeepRelativeTransorm);