Files
Plugin/Source/SenseGloveCore/Public/SGCore/SGTracking.h
T

285 lines
8.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 "Math/Quat.h"
#include "Math/Vector.h"
#include "SGTypes/SGCoreTypes.h"
#include "SGTracking.generated.h"
/**
*
*/
USTRUCT()
struct SENSEGLOVECORE_API FSGTracking
{
GENERATED_BODY()
public:
/**
* Knowing a position & rotation in 3D space, calculate a relative location based on offsets.
*/
static void CalculateLocation(
const FVector& TrackedPosition, const FQuat& TrackedRotation,
const FVector& PositionOffset, const FQuat& RotationOffset,
FVector& OutNewPosition, FQuat& OutNewRotation);
/**
* Knowing a position & rotation in 3D space, calculate a relative location based on offsets.
*/
static void CalculateLocation(
const FVector& TrackedPosition, const FRotator& TrackedRotation,
const FVector& PositionOffset, const FRotator& RotationOffset,
FVector& OutNewPosition, FRotator& OutNewRotation);
/**
* Positional offset from each finger to the glove origin.
*/
static TArray<FVector> GetSenseGloveFingerToGlovePositionOrigin();
/**
*
*/
static TArray<FQuat> GetSenseGloveFingerToGloveRotationOriginQ();
/**
*
*/
static TArray<FRotator> GetSenseGloveFingerToGloveRotationOrigin();
/**
* Default position offset from glove origin to wrist location, in cm.
*/
static FVector GetSenseGloveWristPositionOffset();
/**
* Default rotation offset from glove origin to wrist location.
*/
static FQuat GetSenseGloveWristRotationOffsetQ();
/**
* Default rotation offset from glove origin to wrist location.
*/
static FRotator GetSenseGloveWristRotationOffset();
/**
* Get the position and rotation offsets to go from the glove origin to the mounted position.
* @remarks Based on CAD. needs to be inverted when going from tracker to glove origin.
*/
static void GetSenseGloveMountOffset(bool bRightHanded, ESGFinger ToFinger,
FVector& OutIPosition, FQuat& OutIRotation);
/**
* Get the position and rotation offsets to go from the glove origin to the mounted position.
* @remarks Based on CAD. needs to be inverted when going from tracker to glove origin.
*/
static void GetSenseGloveMountOffset(bool bRightHanded, ESGFinger ToFinger,
FVector& OutIPosition, FRotator& OutIRotation);
/**
* Get the offset to get from the TrackedHardware to a SenseGlove mounting location. Combined with Glove-Mount offset to get the glove location.
*/
static void GetSenseGloveTrackerMountOffset(ESGPositionalTrackingHardware Hardware, bool bRightHanded,
FVector& OutPositionOffset, FQuat& OutRotationOffset);
/**
* Get the offset to get from the TrackedHardware to a SenseGlove mounting location. Combined with Glove-Mount offset to get the glove location.
*/
static void GetSenseGloveTrackerMountOffset(ESGPositionalTrackingHardware Hardware, bool bRightHanded,
FVector& OutPositionOffset, FRotator& OutRotationOffset);
/**
* Vive Tracker origin to Finger rotational offset.
*/
static FVector GetSenseGloveViveToAttachPosition();
/**
* Vive Tracker origin to Finger rotational offset.
*/
static FQuat GetSenseGloveViveToAttachRotationQ();
/**
* Vive Tracker origin to Finger rotational offset.
*/
static FRotator GetSenseGloveViveToAttachRotation();
/**
* Oculus Touch origin to Finger rotational offset.
*/
static FVector GetSenseGloveOculusTouchToAttachPosition();
/**
* Oculus Touch origin to Finger rotational offset.
*/
static FQuat GetSenseGloveOculusTouchToAttachRotationQ();
/**
* Oculus Touch origin to Finger rotational offset.
*/
static FRotator GetSenseGloveOculusTouchToAttachRotation();
/**
* Positional offset between Nova Glove Origin and Wrist.
*/
static FVector GetNovaToWristPositionOffset();
/**
* Rotational offset between Nova Glove Origin and Wrist.
*/
static FQuat GetNovaToWristRotationOffsetQ();
/**
* Rotational offset between Nova Glove Origin and Wrist.
*/
static FRotator GetNovaToWristRotationOffset();
/**
* Returns the Offsets that will bring us from the Nova origin to the wrist position.
*/
static void GetNovaGloveWristOffset(bool bRightHanded, FVector& OutPositionOffset, FQuat& OutRotationOffset);
/**
* Returns the Offsets that will bring us from the Nova origin to the wrist position.
*/
static void GetNovaGloveWristOffset(bool bRightHanded, FVector& OutPositionOffset, FRotator& OutRotationOffset);
/**
*
*/
static FVector GetRightNovaViveToAttachPosition();
/**
*
*/
static FQuat GetRightNovaViveToAttachRotationQ();
/**
*
*/
static FRotator GetRightNovaViveToAttachRotation();
/**
*
*/
static FVector GetLeftNovaViveToAttachPosition();
/**
*
*/
static FQuat GetLeftNovaViveToAttachRotationQ();
/**
*
*/
static FRotator GetLeftNovaViveToAttachRotation();
/**
*
*/
static FVector GetRightNovaQuest2ToAttachPosition();
/**
*
*/
static FQuat GetRightNovaQuest2ToAttachRotationQ();
/**
*
*/
static FRotator GetRightNovaQuest2ToAttachRotation();
/**
*
*/
static FVector GetLeftNovaQuest2ToAttachPosition();
/**
*
*/
static FQuat GetLeftNovaQuest2ToAttachRotationQ();
/**
*
*/
static FRotator GetLeftNovaQuest2ToAttachRotation();
/**
* @remarks Left is a mirror, so we only need R pos.
*/
static FVector GetRightNovaPico2ToAttachPosition();
/**
*
*/
static FQuat GetRightNovaPico2ToAttachRotationQ();
/**
*
*/
static FRotator GetRightNovaPico2ToAttachRotation();
/**
*
*/
static FQuat GetLeftNovaPico2ToAttachRotationQ();
/**
*
*/
static FRotator GetLeftNovaPico2ToAttachRotation();
/**
* Retrieves Offsets for a particular device.
*/
static void GetNovaGloveTrackerOffset(ESGPositionalTrackingHardware Hardware, bool bRightHanded,
FVector& OutPositionOffset, FQuat& OutRotationOffset);
/**
* Retrieves Offsets for a particular device.
*/
static void GetNovaGloveTrackerOffset(ESGPositionalTrackingHardware Hardware, bool bRightHanded,
FVector& OutPositionOffset, FRotator& OutRotationOffset);
/**
*
*/
static FString ToString(ESGPositionalTrackingHardware Hardware);
};