295 lines
12 KiBLFS
C++
295 lines
12 KiBLFS
C++
/**
|
|
* @file
|
|
*
|
|
* @author Max Lammers <max@senseglove.com>
|
|
* @author Mamadou Babaei <mamadou@senseglove.com>
|
|
*
|
|
* @section LICENSE
|
|
*
|
|
* Copyright (c) 2020 - 2022 SenseGlove
|
|
*
|
|
* @section DESCRIPTION
|
|
*
|
|
* An interface for any of our gloves that can track hand motion and/or send
|
|
* force / vibrotactile feedback.
|
|
*/
|
|
|
|
|
|
#pragma once
|
|
|
|
#include <memory>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "Platform.hpp"
|
|
#include "SGDevice.hpp"
|
|
#include "Tracking.hpp"
|
|
|
|
namespace SGCore
|
|
{
|
|
namespace Haptics
|
|
{
|
|
class BuzzCommand;
|
|
|
|
class ForceFeedbackCommand;
|
|
|
|
class ThumperCommand;
|
|
};// namespace Haptics
|
|
|
|
namespace Kinematics
|
|
{
|
|
class BasicHandModel;
|
|
|
|
class Quat;
|
|
|
|
class Vect3D;
|
|
};// namespace Kinematics
|
|
|
|
class HandPose;
|
|
|
|
class HandProfile;
|
|
|
|
/// <summary> A glove developed by SenseGlove, that has hand tracking and/or haptic feedback functionality. </summary>
|
|
class SGCORE_API HapticGlove;
|
|
};// namespace SGCore
|
|
|
|
/// <summary> A glove developed by SenseGlove, that has hand tracking and/or haptic feedback functionality. </summary>
|
|
class SGCORE_API SGCore::HapticGlove : public SGDevice
|
|
{
|
|
public:
|
|
//--------------------------------------------------------------------------------------
|
|
// Device Detection / enumeration
|
|
|
|
/// <summary> Get all Haptic Gloves detected on this system..</summary>
|
|
/// <returns></returns>
|
|
static std::vector<std::shared_ptr<HapticGlove>> GetHapticGloves();
|
|
|
|
|
|
/// <summary> Get the first Haptic Glove detected on this system. </summary>
|
|
/// <param name="out_glove"></param>
|
|
/// <returns></returns>
|
|
static bool GetGlove(std::shared_ptr<HapticGlove>& out_glove);
|
|
|
|
|
|
/// <summary> Get the first left/right Haptic Glove detected on this system. </summary>
|
|
/// <param name="out_glove"></param>
|
|
/// <returns></returns>
|
|
static bool GetGlove(bool bRightHanded, std::shared_ptr<HapticGlove>& out_glove);
|
|
|
|
private:
|
|
struct Impl;
|
|
std::unique_ptr<Impl> Pimpl;
|
|
|
|
public:
|
|
/// <summary> The basic constructor. </summary>
|
|
HapticGlove();
|
|
|
|
/**
|
|
* The copy constructor.
|
|
*/
|
|
HapticGlove(const HapticGlove& rhs);
|
|
|
|
/**
|
|
* The move constructor.
|
|
*/
|
|
HapticGlove(HapticGlove&& rhs) noexcept;
|
|
|
|
/// <summary> The basic destructor. </summary>
|
|
virtual ~HapticGlove() override;
|
|
|
|
public:
|
|
/**
|
|
* The copy assignment operator.
|
|
*/
|
|
HapticGlove& operator=(const HapticGlove& rhs);
|
|
|
|
/**
|
|
* The move assignment operator.
|
|
*/
|
|
HapticGlove& operator=(HapticGlove&& rhs) noexcept;
|
|
|
|
protected:
|
|
//--------------------------------------------------------------------------------------
|
|
// Properties
|
|
|
|
/// <summary> The last Force-Feedback command sent by this glove. </summary>
|
|
[[nodiscard]] const Haptics::ForceFeedbackCommand& GetLastForceFeedbackCommand() const;
|
|
|
|
void SetLastForceFeedbackCommand(const Haptics::ForceFeedbackCommand& command);
|
|
|
|
/// <summary> The Vibromotor command sent by this glove. </summary>
|
|
[[nodiscard]] const Haptics::BuzzCommand& GetLastBuzzCommand() const;
|
|
|
|
void SetLastBuzzCommand(const Haptics::BuzzCommand& command);
|
|
|
|
/// <summary> The thumper command sent by this glove. </summary>
|
|
[[nodiscard]] const Haptics::ThumperCommand& GetLastThumperCommand() const;
|
|
|
|
void SetLastThumperCommand(const Haptics::ThumperCommand& command);
|
|
|
|
/// <summary> The minimum calibration values measured by this glove. </summary>
|
|
[[nodiscard]] const std::vector<Kinematics::Vect3D>& GetMinValues() const;
|
|
|
|
void SetMinValues(const std::vector<Kinematics::Vect3D>& values);
|
|
|
|
/// <summary> The maximum calibration values measured by this glove. </summary>
|
|
[[nodiscard]] const std::vector<Kinematics::Vect3D>& GetMaxValues() const;
|
|
|
|
void SetMaxValues(const std::vector<Kinematics::Vect3D>& values);
|
|
|
|
public:
|
|
//--------------------------------------------------------------------------------------
|
|
// SGDevice Methods
|
|
|
|
///<summary> Get the DeviceType enumerator of this device; used to check if its a SenseGlove/Nova/etc. </summary>
|
|
[[nodiscard]] virtual EDeviceType GetDeviceType() const override;
|
|
|
|
/// <summary> Retrieve this glove's unique identifier. </summary>
|
|
[[nodiscard]] virtual std::string GetDeviceId() const override;
|
|
|
|
/// <summary> Retrieve this glove's hardware (sub) version. "DK1", "DK2", etc. </summary>
|
|
[[nodiscard]] virtual std::string GetHardwareVersion() const override;
|
|
|
|
/// <summary> Retrieve this device's main firmware version. v4.12 returns 4. </summary>
|
|
[[nodiscard]] virtual int32_t GetFirmwareVersion() const override;
|
|
|
|
/// <summary> Retrieve this device's sub firmware version. v4.12 returns 12. </summary>
|
|
[[nodiscard]] virtual int32_t GetSubFirmwareVersion() const override;
|
|
|
|
public:
|
|
//--------------------------------------------------------------------------------------
|
|
// Tracking Methods
|
|
|
|
/// <summary> Returns true if this glove is made for a right hand. If false, it's a left hand. </summary>
|
|
/// <returns></returns>
|
|
#if SENSEGLOVE_UNREAL_ENGINE_PLUGIN
|
|
[[nodiscard]] virtual bool IsRight() const;
|
|
#else
|
|
[[nodiscard]] virtual bool IsRight() const = 0;
|
|
#endif /* SENSEGLOVE_UNREAL_ENGINE_PLUGIN */
|
|
|
|
/// <summary> Retrieve this glove's IMU rotation, if if has any. </summary>
|
|
/// <param name="IMU"></param>
|
|
/// <returns></returns>
|
|
virtual bool GetImuRotation(Kinematics::Quat& out_imu);
|
|
|
|
/// <summary> Calculate the Hand Pose of this device, provided it has Hand Tracking available </summary>
|
|
/// <param name="profile"></param>
|
|
/// <param name="handPose"></param>
|
|
/// <returns></returns>
|
|
virtual bool GetHandPose(const Kinematics::BasicHandModel& handGeometry, const HandProfile& handProfile,
|
|
HandPose& out_handPose);
|
|
|
|
/// <summary> Calculate the HandPose of this Device, taking into account user values, but not hand geometry. </summary>
|
|
/// <param name="handProfile"></param>
|
|
/// <param name="handPose"></param>
|
|
/// <returns></returns>
|
|
virtual bool GetHandPose(const HandProfile& handProfile, HandPose& out_handPose);
|
|
|
|
/// <summary> Retrieve a HandPose based on the latest profile, but with a specific hand geometry. </summary>
|
|
/// <param name="handGeometry"></param>
|
|
/// <param name="handPose"></param>
|
|
/// <returns></returns>
|
|
virtual bool GetHandPose(const Kinematics::BasicHandModel& handGeometry, HandPose& out_handPose);
|
|
|
|
/// <summary> Retrieve a HandPose based on the latest profile and default hand Geometry. </summary>
|
|
/// <param name="handGeometry"></param>
|
|
/// <param name="handPose"></param>
|
|
/// <returns></returns>
|
|
virtual bool GetHandPose(HandPose& out_handPose);
|
|
|
|
public:
|
|
//--------------------------------------------------------------------------------------
|
|
// Haptics Methods.
|
|
|
|
/// <summary> Stops all Haptic effects if any are currently playing. Useful at the end of simulations or when resetting. </summary>
|
|
virtual void StopHaptics();
|
|
|
|
virtual void StopVibrations();
|
|
|
|
//other -generic- force-feedback methods (?)
|
|
|
|
/// <summary> Send Haptic Commands to this Glove. </summary>
|
|
/// <param name="forceFeedbackCommand"></param>
|
|
virtual void SendHaptics(const Haptics::ForceFeedbackCommand& forceFeedbackCommand);
|
|
|
|
/// <summary> Send Haptic Commands to this Glove. </summary>
|
|
/// <param name="buzzCommand"></param>
|
|
virtual void SendHaptics(const Haptics::BuzzCommand& buzzCommand);
|
|
|
|
/// <summary> Send Haptic Commands to this Glove. </summary>
|
|
/// <param name="thumperCommand"></param>
|
|
virtual void SendHaptics(const Haptics::ThumperCommand& thumperCommand);
|
|
|
|
/// <summary> Send Haptic Commands to this Glove. </summary>
|
|
/// <param name="forceFeedbackCommand"></param>
|
|
/// <param name="buzzCommand"></param>
|
|
virtual void SendHaptics(const Haptics::ForceFeedbackCommand& forceFeedbackCommand,
|
|
const Haptics::BuzzCommand& buzzCommand);
|
|
|
|
/// <summary> Send Haptic Commands to this Glove. </summary>
|
|
/// <param name="forceFeedbackCommand"></param>
|
|
/// <param name="buzzCommand"></param>
|
|
/// <param name="thumperCommand"></param>
|
|
virtual void SendHaptics(const Haptics::ForceFeedbackCommand& forceFeedbackCommand,
|
|
const Haptics::BuzzCommand& buzzCommand,
|
|
const Haptics::ThumperCommand& thumperCommand);
|
|
|
|
public:
|
|
//--------------------------------------------------------------------------------------
|
|
// Calibration Methods
|
|
|
|
/// <summary> Retrieve calibration values of this glove, as an array of size 5, containing x (roll), y (flexion), z (abduction) values. </summary>
|
|
virtual bool GetCalibrationValues(std::vector<Kinematics::Vect3D>& out_values);
|
|
|
|
/// <summary> Reset Calibration range for this Device. </summary>
|
|
virtual void ResetCalibrationRange();
|
|
|
|
/// <summary> Updates calibration values only. </summary>
|
|
virtual void UpdateCalibrationRange();
|
|
|
|
/// <summary> Updates calibration values only. </summary>
|
|
virtual void UpdateCalibrationRange(const std::vector<Kinematics::Vect3D>& calibrationValues);
|
|
|
|
/// <summary> Access the minimum- and maximum sensor values measured by this Haptic Glove, in this session. </summary>
|
|
/// <param name="out_minValues"></param>
|
|
/// <param name="out_maxValues"></param>
|
|
virtual void GetCalibrationRange(std::vector<Kinematics::Vect3D>& out_minValues,
|
|
std::vector<Kinematics::Vect3D>& out_maxValues);
|
|
|
|
/// <summary> Updates Calibration values and applies it to the Profile. </summary>
|
|
/// <param name="out_profile"></param>
|
|
virtual void UpdateCalibration(HandProfile& out_profile);
|
|
|
|
/// <summary> Apply this glove's calibration range to a handProfile. </summary>
|
|
/// <param name="out_profile"></param>
|
|
virtual void ApplyCalibration(HandProfile& out_profile) const;
|
|
|
|
public:
|
|
//--------------------------------------------------------------------------------------
|
|
// 6DoF Position Tracking
|
|
|
|
/// <summary> Retrieve the location of the wrist, based on a reference location and default glove-hand offsets. </summary>
|
|
/// <remarks> The simplest interface, using default offsets. </remarks>
|
|
/// <param name="referencePosition">Position of the tracked object, in mm, relative to your origin</param>
|
|
/// <param name="referenceRotation">Rotation of the tracked object relative to your origin</param>
|
|
/// <param name="trackingHardware">The hardware mounted on the SenseGlove.</param>
|
|
/// <param name="out_wristPosition">The 3D Position of the wrist, in mm, relative to your origin</param>
|
|
/// <param name="out_wristRotation">The 3D Rotation of the wrist, relative to your origin</param>
|
|
virtual void GetWristLocation(const Kinematics::Vect3D& referencePosition,
|
|
const Kinematics::Quat& referenceRotation,
|
|
EPositionalTrackingHardware trackingHardware,
|
|
Kinematics::Vect3D& out_wristPosition, Kinematics::Quat& out_wristRotation) const;
|
|
|
|
/// <summary> Retrieve the location of the glove origin, based on a reference location. </summary>
|
|
/// <param name="referencePosition">Position of the tracked object, in mm, relative to your origin</param>
|
|
/// <param name="referenceRotation">Rotation of the tracked object relative to your origin</param>
|
|
/// <param name="trackingHardware">The hardware mounted on the SenseGlove.</param>
|
|
/// <param name="out_glovePosition">The 3D Position of the glove, in mm, relative to your origin</param>
|
|
/// <param name="out_gloveRotation">The 3D Rotation of the glove, relative to your origin</param>
|
|
virtual void GetGloveLocation(const Kinematics::Vect3D& referencePosition,
|
|
const Kinematics::Quat& referenceRotation,
|
|
EPositionalTrackingHardware trackingHardware,
|
|
Kinematics::Vect3D& out_glovePosition, Kinematics::Quat& out_gloveRotation) const;
|
|
};
|