Files
Plugin/Source/SenseGloveCore/Public/SGCore/SGHapticGloveCalibrationSequence.h
T
Mamadou Babaei 494d97c43f * Expose SenseGloveTypes as a public dependency in SenseGloveConnect and
SenseGloveCore modules, so that the C++ users of the API don't need to
 explicitly add it as a dependency
* Clean up the redundant headers/modules dependency from SGCore headers
* Fix RunUAT build issues for Epic Store submission
2022-11-25 15:09:20 +01:00

288 lines
9.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
*
*/
#pragma once
#include "Containers/Array.h"
#include "Containers/UnrealString.h"
#include "Templates/UniquePtr.h"
#include "UObject/Object.h"
#include "UObject/ObjectMacros.h"
#include "SGTypes/SGCoreTypes.h"
#include "SGHapticGloveCalibrationSequence.generated.h"
class FSGHapticGloveCalibrationSequenceImpl;
class FSGHapticGloveQuickCalibrationImpl;
class USGCalibrationDataPoint;
class USGHandPose;
class USGHandProfile;
class USGHapticGlove;
class USGSensorRange;
/**
* A sequence which collects data points until specific criteria have been met. It must be 'fed' an Update command from your program in order to work.
*/
UCLASS(BlueprintType)
class SENSEGLOVECORE_API USGHapticGloveCalibrationSequence : public UObject
{
GENERATED_BODY()
public:
static USGHapticGloveCalibrationSequence* NewHapticGloveCalibrationSequence(
UObject* Outer, const FSGHapticGloveCalibrationSequenceImpl& HapticGloveCalibrationSequence);
static USGHapticGloveCalibrationSequence* NewHapticGloveCalibrationSequence(
UObject* Outer, TSharedRef<FSGHapticGloveCalibrationSequenceImpl> HapticGloveCalibrationSequence);
protected:
/**
*
*/
static USGHapticGloveCalibrationSequence* NewHapticGloveCalibrationSequence(UObject* Outer);
public:
/**
* Create a new instance of a base HapitcGlove Calibration Sequence.
*/
static USGHapticGloveCalibrationSequence* NewHapticGloveCalibrationSequence(
UObject* Outer, const USGHapticGlove* LinkedGlove);
public:
/**
* The maximum buffer size for calibration points. Once calibrationPoints exceeds this value, the
*/
static int32 GetMaxDataPoints();
public:
/**
* Converts a calibration range taken from a Calibration sequence, and converts it into a profile. Use this if you're not actually using the sequence.
*/
static bool CompileProfile(UObject* Outer,
const USGSensorRange* SensorRange, ESGDeviceType ForDevice, bool bRightHanded,
USGHandProfile*& OutProfile);
private:
struct FImpl;
struct FImplDeleter
{
void operator()(const FImpl* P) const;
};
TUniquePtr<FImpl, FImplDeleter> Pimpl;
FImplDeleter PimplDeleter;
protected:
/**
*
*/
USGHapticGloveCalibrationSequence();
public:
/**
* Create a new instance of a base HapitcGlove Calibration Sequence.
*/
explicit USGHapticGloveCalibrationSequence(const USGHapticGlove* LinkedGlove);
public:
/**
* The cast from underlying type constructor.
*/
explicit USGHapticGloveCalibrationSequence(
const FSGHapticGloveCalibrationSequenceImpl& HapticGloveCalibrationSequenceImpl);
/**
* The cast from underlying child type constructor.
*/
explicit USGHapticGloveCalibrationSequence(
const FSGHapticGloveQuickCalibrationImpl& HapticGloveQuickCalibrationImpl);
protected:
/**
* The cast from underlying pointer type constructor.
*/
explicit USGHapticGloveCalibrationSequence(
TSharedRef<FSGHapticGloveCalibrationSequenceImpl> HapticGloveCalibrationSequenceImpl);
/**
* The cast from underlying child pointer type constructor.
*/
explicit USGHapticGloveCalibrationSequence(
TSharedRef<FSGHapticGloveQuickCalibrationImpl> HapticGloveQuickCalibrationImpl);
public:
/**
* The destructor.
*/
virtual ~USGHapticGloveCalibrationSequence() override;
protected:
/**
* Allows the child classes to set the underlying object after construction.
*/
void SetHapticGloveCalibrationSequenceImpl(
const FSGHapticGloveCalibrationSequenceImpl& HapticGloveCalibrationSequenceImpl);
/**
* Allows the child classes to set the underlying object after construction.
*/
void SetHapticGloveCalibrationSequenceImpl(
const FSGHapticGloveQuickCalibrationImpl& HapticGloveQuickCalibrationImpl);
/**
* Allows the child classes to set the underlying object after construction.
*/
void SetHapticGloveCalibrationSequenceImpl(
TSharedRef<FSGHapticGloveCalibrationSequenceImpl> HapticGloveCalibrationSequenceImpl);
/**
* Allows the child classes to set the underlying object after construction.
*/
void SetHapticGloveCalibrationSequenceImpl(
TSharedRef<FSGHapticGloveQuickCalibrationImpl> HapticGloveQuickCalibrationImpl);
public:
/**
* The cast to underlying type method.
*/
TSharedRef<FSGHapticGloveCalibrationSequenceImpl> ToHapticGloveCalibrationSequenceImpl() const;
protected:
/**
* Allows the child classes to synchronize the parent's underlying object at any time.
*/
virtual void SyncImplObject() const;
/**
* Allows the child classes to synchronize the parent's uproperties at any time.
*/
virtual void SyncUProperties();
public:
/**
* Glove linked to this calibration sequence. Will attempt to grab data from this glove evey time Update() is called.
*/
USGHapticGlove* GetLinkedGlove(UObject* Outer) const;
/**
*
*/
void SetLinkedGlove(const USGHapticGlove* LinkedGlove);
/**
* Calibration points collected during this calibration process. One is added every time the "Update()" function is called.
* Used to create a profile after the calibration finishes.
*/
TArray<USGCalibrationDataPoint*> GetCalibrationPoints(UObject* Outer) const;
/**
* How much time has elapsed during this calibration sequence. Useful for logging or for automated functions.
*/
float GetElapsedTime() const;
/**
* Used to determine if the user has manually ended the sequence, to prevent us from adding any more calibration points.
*/
bool IsManuallyCompleted() const;
/**
* If a sequence consists of multiple stages, this integer will show you which one is currently active.
*/
int32 GetCurrentStage() const;
/**
* Returns the amount of calibration points collected so far.
*/
SIZE_T GetCalibrationPointsCount() const;
/**
* Whether or not this sequence was completed as per its own rules.
*/
bool AutoCompleted() const;
/**
* Returns true if this sequence is marked as 'complete' and can begin compiling a profile.
*/
bool Completed() const;
public:
/**
* Resets this calibration sequence's data, but not it's LinkedGlove.
*/
void Reset();
/**
*
*/
void AddDataPoint(const TArray<FVector>& CalibrationPoints);
/**
* Update this calibration sequence with new data. We use deltaSeconds to check for things like stability.
*/
void Update(float DeltaSeconds);
/**
* Manual confirmation of whatever step we're supposed to making at the moment.
*/
void ConfirmCurrentStep();
public:
/**
* Compile a min/max range from the data points collected by this sequence. Returns true if it's actually possible.
*/
bool CompileRange(UObject* Outer, USGSensorRange*& OutSensorRange) const;
/**
* Compile a profile from the data points collected by this sequence. Returns true if it's actually possible.
*/
bool CompileProfile(UObject* Outer, ESGDeviceType ForDevice, bool bRightHanded, USGHandProfile*& OutProfile) const;
/**
* Returns the current HandPose; either the one we should be making, or what it would look like at the moment.
*/
bool GetHandPose(UObject* Outer, USGHandPose*& OutCurrentHandPose) const;
/**
* Returns the current HandPose; either the one we should be making, or what it would look like at the moment.
*/
bool GetHandPose(UObject* Outer, bool bRightHanded, USGHandPose*& OutCurrentHandPose) const;
/**
* Retrieve instructions on what to do during the current step.
*/
FString GetCurrentInstruction(const FString& NextStepKey = FString{""}) const;
};