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

387 lines
17 KiB
C++

/**
* @file
*
* @author Mamadou Babaei <mamadou@senseglove.com>
*
* @section LICENSE
*
* (The MIT License)
*
* Copyright (c) 2020 - 2022 NovaGlove
*
* 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 the "Nova" - a soft glove.
* Contains methods for Kinematics, Haptics and Serialization.
*/
#pragma once
#include "SGKismet/SGBlueprintFunctionLibrary.h"
#include "SGTypes/SGCoreTypes.h"
#include "SGNovaGloveKismetLibrary.generated.h"
class USGBasicHandModel;
class USGBuzzCommand;
class USGDevice;
class USGForceFeedbackCommand;
class USGHandPose;
class USGHandProfile;
class USGNovaGlove;
class USGNovaGloveHandProfile;
class USGNovaGloveSensorData;
class USGThumperCommand;
/**
* A soft glove with Force- and Vibrotactile Feedback and limited tracking.
*/
UCLASS(meta=(ScriptName = "SesneGloveNovaGloveKismetLibrary"))
class SENSEGLOVECOREKISMET_API USGNovaGloveKismetLibrary final : public USGBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
/**
* Byte indicating a new Nova haptic command.
*/
UFUNCTION(BlueprintCallable, Category="SenseGlove | Core | Nova | Nova Glove")
static FString GetHapticsByte();
/**
* Minimum calibration value distance until we apply the range.
*/
UFUNCTION(BlueprintCallable, Category="SenseGlove | Core | Nova | Nova Glove")
static FVector GetMinCalibrationRange();
/**
* Calculate a Hand Pose based on a HandMode; sensor data from a Nova, and a UserProfile.
*/
UFUNCTION(BlueprintCallable, Category="SenseGlove | Core | Nova | Nova Glove",
meta=(WorldContext="WorldContextObject"))
static USGHandPose* CalculateHandPose(UObject* WorldContextObject,
const USGBasicHandModel* HandModel,
const USGNovaGloveSensorData* NovaData,
const USGNovaGloveHandProfile* Profile);
/**
* Deserializes a Nova from its ConstantsString. Returns a nullptr if unsuccessful.
*/
UFUNCTION(BlueprintCallable, Category="SenseGlove | Core | Nova | Nova Glove",
meta=(WorldContext="WorldContextObject"))
static USGDevice* Parse(UObject* WorldContextObject, const FString& ConstantsString);
/**
* Retrieve all Nova's.
*/
UFUNCTION(BlueprintCallable, Category="SenseGlove | Core | Nova | Nova Glove",
meta=(WorldContext="WorldContextObject"))
static TArray<USGNovaGlove*> GetNovaGloves(UObject* WorldContextObject);
/**
* Retrieve the first connected Nova there is.
*/
UFUNCTION(BlueprintCallable, DisplayName="Get Nova Glove", Category="SenseGlove | Core | Nova | Nova Glove",
meta=(WorldContext="WorldContextObject"))
static bool GetNovaGlove_OutG(UObject* WorldContextObject, USGNovaGlove*& OutGlove);
/**
* Retrieve the first (connected) right or left handed Nova.
*/
UFUNCTION(BlueprintCallable, DisplayName="Get Nova Glove", Category="SenseGlove | Core | Nova | Nova Glove",
meta=(WorldContext="WorldContextObject"))
static bool GetNovaGlove_bRH_OutG(UObject* WorldContextObject,
bool bRightHanded, USGNovaGlove*& OutGlove);
/**
* Convert a SenseGlove GlovePose into calibrationValues.
*/
UFUNCTION(BlueprintCallable, DisplayName="Get Calibration Values", Category="SenseGlove | Core | Nova | Nova Glove")
static TArray<FVector> GetCalibrationValues_SD(const USGNovaGloveSensorData* SensorData);
/**
*
*/
UFUNCTION(BlueprintCallable, Category="SenseGlove | Core | Nova | Nova Glove",
meta=(WorldContext="WorldContextObject"))
static void CalibrateInterpolation(UObject* WorldContextObject,
const TArray<FVector>& MinValues, const TArray<FVector>& MaxValues,
USGNovaGloveHandProfile*& OutProfile);
/**
* Retrieve the location of the glove origin, based on a reference location without requiring an object reference.
*/
UFUNCTION(BlueprintCallable, DisplayName="Calculate Glove Location",
Category="SenseGlove | Core | Nova | Nova Glove")
static void CalculateGloveLocation_RP_FQuat_RR_TH_bRH_OutGP_OutGR(
const FVector& ReferencePosition, const FQuat& ReferenceRotation,
ESGPositionalTrackingHardware TrackingHardware, bool bRightHanded,
FVector& OutGlovePosition, FQuat& OutGloveRotation);
/**
* Retrieve the location of the glove origin, based on a reference location without requiring an object reference.
*/
UFUNCTION(BlueprintCallable, DisplayName="Calculate Glove Location",
Category="SenseGlove | Core | Nova | Nova Glove")
static void CalculateGloveLocation_RP_FRotator_RR_TH_bRH_OutGP_OutGR(
const FVector& ReferencePosition, const FRotator& ReferenceRotation,
ESGPositionalTrackingHardware TrackingHardware, bool bRightHanded,
FVector& OutGlovePosition, FRotator& OutGloveRotation);
/**
* Retrieve the location of the wrist, based on a reference location and default glove-hand offsets, without needing an object reference.
*/
UFUNCTION(BlueprintCallable, DisplayName="Calculate Wrist Location",
Category="SenseGlove | Core | Nova | Nova Glove")
static void CalculateWristLocation_RP_FQuat_RR_TH_bRH_OutWP_OutWR(
const FVector& ReferencePosition, const FQuat& ReferenceRotation,
ESGPositionalTrackingHardware TrackingHardware, bool bRightHanded,
FVector& OutWristPosition, FQuat& OutWristRotation);
/**
* Retrieve the location of the wrist, based on a reference location and default glove-hand offsets, without needing an object reference.
*/
UFUNCTION(BlueprintCallable, DisplayName="Calculate Wrist Location",
Category="SenseGlove | Core | Nova | Nova Glove")
static void CalculateWristLocation_RP_FRotator_RR_TH_bRH_OutWP_OutWR(
const FVector& ReferencePosition, const FRotator& ReferenceRotation,
ESGPositionalTrackingHardware TrackingHardware, bool bRightHanded,
FVector& OutWristPosition, FRotator& OutWristRotation);
/**
* Converts a thumper command into bytes that the Nova can understand.
*/
UFUNCTION(BlueprintCallable, DisplayName="To Bytes", Category="SenseGlove | Core | Nova | Nova Glove")
static FString ToBytes_TC(const USGThumperCommand* ThumperCommand);
/**
* Converts a force-feedback command into bytes that the Nova can understand.
*/
UFUNCTION(BlueprintCallable, DisplayName="To Bytes", Category="SenseGlove | Core | Nova | Nova Glove")
static FString ToBytes_FFC(const USGForceFeedbackCommand* ForceFeedbackCommand);
/**
* Converts a buzz-motor command into bytes that the Nova can understand.
*/
UFUNCTION(BlueprintCallable, DisplayName="To Bytes", Category="SenseGlove | Core | Nova | Nova Glove")
static FString ToBytes_BC(const USGBuzzCommand* BuzzCommand);
/**
* Return the DeviceType of this Nova.
*/
UFUNCTION(BlueprintPure, Category="SenseGlove | Core | Nova | Nova Glove")
static ESGDeviceType GetDeviceType(const USGNovaGlove* NovaGlove);
/**
* Returns this device's unique identifier.
*/
UFUNCTION(BlueprintPure, Category="SenseGlove | Core | Nova | Nova Glove")
static FString GetDeviceId(const USGNovaGlove* NovaGlove);
/**
* Access this device's hardware designation.
*/
UFUNCTION(BlueprintPure, Category="SenseGlove | Core | Nova | Nova Glove")
static FString GetHardwareVersion(const USGNovaGlove* NovaGlove);
/**
* Access this device's main firmware version. (ex: v3.2 -> 3).
*/
UFUNCTION(BlueprintPure, Category="SenseGlove | Core | Nova | Nova Glove")
static int32 GetFirmwareVersion(const USGNovaGlove* NovaGlove);
/**
* Access this device's sub-firmware version. (ex: v3.2 -> 2).
*/
UFUNCTION(BlueprintPure, Category="SenseGlove | Core | Nova | Nova Glove")
static int32 GetSubFirmwareVersion(const USGNovaGlove* NovaGlove);
/**
* Returns true if this device operates on a battery.
*/
UFUNCTION(BlueprintPure, Category="SenseGlove | Core | Nova | Nova Glove")
static bool HasBattery(const USGNovaGlove* NovaGlove);
/**
* Returns true if this device is currently charging.
*/
UFUNCTION(BlueprintCallable, Category="SenseGlove | Core | Nova | Nova Glove")
static bool IsCharging(UPARAM(ref) USGNovaGlove* NovaGlove);
/**
* Returns the device's battery level, as a value between 0 (empty) and 1 (full).
*/
UFUNCTION(BlueprintCallable, Category="SenseGlove | Core | Nova | Nova Glove")
static bool GetBatteryLevel(UPARAM(ref) USGNovaGlove* NovaGlove, float& OutBatteryLevel);
/**
* Get the latest Sensor Data from this Sense Glove.
*/
UFUNCTION(BlueprintCallable, Category="SenseGlove | Core | Nova | Nova Glove",
meta=(WorldContext="WorldContextObject"))
static bool GetSensorData(UObject* WorldContextObject,
UPARAM(ref) USGNovaGlove* NovaGlove, USGNovaGloveSensorData*& OutSensorData);
/**
* Retrieve Nova rotation.
*/
UFUNCTION(BlueprintCallable, DisplayName="Get Imu Rotation", Category="SenseGlove | Core | Nova | Nova Glove")
static bool GetImuRotation_FQuat_OutI(UPARAM(ref) USGNovaGlove* NovaGlove, FQuat& OutImu);
/**
* Retrieve Nova rotation.
*/
UFUNCTION(BlueprintCallable, DisplayName="Get Imu Rotation", Category="SenseGlove | Core | Nova | Nova Glove")
static bool GetImuRotation_FRotator_OutI(UPARAM(ref) USGNovaGlove* NovaGlove, FRotator& OutImu);
/**
* Retrieve a new hand pose using this glove, based on (calibrated) user data.
*/
UFUNCTION(BlueprintCallable, DisplayName="Get Hand Pose", Category="SenseGlove | Core | Nova | Nova Glove",
meta=(WorldContext="WorldContextObject"))
static bool GetHandPose_HM_P_OutHP(UObject* WorldContextObject,
UPARAM(ref) USGNovaGlove* NovaGlove,
const USGBasicHandModel* HandModel,
const USGNovaGloveHandProfile* Profile,
USGHandPose*& OutHandPose);
/**
* Retrieve a new hand pose using this glove, based on (calibrated) user data.
*/
UFUNCTION(BlueprintCallable, DisplayName="Get Hand Pose", Category="SenseGlove | Core | Nova | Nova Glove",
meta=(WorldContext="WorldContextObject"))
static bool GetHandPose_HG_HP_OutHP(UObject* WorldContextObject,
UPARAM(ref) USGNovaGlove* NovaGlove,
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 | Nova | Nova Glove",
meta=(WorldContext="WorldContextObject"))
static bool GetHandPose_HP_OutHP(UObject* WorldContextObject,
UPARAM(ref) USGNovaGlove* NovaGlove,
const USGHandProfile* HandProfile,
USGHandPose*& OutHandPose);
/**
* Send all available haptics to a Nova.
*/
UFUNCTION(BlueprintCallable, DisplayName="Send Haptics", Category="SenseGlove | Core | Nova | Nova Glove")
static void SendHaptics_FFC(UPARAM(ref) USGNovaGlove* NovaGlove,
const USGForceFeedbackCommand* ForceFeedbackCommand);
/**
* Send Haptic Commands to this Glove.
*/
UFUNCTION(BlueprintCallable, DisplayName="Send Haptics", Category="SenseGlove | Core | Nova | Nova Glove")
static void SendHaptics_BC(UPARAM(ref) USGNovaGlove* NovaGlove, const USGBuzzCommand* BuzzCommand);
/**
* Send Haptic Commands to this Glove.
*/
UFUNCTION(BlueprintCallable, DisplayName="Send Haptics", Category="SenseGlove | Core | Nova | Nova Glove")
static void SendHaptics_TC(UPARAM(ref) USGNovaGlove* NovaGlove, const USGThumperCommand* ThumperCommand);
/**
* Send Haptic Commands to this Glove.
*/
UFUNCTION(BlueprintCallable, DisplayName="Send Haptics", Category="SenseGlove | Core | Nova | Nova Glove")
static void SendHaptics_FFC_BC_TC(
UPARAM(ref) USGNovaGlove* NovaGlove,
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, DisplayName="Get Calibration Values", Category="SenseGlove | Core | Nova | Nova Glove")
static bool GetCalibrationValues_OutV(UPARAM(ref) USGNovaGlove* NovaGlove, TArray<FVector>& OutValues);
/**
* Applies the calibration range of this Nova a HandProfile.
*/
UFUNCTION(BlueprintPure, DisplayName="Apply Calibration", Category="SenseGlove | Core | Nova | Nova Glove",
meta=(WorldContext="WorldContextObject"))
static void ApplyCalibration_USGHandProfile_OutP(UObject* WorldContextObject,
const USGNovaGlove* NovaGlove,
USGHandProfile*& OutProfile);
/**
* Applies the calibration range of this SenseGlove to a NovaGloveHandProfile.
*/
UFUNCTION(BlueprintPure, DisplayName="Apply Calibration", Category="SenseGlove | Core | Nova | Nova Glove",
meta=(WorldContext="WorldContextObject"))
static void ApplyCalibration_USGNovaGloveHandProfile_OutP(UObject* WorldContextObject,
const USGNovaGlove* NovaGlove,
USGNovaGloveHandProfile*& OutProfile);
/**
* Retrieve the location of the glove origin, based on a reference location.
*/
UFUNCTION(BlueprintPure, DisplayName="Get Glove Location", Category="SenseGlove | Core | Nova | Nova Glove")
static void GetGloveLocation_RP_FQuat_RR_TH_OutGP_FQuat_OutGR(
const USGNovaGlove* NovaGlove,
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 | Nova | Nova Glove")
static void GetGloveLocation_RP_FRotator_RR_TH_OutGP_FRotator_OutGR(
const USGNovaGlove* NovaGlove,
const FVector& ReferencePosition, const FRotator& ReferenceRotation,
ESGPositionalTrackingHardware TrackingHardware,
FVector& OutGlovePosition, FRotator& OutGloveRotation);
/**
* Retrieve the location of the wrist, based on a reference location and default glove-hand offsets.
*/
UFUNCTION(BlueprintPure, DisplayName="Get Wrist Location", Category="SenseGlove | Core | Nova | Nova Glove")
static void GetWristLocation_RP_FQuat_RR_TH_OutWP_FQuat_OutWR(
const USGNovaGlove* NovaGlove,
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.
*/
UFUNCTION(BlueprintPure, DisplayName="Get Wrist Location", Category="SenseGlove | Core | Nova | Nova Glove")
static void GetWristLocation_RP_FRotator_RR_TH_OutWP_FRotator_OutWR(
const USGNovaGlove* NovaGlove,
const FVector& ReferencePosition, const FRotator& ReferenceRotation,
ESGPositionalTrackingHardware TrackingHardware,
FVector& OutWristPosition, FRotator& OutWristRotation);
/**
* Create a string representation of this device for reporting purposes.
*/
UFUNCTION(BlueprintPure, Category="SenseGlove | Core | Nova | Nova Glove")
static FString ToString(const USGNovaGlove* NovaGlove);
};