/** * @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 * * Contains position and rotation data of a SenseGlove's exoskeleton, along * with accessors for relevant variables. */ #pragma once #include "Containers/Array.h" #include "Containers/UnrealString.h" #include "Math/Quat.h" #include "Math/Vector.h" #include "Templates/UniquePtr.h" #include "UObject/Object.h" #include "UObject/ObjectMacros.h" #include "SGCore/SGQuatArray.h" #include "SGCore/SGRotatorArray.h" #include "SGCore/SGVectorArray.h" #include "SGSenseGlovePose.generated.h" class FSGSenseGlovePoseImpl; class USGSenseGloveHandProfile; class USGSenseGloveInfo; /** * Represents a pose of a Sense Glove exoskeleton. */ UCLASS(BlueprintType) class SENSEGLOVECORE_API USGSenseGlovePose final : public UObject { GENERATED_BODY() public: static USGSenseGlovePose* NewSenseGlovePose( UObject* Outer, const FSGSenseGlovePoseImpl& SenseGlovePoseImpl); public: /** * The basic constructor. */ static USGSenseGlovePose* NewSenseGlovePose(UObject* Outer); /** * Creates a new instance of a SenseGlovePose. */ static USGSenseGlovePose* NewSenseGlovePose(UObject* Outer, bool bRightHanded, const TArray>& JointPositions, const TArray>& JointRotations, const TArray>& GloveAngles); /** * Creates a new instance of a SenseGlovePose. */ static USGSenseGlovePose* NewSenseGlovePose(UObject* Outer, bool bRightHanded, const TArray>& JointPositions, const TArray>& JointRotations, const TArray>& GloveAngles); /** * Creates a new instance of a SenseGlovePose. */ static USGSenseGlovePose* NewSenseGlovePose(UObject* Outer, bool bRightHanded, const TArray& JointPositions, const TArray& JointRotations, const TArray& GloveAngles); /** * Creates a new instance of a SenseGlovePose. */ static USGSenseGlovePose* NewSenseGlovePose(UObject* Outer, bool bRightHanded, const TArray& JointPositions, const TArray& JointRotations, const TArray& GloveAngles); public: /** * Returns an idle pose for the Sense Glove if no data can be found. */ static USGSenseGlovePose* IdlePose(UObject* Outer, const USGSenseGloveInfo* GloveInfo); /** * Deserialize a GlovePose back into usable values. */ static USGSenseGlovePose* Deserialize(UObject* Outer, const FString& SerializedString); private: struct FImpl; struct FImplDeleter { void operator()(const FImpl* P) const; }; TUniquePtr Pimpl; FImplDeleter PimplDeleter; public: /** * The basic constructor. */ USGSenseGlovePose(); /** * Creates a new instance of a SenseGlovePose. */ USGSenseGlovePose(bool bRightHanded, const TArray>& JointPositions, const TArray>& JointRotations, const TArray>& GloveAngles); /** * Creates a new instance of a SenseGlovePose. */ USGSenseGlovePose(bool bRightHanded, const TArray>& JointPositions, const TArray>& JointRotations, const TArray>& GloveAngles); /** * Creates a new instance of a SenseGlovePose. */ USGSenseGlovePose(bool bRightHanded, const TArray& JointPositions, const TArray& JointRotations, const TArray& GloveAngles); /** * Creates a new instance of a SenseGlovePose. */ USGSenseGlovePose(bool bRightHanded, const TArray& JointPositions, const TArray& JointRotations, const TArray& GloveAngles); public: /** * The cast from underlying type constructor. */ explicit USGSenseGlovePose(const FSGSenseGlovePoseImpl& SenseGlovePoseImpl); public: /** * The destructor. */ virtual ~USGSenseGlovePose() override; protected: /** * Allows to set the underlying object after construction. */ void SetSenseGlovePoseImpl(const FSGSenseGlovePoseImpl& SenseGlovePoseImpl); public: /** * The cast to underlying type method. */ const FSGSenseGlovePoseImpl& ToSenseGlovePoseImpl() const; public: /** * Whether this Glove Pose was created for be a right- or left hand, or not. */ bool IsRight() const; /** * Positions of each glove joint, relative to the Glove's Origin. */ TArray> GetJointPositions() const; /** * Quaternion rotation of each glove joint, relative to the Glove Origin. */ TArray> GetJointRotationsQ() const; /** * Rotation of each glove joint, relative to the Glove Origin. */ TArray> GetJointRotations() const; /** * Glove joint angles in euler notation, relative to the last segment. * * @remarks Essentially sensor angles, though placed in their proper xyz notation. */ TArray> GetGloveAngles() const; public: /** * The position of the tip of the 'thimbles', the furthest link on each glove link. */ TArray GetThimblePositions() const; /** * The (quaternion) rotation of the 'thimbles', the furthest link on each link. */ TArray GetThimbleRotationsQ() const; /** * The rotation of the 'thimbles', the furthest link on each link. */ TArray GetThimbleRotations() const; /** * Sum of the Sensor angles in each (xyz) direction. "Total Pronation / Flexion / Abduction". */ TArray GetTotalGloveAngles() const; /** * Calculate fingertip positions based on a user profile. */ TArray CalculateFingerTips(const USGSenseGloveHandProfile* SenseGloveHandProfile) const; /** * Calculate fingertip positions, knowing the offset between thimble and fingertips. */ TArray CalculateFingerTips(const TArray& FingerOffsets) const; /** * Returns true if this glove pose equals another. */ bool Equals(const USGSenseGlovePose* SenseGlovePose) const; public: /** * Returns a user-friendly string representation of this GlovePose for reporting. */ FString ToString(bool bShortFormat = false) const; /** * Serialize this GlovePose into a string representation. */ FString SGSerialize() const; };