SenseGloveCore modules, so that the C++ users of the API don't need to explicitly add it as a dependency * Clean up the redundant headers/modules dependency from SGCore headers * Fix RunUAT build issues for Epic Store submission
266 lines
8.4 KiB
C++
266 lines
8.4 KiB
C++
/**
|
|
* @file
|
|
*
|
|
* @author Mamadou Babaei <mamadou@senseglove.com>
|
|
*
|
|
* @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<TArray<FVector>>& JointPositions,
|
|
const TArray<TArray<FQuat>>& JointRotations,
|
|
const TArray<TArray<FVector>>& GloveAngles);
|
|
|
|
/**
|
|
* Creates a new instance of a SenseGlovePose.
|
|
*/
|
|
static USGSenseGlovePose* NewSenseGlovePose(UObject* Outer, bool bRightHanded,
|
|
const TArray<TArray<FVector>>& JointPositions,
|
|
const TArray<TArray<FRotator>>& JointRotations,
|
|
const TArray<TArray<FVector>>& GloveAngles);
|
|
|
|
/**
|
|
* Creates a new instance of a SenseGlovePose.
|
|
*/
|
|
static USGSenseGlovePose* NewSenseGlovePose(UObject* Outer, bool bRightHanded,
|
|
const TArray<FSGVectorArray>& JointPositions,
|
|
const TArray<FSGQuatArray>& JointRotations,
|
|
const TArray<FSGVectorArray>& GloveAngles);
|
|
|
|
/**
|
|
* Creates a new instance of a SenseGlovePose.
|
|
*/
|
|
static USGSenseGlovePose* NewSenseGlovePose(UObject* Outer, bool bRightHanded,
|
|
const TArray<FSGVectorArray>& JointPositions,
|
|
const TArray<FSGRotatorArray>& JointRotations,
|
|
const TArray<FSGVectorArray>& 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<FImpl, FImplDeleter> Pimpl;
|
|
FImplDeleter PimplDeleter;
|
|
|
|
public:
|
|
/**
|
|
* The basic constructor.
|
|
*/
|
|
USGSenseGlovePose();
|
|
|
|
/**
|
|
* Creates a new instance of a SenseGlovePose.
|
|
*/
|
|
USGSenseGlovePose(bool bRightHanded,
|
|
const TArray<TArray<FVector>>& JointPositions,
|
|
const TArray<TArray<FQuat>>& JointRotations,
|
|
const TArray<TArray<FVector>>& GloveAngles);
|
|
|
|
/**
|
|
* Creates a new instance of a SenseGlovePose.
|
|
*/
|
|
USGSenseGlovePose(bool bRightHanded,
|
|
const TArray<TArray<FVector>>& JointPositions,
|
|
const TArray<TArray<FRotator>>& JointRotations,
|
|
const TArray<TArray<FVector>>& GloveAngles);
|
|
|
|
/**
|
|
* Creates a new instance of a SenseGlovePose.
|
|
*/
|
|
USGSenseGlovePose(bool bRightHanded,
|
|
const TArray<FSGVectorArray>& JointPositions,
|
|
const TArray<FSGQuatArray>& JointRotations,
|
|
const TArray<FSGVectorArray>& GloveAngles);
|
|
|
|
/**
|
|
* Creates a new instance of a SenseGlovePose.
|
|
*/
|
|
USGSenseGlovePose(bool bRightHanded,
|
|
const TArray<FSGVectorArray>& JointPositions,
|
|
const TArray<FSGRotatorArray>& JointRotations,
|
|
const TArray<FSGVectorArray>& 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<TArray<FVector>> GetJointPositions() const;
|
|
|
|
/**
|
|
* Quaternion rotation of each glove joint, relative to the Glove Origin.
|
|
*/
|
|
TArray<TArray<FQuat>> GetJointRotationsQ() const;
|
|
|
|
/**
|
|
* Rotation of each glove joint, relative to the Glove Origin.
|
|
*/
|
|
TArray<TArray<FRotator>> 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<TArray<FVector>> GetGloveAngles() const;
|
|
|
|
public:
|
|
/**
|
|
* The position of the tip of the 'thimbles', the furthest link on each glove link.
|
|
*/
|
|
TArray<FVector> GetThimblePositions() const;
|
|
|
|
/**
|
|
* The (quaternion) rotation of the 'thimbles', the furthest link on each link.
|
|
*/
|
|
TArray<FQuat> GetThimbleRotationsQ() const;
|
|
|
|
/**
|
|
* The rotation of the 'thimbles', the furthest link on each link.
|
|
*/
|
|
TArray<FRotator> GetThimbleRotations() const;
|
|
|
|
/**
|
|
* Sum of the Sensor angles in each (xyz) direction. "Total Pronation / Flexion / Abduction".
|
|
*/
|
|
TArray<FVector> GetTotalGloveAngles() const;
|
|
|
|
/**
|
|
* Calculate fingertip positions based on a user profile.
|
|
*/
|
|
TArray<FVector> CalculateFingerTips(const USGSenseGloveHandProfile* SenseGloveHandProfile) const;
|
|
|
|
/**
|
|
* Calculate fingertip positions, knowing the offset between thimble and fingertips.
|
|
*/
|
|
TArray<FVector> CalculateFingerTips(const TArray<FVector>& 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;
|
|
};
|