/** * @file * * @author Mamadou Babaei * * @section LICENSE * * (The MIT License) * * Copyright (c) 2020 - 2022 SenseGlove * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * * @section DESCRIPTION * * Input for Sense Glove kinematics to calculate a HandPose. * Output of calibration algorithms. */ #pragma once #include "Containers/UnrealString.h" #include "HAL/Platform.h" #include "Math/Vector.h" #include "Templates/UniquePtr.h" #include "UObject/Object.h" #include "UObject/ObjectMacros.h" #include "SGTypes/SGCoreTypes.h" #include "SGSenseGloveHandProfile.generated.h" class FSGSenseGloveHandProfileImpl; class USGHandInterpolator; /** * Contains everything a Sense Glove needs to calculate a HandPose. */ UCLASS(BlueprintType) class SENSEGLOVECORE_API USGSenseGloveHandProfile final : public UObject { GENERATED_BODY() public: static USGSenseGloveHandProfile* NewSenseGloveHandProfile( UObject* Outer, const FSGSenseGloveHandProfileImpl& SenseGloveHandProfileImpl); public: /** * The basic constructor. */ static USGSenseGloveHandProfile* NewSenseGloveHandProfile(UObject* Outer); /** * Create a new Hand Profile for the Sense Glove. */ static USGSenseGloveHandProfile* NewSenseGloveHandProfile( UObject* Outer, bool bRightHanded, const USGHandInterpolator* Interpolator, ESGThumbSolver ThumbSolver, ESGFingerSolver FingerSolver, const TArray& FingerThimbleOffset); public: /** * Retrieve a 'new' profile, for either a left or right hand. */ static USGSenseGloveHandProfile* Default(UObject* Outer, bool bRightHanded); /** * Deserialize a HandProfile back into usable values. */ static USGSenseGloveHandProfile* Deserialize(UObject* Outer, const FString& SerializedString); public: /** * Default offset from thimble to fingertip. */ static FVector GetDefaultThimbleOffset(); private: struct FImpl; struct FImplDeleter { void operator()(const FImpl* P) const; }; TUniquePtr Pimpl; FImplDeleter PimplDeleter; public: /** * The basic constructor. */ USGSenseGloveHandProfile(); /** * Create a new Hand Profile for the Sense Glove. */ USGSenseGloveHandProfile(bool bRightHanded, const USGHandInterpolator* Interpolator, ESGThumbSolver ThumbSolver, ESGFingerSolver FingerSolver, const TArray& FingerThimbleOffset); public: /** * The cast from underlying type constructor. */ explicit USGSenseGloveHandProfile(const FSGSenseGloveHandProfileImpl& SenseGloveHandProfileImpl); public: /** * The destructor. */ virtual ~USGSenseGloveHandProfile() override; protected: /** * Allows to set the underlying object after construction. */ void SetSenseGloveHandProfileImpl(const FSGSenseGloveHandProfileImpl& SenseGloveHandProfileImpl); public: /** * The cast to underlying type method. */ const FSGSenseGloveHandProfileImpl& ToSenseGloveHandProfileImpl() const; public: /** * Check whether this profile has been created for a right hand (true) or left hand (false). */ bool IsRight() const; /** * Interpolation set to estimate joint angles. */ USGHandInterpolator* GetInterpolationSet(UObject* Outer) const; /** * Solver property that determines _how_ HandPoses are calculated. */ ESGThumbSolver GetThumbSolver() const; /** * Solver property that determines _how_ finger poses are calculated. */ ESGFingerSolver GetFingerSolver() const; /** * Offset from thimble to fingertip, used for Inverse Kinematics. */ TArray GetFingerThimbleOffset() const; public: /** * */ bool Equals(const USGSenseGloveHandProfile* SenseGloveHandProfile) const; /** * Reset calibration on this profile. */ void Reset(); public: /** * Serialize this HandProfile into a string representation. */ FString SGSerialize() const; };