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

fix log output line throwing an error #78

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions Source/USemLog/Classes/Individuals/SLIgnore.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright 2017-2021, Institute for Artificial Intelligence - University of Bremen

#pragma once

#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "SLIgnore.generated.h"


UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class USEMLOG_API USLIgnore : public UActorComponent
{
GENERATED_BODY()

public:
// Sets default values for this component's properties
USLIgnore();

protected:
// Called when the game starts
virtual void BeginPlay() override;

public:
// Called every frame
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;


};
3 changes: 3 additions & 0 deletions Source/USemLog/Classes/Individuals/SLIndividualUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ class USEMLOG_API FSLIndividualUtils
// Get the individual object from the actor (nullptr if it does not exist)
static USLBaseIndividual* GetIndividualObject(AActor* Owner);

//Check whether the the actor has a SLIgnore component and thus should be ignored
static bool CheckIgnoreActor(AActor* Owner);

// Create default individual object depending on the owner type (returns nullptr if failed)
static USLBaseIndividual* CreateIndividualObject(UObject* Outer, AActor* Owner);

Expand Down
1 change: 1 addition & 0 deletions Source/USemLog/Classes/Individuals/Type/SLBaseIndividual.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class USLBaseIndividual : public UObject
FTransform GetCachedPose() const { return CachedPose; };

// Get actor represented by the individual
UFUNCTION(BlueprintCallable)
AActor* GetParentActor() const { return ParentActor; };

// True if individual is part of another individual
Expand Down
3 changes: 2 additions & 1 deletion Source/USemLog/Classes/Monitors/SLBoneContactMonitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class USkeletalMeshComponent;
/**
* Hand type
*/
UENUM()
UENUM(BlueprintType)
enum class ESLBoneContactGroup : uint8
{
A UMETA(DisplayName = "A"),
Expand Down Expand Up @@ -98,6 +98,7 @@ class USEMLOG_API USLBoneContactMonitor : public USphereComponent
void SetAttachedBoneNameChecked(const FName& NewName) { BoneName = NewName; };

// Attach component to bone
UFUNCTION(BLUEPRINTCALLABLE)
bool AttachToBone();

#if WITH_EDITOR
Expand Down
23 changes: 22 additions & 1 deletion Source/USemLog/Classes/Monitors/SLManipulatorMonitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@

#pragma once

#include "CoreMinimal.h"
#include "USemLog.h"
#include "Components/ActorComponent.h"
#include "Monitors/SLMonitorStructs.h"
#include "TimerManager.h"
#include "Monitors/SLGraspHelper.h"
#include "Delegates/Delegate.h"
#include "SLManipulatorMonitor.generated.h"

// Forward declarations
Expand Down Expand Up @@ -72,6 +74,9 @@ struct FSLContactEndEvent
DECLARE_MULTICAST_DELEGATE_FourParams(FSLBeginManipulatorGraspSignature, USLBaseIndividual* /*Self*/, USLBaseIndividual* /*Other*/, float /*Time*/, const FString& /*Type*/);
DECLARE_MULTICAST_DELEGATE_ThreeParams(FSLEndManipulatorGraspSignature, USLBaseIndividual* /*Self*/, USLBaseIndividual* /*Other*/, float /*Time*/);

DECLARE_DYNAMIC_MULTICAST_DELEGATE_FourParams(FSLBeginManipulatorGraspSignatureBP, USLBaseIndividual*,individualOne, USLBaseIndividual*,individualTwo, float,f, const FString&,s);
DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FSLEndManipulatorGraspSignatureBP, USLBaseIndividual*, individualOne, USLBaseIndividual*, individualTwo, float,f);

/**
* Checks for manipulator related events (contact, grasp)
*/
Expand Down Expand Up @@ -105,6 +110,10 @@ class USEMLOG_API USLManipulatorMonitor : public UActorComponent
// Get finished state
bool IsFinished() const { return bIsFinished; };

//Change the AxisOverwrite value
UFUNCTION(BlueprintCallable, Category = "Semantic Logger")
void setAxisOverwriteValue(float axisOverwrite);

protected:
#if WITH_EDITOR
// Called when a property is changed in the editor
Expand Down Expand Up @@ -204,10 +213,17 @@ class USEMLOG_API USLManipulatorMonitor : public UActorComponent
// Event called when grasp begins/ends
FSLBeginManipulatorGraspSignature OnBeginManipulatorGrasp;
FSLEndManipulatorGraspSignature OnEndManipulatorGrasp;

// Additional Events called which are accessible from Blueprint
UPROPERTY(BlueprintAssignable, Category = "Grasp")
FSLBeginManipulatorGraspSignatureBP OnBeginManipulatorGraspBP;
UPROPERTY(BlueprintAssignable, Category = "Grasp")
FSLEndManipulatorGraspSignatureBP OnEndManipulatorGraspBP;

// Event called when a semantic overlap/contact begins/ends
FSLBeginContactSignature OnBeginManipulatorContact;
FSLEndContactSignature OnEndManipulatorContact;


private:
// Log contact related debug messages
Expand Down Expand Up @@ -246,15 +262,20 @@ class USEMLOG_API USLManipulatorMonitor : public UActorComponent

// Ad Hoc grasp helper is active or not
uint8 bIsGraspHelpActive : 1;


#if WITH_EDITORONLY_DATA
// Hand type to load pre-defined parameters
UPROPERTY(EditAnywhere, Category = "Semantic Logger")
ESLGraspHandType HandType;
#endif // WITH_EDITORONLY_DATA

// Read the input directly, avoid biding to various controllers
//Overwrite the axis input. Enabling to let the grab react to other events or values. Compares against InputAxisOverwriteValue then.
UPROPERTY(EditAnywhere, Category = "Semantic Logger")
bool bOverwriteInputAxisInput;

// Input axis to listen for grasp events
UPROPERTY(EditAnywhere, Category = "Semantic Logger", meta = (editcondition = "!bOverwriteInputAxisInput"))
FName InputAxisName;

// Axis input value to wake up from idle
Expand Down
34 changes: 34 additions & 0 deletions Source/USemLog/Private/Individuals/SLIgnore.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright 2017-2021, Institute for Artificial Intelligence - University of Bremen


#include "Individuals/SLIgnore.h"

// Sets default values for this component's properties
USLIgnore::USLIgnore()
{
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
// off to improve performance if you don't need them.
PrimaryComponentTick.bCanEverTick = true;

// ...
}


// Called when the game starts
void USLIgnore::BeginPlay()
{
Super::BeginPlay();

// ...

}


// Called every frame
void USLIgnore::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);

// ...
}

14 changes: 14 additions & 0 deletions Source/USemLog/Private/Individuals/SLIndividualUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "Individuals/SLIndividualUtils.h"
#include "Individuals/SLIndividualComponent.h"
#include "Individuals/Type/SLIndividualTypes.h"
#include "Individuals/SLIgnore.h"

#include "Skeletal/SLSkeletalDataAsset.h"
#include "AssetRegistryModule.h" // FindSkeletalDataAsset
Expand Down Expand Up @@ -556,6 +557,19 @@ USLBaseIndividual* FSLIndividualUtils::GetIndividualObject(AActor* Owner)
return nullptr;
}

//Check whether the the actor has a SLIgnore component and thus should be ignored
bool FSLIndividualUtils::CheckIgnoreActor(AActor* Owner)
{
if (UActorComponent* AC = Owner->GetComponentByClass(USLIgnore::StaticClass()))
{
if (CastChecked<USLIgnore>(AC))
{
return true;
}
}
return false;
}

// Create default individual object depending on the owner type (returns nullptr if failed)
USLBaseIndividual* FSLIndividualUtils::CreateIndividualObject(UObject* Outer, AActor* Owner)
{
Expand Down
50 changes: 49 additions & 1 deletion Source/USemLog/Private/Monitors/SLBoneContactMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ void USLBoneContactMonitor::Init(bool bGrasp, bool bContact)
bIsGraspDetectionPaused ? SetColor(FColor::Yellow) : SetColor(FColor::Red);
}
bIsInit = true;

}
}
}
Expand All @@ -110,8 +111,29 @@ void USLBoneContactMonitor::Start()
// Attach component to bone
bool USLBoneContactMonitor::AttachToBone()
{
//Check if the component attached to is a skeletal Mesh
if (USkeletalMeshComponent* SkelComp = Cast<USkeletalMeshComponent>(GetAttachParent()))
{
if (SkelComp->GetBoneIndex(BoneName) != INDEX_NONE)
{
FAttachmentTransformRules AttachmentRule = bSnapToBone ? FAttachmentTransformRules::SnapToTargetIncludingScale
: FAttachmentTransformRules::KeepRelativeTransform;

if (AttachToComponent(SkelComp, AttachmentRule, BoneName))
{
//UE_LOG(LogTemp, Warning, TEXT("%s::%d Attached component %s to the bone %s"),
// *FString(__func__), __LINE__, *GetName(), *BoneName.ToString());
return true;
}
}
else
{
UE_LOG(LogTemp, Error, TEXT("%s::%d Could not find bone %s for component %s"),
*FString(__func__), __LINE__, *BoneName.ToString(), *GetName());
}
}
// Check if owner is a skeletal actor
if (ASkeletalMeshActor* SkelAct = Cast<ASkeletalMeshActor>(GetOwner()))
else if (ASkeletalMeshActor* SkelAct = Cast<ASkeletalMeshActor>(GetOwner()))
{
// Get the skeletal mesh component
if (USkeletalMeshComponent* SMC = SkelAct->GetSkeletalMeshComponent())
Expand All @@ -135,6 +157,7 @@ bool USLBoneContactMonitor::AttachToBone()
}
}
}

UE_LOG(LogTemp, Error, TEXT("%s::%d Could not attach component %s to the bone %s"),
*FString(__func__), __LINE__, *GetName(), *BoneName.ToString());
return false;
Expand Down Expand Up @@ -401,6 +424,12 @@ void USLBoneContactMonitor::OnGraspOverlapBegin(UPrimitiveComponent* OverlappedC
return;
}

//Check if the other Actor should be ignored
if (FSLIndividualUtils::CheckIgnoreActor(OtherActor)) {
return;

}

// Check if the component or its outer is semantically annotated
USLBaseIndividual* OtherIndividual = FSLIndividualUtils::GetIndividualObject(OtherActor);
if (OtherIndividual == nullptr)
Expand Down Expand Up @@ -463,6 +492,12 @@ void USLBoneContactMonitor::OnGraspOverlapEnd(UPrimitiveComponent* OverlappedCom
return;
}

//Check if the other Actor should be ignored
if (FSLIndividualUtils::CheckIgnoreActor(OtherActor)) {
return;

}

// Check if the component or its outer is semantically annotated
USLBaseIndividual* OtherIndividual = FSLIndividualUtils::GetIndividualObject(OtherActor);
if (OtherIndividual == nullptr)
Expand Down Expand Up @@ -642,6 +677,12 @@ void USLBoneContactMonitor::OnContactOverlapBegin(UPrimitiveComponent* Overlappe
return;
}

//Check if the other Actor should be ignored
if (FSLIndividualUtils::CheckIgnoreActor(OtherActor)) {
return;

}

// Check if the component or its outer is semantically annotated
USLBaseIndividual* OtherIndividual = FSLIndividualUtils::GetIndividualObject(OtherActor);
if (OtherIndividual == nullptr)
Expand Down Expand Up @@ -700,6 +741,13 @@ void USLBoneContactMonitor::OnContactOverlapEnd(UPrimitiveComponent* OverlappedC
return;
}

//Check if the other Actor should be ignored
if (FSLIndividualUtils::CheckIgnoreActor(OtherActor)) {
return;

}


// Check if the component or its outer is semantically annotated
USLBaseIndividual* OtherIndividual = FSLIndividualUtils::GetIndividualObject(OtherActor);
if (OtherIndividual == nullptr)
Expand Down
17 changes: 16 additions & 1 deletion Source/USemLog/Private/Monitors/SLContactMonitorInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,12 @@ void ISLContactMonitorInterface::OnOverlapBegin(UPrimitiveComponent* OverlappedC
return;
}

//Check if the other actor should be ignored
if (FSLIndividualUtils::CheckIgnoreActor(OtherActor)) {
return;

}

// Check if the component or its outer is semantically annotated
USLBaseIndividual* OtherIndividual = FSLIndividualUtils::GetIndividualObject(OtherActor);
if (OtherIndividual == nullptr)
Expand Down Expand Up @@ -237,14 +243,23 @@ void ISLContactMonitorInterface::OnOverlapEnd(UPrimitiveComponent* OverlappedCom
return;
}

//Check if the other actor should be ignored
if (FSLIndividualUtils::CheckIgnoreActor(OtherActor)) {
return;

}


// Check if the component or its outer is semantically annotated
USLBaseIndividual* OtherIndividual = FSLIndividualUtils::GetIndividualObject(OtherActor);
if (OtherIndividual == nullptr)
{
UE_LOG(LogTemp, Error, TEXT("%s::%d %s is not annotated, this should not happen.."), *FString(__FUNCTION__), __LINE__);
UE_LOG(LogTemp, Error, TEXT("%s::%d %s is not annotated, this should not happen.."), *FString(__FUNCTION__), __LINE__, *OtherActor->GetName());
return;
}



// Delay publishing the overlap event in case of possible concatenations
RecentlyEndedOverlapEvents.Emplace(FSLOverlapEndEvent(OtherComp, OtherIndividual, World->GetTimeSeconds()));

Expand Down
Loading