initial public release
This commit is contained in:
@@ -0,0 +1,270 @@
|
||||
/**
|
||||
* @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
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "SGHapticGlove.h"
|
||||
#include "Containers/Array.h"
|
||||
#include "HAL/Platform.h"
|
||||
#include "Math/Quat.h"
|
||||
#include "Math/Vector.h"
|
||||
|
||||
#include "SGCore/SGBasicHandModel.h"
|
||||
#include "SGCore/SGHandPose.h"
|
||||
#include "SGCore/SGHandProfile.h"
|
||||
#include "SGCore/SGHapticGlove.h"
|
||||
#include "SGCore/SGSenseGlovePose.h"
|
||||
#include "SGCore/SGSenseGloveSensorData.h"
|
||||
#include "SGCore/SGThumperCommand.h"
|
||||
#include "SGTypes/SGCoreTypes.h"
|
||||
|
||||
#include "SGSenseGlove.generated.h"
|
||||
|
||||
class FSGSenseGloveImpl;
|
||||
class USGBuzzCommand;
|
||||
class USGForceFeedbackCommand;
|
||||
|
||||
UCLASS(BlueprintType)
|
||||
class SENSEGLOVECORE_API USGSenseGlove final : public USGHapticGlove
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
static USGSenseGlove* NewSenseGlove(UObject* Outer, const FSGSenseGloveImpl& SenseGloveImpl);
|
||||
|
||||
static USGSenseGlove* NewSenseGlove(UObject* Outer, TSharedRef<FSGSenseGloveImpl> SenseGloveImpl);
|
||||
|
||||
public:
|
||||
static USGSenseGlove* NewSenseGlove(UObject* Outer);
|
||||
|
||||
static USGSenseGlove* NewSenseGlove(UObject* Outer, const USGSenseGloveInfo& Model);
|
||||
|
||||
public:
|
||||
static ANSICHAR GetHapticsByte();
|
||||
|
||||
static ANSICHAR GetThumperByte();
|
||||
|
||||
public:
|
||||
static USGSenseGlovePose* CalculateGlovePose(UObject* Outer,
|
||||
const USGSenseGloveSensorData* SensorData,
|
||||
const USGSenseGloveInfo* GloveModel);
|
||||
|
||||
static USGSenseGlovePose* CalculateGlovePose(UObject* Outer,
|
||||
const TArray<TArray<FVector>>& GloveAngles,
|
||||
const USGSenseGloveInfo* GloveModel);
|
||||
|
||||
static USGHandPose* CalculateHandPose(UObject* Outer,
|
||||
const USGSenseGlovePose* GlovePose,
|
||||
const USGBasicHandModel* HandModel,
|
||||
const USGSenseGloveHandProfile* Profile);
|
||||
|
||||
public:
|
||||
static USGDevice* Parse(UObject* Outer, const FString& ConstantsString);
|
||||
|
||||
static TArray<USGSenseGlove*> GetSenseGloves(UObject* Outer);
|
||||
|
||||
static bool GetSenseGlove(UObject* Outer, USGSenseGlove*& OutGlove);
|
||||
|
||||
static bool GetSenseGlove(UObject* Outer, bool bRightHanded, USGSenseGlove*& OutGlove);
|
||||
|
||||
public:
|
||||
static TArray<FVector> GetCalibrationValues(const USGSenseGlovePose* GlovePose);
|
||||
|
||||
static void CalibrateInterpolation(UObject* Outer,
|
||||
const TArray<FVector>& MinValues, const TArray<FVector>& MaxValues,
|
||||
bool bRightHanded, USGSenseGloveHandProfile*& OutProfile);
|
||||
|
||||
public:
|
||||
static void CalculateGloveLocation(const FVector& ReferencePosition, const FQuat& ReferenceRotation,
|
||||
ESGPositionalTrackingHardware TrackingHardware,
|
||||
bool bRightHanded, ESGFinger MountedOn,
|
||||
FVector& OutGlovePosition, FQuat& OutGloveRotation);
|
||||
|
||||
static void CalculateWristLocation(const FVector& ReferencePosition, const FQuat& ReferenceRotation,
|
||||
ESGPositionalTrackingHardware TrackingHardware,
|
||||
bool bRightHanded, ESGFinger MountedOn,
|
||||
const FVector& GloveWristPositionOffset,
|
||||
const FQuat& GloveWristRotationOffset,
|
||||
FVector& OutWristPosition, FQuat& OutWristRotation);
|
||||
|
||||
private:
|
||||
struct FImpl;
|
||||
|
||||
struct FImplDeleter
|
||||
{
|
||||
void operator()(const FImpl* P) const;
|
||||
};
|
||||
|
||||
TUniquePtr<FImpl, FImplDeleter> Pimpl;
|
||||
FImplDeleter PimplDeleter;
|
||||
|
||||
protected:
|
||||
USGSenseGlove();
|
||||
|
||||
explicit USGSenseGlove(const USGSenseGloveInfo& Model);
|
||||
|
||||
public:
|
||||
/**
|
||||
* The cast from underlying parent type constructor.
|
||||
*/
|
||||
explicit USGSenseGlove(const FSGDeviceImpl& SGDeviceImpl);
|
||||
|
||||
/**
|
||||
* The cast from underlying parent type constructor.
|
||||
*/
|
||||
explicit USGSenseGlove(const FSGHapticGloveImpl& HapticGloveImpl);
|
||||
|
||||
/**
|
||||
* The cast from underlying type constructor.
|
||||
*/
|
||||
explicit USGSenseGlove(const FSGSenseGloveImpl& SenseGloveImpl);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* The cast from underlying parent pointer type constructor.
|
||||
*/
|
||||
explicit USGSenseGlove(TSharedRef<FSGDeviceImpl> SGDeviceImpl);
|
||||
|
||||
/**
|
||||
* The cast from underlying parent pointer type constructor.
|
||||
*/
|
||||
explicit USGSenseGlove(TSharedRef<FSGHapticGloveImpl> HapticGloveImpl);
|
||||
|
||||
/**
|
||||
* The cast from underlying pointer type constructor.
|
||||
*/
|
||||
explicit USGSenseGlove(TSharedRef<FSGSenseGloveImpl> SenseGloveImpl);
|
||||
|
||||
public:
|
||||
/**
|
||||
* The destructor.
|
||||
*/
|
||||
virtual ~USGSenseGlove() override;
|
||||
|
||||
public:
|
||||
/**
|
||||
* The cast to underlying type method.
|
||||
*/
|
||||
TSharedRef<FSGSenseGloveImpl> ToSenseGloveImpl() const;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Allows the child classes to synchronize the parent's underlying object at any time.
|
||||
*/
|
||||
virtual void SyncImplObject() const override;
|
||||
|
||||
/**
|
||||
* Allows the child classes to synchronize the parent's uproperties at any time.
|
||||
*/
|
||||
virtual void SyncUProperties() override;
|
||||
|
||||
public:
|
||||
USGSenseGloveInfo* GetGloveModel(UObject* Outer) const;
|
||||
|
||||
virtual bool IsRight() const override;
|
||||
|
||||
public:
|
||||
virtual ESGDeviceType GetDeviceType() const override;
|
||||
|
||||
virtual FString GetDeviceId() const override;
|
||||
|
||||
virtual FString GetHardwareVersion() const override;
|
||||
|
||||
virtual int32 GetFirmwareVersion() const override;
|
||||
|
||||
virtual int32 GetSubFirmwareVersion() const override;
|
||||
|
||||
public:
|
||||
bool GetSensorData(UObject* Outer, USGSenseGloveSensorData*& OutSensorData) const;
|
||||
|
||||
virtual bool GetImuRotation(FQuat& OutImu) override;
|
||||
|
||||
bool GetGlovePose(UObject* Outer, USGSenseGlovePose*& OutGlovePose);
|
||||
|
||||
bool GetGlovePose(UObject* Outer, const USGSenseGloveSensorData* SensorData, USGSenseGlovePose*& OutGlovePose);
|
||||
|
||||
/// HACK
|
||||
/// 'FSGSenseGloveImpl::GetHandPose' hides overloaded virtual functions [-Werror,-Woverloaded-virtual]
|
||||
/// tell the compiler we want both the GetHandPose from FSGHapticGloveImpl and FSGSenseGloveImpl
|
||||
using USGHapticGlove::GetHandPose;
|
||||
|
||||
bool GetHandPose(UObject* Outer, const USGBasicHandModel* HandModel, const USGSenseGloveHandProfile* Profile,
|
||||
USGHandPose*& OutHandPose);
|
||||
|
||||
virtual bool GetHandPose(UObject* Outer, const USGBasicHandModel* HandGeometry, const USGHandProfile* HandProfile,
|
||||
USGHandPose*& OutHandPose) override;
|
||||
|
||||
virtual bool GetHandPose(UObject* Outer, const USGHandProfile* HandProfile, USGHandPose*& OutHandPose) override;
|
||||
|
||||
public:
|
||||
virtual void SendHaptics(const USGForceFeedbackCommand* ForceFeedbackCommand) override;
|
||||
|
||||
virtual void SendHaptics(const USGBuzzCommand* BuzzCommand) override;
|
||||
|
||||
virtual void SendHaptics(const USGForceFeedbackCommand* ForceFeedbackCommand,
|
||||
const USGBuzzCommand* BuzzCommand,
|
||||
const USGThumperCommand* ThumperCommand) override;
|
||||
|
||||
public:
|
||||
virtual bool GetCalibrationValues(TArray<FVector>& OutValues) override;
|
||||
|
||||
virtual void ResetCalibrationRange() override;
|
||||
|
||||
virtual void ApplyCalibration(UObject* Outer, USGHandProfile*& OutProfile) const override;
|
||||
|
||||
void ApplyCalibration(UObject* Outer, USGSenseGloveHandProfile*& OutProfile) const;
|
||||
|
||||
public:
|
||||
virtual void GetGloveLocation(const FVector& ReferencePosition, const FQuat& ReferenceRotation,
|
||||
ESGPositionalTrackingHardware TrackingHardware,
|
||||
FVector& OutGlovePosition, FQuat& OutGloveRotation) const override;
|
||||
|
||||
void GetGloveLocation(const FVector& ReferencePosition, const FQuat& ReferenceRotation,
|
||||
ESGPositionalTrackingHardware TrackingHardware, ESGFinger MountedOn,
|
||||
FVector& OutGlovePosition, FQuat& OutGloveRotation) const;
|
||||
|
||||
virtual void GetWristLocation(const FVector& ReferencePosition, const FQuat& ReferenceRotation,
|
||||
ESGPositionalTrackingHardware TrackingHardware,
|
||||
FVector& OutWristPosition, FQuat& OutWristRotation) const override;
|
||||
|
||||
void GetWristLocation(const FVector& ReferencePosition, const FQuat& ReferenceRotation,
|
||||
ESGPositionalTrackingHardware TrackingHardware,
|
||||
const FVector& GloveWristPositionOffset,
|
||||
const FQuat& GloveWristRotationOffset,
|
||||
FVector& OutWristPosition, FQuat& OutWristRotation) const;
|
||||
|
||||
public:
|
||||
virtual FString ToString() const override;
|
||||
};
|
||||
Reference in New Issue
Block a user