304 lines
13 KiB
C++
304 lines
13 KiB
C++
/**
|
|
* @file
|
|
*
|
|
* @author Mamadou Babaei <mamadou@senseglove.com>
|
|
*
|
|
* @section LICENSE
|
|
*
|
|
* (The MIT License)
|
|
*
|
|
* Copyright (c) 2020 - 2023 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
|
|
*
|
|
* A data class containing the minimum required data for a hand's forward
|
|
* kinematics.
|
|
* Used in both kinematics and calibration.
|
|
*/
|
|
|
|
|
|
#pragma once
|
|
|
|
#include "SGKismet/SGBlueprintFunctionLibrary.h"
|
|
#include "SGTypes/SGCoreTypes.h"
|
|
#include "SGTypes/SGFloatArray.h"
|
|
|
|
#include "SGBasicHandModelKismetLibrary.generated.h"
|
|
|
|
class USGBasicHandModel;
|
|
|
|
/**
|
|
* Represents data of a user's hand required for forward kinematics.
|
|
*/
|
|
UCLASS(meta=(ScriptName = "SesneGloveBasicHandModelKismetLibrary"))
|
|
class SENSEGLOVECOREKISMET_API USGBasicHandModelKismetLibrary final : public USGBlueprintFunctionLibrary
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
public:
|
|
/**
|
|
* The basic class constructor.
|
|
*/
|
|
UFUNCTION(BlueprintCallable, Category="SenseGlove | Core | Kinematics | Basic Hand Model",
|
|
meta=(WorldContext="WorldContextObject"))
|
|
static USGBasicHandModel* MakeBasicHandModel(UObject* WorldContextObject);
|
|
|
|
/**
|
|
* Create a new BasicHandModel with no starting rotations.
|
|
*/
|
|
UFUNCTION(BlueprintCallable, DisplayName="Make Basic Hand Model",
|
|
Category="SenseGlove | Core | Kinematics | Basic Hand Model",
|
|
meta=(WorldContext="WorldContextObject"))
|
|
static USGBasicHandModel* MakeBasicHandModel_bRH_L_SP(
|
|
UObject* WorldContextObject,
|
|
bool bRightHanded, const TArray<FSGFloatArray>& Lengths, const TArray<FVector>& StartPositions);
|
|
|
|
/**
|
|
* Create a new BasicHandModel.
|
|
*/
|
|
UFUNCTION(BlueprintCallable, DisplayName="Make Basic Hand Model",
|
|
Category="SenseGlove | Core | Kinematics | Basic Hand Model",
|
|
meta=(WorldContext="WorldContextObject"))
|
|
static USGBasicHandModel* MakeBasicHandModel_bRH_L_SP_TArrayFQuat_SR(
|
|
UObject* WorldContextObject,
|
|
bool bRightHanded, const TArray<FSGFloatArray>& Lengths,
|
|
const TArray<FVector>& StartPositions, const TArray<FQuat>& StartRotations);
|
|
|
|
/**
|
|
* Create a new BasicHandModel.
|
|
*/
|
|
UFUNCTION(BlueprintCallable, DisplayName="Make Basic Hand Model",
|
|
Category="SenseGlove | Core | Kinematics | Basic Hand Model",
|
|
meta=(WorldContext="WorldContextObject"))
|
|
static USGBasicHandModel* MakeBasicHandModel_bRH_L_SP_TArrayFRotator_SR(
|
|
UObject* WorldContextObject,
|
|
bool bRightHanded, const TArray<FSGFloatArray>& Lengths,
|
|
const TArray<FVector>& StartPositions, const TArray<FRotator>& StartRotations);
|
|
|
|
/**
|
|
* Retrieve a default left or right hand model.
|
|
*/
|
|
UFUNCTION(BlueprintCallable, Category="SenseGlove | Core | Kinematics | Basic Hand Model",
|
|
meta=(WorldContext="WorldContextObject"))
|
|
static USGBasicHandModel* Default(UObject* WorldContextObject, bool bRightHanded);
|
|
|
|
/**
|
|
* Convert a serialized HandModel back into its class representation.
|
|
*/
|
|
UFUNCTION(BlueprintCallable, Category="SenseGlove | Core | Kinematics | Basic Hand Model",
|
|
meta=(WorldContext="WorldContextObject"))
|
|
static USGBasicHandModel* Deserialize(UObject* WorldContextObject, const FString& SerializedString);
|
|
|
|
/**
|
|
* Default finger lengths (based on right hand).
|
|
*
|
|
* @remarks Any missing fingers are replaced with their respective value.
|
|
*/
|
|
UFUNCTION(BlueprintCallable, Category="SenseGlove | Core | Kinematics | Basic Hand Model")
|
|
static TArray<FSGFloatArray> GetBaseFingerLengths();
|
|
|
|
/**
|
|
* Default joint positions (based on right hand).
|
|
*
|
|
* @remarks Any missing positions are replaced with their respective value.
|
|
*/
|
|
UFUNCTION(BlueprintCallable, Category="SenseGlove | Core | Kinematics | Basic Hand Model")
|
|
static TArray<FVector> GetBaseJointPositions();
|
|
|
|
/**
|
|
* Default joint angles (based on right hand).
|
|
*
|
|
* @remarks Any missing angles are replaced with their respective value.
|
|
*/
|
|
UFUNCTION(BlueprintCallable, Category="SenseGlove | Core | Kinematics | Basic Hand Model")
|
|
static TArray<FVector> GetBaseJointAngles();
|
|
|
|
/**
|
|
* Whether or not this BasicHandModel was created for a left- or right hand. Used for validation.
|
|
*/
|
|
UFUNCTION(BlueprintPure, Category="SenseGlove | Core | Kinematics | Basic Hand Model")
|
|
static bool IsRight(const USGBasicHandModel* BasicHandModel);
|
|
|
|
/**
|
|
* The length of individual finger phalangers in mm, sorted per finger. Generally 5x3.
|
|
*/
|
|
UFUNCTION(BlueprintPure, Category="SenseGlove | Core | Kinematics | Basic Hand Model")
|
|
static TArray<FSGFloatArray> GetFingerLengths(const USGBasicHandModel* BasicHandModel);
|
|
|
|
/**
|
|
* Retrieve the finger lengths of a specific finger in cm.
|
|
*/
|
|
UFUNCTION(BlueprintPure, DisplayName="Get Finger Lengths",
|
|
Category="SenseGlove | Core | Kinematics | Basic Hand Model")
|
|
static TArray<float> GetFingerLengths_F(const USGBasicHandModel* BasicHandModel, ESGFinger Finger);
|
|
|
|
/**
|
|
* Set the finger lengths of a specific finger in cm.
|
|
*/
|
|
UFUNCTION(BlueprintCallable, DisplayName="Set Finger Lengths",
|
|
Category="SenseGlove | Core | Kinematics | Basic Hand Model")
|
|
static void SetFingerLengths_ESGFinger_F_L(UPARAM(ref) USGBasicHandModel* BasicHandModel, ESGFinger Finger,
|
|
const TArray<float>& Lengths);
|
|
|
|
/**
|
|
* Set the finger lengths of a specific finger in cm.
|
|
*/
|
|
UFUNCTION(BlueprintCallable, DisplayName="Set Finger Lengths",
|
|
Category="SenseGlove | Core | Kinematics | Basic Hand Model")
|
|
static void SetFingerLengths_uint8_F_L(UPARAM(ref) USGBasicHandModel* BasicHandModel, uint8 Finger,
|
|
const TArray<float>& Lengths);
|
|
|
|
/**
|
|
* Get the finger ratios of all fingers.
|
|
*/
|
|
UFUNCTION(BlueprintPure, Category="SenseGlove | Core | Kinematics | Basic Hand Model")
|
|
TArray<FSGFloatArray> GetFingerRatios(const USGBasicHandModel* BasicHandModel) const;
|
|
|
|
/**
|
|
* Get the finger ratios of a specific finger.
|
|
*/
|
|
UFUNCTION(BlueprintPure, DisplayName="Get Finger Ratios",
|
|
Category="SenseGlove | Core | Kinematics | Basic Hand Model")
|
|
static TArray<float> GetFingerRatios_F(const USGBasicHandModel* BasicHandModel, ESGFinger Finger);
|
|
|
|
/**
|
|
* Starting joint positions relative to the device Origin.
|
|
*/
|
|
UFUNCTION(BlueprintPure, Category="SenseGlove | Core | Kinematics | Basic Hand Model")
|
|
static TArray<FVector> GetStartJointPositions(const USGBasicHandModel* BasicHandModel);
|
|
|
|
/**
|
|
*
|
|
*/
|
|
UFUNCTION(BlueprintCallable, DisplayName="Set Start Joint Position",
|
|
Category="SenseGlove | Core | Kinematics | Basic Hand Model")
|
|
static void SetStartJointPosition_ESGFinger_F_P(UPARAM(ref) USGBasicHandModel* BasicHandModel, ESGFinger Finger,
|
|
const FVector& Position);
|
|
|
|
/**
|
|
*
|
|
*/
|
|
UFUNCTION(BlueprintPure, DisplayName="Set Start Joint Position",
|
|
Category="SenseGlove | Core | Kinematics | Basic Hand Model")
|
|
static void SetStartJointPosition_uint8_F_P(UPARAM(ref) USGBasicHandModel* BasicHandModel, uint8 Finger,
|
|
const FVector& Position);
|
|
|
|
/**
|
|
* Starting joint rotations relative to the device Origin.
|
|
*/
|
|
UFUNCTION(BlueprintPure, DisplayName="Get Start Joint Rotations",
|
|
Category="SenseGlove | Core | Kinematics | Basic Hand Model")
|
|
static TArray<FQuat> GetStartJointRotations_TArrayFQuat(const USGBasicHandModel* BasicHandModel);
|
|
|
|
/**
|
|
* Starting joint rotations relative to the device Origin.
|
|
*/
|
|
UFUNCTION(BlueprintPure, DisplayName="Get Start Joint Rotations",
|
|
Category="SenseGlove | Core | Kinematics | Basic Hand Model")
|
|
static TArray<FRotator> GetStartJointRotations_TArrayFRotator(const USGBasicHandModel* BasicHandModel);
|
|
|
|
/**
|
|
* Retrieve the start position of a specific finger.
|
|
*/
|
|
UFUNCTION(BlueprintPure, Category="SenseGlove | Core | Kinematics | Basic Hand Model")
|
|
static FVector GetJointPosition(const USGBasicHandModel* BasicHandModel, ESGFinger Finger);
|
|
|
|
/**
|
|
* Set the start position of a specific finger.
|
|
*/
|
|
UFUNCTION(BlueprintCallable, Category="SenseGlove | Core | Kinematics | Basic Hand Model")
|
|
static void SetJointPosition(UPARAM(ref) USGBasicHandModel* BasicHandModel, const FVector& NewPosition,
|
|
ESGFinger Finger);
|
|
|
|
/**
|
|
* Retrieve the start rotation of a specific finger.
|
|
*/
|
|
UFUNCTION(BlueprintPure, DisplayName="Get Joint Rotation",
|
|
Category="SenseGlove | Core | Kinematics | Basic Hand Model")
|
|
static FQuat GetJointRotation_FQuat(const USGBasicHandModel* BasicHandModel, ESGFinger Finger);
|
|
|
|
/**
|
|
* Retrieve the start rotation of a specific finger.
|
|
*/
|
|
UFUNCTION(BlueprintPure, DisplayName="Get Joint Rotation",
|
|
Category="SenseGlove | Core | Kinematics | Basic Hand Model")
|
|
static FRotator GetJointRotation_FRotator(const USGBasicHandModel* BasicHandModel, ESGFinger Finger);
|
|
|
|
/**
|
|
* Set the start rotation of a specific finger.
|
|
*/
|
|
UFUNCTION(BlueprintCallable, DisplayName="Set Joint Rotation",
|
|
Category="SenseGlove | Core | Kinematics | Basic Hand Model")
|
|
static void SetJointRotation_FQuat_NR_F(
|
|
UPARAM(ref) USGBasicHandModel* BasicHandModel, const FQuat& NewRotation, ESGFinger Finger);
|
|
|
|
/**
|
|
* Set the start rotation of a specific finger.
|
|
*/
|
|
UFUNCTION(BlueprintCallable, DisplayName="Set Joint Rotation",
|
|
Category="SenseGlove | Core | Kinematics | Basic Hand Model")
|
|
static void SetJointRotation_FRotator_NR_F(
|
|
UPARAM(ref) USGBasicHandModel* BasicHandModel, const FRotator& NewRotation, ESGFinger Finger);
|
|
|
|
/**
|
|
* Get the total lengths of fingers, in cm.
|
|
*/
|
|
UFUNCTION(BlueprintPure, Category="SenseGlove | Core | Kinematics | Basic Hand Model")
|
|
static TArray<float> GetTotalLengths(const USGBasicHandModel* BasicHandModel);
|
|
|
|
/**
|
|
* Get the total length of a specific finger, in mm.
|
|
*/
|
|
UFUNCTION(BlueprintPure, Category="SenseGlove | Core | Kinematics | Basic Hand Model")
|
|
static float GetTotalLength(const USGBasicHandModel* BasicHandModel, ESGFinger Finger);
|
|
|
|
/**
|
|
* Retrieve the lengths of a specific finger, as BasicHandModel representation (L, 0, 0).
|
|
*
|
|
* @remarks Used for forwards kinematics.
|
|
*/
|
|
UFUNCTION(BlueprintPure, Category="SenseGlove | Core | Kinematics | Basic Hand Model")
|
|
static TArray<FVector> Get3DLengths(const USGBasicHandModel* BasicHandModel, ESGFinger Finger);
|
|
|
|
/**
|
|
* Check if this BasicHandModel has the same values as another BasicHandModel.
|
|
*/
|
|
UFUNCTION(BlueprintPure, Category="SenseGlove | Core | Kinematics | Basic Hand Model")
|
|
static bool Equals(const USGBasicHandModel* A, const USGBasicHandModel* B);
|
|
|
|
/**
|
|
* Convert this handModel into a string notation, readable for humans. Does not include starting positions / rotations.
|
|
*/
|
|
UFUNCTION(BlueprintPure, Category="SenseGlove | Core | Kinematics | Basic Hand Model")
|
|
static FString ToString(const USGBasicHandModel* BasicHandModel);
|
|
|
|
/**
|
|
* Convert this handModel into a string notation, readable for humans. Optionally includes starting positions / rotations.
|
|
*/
|
|
UFUNCTION(BlueprintPure, DisplayName="To String", Category="SenseGlove | Core | Kinematics | Basic Hand Model")
|
|
static FString ToString_bLO(const USGBasicHandModel* BasicHandModel, bool bLengthsOnly);
|
|
|
|
/**
|
|
* Serialize this HandModel into a string representation.
|
|
*/
|
|
UFUNCTION(BlueprintPure, DisplayName="Serialize", Category="SenseGlove | Core | Kinematics | Basic Hand Model")
|
|
static FString SGSerialize(const USGBasicHandModel* BasicHandModel);
|
|
}; |