191 lines
8.0 KiB
C++
191 lines
8.0 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 "SGCore/SGQuatArray.h"
|
|
#include "SGCore/SGRotatorArray.h"
|
|
#include "SGCore/SGVectorArray.h"
|
|
#include "SGKismet/SGBlueprintFunctionLibrary.h"
|
|
|
|
#include "SGSenseGlovePoseKismetLibrary.generated.h"
|
|
|
|
class USGSenseGloveHandProfile;
|
|
class USGSenseGloveInfo;
|
|
class USGSenseGlovePose;
|
|
|
|
/**
|
|
* Represents a pose of a Sense Glove exoskeleton.
|
|
*/
|
|
UCLASS(meta=(ScriptName = "SesneGloveSenseGlovePoseKismetLibrary"))
|
|
class SENSEGLOVECOREKISMET_API USGSenseGlovePoseKismetLibrary final : public USGBlueprintFunctionLibrary
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
public:
|
|
/**
|
|
* The basic constructor.
|
|
*/
|
|
UFUNCTION(BlueprintCallable, Category="SenseGlove | Core | SG | Sense Glove Pose",
|
|
meta=(WorldContext="WorldContextObject"))
|
|
static USGSenseGlovePose* MakeSenseGlovePose(UObject* WorldContextObject);
|
|
|
|
/**
|
|
* Creates a new instance of a SenseGlovePose.
|
|
*/
|
|
UFUNCTION(BlueprintCallable, DisplayName="Make Sense Glove Pose",
|
|
Category="SenseGlove | Core | SG | Sense Glove Pose", meta=(WorldContext="WorldContextObject"))
|
|
static USGSenseGlovePose* MakeSenseGlovePose_bRH_JP_TArrayFSGQuatArray_JR_GA(
|
|
UObject* WorldContextObject, bool bRightHanded,
|
|
const TArray<FSGVectorArray>& JointPositions,
|
|
const TArray<FSGQuatArray>& JointRotations,
|
|
const TArray<FSGVectorArray>& GloveAngles);
|
|
|
|
/**
|
|
* Creates a new instance of a SenseGlovePose.
|
|
*/
|
|
UFUNCTION(BlueprintCallable, DisplayName="Make Sense Glove Pose",
|
|
Category="SenseGlove | Core | SG | Sense Glove Pose", meta=(WorldContext="WorldContextObject"))
|
|
static USGSenseGlovePose* MakeSenseGlovePose_bRH_JP_TArrayFSGRotatorArray_JR_GA(
|
|
UObject* WorldContextObject, bool bRightHanded,
|
|
const TArray<FSGVectorArray>& JointPositions,
|
|
const TArray<FSGRotatorArray>& JointRotations,
|
|
const TArray<FSGVectorArray>& GloveAngles);
|
|
|
|
/**
|
|
* Returns an idle pose for the Sense Glove if no data can be found.
|
|
*/
|
|
UFUNCTION(BlueprintCallable, Category="SenseGlove | Core | SG | Sense Glove Pose",
|
|
meta=(WorldContext="WorldContextObject"))
|
|
static USGSenseGlovePose* IdlePose(UObject* WorldContextObject, const USGSenseGloveInfo* GloveInfo);
|
|
|
|
/**
|
|
* Deserialize a GlovePose back into usable values.
|
|
*/
|
|
UFUNCTION(BlueprintCallable, Category="SenseGlove | Core | SG | Sense Glove Pose",
|
|
meta=(WorldContext="WorldContextObject"))
|
|
static USGSenseGlovePose* Deserialize(UObject* WorldContextObject, const FString& SerializedString);
|
|
|
|
/**
|
|
* Whether this Glove Pose was created for be a right- or left hand, or not.
|
|
*/
|
|
UFUNCTION(BlueprintPure, Category="SenseGlove | Core | SG | Sense Glove Pose")
|
|
static bool IsRight(const USGSenseGlovePose* SenseGlovePose);
|
|
|
|
/**
|
|
* Positions of each glove joint, relative to the Glove's Origin.
|
|
*/
|
|
UFUNCTION(BlueprintPure, Category="SenseGlove | Core | SG | Sense Glove Pose")
|
|
static TArray<FSGVectorArray> GetJointPositions(const USGSenseGlovePose* SenseGlovePose);
|
|
|
|
/**
|
|
* Quaternion rotation of each glove joint, relative to the Glove Origin.
|
|
*/
|
|
UFUNCTION(BlueprintPure, DisplayName="Get Joint Rotations", Category="SenseGlove | Core | SG | Sense Glove Pose")
|
|
static TArray<FSGQuatArray> GetJointRotations_TArrayFSGQuatArray(const USGSenseGlovePose* SenseGlovePose);
|
|
|
|
/**
|
|
* Rotation of each glove joint, relative to the Glove Origin.
|
|
*/
|
|
UFUNCTION(BlueprintPure, DisplayName="Get Joint Rotations", Category="SenseGlove | Core | SG | Sense Glove Pose")
|
|
static TArray<FSGRotatorArray> GetJointRotations_TArrayFSGRotatorArray(const USGSenseGlovePose* SenseGlovePose);
|
|
|
|
/**
|
|
* Glove joint angles in euler notation, relative to the last segment.
|
|
*
|
|
* @remarks Essentially sensor angles, though placed in their proper xyz notation.
|
|
*/
|
|
UFUNCTION(BlueprintPure, Category="SenseGlove | Core | SG | Sense Glove Pose")
|
|
static TArray<FSGVectorArray> GetGloveAngles(const USGSenseGlovePose* SenseGlovePose);
|
|
|
|
/**
|
|
* The position of the tip of the 'thimbles', the furthest link on each glove link.
|
|
*/
|
|
UFUNCTION(BlueprintPure, Category="SenseGlove | Core | SG | Sense Glove Pose")
|
|
static TArray<FVector> GetThimblePositions(const USGSenseGlovePose* SenseGlovePose);
|
|
|
|
/**
|
|
* The (quaternion) rotation of the 'thimbles', the furthest link on each link.
|
|
*/
|
|
UFUNCTION(BlueprintPure, DisplayName="Get Thimble Rotations", Category="SenseGlove | Core | SG | Sense Glove Pose")
|
|
static TArray<FQuat> GetThimbleRotations_FQuat(const USGSenseGlovePose* SenseGlovePose);
|
|
|
|
/**
|
|
* The rotation of the 'thimbles', the furthest link on each link.
|
|
*/
|
|
UFUNCTION(BlueprintPure, DisplayName="Get Thimble Rotations", Category="SenseGlove | Core | SG | Sense Glove Pose")
|
|
static TArray<FRotator> GetThimbleRotations_FRotator(const USGSenseGlovePose* SenseGlovePose);
|
|
|
|
/**
|
|
* Sum of the Sensor angles in each (xyz) direction. "Total Pronation / Flexion / Abduction".
|
|
*/
|
|
UFUNCTION(BlueprintPure, Category="SenseGlove | Core | SG | Sense Glove Pose")
|
|
static TArray<FVector> GetTotalGloveAngles(const USGSenseGlovePose* SenseGlovePose);
|
|
|
|
/**
|
|
* Calculate fingertip positions based on a user profile.
|
|
*/
|
|
UFUNCTION(BlueprintPure, Category="SenseGlove | Core | SG | Sense Glove Pose")
|
|
static TArray<FVector> CalculateFingerTips_SenseGloveHandProfileImpl(
|
|
const USGSenseGlovePose* SenseGlovePose,
|
|
const USGSenseGloveHandProfile* SenseGloveHandProfile);
|
|
|
|
/**
|
|
* Calculate fingertip positions, knowing the offset between thimble and fingertips.
|
|
*/
|
|
UFUNCTION(BlueprintPure, Category="SenseGlove | Core | SG | Sense Glove Pose")
|
|
static TArray<FVector> CalculateFingerTips_FingerOffsets(const USGSenseGlovePose* SenseGlovePose,
|
|
const TArray<FVector>& FingerOffsets);
|
|
|
|
/**
|
|
* Returns true if this glove pose equals another.
|
|
*/
|
|
UFUNCTION(BlueprintPure, Category="SenseGlove | Core | SG | Sense Glove Pose")
|
|
static bool Equals(const USGSenseGlovePose* A, const USGSenseGlovePose* B);
|
|
|
|
/**
|
|
* Returns a user-friendly string representation of this GlovePose for reporting.
|
|
*/
|
|
UFUNCTION(BlueprintPure, Category="SenseGlove | Core | SG | Sense Glove Pose")
|
|
static FString ToString(const USGSenseGlovePose* SenseGlovePose, bool bShortFormat = false);
|
|
|
|
/**
|
|
* Serialize this GlovePose into a string representation.
|
|
*/
|
|
UFUNCTION(BlueprintPure, DisplayName="Serialize", Category="SenseGlove | Core | SG | Sense Glove Pose")
|
|
static FString SGSerialize(const USGSenseGlovePose* SenseGlovePose);
|
|
};
|