Files
Plugin/Source/SenseGloveCoreKismet/Public/SGCoreKismet/SGHapticGloveKismetLibrary.h
T

310 lines
14 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
*
* An interface for any of our gloves that can track hand motion and/or send
* force / vibrotactile feedback.
*/
#pragma once
#include "SGKismet/SGBlueprintFunctionLibrary.h"
#include "SGTypes/SGCoreTypes.h"
#include "SGHapticGloveKismetLibrary.generated.h"
class USGBasicHandModel;
class USGBuzzCommand;
class USGForceFeedbackCommand;
class USGHandPose;
class USGHandProfile;
class USGHapticGlove;
class USGThumperCommand;
/**
* A glove developed by SenseGlove, that has hand tracking and/or haptic feedback functionality.
*/
UCLASS(meta=(ScriptName = "SesneGloveHapticGloveKismetLibrary"))
class SENSEGLOVECOREKISMET_API USGHapticGloveKismetLibrary : public USGBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
/**
* Get all Haptic Gloves detected on this system.
*/
UFUNCTION(BlueprintCallable, Category="SenseGlove | Core | Haptic Glove", meta=(WorldContext="WorldContextObject"))
static TArray<USGHapticGlove*> GetHapticGloves(UObject* WorldContextObject);
/**
* Get the first Haptic Glove detected on this system.
*/
UFUNCTION(BlueprintCallable, DisplayName="Get Glove", Category="SenseGlove | Core | Haptic Glove",
meta=(WorldContext="WorldContextObject"))
static bool GetGlove_OutG(UObject* WorldContextObject, USGHapticGlove*& OutGlove);
/**
* Get the first left/right Haptic Glove detected on this system.
*/
UFUNCTION(BlueprintCallable, DisplayName="Get Glove", Category="SenseGlove | Core | Haptic Glove",
meta=(WorldContext="WorldContextObject"))
static bool GetGlove_bRH_OutG(UObject* WorldContextObject, bool bRightHanded,
USGHapticGlove*& OutGlove);
/**
* Get the DeviceType enumerator of this device; used to check if its a SenseGlove/Nova/etc.
*/
UFUNCTION(BlueprintPure, Category="SenseGlove | Core | Haptic Glove")
static ESGDeviceType GetDeviceType(const USGHapticGlove* HapticGlove);
/**
* Retrieve this glove's unique identifier.
*/
UFUNCTION(BlueprintPure, Category="SenseGlove | Core | Haptic Glove")
static FString GetDeviceId(const USGHapticGlove* HapticGlove);
/**
* Retrieve this glove's hardware (sub) version. "DK1", "DK2", etc.
*/
UFUNCTION(BlueprintPure, Category="SenseGlove | Core | Haptic Glove")
static FString GetHardwareVersion(const USGHapticGlove* HapticGlove);
/**
* Retrieve this device's main firmware version. v4.12 returns 4.
*/
UFUNCTION(BlueprintPure, Category="SenseGlove | Core | Haptic Glove")
static int32 GetFirmwareVersion(const USGHapticGlove* HapticGlove);
/**
* Retrieve this device's sub firmware version. v4.12 returns 12.
*/
UFUNCTION(BlueprintPure, Category="SenseGlove | Core | Haptic Glove")
static int32 GetSubFirmwareVersion(const USGHapticGlove* HapticGlove);
/**
* Returns true if this glove is made for a right hand. If false, it's a left hand.
*/
UFUNCTION(BlueprintPure, Category="SenseGlove | Core | Haptic Glove")
static bool IsRight(const USGHapticGlove* HapticGlove);
/**
* Retrieve this glove's IMU rotation, if if has any.
*/
UFUNCTION(BlueprintCallable, DisplayName="Get Imu Rotation", Category="SenseGlove | Core | Haptic Glove")
static bool GetImuRotation_FQuat_OutI(UPARAM(ref) USGHapticGlove* HapticGlove, FQuat& OutImu);
/**
* Retrieve this glove's IMU rotation, if if has any.
*/
UFUNCTION(BlueprintCallable, DisplayName="Get Imu Rotation", Category="SenseGlove | Core | Haptic Glove")
static bool GetImuRotation_FRotator_OutI(UPARAM(ref) USGHapticGlove* HapticGlove, FRotator& OutImu);
/**
* Calculate the Hand Pose of this device, provided it has Hand Tracking available
*/
UFUNCTION(BlueprintCallable, DisplayName="Get Hand Pose", Category="SenseGlove | Core | Haptic Glove",
meta=(WorldContext="WorldContextObject"))
static bool GetHandPose_HG_HP_OutHP(UObject* WorldContextObject,
UPARAM(ref) USGHapticGlove* HapticGlove,
const USGBasicHandModel* HandGeometry,
const USGHandProfile* HandProfile,
USGHandPose*& OutHandPose);
/**
* Calculate the HandPose of this Device, taking into account user values, but not hand geometry.
*/
UFUNCTION(BlueprintCallable, DisplayName="Get Hand Pose", Category="SenseGlove | Core | Haptic Glove",
meta=(WorldContext="WorldContextObject"))
static bool GetHandPose_HP_OutHP(UObject* WorldContextObject,
UPARAM(ref) USGHapticGlove* HapticGlove,
const USGHandProfile* HandProfile,
USGHandPose*& OutHandPose);
/**
* Retrieve a HandPose based on the latest profile, but with a specific hand geometry.
*/
UFUNCTION(BlueprintCallable, DisplayName="Get Hand Pose", Category="SenseGlove | Core | Haptic Glove",
meta=(WorldContext="WorldContextObject"))
static bool GetHandPose_HG_OutHP(UObject* WorldContextObject,
UPARAM(ref) USGHapticGlove* HapticGlove,
const USGBasicHandModel* HandGeometry,
USGHandPose*& OutHandPose);
/**
* Retrieve a HandPose based on the latest profile and default hand Geometry.
*/
UFUNCTION(BlueprintCallable, DisplayName="Get Hand Pose", Category="SenseGlove | Core | Haptic Glove",
meta=(WorldContext="WorldContextObject"))
static bool GetHandPose_OutHP(UObject* WorldContextObject,
UPARAM(ref) USGHapticGlove* HapticGlove,
USGHandPose*& OutHandPose);
/**
* Stops all Haptic effects if any are currently playing. Useful at the end of simulations or when resetting.
*/
UFUNCTION(BlueprintCallable, Category="SenseGlove | Core | Haptic Glove")
static void StopHaptics(UPARAM(ref) USGHapticGlove* HapticGlove);
/**
*
*/
UFUNCTION(BlueprintCallable, Category="SenseGlove | Core | Haptic Glove")
static void StopVibrations(UPARAM(ref) USGHapticGlove* HapticGlove);
/**
* Send Haptic Commands to this Glove.
*/
UFUNCTION(BlueprintCallable, DisplayName="Send Haptics", Category="SenseGlove | Core | Haptic Glove")
static void SendHaptics_FFC(UPARAM(ref) USGHapticGlove* HapticGlove,
const USGForceFeedbackCommand* ForceFeedbackCommand);
/**
* Send Haptic Commands to this Glove.
*/
UFUNCTION(BlueprintCallable, DisplayName="Send Haptics", Category="SenseGlove | Core | Haptic Glove")
static void SendHaptics_BC(UPARAM(ref) USGHapticGlove* HapticGlove,
const USGBuzzCommand* BuzzCommand);
/**
* Send Haptic Commands to this Glove.
*/
UFUNCTION(BlueprintCallable, DisplayName="Send Haptics", Category="SenseGlove | Core | Haptic Glove")
static void SendHaptics_TC(UPARAM(ref) USGHapticGlove* HapticGlove,
const USGThumperCommand* ThumperCommand);
/**
* Send Haptic Commands to this Glove.
*/
UFUNCTION(BlueprintCallable, DisplayName="Send Haptics", Category="SenseGlove | Core | Haptic Glove")
static void SendHaptics_FFC_BC(UPARAM(ref) USGHapticGlove* HapticGlove,
const USGForceFeedbackCommand* ForceFeedbackCommand,
const USGBuzzCommand* BuzzCommand);
/**
* Send Haptic Commands to this Glove.
*/
UFUNCTION(BlueprintCallable, DisplayName="Send Haptics", Category="SenseGlove | Core | Haptic Glove")
static void SendHaptics_FFC_BC_TC(UPARAM(ref) USGHapticGlove* HapticGlove,
const USGForceFeedbackCommand* ForceFeedbackCommand,
const USGBuzzCommand* BuzzCommand,
const USGThumperCommand* ThumperCommand);
/**
* Retrieve calibration values of this glove, as an array of size 5, containing x (roll), y (flexion), z (abduction) values.
*/
UFUNCTION(BlueprintCallable, Category="SenseGlove | Core | Haptic Glove")
static bool GetCalibrationValues(UPARAM(ref) USGHapticGlove* HapticGlove, TArray<FVector>& OutValues);
/**
* Reset Calibration range for this Device.
*/
UFUNCTION(BlueprintCallable, Category="SenseGlove | Core | Haptic Glove")
static void ResetCalibrationRange(UPARAM(ref) USGHapticGlove* HapticGlove);
/**
* Updates calibration values only.
*/
UFUNCTION(BlueprintCallable, Category="SenseGlove | Core | Haptic Glove")
static void UpdateCalibrationRange(UPARAM(ref) USGHapticGlove* HapticGlove);
/**
* Updates calibration values only.
*/
UFUNCTION(BlueprintCallable, DisplayName="Update Calibration", Category="SenseGlove | Core | Haptic Glove")
static void UpdateCalibrationRange_CV(UPARAM(ref) USGHapticGlove* HapticGlove,
const TArray<FVector>& CalibrationValues);
/**
* Access the minimum- and maximum sensor values measured by this Haptic Glove, in this session.
*/
UFUNCTION(BlueprintCallable, Category="SenseGlove | Core | Haptic Glove")
static void GetCalibrationRange(UPARAM(ref) USGHapticGlove* HapticGlove,
TArray<FVector>& OutMinValues, TArray<FVector>& OutMaxValues);
/**
* Updates Calibration values and applies it to the Profile.
*/
UFUNCTION(BlueprintCallable, Category="SenseGlove | Core | Haptic Glove", meta=(WorldContext="WorldContextObject"))
static void UpdateCalibration(UObject* WorldContextObject,
UPARAM(ref) USGHapticGlove* HapticGlove, USGHandProfile*& OutProfile);
/**
* Apply this glove's calibration range to a handProfile.
*/
UFUNCTION(BlueprintPure, Category="SenseGlove | Core | Haptic Glove", meta=(WorldContext="WorldContextObject"))
static void ApplyCalibration(UObject* WorldContextObject,
const USGHapticGlove* HapticGlove, USGHandProfile*& OutProfile);
/**
* Retrieve the location of the wrist, based on a reference location and default glove-hand offsets.
*
* @remarks The simplest interface, using default offsets.
*/
UFUNCTION(BlueprintPure, DisplayName="Get Wrist Location", Category="SenseGlove | Core | Haptic Glove")
static void GetWristLocation_RP_FQuat_RR_TH_OutWP_Out_WR(
const USGHapticGlove* HapticGlove,
const FVector& ReferencePosition, const FQuat& ReferenceRotation,
ESGPositionalTrackingHardware TrackingHardware,
FVector& OutWristPosition, FQuat& OutWristRotation);
/**
* Retrieve the location of the wrist, based on a reference location and default glove-hand offsets.
*
* @remarks The simplest interface, using default offsets.
*/
UFUNCTION(BlueprintPure, DisplayName="Get Wrist Location", Category="SenseGlove | Core | Haptic Glove")
static void GetWristLocation_RP_FRotator_RR_TH_OutWP_OutWR(
const USGHapticGlove* HapticGlove,
const FVector& ReferencePosition, const FRotator& ReferenceRotation,
ESGPositionalTrackingHardware TrackingHardware,
FVector& OutWristPosition, FRotator& OutWristRotation);
/**
* Retrieve the location of the glove origin, based on a reference location.
*/
UFUNCTION(BlueprintPure, DisplayName="Get Glove Location", Category="SenseGlove | Core | Haptic Glove")
static void GetGloveLocation_RP_FQuat_RR_TH_OutGP_OutGR(
const USGHapticGlove* HapticGlove,
const FVector& ReferencePosition, const FQuat& ReferenceRotation,
ESGPositionalTrackingHardware TrackingHardware,
FVector& OutGlovePosition, FQuat& OutGloveRotation);
/**
* Retrieve the location of the glove origin, based on a reference location.
*/
UFUNCTION(BlueprintPure, DisplayName="Get Glove Location", Category="SenseGlove | Core | Haptic Glove")
static void GetGloveLocation_RP_FRotator_RR_TH_OutGP_OutGR(
const USGHapticGlove* HapticGlove,
const FVector& ReferencePosition, const FRotator& ReferenceRotation,
ESGPositionalTrackingHardware TrackingHardware,
FVector& OutGlovePosition, FRotator& OutGloveRotation);
};