update unreal api to take care of radians/degrees conversions where possible

This commit is contained in:
Mamadou Babaei
2023-03-03 18:01:34 +01:00
parent caa119c4c1
commit 5351301108
12 changed files with 38 additions and 31 deletions
@@ -68,14 +68,14 @@ float FSGAnatomy::GetThumbJointLimit(const bool bRightHanded, const int32 Joint,
return SGCoreImpl_FSGAnatomyImpl_GetThumbJointLimit(bRightHanded, Joint, Movement, bMax);
}
float FSGAnatomy::NormalizeFingerFlexion(const float FlexionInRadians)
float FSGAnatomy::NormalizeFingerFlexion(const float FlexionInDegrees)
{
return SGCoreImpl_FSGAnatomyImpl_NormalizeFingerFlexion(FlexionInRadians);
return SGCoreImpl_FSGAnatomyImpl_NormalizeFingerFlexion(FlexionInDegrees);
}
float FSGAnatomy::NormalizeThumbFlexion(const float FlexionInRadians)
float FSGAnatomy::NormalizeThumbFlexion(const float FlexionInDegrees)
{
return SGCoreImpl_FSGAnatomyImpl_NormalizeThumbFlexion(FlexionInRadians);
return SGCoreImpl_FSGAnatomyImpl_NormalizeThumbFlexion(FlexionInDegrees);
}
TArray<TArray<FVector>> FSGAnatomy::GetDefaultHandAngles(const bool bRightHanded)
@@ -82,14 +82,14 @@ public:
static float GetThumbJointLimit(bool bRightHanded, int32 Joint, int32 Movement, bool bMax);
/**
* Convert a total finger flexion in radians into a 0..1 representation.
* Convert a total finger flexion in degrees.
*/
static float NormalizeFingerFlexion(float FlexionInRadians);
static float NormalizeFingerFlexion(float FlexionInDegrees);
/**
* Convert a total thumb flexion in radians into a 0..1 representation.
* Convert a total thumb flexion in degrees.
*/
static float NormalizeThumbFlexion(float FlexionInRadians);
static float NormalizeThumbFlexion(float FlexionInDegrees);
/**
* Get Hand Angles that would make a Default (Idle) Pose.
@@ -178,7 +178,7 @@ public:
public:
/**
* Glove angles in radians, sorted by finger, from proximal to distal.
* Glove angles in degrees, sorted by finger, from proximal to distal.
*/
TArray<TArray<float>> GetSensorAngles() const;
@@ -75,14 +75,20 @@ float FSGAnatomyImpl::GetThumbJointLimit(
Movement, FAnatomyType::GetThumbJointLimit(bRightHanded, Joint, Movement, bMax));
}
float FSGAnatomyImpl::NormalizeFingerFlexion(const float FlexionInRadians)
float FSGAnatomyImpl::NormalizeFingerFlexion(const float FlexionInDegrees)
{
return FAnatomyType::NormalizeFingerFlexion(FlexionInRadians);
return FSGAngles::TransformToUnreal(
FAnatomyType::NormalizeFingerFlexion(
FSGAngles::TransformToSenseGlove(
FlexionInDegrees)));
}
float FSGAnatomyImpl::NormalizeThumbFlexion(const float FlexionInRadians)
float FSGAnatomyImpl::NormalizeThumbFlexion(const float FlexionInDegrees)
{
return FAnatomyType::NormalizeThumbFlexion(FlexionInRadians);
return FSGAngles::TransformToUnreal(
FAnatomyType::NormalizeThumbFlexion(
FSGAngles::TransformToSenseGlove(
FlexionInDegrees)));
}
TArray<TArray<FVector>> FSGAnatomyImpl::GetDefaultHandAngles(const bool bRightHanded)
@@ -209,15 +209,15 @@ float SGCoreImpl_FSGAnatomyImpl_GetThumbJointLimit(
}
float SGCoreImpl_FSGAnatomyImpl_NormalizeFingerFlexion(
const float FlexionInRadians)
const float FlexionInDegrees)
{
return FSGAnatomyImpl::NormalizeFingerFlexion(FlexionInRadians);
return FSGAnatomyImpl::NormalizeFingerFlexion(FlexionInDegrees);
}
float SGCoreImpl_FSGAnatomyImpl_NormalizeThumbFlexion(
const float FlexionInRadians)
const float FlexionInDegrees)
{
return FSGAnatomyImpl::NormalizeThumbFlexion(FlexionInRadians);
return FSGAnatomyImpl::NormalizeThumbFlexion(FlexionInDegrees);
}
void SGCoreImpl_FSGAnatomyImpl_GetDefaultHandAngles(
@@ -177,7 +177,7 @@ const FSGSenseGloveSensorDataImpl::FSenseGloveSensorDataType& FSGSenseGloveSenso
TArray<TArray<float>> FSGSenseGloveSensorDataImpl::GetSensorAngles() const
{
TArray<TArray<float>> SensorAngles{
FSGArrayUtils::FromStdVector<float>(Pimpl->SenseGloveSensorData.GetSensorAngles())
FSGArrayUtils::FromSenseGloveAngles(Pimpl->SenseGloveSensorData.GetSensorAngles())
};
return MoveTemp(SensorAngles);
}
@@ -64,9 +64,9 @@ public:
static float GetThumbJointLimit(bool bRightHanded, int32 Joint, int32 Movement, bool bMax);
static float NormalizeFingerFlexion(float FlexionInRadians);
static float NormalizeFingerFlexion(float FlexionInDegrees);
static float NormalizeThumbFlexion(float FlexionInRadians);
static float NormalizeThumbFlexion(float FlexionInDegrees);
public:
static TArray<TArray<FVector>> GetDefaultHandAngles(bool bRightHanded);
@@ -103,10 +103,10 @@ SENSEGLOVECOREIMPL_PUBLIC_API float SGCoreImpl_FSGAnatomyImpl_GetThumbJointLimit
bool bMax);
SENSEGLOVECOREIMPL_PUBLIC_API float SGCoreImpl_FSGAnatomyImpl_NormalizeFingerFlexion(
float FlexionInRadians);
float FlexionInDegrees);
SENSEGLOVECOREIMPL_PUBLIC_API float SGCoreImpl_FSGAnatomyImpl_NormalizeThumbFlexion(
float FlexionInRadians);
float FlexionInDegrees);
SENSEGLOVECOREIMPL_PUBLIC_API void SGCoreImpl_FSGAnatomyImpl_GetDefaultHandAngles(
void* OutAngles,
@@ -70,14 +70,14 @@ float USGAnatomyKismetLibrary::GetThumbJointLimit(const bool bRightHanded, const
return FSGAnatomy::GetThumbJointLimit(bRightHanded, Joint, Movement, bMax);
}
float USGAnatomyKismetLibrary::NormalizeFingerFlexion(const float FlexionInRadians)
float USGAnatomyKismetLibrary::NormalizeFingerFlexion(const float FlexionInDegrees)
{
return FSGAnatomy::NormalizeFingerFlexion(FlexionInRadians);
return FSGAnatomy::NormalizeFingerFlexion(FlexionInDegrees);
}
float USGAnatomyKismetLibrary::NormalizeThumbFlexion(const float FlexionInRadians)
float USGAnatomyKismetLibrary::NormalizeThumbFlexion(const float FlexionInDegrees)
{
return FSGAnatomy::NormalizeThumbFlexion(FlexionInRadians);
return FSGAnatomy::NormalizeThumbFlexion(FlexionInDegrees);
}
TArray<FSGVectorArray> USGAnatomyKismetLibrary::GetDefaultHandAngles(const bool bRightHanded)
@@ -36,6 +36,7 @@
#include "SGCoreKismet/SGSenseGloveSensorDataKismetLibrary.h"
#include "SGCore/SGSenseGloveSensorData.h"
#include "SGUtils/SGArrayUtils.h"
USGSenseGloveSensorData* USGSenseGloveSensorDataKismetLibrary::MakeSenseGloveSensorData(UObject* WorldContextObject)
{
@@ -90,16 +90,16 @@ public:
static float GetThumbJointLimit(bool bRightHanded, int32 Joint, int32 Movement, bool bMax);
/**
* Convert a total finger flexion in radians into a 0..1 representation.
* Convert a total finger flexion in degrees.
*/
UFUNCTION(BlueprintCallable, Category="SenseGlove | Core | Kinematics | Anatomy")
static float NormalizeFingerFlexion(float FlexionInRadians);
static float NormalizeFingerFlexion(float FlexionInDegrees);
/**
* Convert a total thumb flexion in radians into a 0..1 representation.
* Convert a total thumb flexion in degrees.
*/
UFUNCTION(BlueprintCallable, Category="SenseGlove | Core | Kinematics | Anatomy")
static float NormalizeThumbFlexion(float FlexionInRadians);
static float NormalizeThumbFlexion(float FlexionInDegrees);
/**
* Get Hand Angles that would make a Default (Idle) Pose.
@@ -101,7 +101,7 @@ public:
static USGSenseGloveSensorData* Deserialize(UObject* WorldContextObject, const FString& SerializedString);
/**
* Glove angles in radians, sorted by finger, from proximal to distal.
* Glove angles in degrees, sorted by finger, from proximal to distal.
*/
UFUNCTION(BlueprintPure, Category="SenseGlove | Core | SG | Sense Glove Sensor Data")
static TArray<FSGFloatArray> GetSensorAngles(const USGSenseGloveSensorData* SenseGloveSensorData);