diff --git a/Source/USemLog/Classes/Individuals/SLIgnore.h b/Source/USemLog/Classes/Individuals/SLIgnore.h new file mode 100644 index 00000000..4e38b670 --- /dev/null +++ b/Source/USemLog/Classes/Individuals/SLIgnore.h @@ -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; + + +}; diff --git a/Source/USemLog/Classes/Individuals/SLIndividualUtils.h b/Source/USemLog/Classes/Individuals/SLIndividualUtils.h index be89a512..03251877 100644 --- a/Source/USemLog/Classes/Individuals/SLIndividualUtils.h +++ b/Source/USemLog/Classes/Individuals/SLIndividualUtils.h @@ -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); diff --git a/Source/USemLog/Classes/Individuals/Type/SLBaseIndividual.h b/Source/USemLog/Classes/Individuals/Type/SLBaseIndividual.h index 20239907..dfc45f24 100644 --- a/Source/USemLog/Classes/Individuals/Type/SLBaseIndividual.h +++ b/Source/USemLog/Classes/Individuals/Type/SLBaseIndividual.h @@ -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 diff --git a/Source/USemLog/Classes/Monitors/SLBoneContactMonitor.h b/Source/USemLog/Classes/Monitors/SLBoneContactMonitor.h index 7c827a6b..61b30d8f 100644 --- a/Source/USemLog/Classes/Monitors/SLBoneContactMonitor.h +++ b/Source/USemLog/Classes/Monitors/SLBoneContactMonitor.h @@ -15,7 +15,7 @@ class USkeletalMeshComponent; /** * Hand type */ -UENUM() +UENUM(BlueprintType) enum class ESLBoneContactGroup : uint8 { A UMETA(DisplayName = "A"), @@ -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 diff --git a/Source/USemLog/Classes/Monitors/SLManipulatorMonitor.h b/Source/USemLog/Classes/Monitors/SLManipulatorMonitor.h index 8890981e..50553ef3 100644 --- a/Source/USemLog/Classes/Monitors/SLManipulatorMonitor.h +++ b/Source/USemLog/Classes/Monitors/SLManipulatorMonitor.h @@ -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 @@ -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) */ @@ -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 @@ -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 @@ -246,6 +262,7 @@ 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 @@ -253,8 +270,12 @@ class USEMLOG_API USLManipulatorMonitor : public UActorComponent 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 diff --git a/Source/USemLog/Private/Individuals/SLIgnore.cpp b/Source/USemLog/Private/Individuals/SLIgnore.cpp new file mode 100644 index 00000000..1000b480 --- /dev/null +++ b/Source/USemLog/Private/Individuals/SLIgnore.cpp @@ -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); + + // ... +} + diff --git a/Source/USemLog/Private/Individuals/SLIndividualUtils.cpp b/Source/USemLog/Private/Individuals/SLIndividualUtils.cpp index 57240617..68e16325 100644 --- a/Source/USemLog/Private/Individuals/SLIndividualUtils.cpp +++ b/Source/USemLog/Private/Individuals/SLIndividualUtils.cpp @@ -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 @@ -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(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) { diff --git a/Source/USemLog/Private/Monitors/SLBoneContactMonitor.cpp b/Source/USemLog/Private/Monitors/SLBoneContactMonitor.cpp index 914c301e..e1048e7b 100644 --- a/Source/USemLog/Private/Monitors/SLBoneContactMonitor.cpp +++ b/Source/USemLog/Private/Monitors/SLBoneContactMonitor.cpp @@ -85,6 +85,7 @@ void USLBoneContactMonitor::Init(bool bGrasp, bool bContact) bIsGraspDetectionPaused ? SetColor(FColor::Yellow) : SetColor(FColor::Red); } bIsInit = true; + } } } @@ -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(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(GetOwner())) + else if (ASkeletalMeshActor* SkelAct = Cast(GetOwner())) { // Get the skeletal mesh component if (USkeletalMeshComponent* SMC = SkelAct->GetSkeletalMeshComponent()) @@ -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; @@ -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) @@ -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) @@ -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) @@ -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) diff --git a/Source/USemLog/Private/Monitors/SLContactMonitorInterface.cpp b/Source/USemLog/Private/Monitors/SLContactMonitorInterface.cpp index 69f1ee21..81bb9915 100644 --- a/Source/USemLog/Private/Monitors/SLContactMonitorInterface.cpp +++ b/Source/USemLog/Private/Monitors/SLContactMonitorInterface.cpp @@ -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) @@ -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())); diff --git a/Source/USemLog/Private/Monitors/SLManipulatorMonitor.cpp b/Source/USemLog/Private/Monitors/SLManipulatorMonitor.cpp index ae875e1d..9b9116f3 100644 --- a/Source/USemLog/Private/Monitors/SLManipulatorMonitor.cpp +++ b/Source/USemLog/Private/Monitors/SLManipulatorMonitor.cpp @@ -33,9 +33,9 @@ USLManipulatorMonitor::USLManipulatorMonitor() bIsFinished = false; bIsGraspDetectionPaused = false; InputAxisName = "LeftGrasp"; + bOverwriteInputAxisInput = false; bIsNotSkeletal = false; InputAxisTriggerThresholdValue = 0.3f; - bLogContactDebug = false; bLogGraspDebug = false; bLogVerboseGraspDebug = false; @@ -165,6 +165,9 @@ void USLManipulatorMonitor::Start() // Mark as started bIsStarted = true; + //Lets start with grasp detection paused + PauseGraspDetection(true); + UE_LOG(LogTemp, Warning, TEXT("%s::%d Succefully started %s::%s at %.4fs.."), *FString(__FUNCTION__), __LINE__, *GetOwner()->GetName(), *GetName(), GetWorld()->GetTimeSeconds()); } @@ -257,6 +260,7 @@ void USLManipulatorMonitor::Finish(bool bForced) *GetOwner()->GetName(), *GetName(), *EvItr.Other->GetParentActor()->GetName()); } OnEndManipulatorGrasp.Broadcast(OwnerIndividualObject, EvItr.Other, EvItr.Time); + OnEndManipulatorGraspBP.Broadcast(OwnerIndividualObject, EvItr.Other, EvItr.Time); } RecentlyEndedGraspEvents.Empty(); @@ -504,28 +508,33 @@ void USLManipulatorMonitor::OnGraspType(const FString& Type) // Bind user inputs void USLManipulatorMonitor::SetupInputBindings() { - // Bind grasp trigger input and update check functions - if (APlayerController* PC = GetWorld()->GetFirstPlayerController()) - { - if (UInputComponent* IC = PC->InputComponent) + // Bind axis when it should not be overwritten + if (!bOverwriteInputAxisInput) { + // Bind grasp trigger input and update check functions + if (APlayerController* PC = GetWorld()->GetFirstPlayerController()) { - IC->BindAxis(InputAxisName, this, &USLManipulatorMonitor::GraspInputAxisCallback); - if (bUseGraspHelper && GraspHelper.bUseUserInput) + + if (UInputComponent* IC = PC->InputComponent) + { + IC->BindAxis(InputAxisName, this, &USLManipulatorMonitor::GraspInputAxisCallback); + if (bUseGraspHelper && GraspHelper.bUseUserInput) + { + IC->BindAction(GraspHelper.InputActionName, IE_Pressed, this, &USLManipulatorMonitor::GraspHelperInputCallback); + } + } + else { - IC->BindAction(GraspHelper.InputActionName, IE_Pressed, this, &USLManipulatorMonitor::GraspHelperInputCallback); + UE_LOG(LogTemp, Error, TEXT("%s::%d No Input Component found.."), *FString(__func__), __LINE__); + return; } + } else { - UE_LOG(LogTemp, Error, TEXT("%s::%d No Input Component found.."), *FString(__func__), __LINE__); + UE_LOG(LogTemp, Error, TEXT("%s::%d No Player controller found.."), *FString(__func__), __LINE__); return; } } - else - { - UE_LOG(LogTemp, Error, TEXT("%s::%d No Player controller found.."), *FString(__func__), __LINE__); - return; - } } // Check if the grasp trigger is active @@ -541,6 +550,23 @@ void USLManipulatorMonitor::GraspInputAxisCallback(float Value) } } +//When Axis input is overwritten and the new value is greater than the threshold initiate Grasp detection till the value falls below the threshhold +void USLManipulatorMonitor::setAxisOverwriteValue(float axisOverwrite) +{ + if (bOverwriteInputAxisInput) { + if (axisOverwrite >= InputAxisTriggerThresholdValue) { + PauseGraspDetection(false); + //UE_LOG(LogTemp, Warning, TEXT("%s::%d \t\t AxisValueOverwrite: %f"), *FString(__FUNCTION__), __LINE__, axisOverwrite); + + } + else + { + PauseGraspDetection(true); + //UE_LOG(LogTemp, Warning, TEXT("%s::%d \t\t AxisValueOverwrite Cancel: %f"), *FString(__FUNCTION__), __LINE__, axisOverwrite); + } + } +} + // Process beginning of grasp in group A void USLManipulatorMonitor::OnGroupAGraspContactBegin(USLBaseIndividual* OtherIndividual, const FName& BoneName) { @@ -552,7 +578,7 @@ void USLManipulatorMonitor::OnGroupAGraspContactBegin(USLBaseIndividual* OtherIn { UE_LOG(LogTemp, Warning, TEXT("%s::%d \t\t %.4f %s::%s \t\t GroupA: %s is already in contact with group, new num=%d.."), *FString(__FUNCTION__), __LINE__, GetWorld()->GetTimeSeconds(), - *GetOwner()->GetName(), *GetOwner()->GetName(), *OtherIndividual->GetParentActor()->GetName(), *NumContacts); + *GetOwner()->GetName(), *GetOwner()->GetName(), *OtherIndividual->GetParentActor()->GetName(), NumContacts); } } else @@ -561,9 +587,9 @@ void USLManipulatorMonitor::OnGroupAGraspContactBegin(USLBaseIndividual* OtherIn GroupANumGraspContacts.Add(OtherIndividual, 1); if (bLogVerboseGraspDebug) { - UE_LOG(LogTemp, Warning, TEXT("%s::%d \t\t %.4f %s::%s \t\t GroupA: %s's first contact with group.."), + UE_LOG(LogTemp, Warning, TEXT("%s::%d \t\t %.4f %s::%s \t\t GroupA: %s's first contact with group.. contacts: %d"), *FString(__FUNCTION__), __LINE__, GetWorld()->GetTimeSeconds(), - *GetOwner()->GetName(), *GetOwner()->GetName(), *OtherIndividual->GetParentActor()->GetName(), *NumContacts); + *GetOwner()->GetName(), *GetOwner()->GetName(), *OtherIndividual->GetParentActor()->GetName(), NumContacts); } // Make sure the individual is not already grasped @@ -588,7 +614,7 @@ void USLManipulatorMonitor::OnGroupAGraspContactBegin(USLBaseIndividual* OtherIn { UE_LOG(LogTemp, Warning, TEXT("%s::%d \t\t %.4f %s::%s \t\t GroupA: %s is in contact with other group as well, triggering grasp event.."), *FString(__FUNCTION__), __LINE__, GetWorld()->GetTimeSeconds(), - *GetOwner()->GetName(), *GetOwner()->GetName(), *OtherIndividual->GetParentActor()->GetName(), *NumContacts); + *GetOwner()->GetName(), *GetOwner()->GetName(), *OtherIndividual->GetParentActor()->GetName(), NumContacts); } // Trigger grasp started event GraspStarted(OtherIndividual); @@ -599,7 +625,7 @@ void USLManipulatorMonitor::OnGroupAGraspContactBegin(USLBaseIndividual* OtherIn { UE_LOG(LogTemp, Warning, TEXT("%s::%d \t\t %.4f %s::%s \t\t GroupA: %s is NOT in contact with other group, grasp will not be triggered.."), *FString(__FUNCTION__), __LINE__, GetWorld()->GetTimeSeconds(), - *GetOwner()->GetName(), *GetOwner()->GetName(), *OtherIndividual->GetParentActor()->GetName(), *NumContacts); + *GetOwner()->GetName(), *GetOwner()->GetName(), *OtherIndividual->GetParentActor()->GetName(), NumContacts); } } } @@ -616,7 +642,7 @@ void USLManipulatorMonitor::OnGroupBGraspContactBegin(USLBaseIndividual* OtherIn { UE_LOG(LogTemp, Warning, TEXT("%s::%d \t\t %.4f %s::%s \t\t GroupB: %s is already in contact with group, new num=%d.."), *FString(__FUNCTION__), __LINE__, GetWorld()->GetTimeSeconds(), - *GetOwner()->GetName(), *GetOwner()->GetName(), *OtherIndividual->GetParentActor()->GetName(), *NumContacts); + *GetOwner()->GetName(), *GetOwner()->GetName(), *OtherIndividual->GetParentActor()->GetName(), NumContacts); } } else @@ -625,9 +651,9 @@ void USLManipulatorMonitor::OnGroupBGraspContactBegin(USLBaseIndividual* OtherIn GroupBNumGraspContacts.Add(OtherIndividual, 1); if (bLogVerboseGraspDebug) { - UE_LOG(LogTemp, Warning, TEXT("%s::%d \t\t %.4f %s::%s \t\t GroupB: %s's first contact with group.."), + UE_LOG(LogTemp, Warning, TEXT("%s::%d \t\t %.4f %s::%s \t\t GroupB: %s's first contact with group.. contactamount %d"), *FString(__FUNCTION__), __LINE__, GetWorld()->GetTimeSeconds(), - *GetOwner()->GetName(), *GetOwner()->GetName(), *OtherIndividual->GetParentActor()->GetName(), *NumContacts); + *GetOwner()->GetName(), *GetOwner()->GetName(), *OtherIndividual->GetParentActor()->GetName(), NumContacts); } // Make sure the individual is not already grasped @@ -652,7 +678,7 @@ void USLManipulatorMonitor::OnGroupBGraspContactBegin(USLBaseIndividual* OtherIn { UE_LOG(LogTemp, Warning, TEXT("%s::%d \t\t %.4f %s::%s \t\t GroupB: %s is in contact with other group as well, triggering grasp event.."), *FString(__FUNCTION__), __LINE__, GetWorld()->GetTimeSeconds(), - *GetOwner()->GetName(), *GetOwner()->GetName(), *OtherIndividual->GetParentActor()->GetName(), *NumContacts); + *GetOwner()->GetName(), *GetOwner()->GetName(), *OtherIndividual->GetParentActor()->GetName(), NumContacts); } // Trigger grasp started event GraspStarted(OtherIndividual); @@ -663,7 +689,7 @@ void USLManipulatorMonitor::OnGroupBGraspContactBegin(USLBaseIndividual* OtherIn { UE_LOG(LogTemp, Warning, TEXT("%s::%d \t\t %.4f %s::%s \t\t GroupB: %s is NOT in contact with other group, grasp will not be triggered.."), *FString(__FUNCTION__), __LINE__, GetWorld()->GetTimeSeconds(), - *GetOwner()->GetName(), *GetOwner()->GetName(), *OtherIndividual->GetParentActor()->GetName(), *NumContacts); + *GetOwner()->GetName(), *GetOwner()->GetName(), *OtherIndividual->GetParentActor()->GetName(), NumContacts); } } } @@ -843,6 +869,9 @@ void USLManipulatorMonitor::GraspStarted(USLBaseIndividual* OtherIndividual) // Broadcast grasp event OnBeginManipulatorGrasp.Broadcast(OwnerIndividualObject, OtherIndividual, GetWorld()->GetTimeSeconds(), ActiveGraspType); + + //Broadcast also to the event accessible by blueprints + OnBeginManipulatorGraspBP.Broadcast(OwnerIndividualObject, OtherIndividual, GetWorld()->GetTimeSeconds(), ActiveGraspType); // Check if the grasped actor should be helped if (bUseGraspHelper) @@ -873,6 +902,8 @@ void USLManipulatorMonitor::GraspEnded(USLBaseIndividual* OtherIndividual) // Grasp ended RecentlyEndedGraspEvents.Emplace(FSLGraspEndEvent(OtherIndividual, GetWorld()->GetTimeSeconds())); + + // Delay publishing for a while, in case the new event is of the same type and should be concatenated if(!GetWorld()->GetTimerManager().IsTimerActive(GraspDelayTimerHandle)) { @@ -880,6 +911,11 @@ void USLManipulatorMonitor::GraspEnded(USLBaseIndividual* OtherIndividual) GetWorld()->GetTimerManager().SetTimer(GraspDelayTimerHandle, this, &USLManipulatorMonitor::DelayedGraspEndCallback, DelayValue, false); } + + //Lets do not delay the BP events since deattaching the object relies on it and it would cause a delayed letting of an item + OnEndManipulatorGraspBP.Broadcast(OwnerIndividualObject, OtherIndividual, GetWorld()->GetTimeSeconds()); + + } else { @@ -909,6 +945,7 @@ void USLManipulatorMonitor::DelayedGraspEndCallback() // Broadcast delayed event OnEndManipulatorGrasp.Broadcast(OwnerIndividualObject, EvItr->Other, EvItr->Time); + // Check if the grasp helper should be ended if (bUseGraspHelper) { @@ -1561,3 +1598,4 @@ void USLManipulatorMonitor::GraspHelperInputCallback() // return false; //} ///* End grasp helper */ + diff --git a/Source/USemLog/Private/Runtime/SLSymbolicLogger.cpp b/Source/USemLog/Private/Runtime/SLSymbolicLogger.cpp index 5b05a2cf..e987ece9 100644 --- a/Source/USemLog/Private/Runtime/SLSymbolicLogger.cpp +++ b/Source/USemLog/Private/Runtime/SLSymbolicLogger.cpp @@ -471,7 +471,8 @@ void ASLSymbolicLogger::UserInputToggleCallback() // Called when a semantic event is done void ASLSymbolicLogger::SemanticEventFinishedCallback(TSharedPtr Event) { - //GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, FString::Printf(TEXT("%s::%d %s"), *FString(__func__), __LINE__, *Event->ToString())); + GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, FString::Printf(TEXT("%s::%d %s"), *FString(__func__), __LINE__, *Event->ToString())); + //UE_LOG(LogTemp,Error , TEXT("%s::%d %s"), *FString(__func__), __LINE__, *Event->ToString()); //UE_LOG(LogTemp, Error, TEXT(">> %s::%d %s"), *FString(__func__), __LINE__, *Event->ToString()); FinishedEvents.Add(Event); diff --git a/Source/USemLog/Private/VizQ/SLVizQCacheEpisodes.cpp b/Source/USemLog/Private/VizQ/SLVizQCacheEpisodes.cpp index 0b99b977..168092e1 100644 --- a/Source/USemLog/Private/VizQ/SLVizQCacheEpisodes.cpp +++ b/Source/USemLog/Private/VizQ/SLVizQCacheEpisodes.cpp @@ -13,7 +13,7 @@ void USLVizQCacheEpisodes::ExecuteImpl(ASLKnowrobManager* KRManager) ASLVizManager* VizManager = KRManager->GetVizManager(); ASLMongoQueryManager* MongoQueryManager = KRManager->GetMongoQueryManager(); - for (const auto& Episode : Episodes) + for (const auto Episode : Episodes) { if (!VizManager->IsEpisodeCached(Episode)) { diff --git a/Source/USemLog/Private/VizQ/SLVizQMarkerArray.cpp b/Source/USemLog/Private/VizQ/SLVizQMarkerArray.cpp index 74abf00f..97759e1e 100644 --- a/Source/USemLog/Private/VizQ/SLVizQMarkerArray.cpp +++ b/Source/USemLog/Private/VizQ/SLVizQMarkerArray.cpp @@ -103,7 +103,7 @@ void USLVizQMarkerArray::PostEditChangeProperty(struct FPropertyChangedEvent& Pr } // Resync MarkerIds.Empty(); - for (const auto& Individual : Individuals) + for (const auto Individual : Individuals) { MarkerIds.Add(MarkerIdPrefix + Individual); } @@ -134,7 +134,7 @@ void USLVizQMarkerArray::PostEditChangeProperty(struct FPropertyChangedEvent& Pr } // Resync MarkerIds.Empty(); - for (const auto& Individual : Individuals) + for (const auto Individual : Individuals) { MarkerIds.Add(MarkerIdPrefix + Individual); } @@ -143,7 +143,7 @@ void USLVizQMarkerArray::PostEditChangeProperty(struct FPropertyChangedEvent& Pr { bSyncMarkerAndIndividualsButton = false; MarkerIds.Empty(); - for (const auto& Individual : Individuals) + for (const auto Individual : Individuals) { MarkerIds.Add(MarkerIdPrefix + Individual); } @@ -151,7 +151,7 @@ void USLVizQMarkerArray::PostEditChangeProperty(struct FPropertyChangedEvent& Pr else if (PropertyName == GET_MEMBER_NAME_CHECKED(USLVizQMarkerArray, MarkerIdPrefix)) { MarkerIds.Empty(); - for (const auto& Individual : Individuals) + for (const auto Individual : Individuals) { MarkerIds.Add(MarkerIdPrefix + Individual); } diff --git a/USemLog.uplugin b/USemLog.uplugin index 08fad47e..9f74add9 100644 --- a/USemLog.uplugin +++ b/USemLog.uplugin @@ -35,6 +35,10 @@ "Name": "UMongoC", "Enabled": true }, + { + "Name": "SRanipal", + "Enabled": true + }, { "Name": "UProtobuf", "Enabled": true