/** * @file * * @author Max Lammers * @author Mamadou Babaei * * @section LICENSE * * Copyright (c) 2020 - 2023 SenseGlove * * @section DESCRIPTION * * Glove information taken from the Sense Glove. */ #pragma once #include #include #include #include #include "Fingers.hpp" #include "Platform.hpp" namespace SGCore { namespace Kinematics { class Quat; class Vect3D; }// namespace Kinematics namespace SG { /// Glove Information taken from a SenseGlove. Contains everything from unique ID, firmware version, etc. class SGCORE_API SenseGloveInfo; }// namespace SG }// namespace SGCore /// Glove Information taken from a SenseGlove. Contains everything from unique ID, firmware version, etc. class SGCORE_API SGCore::SG::SenseGloveInfo { public: /// Create an instance of the SGModel from its string representation. static bool Parse(const std::string& constantsString, SenseGloveInfo& out_gloveInfo, bool bUpdateOldModels = true); /// Deserialize a HandProfile back into usable values. static SenseGloveInfo Deserialize(const std::string& serializedString); private: struct Impl; std::unique_ptr Pimpl; public: /// The default constructor. SenseGloveInfo(); /// Create a new Sense Glove device model. SenseGloveInfo(const std::string& deviceId, const std::string& hardwareVersion, int32_t firmwareVersion, int32_t subFirmwareVersion, bool bRightHanded, int32_t numberOfSensors, const Kinematics::Quat& imuCorrection, const std::vector& startPositions, const std::vector& startRotations, const std::vector>& gloveLengths, const std::vector& functions); /** * The copy constructor. */ SenseGloveInfo(const SenseGloveInfo& rhs); /** * The move constructor. */ SenseGloveInfo(SenseGloveInfo&& rhs) noexcept; /// Default Destructor. virtual ~SenseGloveInfo(); public: /** * The copy assignment operator. */ SenseGloveInfo& operator=(const SenseGloveInfo& rhs); /** * The move assignment operator. */ SenseGloveInfo& operator=(SenseGloveInfo&& rhs) noexcept; public: /// Unique identifier of this device. #if !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) [[nodiscard]] #endif /* !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) */ const std::string& GetDeviceId() const; #if SENSEGLOVE_UNREAL_ENGINE_PLUGIN void SetDeviceId(const std::string& deviceId); #endif /* SENSEGLOVE_UNREAL_ENGINE_PLUGIN */ /// Hardware (sub) version of this Sense Glove Device. #if !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) [[nodiscard]] #endif /* !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) */ const std::string& GetHardwareVersion() const; #if SENSEGLOVE_UNREAL_ENGINE_PLUGIN void SetHardwareVersion(const std::string& hardwareVersion); #endif /* SENSEGLOVE_UNREAL_ENGINE_PLUGIN */ /// Firmware version running on the device's MicroController. #if !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) [[nodiscard]] #endif /* !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) */ int32_t GetFirmwareVersion() const; #if SENSEGLOVE_UNREAL_ENGINE_PLUGIN void SetFirmwareVersion(int32_t firmwareVersion); #endif /* SENSEGLOVE_UNREAL_ENGINE_PLUGIN */ /// Sub-Firmware version running on the device's MicroController. #if !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) [[nodiscard]] #endif /* !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) */ int32_t GetSubFirmwareVersion() const; #if SENSEGLOVE_UNREAL_ENGINE_PLUGIN void SetSubFirmwareVersion(int32_t subFirmwareVersion); #endif /* SENSEGLOVE_UNREAL_ENGINE_PLUGIN */ /// Check if this Sense Glove belongs to a left or right hand. #if !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) [[nodiscard]] #endif /* !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) */ bool IsRight() const; #if SENSEGLOVE_UNREAL_ENGINE_PLUGIN void SetIsRight(bool bRightHanded); #endif /* SENSEGLOVE_UNREAL_ENGINE_PLUGIN */ /// The number of Sensors in this SenseGlove. #if !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) [[nodiscard]] #endif /* !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) */ int32_t GetNumberOfSensors() const; #if SENSEGLOVE_UNREAL_ENGINE_PLUGIN void SetNumberOfSensors(int32_t numberOfSensors); #endif /* SENSEGLOVE_UNREAL_ENGINE_PLUGIN */ /// The IMU correction of this Sense Glove. #if !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) [[nodiscard]] #endif /* !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) */ const Kinematics::Quat& GetImuCorrection() const; #if SENSEGLOVE_UNREAL_ENGINE_PLUGIN void SetImuCorrection(const Kinematics::Quat& imuCorrection); #endif /* SENSEGLOVE_UNREAL_ENGINE_PLUGIN */ /// The starting positions of each Sense Glove finger, relative to the glove origin. #if !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) [[nodiscard]] #endif /* !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) */ const std::vector& GetStartPositions() const; #if SENSEGLOVE_UNREAL_ENGINE_PLUGIN void SetStartPositions(const std::vector& startPositions); #endif /* SENSEGLOVE_UNREAL_ENGINE_PLUGIN */ /// The starting rotations of each Sense Glove finger, relative to the glove origin. #if !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) [[nodiscard]] #endif /* !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) */ const std::vector& GetStartRotations() const; #if SENSEGLOVE_UNREAL_ENGINE_PLUGIN void SetStartRotations(const std::vector& startRotations); #endif /* SENSEGLOVE_UNREAL_ENGINE_PLUGIN */ /// The lengths of each Sense Glove finger section, in mm. #if !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) [[nodiscard]] #endif /* !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) */ const std::vector>& GetGloveLengths() const; #if SENSEGLOVE_UNREAL_ENGINE_PLUGIN void SetGloveLengths(const std::vector>& gloveLengths); #endif /* SENSEGLOVE_UNREAL_ENGINE_PLUGIN */ /// Whether this device has a specific function (T/F). #if !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) [[nodiscard]] #endif /* !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) */ const std::vector& GetFunctions() const; #if SENSEGLOVE_UNREAL_ENGINE_PLUGIN void SetFunctions(const std::vector& functions); #endif /* SENSEGLOVE_UNREAL_ENGINE_PLUGIN */ public: /// The starting position of one Sense Glove finger, relative to the glove origin. #if !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) [[nodiscard]] #endif /* !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) */ const Kinematics::Vect3D& GetStartPosition(SGCore::EFinger finger) const; /// The starting rotation of one Sense Glove finger, relative to the glove origin. #if !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) [[nodiscard]] #endif /* !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) */ const Kinematics::Quat& GetStartRotation(SGCore::EFinger finger) const; /// The lengths of one Sense Glove finger's sections, in mm. #if !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) [[nodiscard]] #endif /* !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) */ const std::vector& GetGloveLengths(SGCore::EFinger finger) const; public: /// Place incoming sensor data into the right format, according to this glove's model. #if !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) [[nodiscard]] #endif /* !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) */ std::vector> ToGloveAngles( const std::vector>& sensorAngles) const; /// Returns true if this SG_Model has the same values as another. #if !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) [[nodiscard]] #endif /* !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) */ bool Equals(const SenseGloveInfo& senseGloveGloveInfo, bool bGeometryOnly = false) const; public: /// Create a string representation for logging. If shortNotation is false, all values are reported. #if !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) [[nodiscard]] #endif /* !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) */ std::string ToString(bool bShortNotation) const; /// Create a string representation for fast logging. #if !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) [[nodiscard]] #endif /* !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) */ std::string ToString() const; /// Serialize this HandProfile into a string representation. #if !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) [[nodiscard]] #endif /* !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) */ std::string Serialize() const; };