C++ API Reference

API reference that also contains extensive explanation for specific classes and namespaces. Use the menu left to navigate quickly!

Main classes

class SGCore::BetaDevice : public SGCore::SGDevice

A Device that adheres to the SenseGlove communications protocol, but which has no implementation in this API.

Public Functions

BetaDevice()

Basic Class Constructor.

~BetaDevice()

Basic Class Destructor.

BetaDevice(std::string constants, std::string id, std::string hwVer, int fwMain, int fwSub)

Creates a new instance of a Beta Device.

DeviceType GetDeviceType() override

Get the DeviceType enumerator of this SenseGlove, used in DeviceList enumeration.

std::string GetDeviceID() override

Get the unique identifier of this device.

std::string GetHardwareVersion() override

Retrieve this device’s hardware version.

int GetFirmwareVersion() override

Retireve this device’s firmware version.

int GetSubFirmwareVersion() override

Retireve this device’s sub-firmware version.

std::string GetConstantsString()

Retrieve the Constants string for additional processing.

std::string GetSensorData()

Retrieve a raw sensor string from this Beta Device.

std::string GetLastCmd()

Retireve a the last command retrieved from this Beta Device.

bool SendHaptics(std::string command)

Send a raw string command to this device.

summary> Create a string representation of this device for reporting purposes.

std::string ToString() override

Get a string representation of this SGDevice, used for debugging.

Public Static Functions

std::shared_ptr<SGDevice> Parse(std::string cstring)

Deserialize a beta device from its basic cstring. Returns nullptr is unsuccesfull.

class SGCore::DeviceList

Interface for SenseComm, allows the retrieval of Devices and Data.

Public Static Functions

SGCORE_API int ActiveDevices ()

Retrieve the number of devices that have been detected by the SenseComm executable.

SGCORE_API bool SenseCommRunning ()

Returns true if the SenseComm program is running.

SGCORE_API void Dispose ()

Clear the device list, and block any further attempt to add to it untill ReInitialize is called.

Useful if your IDE has troubles unloading dlls (cough, Unity, Cough).

Return

SGCORE_API void ReInitialize ()

When you’ve accidentaly disposed of the list before you meant to.

Return

SGCORE_API std::vector< std::shared_ptr< SGDevice > > GetDevices ()

Retrieve all Sense Glove Devices connected to this system.

template<class T>
std::vector<std::shared_ptr<T>> GetDevices()

Retrieve a list of SGDevices of a specific class.

SGCORE_API bool GetSensorDataString (int ipcIndex, std::string &ipcAddress, std::string &output)

Retrieve the latest (raw) sensor data from a specific device in our list.

summary> Send a (raw) command to a specific device in the list.

std::string GetAddress(int ipcIndex, std::string &ipcAddress)

Retrieve Device Address

SGDevice::ConnectionType GetConnectionType(int ipcIndex, std::string &ipcAddress)

Retieve this device’s connectionType.

bool IsConnected(int ipcIndex, std::string &ipcAddress)

Returns true if the device at this connection side is properly connected.

int PacketsPerSecondReceived(int ipcIndex, std::string &ipcAddress)

Retrieve the device’s Packets per Second Variable

Return

int PacketsPerSecondSent(int ipcIndex, std::string &ipcAddress)

Retrieve the device’s Packets per Second sent Variable

Return

class SGCore::DeviceModel

Base class containing the minimum amount of data for device models.

Public Functions

std::string GetDeviceID()

Retrieve the Unique identifier of this device.

std::string GetHardwareVersion()

Retrieve the Hardware (sub) version of this Sense Glove Device.

int GetFirmwareVersion()

Firmware version running on the device’s MicroController. (as v4.12, this is the 4)

int GetSubFirmwareVersion()

Sub firmware version runnning on the device’s microcontroller (as v4.12, this is the .12)

Return

Public Static Functions

void ParseFirmware(std::string &rawFW, int &mainVer, int &subVer)

Parameters
  • rawFW
  • mainVer
  • subVer

HandPose

Overview

The HandPose is a class containing all positions- and rotations that can be used to represent a hand in 3D space. It consists of four variables:

The isRight boolean variable shows that this HandPose was generated for a right hand (if true) - or left hand (if false). Its mainly used to match a HandPose to the appropriate (virtual) hand.

The handAngles parameter represents the articulation of the finger’s joints, in radians, relative to the previous hand bone. It is a 5x3 array of Vectors (Vect3D), which represents these angles as Pronation/Supination (x), Flexion/Extension (y) and Abduction/Adduction (z) of said joint. The first index indicates the finger, from thumb (0) to pinky (4), while the second indicates the joint of said finger. It does not include the fingertip.

The jointPositions represent the position of the hand joints in 3D space, in millimeters, relative to the wrist (0, 0, 0). JointPositions is a 5x4 array of Vectors (Vect3D). The first index of this array indicates the finger, from thumb (0) to pinky (4), while the second indicates the joint of said finger, including the fingertips. Use these to draw a wireframe, or to calculate the distance between finger joints.

The jointRotations represent the 3D (quaternion) rotation relative to the wrist. Note that “relative to the wrist” does not take into account the (IMU) rotation of the glove. JointRotations is a 5x4 array of Quaternions (Quat). The first index indicates the finger, from thumb (0) to pinky (4), while the second indicates the joint of said finger, including the fingertips. By ‘multiplying’ the output quaternions of each joint with the quaternion rotation of the wrist, you can get each rotation in your world space.

Coordinate System

  • The x-axis is aligned along the metacarpal bone of the middle finger.

  • The y-axis points towards the thumb of the right hand, and towards the pinky of the left hand.

  • The z-axis runs perpendicular to the hand palm, going up from the dorsal side of the hand.

Note

The pronation/supination and abduction/adduction have opposite signs (+/-) for a left- and right hand due to them being opposite sides of the body.

  • Pronation / Supination, a.k.a. the twist of the finger, is the angle around the x-axis (roll)..

  • Flexion / Extension of the finger is the angle around the y-axis (pitch)

  • Abduction / Adduction, a.k.a. the spreading of the fingers, is the angle around the z-axis (yaw)

Mapping a HandPose to a Virtual Hand Model

Using the SenseGlove Unity SDK

SG_HandAnimator & SG_HandModelInfo

Using your own animation method

This greatly depends if you’re using articulation angles or quaternion rotations (relative to the wrist, or to the world origin)

class SGCore::HandPose

Contains all variables required to draw or analyze a virtual hand.

Public Functions

HandPose()

Default Constructor.

~HandPose()

Default Destructor.

HandPose(bool right, std::vector<std::vector<Kinematics::Vect3D>> jointPos, std::vector<std::vector<Kinematics::Quat>> jointRot, std::vector<std::vector<Kinematics::Vect3D>> hAngles)

Create a new instance of HandPose.

bool Equals(HandPose other)

Returns true of these two handposes are roughly equal.

std::string ToString(bool shortFormat = false)

summary> Serialize this HandProfile into a string representation

std::string Serialize()

summary> Deserialize a HandProfile back into useable values.

float GetNormalizedFlexion(Finger finger, bool clamp01 = true)

Returns the total flexion of a specific finger as a value between 0 (fully extended) and 1 (fully flexed).

remarks> Useful for animation or for detecting gestures

summary> Returns the total flexion the fingers as a value between 0 (fully extended) and 1 (fully flexed).

remarks> Useful for animation or for detecting gestures

Public Members

bool isRight

Whether or not this HandPose was created for be a right- or left hand.

summary> Positions of all hand joints relative to the Sense Glove origin. From thumb to pinky, proximal to distal.

std::vector<std::vector<Kinematics::Vect3D>> jointPositions

summary> Quaternion rotations of all hand joints. From thumb to pinky, proximal to distal.

std::vector<std::vector<Kinematics::Quat>> jointRotations

summary> Euler representations of all possible hand angles. From thumb to pinky, proximal to distal.

Public Static Functions

HandPose FromHandAngles(std::vector<std::vector<Kinematics::Vect3D>> &handAngles, bool rightHanded, Kinematics::BasicHandModel &handDimensions)

Generate a HandPose based on articulation angles (handAngles).

Return

Parameters
  • handAngles
  • rightHanded
  • handDimensions

HandPose FromHandAngles(std::vector<std::vector<Kinematics::Vect3D>> &handAngles, bool rightHanded)

Generate a HandPose based on articulation angles (handAngles), with a default HandModel.

Return

Parameters
  • handAngles
  • rightHanded

HandPose DefaultIdle(bool rightHand, Kinematics::BasicHandModel &handDimensions)

Create a new instance of a left or right handed Pose that is “idle”; in a neutral position.

Return

Parameters
  • rightHand
  • handDimensions

HandPose DefaultIdle(bool rightHand)

Create a new instance of a left or right handed Pose that is “idle”; in a neutral position.

Return

Parameters
  • rightHand

HandPose FlatHand(bool rightHand, Kinematics::BasicHandModel &handDimensions)

Generates a HandPose representing an ‘open hand’, used in calibration to determine finger extension.

Return

Parameters
  • rightHand
  • handDimensions

HandPose FlatHand(bool rightHand)

Generates a HandPose representing an ‘open hand’, used in calibration to determine finger extension.

Return

Parameters
  • rightHand

HandPose ThumbsUp(bool rightHand, Kinematics::BasicHandModel &handDimensions)

Generates a HandPose representing a ‘thumbs up’, used in calibration to determine finger flexion, thumb extension and adduction.

Return

Parameters
  • rightHand
  • handDimensions

HandPose ThumbsUp(bool rightHand)

Generates a HandPose representing a ‘thumbs up’, used in calibration to determine finger flexion, thumb extension and adduction.

Return

Parameters
  • rightHand

HandPose Fist(bool rightHand, Kinematics::BasicHandModel &handDimensions)

Generates a HandPose representing a ‘fist’, used in calibration to determine, thumb flexion and abduction.

Return

Parameters
  • rightHand
  • handDimensions

HandPose Fist(bool rightHand)

Generates a HandPose representing a ‘fist’, used in calibration to determine, thumb flexion and abduction.

Return

Parameters
  • rightHand

HandProfile

A HandProfile is data class that contains the variables required for any HapticGlove to calculate a HandPose. Since the API is built to support multiple types of hand tracking over time, each with their own calibration methods, this class is used to add more variables without the function signature changing from HapticGlove.GetHandPose(BasicHandModel, HandProfile, HandPose). The HapticGlove (sub)classes select which of the variables to use from the HandProfile.

SG_HandProfile

The HandProfile differs from the SG_HandProfile in the SGCore.SG namespace: The SG_HandProfile contains the variables required for a SenseGlove to calculate one’s HandPose. The SG_HandProfile contains three variables:

  • The solver parameter determines how the hand angles are calculated. At the moment, only the Interpolation solver is available.

  • The interpolationSet contains the (calibrated) sensor-to-handAngle interpolation sets. This set of variables is used to calculate the HandPose when using the Interpolation solver.

  • The fingerThimbleOffset is an array of size 5, which contains the offset (in mm) from the tip of the last exoskeleton linkage to the fingertip. It is sorted by finger, from Thumb [0] to Pinky [4] It is used to calculate fingertip distance, and will be used for alternate solvers in the future.

class SGCore::HandProfile

Interpolation profiles for a user’s hand, compatible with all HapticGloves.

Public Functions

HandProfile()

Default Constructor

Return

HandProfile(bool rightHand, SG::SG_HandProfile sgProfile, Nova::Nova_Profile nvProfile)

Creates a new instance of a HandProfile.

Return

Parameters
  • rightHand
  • sgProfile
  • fnProfile

void Reset()

Reset this profile back to it’s default values.

std::string Serialize()

Convert this Fino_Profile into a string notation so it can be stored on disk.

Return

Public Members

bool isRight

Whether this profile was created for a lef- or right hand.

SG::SG_HandProfile senseGloveProfile

Profile for SenseGlove’s

Nova::Nova_Profile novaProfile

User profile for Fino

Public Static Functions

HandProfile Default(bool rightHand)

Generate a new handProfile for either a left or right hand.

Return

Parameters
  • rightHand

HandProfile Deserialize(std::string serializedString)

Convert a string notation of a Fino_Profile into a new instance.

Return

Parameters
  • serializedString

std::string GetProfileDir()

Returns the directory where HandProfiles are being stored. Does not include a ‘' at teh end.

Return

std::string GetProfileFileName(bool isRight)

Returns the fileName of the left or right hand profiles.

Return

Parameters
  • isRight

bool GetLatestProfile(bool rightHand, HandProfile &latestProfile)

Retireves the latest HandProfile from disk. If this function returns false, latestProfils is equal to SGCOre::HandProfile::Default(rightHand).

Return

Parameters
  • rightHand

bool StoreProfile(HandProfile &profileToStore)

Stores a HandProfile on disk for other programs to access. Call this function only if your software handles calibration functions.

Return

Parameters
  • profileToStore

bool ResetCalibration(bool rightHand, bool onDisk = true)

Resets the Calibration of a specific back to default values.

Return

Parameters
  • onDisk
  • rightHand

void ResetCalibration(bool onDisk = true)

Resets the Calibration of both hands back to default values.

Return

Parameters
  • onDisk

Public Static Attributes

std::string rhFileName

Filename for right hand profile.

std::string lhFileName

Filename for left hand profile.

class SGCore::HapticGlove : public SGCore::SGDevice

A glove developed by SenseGlove, that has hand tracking and/or haptic feedback functionality.

Subclassed by SGCore::Nova::NovaGlove, SGCore::SG::SenseGlove

Public Functions

DeviceType GetDeviceType() override

Get the DeviceType enumerator of this device; used to check if its a SenseGlove/Fino/etc.

std::string GetDeviceID() override

Retrieve this glove’s unique identifier.

std::string GetHardwareVersion() override

Retrieve this glove’s hardware (sub) version. “DK1”, “DK2”, etc

int GetFirmwareVersion() override

Retrieve this device’s main firmware version. v4.12 returns 4.

int GetSubFirmwareVersion() override

Retrieve this device’s sub firmware version. v4.12 returns 12.

bool IsRight() = 0

Returns true if this glove is made for a right hand. If false, it’s a left hand.

Return

bool GetIMURotation(Kinematics::Quat &IMU)

Retrieve this glove’s IMU rotation, if if has any

Return

Parameters
  • IMU

bool GetHandPose(Kinematics::BasicHandModel &handGeometry, HandProfile &handProfile, HandPose &handPose)

Calculate the Hand Pose of this device, provided it has Hand Tracking available

Return

Parameters
  • profile
  • handPose

bool GetHandPose(HandProfile &handProfile, HandPose &handPose)

Calculate the HandPose of this Device, taking into account user values, but not hand geometry.

Return

Parameters
  • handProfile
  • handPose

void StopHaptics()

Stops all Haptic effects if any are currently playing. Useful at the end of simulations or when resetting.

void SendHaptics(Haptics::SG_FFBCmd ffb)

Send Haptic Commands to this Glove.

Parameters
  • ffb

void SendHaptics(Haptics::SG_BuzzCmd buzz)

Send Haptic Commands to this Glove.

Parameters
  • buzz

void SendHaptics(Haptics::ThumperCmd thumper)

Send Haptic Commands to this Glove.

Parameters
  • thumper

void SendHaptics(Haptics::SG_FFBCmd ffb, Haptics::SG_BuzzCmd buzz)

Send Haptic Commands to this Glove.

Parameters
  • ffb
  • buzz

void SendHaptics(Haptics::SG_FFBCmd ffb, Haptics::SG_BuzzCmd buzz, Haptics::ThumperCmd thumper)

Send Haptic Commands to this Glove.

Parameters
  • ffb
  • buzz
  • thumper

bool GetCalibrationValues(std::vector<SGCore::Kinematics::Vect3D> &values)

Retrieve calibration values of this glove, as an array of size 5, containing x (roll), y (flexion), z (abduction) values.

void ResetCalibrationRange()

Reset Calbratrion range for this Device.

void UpdateCalibrationRange()

Updates calibration values only

void UpdateCalibrationRange(std::vector<Kinematics::Vect3D> calibrationValues)

Updates calibration values only

void GetCalibrationRange(std::vector<Kinematics::Vect3D> &minimumVals, std::vector<Kinematics::Vect3D> &maximumVals)

Access the minumum- and maximum sensor values measured by this Haptic Glove, in this session.

Parameters
  • minimumVals
  • maximumVals

void UpdateCalibration(HandProfile &profile)

Updates Calibration values and applies it to the Profile.

Parameters
  • profile

void ApplyCalibration(HandProfile &profile)

Apply this glove’s calibration range to a handProfile.

Parameters
  • profile

void GetWristLocation(Kinematics::Vect3D &refPosition, Kinematics::Quat &refRotation, PosTrackingHardware trackingHardware, Kinematics::Vect3D &wristPos, Kinematics::Quat &wristRot)

Retrieve the location of the wrist, based on a reference location and default glove-hand offsets.

The simplest interface, using default offsets

Parameters
  • refPosition: Position of the tracked object, in mm, relative to your origin

  • refRotation: Rotation of the tracked object relative to your origin

  • trackingHardware: The hardware mounted on the SenseGlove.

  • wristPos: The 3D Position of the wrist, in mm, relative to your origin

  • wristRot: The 3D Rotation of the wrist, relative to your origin

void GetGloveLocation(Kinematics::Vect3D &refPosition, Kinematics::Quat &refRotation, PosTrackingHardware trackingHardware, Kinematics::Vect3D &glovePos, Kinematics::Quat &gloveRot)

Retrieve the location of the glove origin, based on a reference location.

Parameters
  • refPosition: Position of the tracked object, in mm, relative to your origin

  • refRotation: Rotation of the tracked object relative to your origin

  • trackingHardware: The hardware mounted on the SenseGlove.

  • mountedOn: Which finger module the hardware is mounted on.

  • glovePos: The 3D Position of the glove, in mm, relative to your origin

  • gloveRot: The 3D Rotation of the glove, relative to your origin

Public Static Functions

std::vector<std::shared_ptr<HapticGlove>> GetHapticGloves()

Get all Haptic Gloves detected on this system.

Return

bool GetGlove(std::shared_ptr<HapticGlove> &glove)

Get the first Haptic Glove detected on this System

Return

Parameters
  • glove

bool GetGlove(bool rightHanded, std::shared_ptr<HapticGlove> &glove)

Get the first left/right Haptic Glove detected on this System

Return

Parameters
  • glove

class SGCore::Library

Provides information about this C++ Library.

Public Static Functions

std::string Version()

The version of this C++ Library in string representation

Return

BackEndType GetBackEndType()

Check wwhat back-end connections are used for this version of SGConnect

Return

std::string BackEndVersion()

Back-End version in string notation

Return

std::string SGConnectVersion()

If possible, check what version of SGConnect is paired with this API.

Return

class SGCore::SenseCom

Public Static Functions

bool RegisterExe()

Registers current process as the latest SenseCom build.

Return

bool RegisterExe(std::string exePath)

Register a particular path as the SenseGlove executable location

Return

Parameters
  • exePath

bool GetExePath(std::string exePath)

Retrieve the location of SenseGlove executable

Return

Parameters
  • exePath

bool ScanningActive()

Retruns true if SenseCom scanning is active.

Return

bool GetCurrentExeDir(std::string &path)

Returns the directory of the current process

Return

Parameters
  • path

bool StartupSenseCom()

Force-starts the SenseCom application if it is active on the system

Return

class SGCore::SGDevice

A Sense Glove device that can send / recieve data via the SenseComm program.

Subclassed by SGCore::BetaDevice, SGCore::HapticGlove

Public Types

enum ConnectionType

Connection type of this device, as detected by the SGConnect library.

Values:

enumerator Unknown

Could not determine which connection type this SGDevice is using, most likely because it is disconnected.

enumerator Serial

USB Serial communication.

enumerator BluetoothSerial

A bluetooth connection that creates up to two Serial Ports.

enumerator BluetoothAndroid

Bluetooth Connection Via Android/Java SDK

Public Functions

SGDevice()

Basic Constructor.

~SGDevice()

Basic Destructor.

DeviceType GetDeviceType()

Check which DeviceType this class belongs to

std::string GetDeviceID() = 0

Retrieve this device’s unique identifier.

std::string GetHardwareVersion() = 0

Retrieve this device’s hardware version.

int GetFirmwareVersion() = 0

Retrieve this device’s main firmware version. v4.12 returns 4.

int GetSubFirmwareVersion()

Retrieve this device’s sub firmware version. v4.12 returns 12.

std::string GetAddress()

Retrieve this Device’s Serial/Bluetooth address.

bool IsConnected()

Check if this device is currently connected to the system.

ConnectionType GetConnectionType()

Retrieve the connection type of this Sense Glove.

int PacketsPerSecondReceived()

Retrieve the device’s Packets per Second Variable

int PacketsPerSecondSent()

Retrieve the device’s Packets per Second Variable

int GetDeviceIndex()

Retrieve the index of this device within SenseComm.

void SetDeviceIndex(int newIndex)

Change this device’s index within the SenseComm. Warning: Can cause errors.

bool IsWireless()

Returns true if this device is connected over a connection other than usb cable.

Return

bool HasBattery()

Returns true if this device operates on a battery

Return

bool IsCharging()

Returns true if this device is currently charging

Return

bool GetBatteryLevel(float &battLvl)

Returns the device’s battery level, as a value between 0 (empty) and 1 (full).

Return

Parameters
  • battLvl

std::string ToString()

Get a string representation of this SGDevice, used for debugging.

Public Static Functions

void ParseFirmware(std::string rawFW, int &mainVer, int &subVer)

Parse a main and sub firmware version from its raw (v4.12) notation

class SGCore::SharedMem

Utility Class used to write and read to/from IPC

Public Static Functions

bool WriteTo(std::string block, std::string address, std::string value, unsigned int size = stdSize)

Write a string to Shared Memory at block-addess. Returns true if succesful.

summary> Retrieve value from Shared Memory at block-addess. Returns true if succesful.

bool ReadFrom(std::string block, std::string address, std::string &output)

summary> Dispose of a shared memory block so it no longer takes up space on the PC. Returns true if succesful.

bool ScanningActive()

Access the time since the last update from SGConnect

Public Static Attributes

const std::string devices

Shared Memory block containing number of devices and deviceInfo from each device

summary> Shared Memory block containing haptic commands from each device

const std::string haptics

summary> Shared Memory block containing sensor data from each device

const std::string data

summary> Shared Memory block containing commands to be sent to the devices

const std::string inCommands

summary> Shared Memory block containing commands/reposnes from the devices

const std::string outCommands

summary> Address in devices where the number of devices is stored.

const std::string numDevices

summary> Address in devices where the scanner’s processing id is stored.

const std::string scanActive

summary> Address in devices where the scanner’s processing id is stored.

const long maxTimeTick

summary> Delimiter to split data in Shared Memory

const char listDelim

summary> Standard size of Shared Memory. It works with this but could probably use a lower value.

class SGCore::Tracking

Public Static Functions

void CalculateLocation(Kinematics::Vect3D trackedPos, Kinematics::Quat trackedRot, Kinematics::Vect3D posOffset, Kinematics::Quat rotOffset, Kinematics::Vect3D &newPos, Kinematics::Quat &newRot)

Knowing a position & rotation in 3D space, calculate a relative location based on offsets.

Parameters
  • trackedPos
  • trackedRot
  • posOffset
  • rotOffset
  • newPos
  • newRot

void GetSenseGloveOffset_Glove_Mount(bool rightHand, Finger toFinger, Kinematics::Vect3D &iPos, Kinematics::Quat &iRot)

Get the position and rotation offsets to go from the glove origin to the mounted position

Based on CAD. needs to be inverted when going from tracker to glove origin.

Parameters
  • rightHand
  • toFinger
  • iPos
  • iRot

void GetSenseGloveOffset_Tracker_Mount(PosTrackingHardware hardware, bool rightHand, Kinematics::Vect3D &posOffset, Kinematics::Quat &rotOffset)

Get the offset to get from the TrackedHardware to a SenseGlove mounting location. Combined with Glove-Mount offset to get the glove location.

Parameters
  • hardware
  • rightHand
  • posOffset
  • rotOffset

void GetNovaOffset_Glove_Wrist(bool rightHand, Kinematics::Vect3D &posOffset, Kinematics::Quat &rotOffset)

Returns the Offsets that will bring us from the Nova origin to the wrist position

Parameters
  • rightHand
  • posOffset
  • rotOffset

void GetNovaOffset_Tracker_Glove(PosTrackingHardware hardware, bool rightHand, Kinematics::Vect3D &posOffset, Kinematics::Quat &rotOffset)

Retrieves Offsets for a particular device.

Parameters
  • hardware
  • rightHand
  • posOffset
  • rotOffset

Public Static Attributes

static const std::vector<Kinematics::Vect3D> sg_fingerToGloveOrigin_Pos

Positional offset from each finger to the glove origin

static const Kinematics::Vect3D sg_gloveWristOffsetPos

Default position offset from glove origin to wrist location, in mm.

static const Kinematics::Quat sg_gloveWristOffsetRot

Default rotation offset from glove origin to wrist location.

static const Kinematics::Vect3D sg_viveToAttach_Pos

Vive Tracker origin to Finger rotational offset

static const Kinematics::Quat sg_viveToAttach_Rot

Vive Tracker origin to Finger rotational offset

static const Kinematics::Vect3D sg_ocTouchToAttach_Pos

Oculus Touch origin to Finger rotational offset

static const Kinematics::Quat sg_ocTouchToAttach_Rot

Oculus Touch origin to Finger rotational offset

static const Kinematics::Vect3D nova_o_to_Wrist_Pos

Positional offset between Nova Glove Origin and Wrist.

static const Kinematics::Quat nova_o_to_Wrist_Rot

Rotational offset between Nova Glove Origin and Wrist.

Reference for Calibration

namespace SGCore::Calibration
class CalDataPoint

Public Functions

CalDataPoint(int currSate, std::vector<Kinematics::Vect3D> calVals)

Create a new data point

Parameters
  • currSate
  • calVals

std::string ToLogData(std::string delim = "\t")

Log Calibration values for storing on disk

Return

Parameters
  • delim

Public Members

std::vector<Kinematics::Vect3D> calibrationValues

Actual calibration values.

int stage

The Calibration stage this data point belongs to.

class HG_CalCheck
#include <HG_CalCheck.h>

An algorithm that checks whether or not our current user is running in the same calibration range as last time.

Public Functions

bool ReachedConclusion()

Whether or not his algorithm has determined if calibration is required.

HG_CalCheck()

The last calibration range can be null, at which point you defnitely need calibration.

Parameters
  • lastCalibrationRange

HG_CalCheck(SGCore::Calibration::SensorRange &lastCalibrationRange)

The last calibration range can be null, at which point you defnitely need calibration.

Parameters
  • lastCalibrationRange

void Reset()

Reset the calibrationCheck. so it may be used again. This does not reset the LastRange.

void CheckRange(std::vector<Kinematics::Vect3D> &currentValues, float deltaTime_s, DeviceType deviceType)

Using the currently received Sensor Values, check if calibration is required. This function will have to be called until a conclusion can be reached.

Parameters
  • currentValues
  • deltaTime_s
  • deviceType

Public Members

SensorRange lastRange

The calibration range from last time, that we are checking against.

SensorRange currentRange

The calibration range measured as of right now.

float perfectThresholdTime = 0.5f

If we’re ‘around’ the lastRange for this amount of time, we’re calling it ‘done’.

float timer_atThreshold = 0

Time that we’ve been around the last range for.

bool movedMinimum = false

Whether or not we’ve moved a minimum amount. Something that even someone with the smallest hands can do.

float minMoveTime = 3.0f

After moving the minimum amount of time but not reaching the perivous range, we’ll say the hand is too small.

float timer_MinMove = 0.0f

Time since we made the minumum amount of movement

float outOfBoundsTime = 0.1f

The amount of time the current values can be out of range for. Catches a minor case where sensor jitter causes us to be outside of the range.

float timer_outOfBounds = 0

Time we’ve been out of bounds for.

Public Static Functions

bool NeedsCheck(SGCore::DeviceType device)

Returns true if this DeviceType requires a calibration check.

Return

Parameters
  • device

int OutOfBounds(SensorRange &previousRange, std::vector<Kinematics::Vect3D> &currentValues, SGCore::DeviceType type)

Checks if current values are operating out of the previous range. Returns -1 if all is fine. 0…4 to indicate which finger is out of bounds.

Return

Parameters
  • previousRange
  • currentValues
  • type

bool MovedMinimum(std::vector<Kinematics::Vect3D> &currentRange, SGCore::DeviceType type)

Returns true if the user has moved enough in both flexion and thumb abduction movement to be considered ‘active’

Return

Parameters
  • currentRange
  • type

bool MatchesLast(std::vector<Kinematics::Vect3D> &currentRange, std::vector<Kinematics::Vect3D> &lastRange, SGCore::DeviceType type)

Returns true if the current sensor values have moved roughly as much as last time.

Return

Parameters
  • currentRange
  • lastRange
  • type

Public Static Attributes

static const float sgThreshold

SenseGlove: How far from the threshold one can be where we would still call it ‘the same as before’

static const float novaThreshold

Nova: How far from the threshold one can be where we would still call it ‘the same as before’

static const float sgMinFlex

SenseGlove: The minumum amount of sensor flexion movement before we start testing for a smaller hand.

static const float novaMinFlex

Nova: The minumum amount of sensor flexion movement before we start testing for a smaller hand.

static const float sgMinAbd

SenseGlove: The minumum amount of sensor movement on the thumb abduction before we start testing for a smaller hand.

static const float novaMinAbd

Nova: The minumum amount of sensor movement on the thumb abduction before we start testing for a smaller hand.

class HG_CalibrationSequence
#include <HG_CalibrationSequence.h>

A sequence which collects data points untill specific criteria have been met. It must be ‘fed’ an Update command from your program in order to work.

Subclassed by SGCore::Calibration::HG_QuickCalibration

Public Functions

HG_CalibrationSequence(std::shared_ptr<SGCore::HapticGlove> gloveToCalibrate)

Create a new instance of a base HapitcGlove Calibration Sequence.

Parameters
  • gloveToCalibrate

int CurrentStageInt()

If a sequence consists of multiple stages, this integer will show you which one is currently active.

std::shared_ptr<SGCore::HapticGlove> GetLinkedGlove()

The Glove linked to this Calibration Sequence. Can be changed or re-assigned.

int DataPointCount()

Returns the amount of calibration points collected so far

bool AutoCompleted()

Whether or not this sequence was completed as per it’s own rules

Return

bool Completed()

Returns true if this sequence is marked as ‘complete’ and can begin compiling a profile.

void Reset()

Resets this calibration sequence’s data, but not it’s LinkedGlove.

void AddDataPoint(std::vector<Kinematics::Vect3D> &calibrationData)

Safely adds calibration data. Automatically done within ‘Update’

Parameters
  • calibrationData

void Update(float deltaTime_s)

Update this calibration sequence with new data. We use deltaTime to check for things like stability.

Parameters
  • deltaTime_s

void ConfirmCurrentStep()

Manual confirmation of whatever step we’re supposed to making at the moment.

bool CompileRange(SensorRange &range)

Compile a min/max range from the datapoints collected by this sequence. Returns true if it’s actually possible.

Return

Parameters
  • range

bool CompileProfile(SGCore::DeviceType forDevice, bool rightHand, SGCore::HandProfile &profile)

Compile a profile from the datapoints collected by this sequence. Returns true if it’s actually possible.

Return

Parameters
  • forDevice
  • rightHand
  • profile

bool GetHandPose(SGCore::HandPose &currentPose)

Returns the current HandPose; either the one we should be making, or what it would look like at the moment.

Return

Parameters
  • currentPose

bool GetHandPose(bool rightHand, SGCore::HandPose &currentPose)

Returns the current HandPose; either the one we should be making, or what it would look like at the moment.

Return

Parameters
  • rightHand
  • currentPose

std::string GetCurrentInstuction(std::string nextStepKey = "")

Retrieve instructions on what to do during the current step.

Return

Public Members

std::vector<CalDataPoint> calibrationPoints = {}

Calibration points colledted during this calibration process. One is added every thme the “Update()” function is called. Used to create a profile after the calibration finishes.

float elapsedTime = 0

How much time has elapsed during this calibration sequence. Useful for logging or for automated functions.

bool manualCompleted = false

Used to determine if the user has manually ended the sequence, to prevent us from adding any more calibration points.

Public Static Functions

bool CompileProfile(SensorRange range, SGCore::DeviceType forDevice, bool rightHand, SGCore::HandProfile &profile)

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.

Return

Parameters
  • range
  • forDevice
  • rightHand
  • profile

Public Static Attributes

static const int maxDataPoints = 60000

The maximum buffer size for calibration points. Once calibrationPoints exceeds this value, the

class HG_QuickCalibration : public SGCore::Calibration::HG_CalibrationSequence

Public Functions

HG_QuickCalibration(std::shared_ptr<SGCore::HapticGlove> gloveToCalibrate, float endAfter_s = autoEndTime)

Create a new instance of a QuickCalibration for Haptic Gloves.

Parameters
  • gloveToCalibrate
  • endAfter_s

bool AutoCompleted() override

This sequence autocmpletes after its autoEndTime has elapsed.

void ConfirmCurrentStep() override

After we confirm the current step, we’re basically done.

void Reset() override

Resets datapoints, min/max ranges and profile.

void Update(float deltaTime_s) override

Update this calibration sequence with new data. We use deltaTime to check for things like stability.

Parameters
  • deltaTime_s

void AddDataPoint(std::vector<Kinematics::Vect3D> &calibrationData) override

Add a new datapoint to this sequence’s collection. Updates the range and profile used to generate a preview.

Parameters
  • calibrationData

bool CompileRange(SensorRange &range) override

Compile a sensor range from the data points collected while the sequence was running. Smoothed by a Moving Average Filter.

Return

Parameters
  • range

std::string GetCurrentInstuction(std::string nextStepKey = "") override

Retrieve instructions on what to do during the current step.

Return

Parameters
  • nextStepKey

bool GetHandPose(bool rightHand, HandPose &currentPose) override

Returns a ‘preview’ of what a HandPose with this sequence’s current settings would look like.

Return

Parameters
  • rightHand
  • currentPose

Public Members

float autoEndAfter

time, in seconds, after which this sequence stops gathering data. Based on the DeltaTime variable passed in the Update() function.

int smoothingSamples = 5

When compiling the final profile, we use a Weighted Moving Average filter with this period to filer out some outliers.

SensorRange sensorRange

The min/max values recorded during this calibration sequence.

SGCore::HandProfile tempProfile

A temporary profile to apply the sensorRange to. Used to generate a ‘preview’ HandPose.

bool canAnimate

Determines if the user has moved enough so that we can animate.

Public Static Attributes

static const float autoEndTime

Default time in seconds, to end this sequence. 15 seconds is very quick for some people.

class Nova_Calibration

Public Static Functions

void ApplyInterpolationValues_DefaultCalibration(std::vector<Kinematics::Vect3D> &retractedValues, std::vector<Kinematics::Vect3D> &extendedValues, Nova::Nova_Profile &profile)

Apply a glove’s default interpolation values to a profile, using the ‘default’ hand angles from calibration

void ApplyInterpolationValues(std::vector<Kinematics::Vect3D> &retractedValues, std::vector<Kinematics::Vect3D> &extendedValues, std::vector<std::vector<Kinematics::Vect3D>> &retractedAngles, std::vector<std::vector<Kinematics::Vect3D>> &extendedAngles, Nova::Nova_Profile &profile)

Apply a set of sensor-to-joint-angle interplations to a nova profile.

Parameters
  • retractedValues
  • extendedValues
  • retractedAngles
  • extendedAngles
  • profile

class SensorRange

Public Functions

SensorRange()

Create a new instance of a SensorRange with values at 0, 0

SensorRange(std::vector<Kinematics::Vect3D> min, std::vector<Kinematics::Vect3D> max)

Create a new SensorRange with predefined Min/Max values.

Parameters
  • min
  • max

std::vector<Kinematics::Vect3D> GetMinValues()

Access the lowest values values of this range.

void SetMinValues(std::vector<Kinematics::Vect3D> value)

Access the lowest values values of this range.

std::vector<Kinematics::Vect3D> GetMaxValues()

Access the lowest values values of this range.

void SetMaxValues(std::vector<Kinematics::Vect3D> value)

Access the lowest values values of this range.

std::vector<Kinematics::Vect3D> GetRange()

Access the difference between min and max values.

void UpdateRange()

Update the Range based on the current minVals and MaxVals.

void CheckForExtremes(std::vector<Kinematics::Vect3D> &otherValues)

In otherValues are greater/smaller than this current range, update them

Parameters
  • otherValues

std::string ToString(bool yOnly = true)

Convert this SensorRange into a string rotation [min … max]

Return

Parameters
  • yOnly

std::string RangeString(bool yOnly = true)

Report the Range value of this SensorRange, separated by a comma

Return

Parameters
  • yOnly

std::string Serialize()

Serialize this SensorRange into a string representation, that can be deserialized later.

Return

Public Static Functions

SensorRange ForCalibration()

Generates a Sensor Range where minumum values are float.MaxValue and maximum values are float.MinValue.

Return

void CheckMax(Kinematics::Vect3D &currVals, Kinematics::Vect3D &maxVals)

Evaluate maxVals so that it contains the highest x, y, and z values between currVals and maxVals.

Parameters
  • currVals
  • maxVals

void CheckMin(Kinematics::Vect3D &currVals, Kinematics::Vect3D &minVals)

Evaluate minVals so that it contains the lowest x, y, and z values between currVals and minVals.

Parameters
  • currVals
  • minVals

SensorRange Deserialize(std::string &serializedString)

Convert a serialized SensorRange back into the appropriate class.

Return

Parameters
  • serializedString

Reference for Diagnostics

namespace SGCore::Diagnostics
class Debugger
#include <Debugger.h>

Used to send Debug Messages to the developer (and user)

Public Static Attributes

const DebugLevel defaultLevel

The Default debug level for any application

DebugLevel debugLevel

The current debug level of the Debugger.

summary> Print a single message with an endline to the console.

Reference for Haptic Commands

Under the hood

A Haptic command sent to the SenseGlove DK1 contains the levels of force- or vibrotactile feedback of each actuator. Once set, the glove will keep the actuators at these levels until a different command is received. For example; one command might tell the SenseGlove to set the Force-Feedback of the index finger to maximum, and to vibrate the thumb at 50% intensity. Until the glove receives a new command, it will keep the force on the index finger and the vibration on the thumb active.

Because the command sent to the glove contains both force- and vibrotactile information, the SenseGlove keeps track of the last sent force-feedback and vibrotactile commands. Sending only force-feedback commands will not affect the buzz motors and vice versa. However, it is faster to send both at the same time

// You can do this, no problem
SenseGlove.SendHaptics(new SGCore.Haptics.SG_BuzzCmd(0, 80, 0, 0, 0)); //writes this buzz cmd and the last sent ffb cmd to memory
SenseGlove.SendHaptics(new SGCore.Haptics.SG_FFBCmd(100, 0, 0, 0, 0)); //writes this ffb cmd and the last buzz cmd (the one above) to memory
// But this does the exact same, and is faster by a few operations
SenseGlove.SendHaptics(new SGCore.Haptics.SG_FFBCmd(100, 0, 0, 0, 0), new SGCore.Haptics.SG_BuzzCmd(0, 80, 0, 0, 0)); //writes both cmds to memory.

New commands are sent to the glove every 5-10 milliseconds. At that point, the latest command in memory will be sent over to the device.

Sending Multiple Commands

Calling a SendCmd function on your SenseGlove instance will clear the older command and replace it with your new one. If you write two haptic commands one after another, only the last one will usually be sent to the glove. This happens because the writing operation takes much less than a milisecond. When the device checks which command to send some 5 miliseconds later, it only sees the last one sent.

// C# Example
mySenseGlove.SendHaptics(new SGCore.Haptics.SG_BuzzCmd(0, 80, 0, 0, 0)); //1: vibrate the index finger at 80% intensity.
mySenseGlove.SendHaptics(new SGCore.Haptics.SG_BuzzCmd(50, 0, 0, 0, 0)); //2: vibrate the thumb at 50% intensity.
// Only the thumb will vibrate, because the first command was overridden by the second one
//If you want both to activate at the same time, use this:
mySenseGlove.SendHaptics(new SGCore.Haptics.SG_BuzzCmd(50, 80, 0, 0, 0)); //2: vibrate thumb at 50% intensity and the index finger at 80% intensity.

As indicated before, sending only Buzz commands will not affect your last Force-Feedback command and vice versa. You could opt to handle these separately, should you so desire.

Force-Feedback parameters

A Force-Feedback command consists of a single integer value between 0 and 100, which represents the voltage sent to the actuator inside the brake housing. Sending a value of 0 will set the motor voltage to 0V, while sending 100 will set the actuator voltage to maximum (24V). This actuator controls the brake force on the cables running through the exoskeleton. The SenseGlove hardware cannot pull on said cables, only apply a braking force. There is currently no control system inside the API or SenseGlove to determine when Force-Feedback should disengage again.

Please note that activating the Force-Feedback will lock the cable to a certain length: Locking the cable (magnitude = 100%) when the finger is semi-flexed will mean that this finger shouldn’t be able to flex further. However, the user is still free to extend their fingers and, since the cable is now locked, it won’t retract to keep up with the motion anymore. The user is free to then flex again up to the original point.

Until a proper Voltage-Force mapping is done, use the following guidelines from our CTO to help you determine what to send and when:

There isn’t any force added to our cables until the PWM duty cycle reaches 60%, and the maximum force is reached when the signal reaches 100%. Using a test setup involving a digital force-sensor, we determined that a brake housing operating at 24V can pull up to 40N before slipping occurs. Once it drops below 30% again, the force on the cables will fall back to 0N.

Buzz Motor Parameters

The Magnitude parameter of the Buzz Motors determines the intensity of the vibration (a.k.a. the Amplitude). With the Eccentric Rotating Mass (ERM) actuators in the DK1, it is impossible to change the frequency of the vibration.

Generally the vibration motors won’t start spinning until a Magnitude of 30% is given.

namespace SGCore::Haptics
class HG_HapticStream

Public Functions

HG_HapticStream()

Create a new HapticsStream for a Haptic Glove.

void ClearFFB()

Clears only the Force-Feedback Queue.

void ClearVibrations()

Clears all vibrations in the queue(s)

void Clear()

Clear all ongaoing effects to this stream.

void AddCmd(SG_FFBCmd ffbCmd)

Add a new Force-Feedback command to the queue. Does not actually send it.

Parameters
  • ffbCmd

void AddCmd(SG_TimedBuzzCmd buzzCmd)

Add a new vibrotactile command to the queue. Does not actually send it.

Parameters
  • buzzCmd

void AddCmd(TimedThumpCmd thumpCmd)

Add a new Thumper command to the queue. Does not actually send it. Does not work with SenseGlove, only for Nova’s

Parameters
  • thumpCmd

void UpdateTimedCommands(float dT_seconds)

Update the active commands, using a deltaTime since last update, in seconds. Any timedCommands that are elapsed will be removed from the list.

Parameters
  • dT_seconds

SG_FFBCmd TotalFFBLevels(SG_FFBCmd lastFFB)

Compiles all FFB Levels in the queue into a single one. Does not clear the queue. Returns lastFFBCmd if no FFB commands are given.

Return

Parameters
  • lastFFB

SG_FFBCmd TotalFFBLevels()

Compiles all FFB Levels in the queue into a single one. Does not clear the queue.

Return

SG_BuzzCmd TotalBuzzLevels()

Compiles all active vibrotactile in the queue into a single list of levels. Does not clear the queue.

ThumperCmd TotalThumperLevels()

Compiles all active vibrotactile in the queue into a single list of levels. Does not clear the queue.

void FlushHaptics(SG_FFBCmd lastBrakeLvl, SG_FFBCmd &ffbCmd, SG_BuzzCmd &buzzCmd, ThumperCmd &thumperCmd, bool clearFFBqueue = true)

Compile all commands in the queue(s) into a single set of commands that can be sent to the glove. Only clears the FFB queue, and only if you want it to.

Return

Parameters
  • lastBrakeLvl
  • ffbCmd
  • buzzCmd
  • thumperCmd
  • clearFFBqueue

void FlushHaptics(float dT_seconds, SG_FFBCmd lastBrakeLvl, SG_FFBCmd &ffbCmd, SG_BuzzCmd &buzzCmd, ThumperCmd &thumperCmd)

Compile all commands in the queue(s) into a single set of commands that can be sent to the glove. Also updates & clears all queues.

Parameters
  • dT_seconds
  • lastBrakeLvl
  • ffbCmd
  • buzzCmd
  • thumperCmd

Public Static Attributes

static const int maxFFBCmds = 50

The base maximum amount of Force-Feedback Commands that can be in a queue.

static const int maxBuzzCmds = 50

The base maximum amount of Vibrotactile Commands that can be in a queue.

static const int maxThumpCmds = 50

The base maximum amount of Thumper Commands that can be in a queue.

class SG_BuzzCmd : public SGCore::Haptics::SG_FingerCmd
#include <SG_BuzzCmd.h>

A vibration command for the Sense Glove, with levels for each finger.

Subclassed by SGCore::Haptics::SG_TimedBuzzCmd

Public Functions

SG_BuzzCmd()

Basic Constructor

SG_BuzzCmd(std::vector<int> buzzLevels)

Create a new buzz motor command, where each finger level is contained inside an array of size 5.

SG_BuzzCmd(int thumb, int index, int middle, int ring, int pinky)

Create a new Buzz Motor command, indicating the intensity for each finger.

SG_BuzzCmd(Finger finger, int buzzLevel)

Create a new Buzz Motor command, with only one finger being activated.

~SG_BuzzCmd()

Basic Destructor

SG_BuzzCmd Merge(SG_BuzzCmd other)

Merge this command with another, taking the maximum value between the two.

SG_BuzzCmd Copy()

Copy this Buzz Command into a new object.

Public Static Attributes

const SG_BuzzCmd off

A command that turns off all vibration motors of the Sense Glove.

class SG_FFBCmd : public SGCore::Haptics::SG_FingerCmd
#include <SG_FFBCmd.h>

A Force-Feedback command for the Sense Glove, with levels for each finger.

Public Functions

SG_FFBCmd(std::vector<int> ffbLevels)

Create a new Force-Feedback Command, with levels for each finger stored in an int[5] array.

summary> Create a new Force-Feedback Command, with levels for each finger

SG_FFBCmd(Finger finger, int level)

Create a new Force-Feedback command, with only one finger being activated.

~SG_FFBCmd()

Basic Destructor

SG_FFBCmd Merge(SG_FFBCmd other)

Merge this finger command with another, taking the maximum value between the two.

Public Static Attributes

const SG_FFBCmd off

A command that turns off all force feedback on the Sense Glove.

class SG_FingerCmd
#include <SG_FingerCmd.h>

A command that contains values (levels) for five fingers.

Subclassed by SGCore::Haptics::SG_BuzzCmd, SGCore::Haptics::SG_FFBCmd

Public Functions

bool Equals(SG_FingerCmd other)

Check if this command contains the same values as another.

std::string ToString()

Return

Create a string representation of this finger command.

class SG_TimedBuzzCmd : public SGCore::Haptics::SG_BuzzCmd
#include <SG_TimedBuzzCmd.h>

Buzz motor commands that is meant to stop after a few miliseconds.

Intended use; this.levels indicates the actual command

Public Functions

SG_TimedBuzzCmd(Finger finger, int magnitude, float duration_seconds, float startTime_seconds = 0)

Create a new TimeBuzzCommand for a single finger.

Parameters
  • finger
  • magnitude
  • duration_seconds
  • startTime_seconds

SG_TimedBuzzCmd(SG_BuzzCmd command, float duration_seconds, float startTime_seconds = 0)

Create a new buzz motor command that expires after timing_ms

Parameters
  • command
  • duration_seconds
  • startTime_seconds: Optional, starts the effect at a certain time

SG_BuzzCmd GetBaseCommand()

Access the base command, which indicates the buzz levels to keep untill time elapses.

Return

bool TimeElapsed()

Check if this timed command’s timing has elapsed

Return

float NormalizedTime(bool clamp01 = true)

Represents how far this effect is in its playtime; [0…1], where 0 means at the start, and 1 means at the end

Parameters
  • clamp01: Optional parameter; ensures this value is always between 0 and 1.

std::string ToString() override

Return

Create a string representation of this finger command.

SG_BuzzCmd Copy() override

Copy this Buzz Command’s values into a new object.

Return

SG_BuzzCmd Merge(SG_BuzzCmd other) override

Merges this basecommand with another command

Return

Parameters
  • other

void ResetTiming()

Reset the timings of this BuzzCmd, allowing us to re-use it.

void UpdateTiming(float dT_seconds)

Update the elapsed time to check if the buzz motors should stop.

Parameters
  • dT_seconds

Public Members

float duration = 0

The total time [millisecons] each buzz motor should be vibrating for.

float elapsedTime = 0

The time elapsed since the command was sent [millisecons].

class ThumperCmd

Public Functions

ThumperCmd(int magn)

Create a new Thumper Command

Return

Parameters
  • magn

ThumperCmd Copy()

Duplicate Thumper command

Return

ThumperCmd Merge(ThumperCmd other)

Merge two ThumperCommands into one.

Return

Parameters
  • other

Public Members

int magnitude

Thumper intensity, a level between 0 and 100.

Public Static Attributes

const ThumperCmd off

A command that turns off all force feedback on the Sense Glove.

class TimedThumpCmd

Public Functions

bool Elapsed()

Returns true if the timed command has elapsed.

TimedThumpCmd(int amplitude, float duration_seconds, float startTime_seconds = 0)

Create a new Timed Thumper Command.

Parameters
  • amplitude: Value between 0 .. 1 representing the magnitude of the system.

  • duration_seconds
  • startTime_seconds

TimedThumpCmd(ThumperCmd baseCmd, float duration_seconds, float startTime_seconds = 0)

Create a new Timed Thumper Command.

Parameters
  • baseCmd
  • duration_seconds
  • startTime_seconds

void Update(float dT_seconds)

Update the timing on this Thumper Command

Parameters
  • dT_seconds

TimedThumpCmd Copy(bool copyElapsed = true)

Copy the parameters of this ThumperCommand into another instance.

Return

Public Members

int magnitude

Magnitude in %

float duration

duration in seconds

float elapsedTime

The elapsed time so far.

Reference for Kinematics

namespace SGCore::Kinematics
class Anatomy
#include <Anatomy.h>

“Database” of anatomical values, such as joint limits.

Public Static Functions

float GetFingerJointLimit(bool right, int joint, int movement, bool max)

Retrieve one of the limits of a finger joint’s movement.

float GetThumbJointLimit(bool right, int joint, int movement, bool max)

Retrieve one of the limits of a thumb joint’s movement.

float NormalizeFingerFlex(float flexionInRad)

Convert a total finger flexion in radians into a 0..1 representation.

Return

Parameters
  • flexionInRad

float NormalizeThumbFlex(float flexionInRad)

Convert a total finger flexion in radians into a 0..1 representation.

Return

Parameters
  • flexionInRad

std::vector<std::vector<Vect3D>> HandAngles_Default(bool rightHand)

Get Hand Angles that would make a Default (Idle) Pose

std::vector<std::vector<Vect3D>> HandAngles_Flat(bool rightHand)

Get Hand Angles that would make a flat hand

std::vector<std::vector<Vect3D>> HandAngles_ThumbsUp(bool rightHand)

Get Hand Angles that would make a thumbs up

std::vector<std::vector<Vect3D>> HandAngles_Fist(bool rightHand)

Get Hand Angles that would make a fist

Public Static Attributes

static const float totalFingerFlexion

Total sum of all finger flexion that would be considered “total flexion”

static const float totalFingerExtension

Total sum of all finger flexion that would be considered “total extension”

static const float totalThumbFlexion

Total sum of all thumb flexion that would be considered “total flexion”

static const float totalThumbExtension

Total sum of all thumb flexion that would be considered “total extension”

class BasicHandModel
#include <BasicHandModel.h>

Represents data of a user’s hand required for forward kinematics.

Public Functions

BasicHandModel()

Basic class Constructor.

BasicHandModel(bool right, std::vector<std::vector<float>> lengths, std::vector<Vect3D> startPositions)

Create a new basicHandModel with no starting rotations.

BasicHandModel(bool right, std::vector<std::vector<float>> lengths, std::vector<Vect3D> startPositions, std::vector<Quat> startRotations)

Create a new basicHandModel

~BasicHandModel()

Basic class Destructor.

std::vector<float> GetFingerLengths(Finger finger)

Retrieve the finger lengths of a specific finger.

void SetFingerLengths(std::vector<float>, Finger finger)

Set the finger lengths of a specific finger.

Vect3D GetJointPosition(Finger finger)

Retrieve the start position of a specific finger.

void SetJointPosition(Vect3D newPosition, Finger finger)

Set the start position of a specific finger

Quat GetJointRotation(Finger finger)

Retrieve the start rotation of a specific finger.

void SetJointRotation(Quat newRotation, Finger finger)

Set the start rotation of a specific finger

float GetTotalLength(Finger finger)

Get the total length of a specific finger, in mm

std::vector<float> GetTotalLengths()

Get the total lengths of a fingers, in mm

std::vector<float> GetFingerRatioes(Finger finger)

Get the finger ratioes of a specific finger.

std::vector<std::vector<float>> GetFingerRatioes()

Get the finger ratioes of all fingers.

std::vector<Vect3D> Get3DLengths(Finger finger)

Retrieve the lengths of a specific finger, as Vect3D representation (L, 0, 0).

Used for forwards kinematics.

bool Equals(BasicHandModel other)

Check if this BasicHandModel has the same values as another BasicHandModel.

Return

Parameters
  • other

std::string ToString()

Convert this handModel into a string notation, readable for humans. Does not include starting positions / rotations.

Return

std::string ToString(bool lengthsOnly)

Convert this handModel into a string notation, readable for humans. Optionally includes starting positions / rotations.

Return

Parameters
  • lengthsOnly

std::string Serialize()

Serialize this HandModel into a string representation.

summary> Convert a serialized HandModel back into its class representation.

Return

Public Members

std::vector<std::vector<float>> fingerLengths

The length of individual finger phalangers in mm, soted per finger. Generally 5x3

std::vector<Vect3D> startJointPositions

Starting joint positions relative to the device Origin

std::vector<Quat> startJointRotations

Starting joint rotations relative to the device Origin

bool isRight

Whether or not this BasicHandModel was created for a left- or right hand. Used for validation.

Public Static Functions

BasicHandModel Default(bool right)

Retrieve a default left or right hand model.

Public Static Attributes

static const std::vector<std::vector<float>> baseFingerLengths

Default finger lengths (based on right hand).

Any missing fingers are replaced with their respective value.

static const std::vector<Vect3D> baseJointPositions

Default joint positions (based on right hand).

Any missing positions are replaced with their respective value.

static const std::vector<Vect3D> baseJointRotations

Default joint rotations (based on right hand).

Any missing rotation are replaced with their respective value.

class HandInterpolator
#include <HandInterpolator.h>

Contains interpolation sets of all joint movements that can be caluclated into a handPose.

Public Functions

HandInterpolator()

Basic Constructor

~HandInterpolator()

Basic Destructor

HandInterpolator(std::vector<std::vector<InterpolationSet>> interpolations)

Create a new basic HandInterpolator without a starting rotation.

HandInterpolator(std::vector<std::vector<InterpolationSet>> interpolations, Quat cmcStart)

Create a new basic HandInterpolator with a starting rotation.

float CalculateAngle(Finger finger, int movement, float value)

Calculate any finger’s movement rotation, using an input value.

float CalculateAngle(Finger finger, FingerMovement movement, float value)

Calculate a finger movement’s rotation, using an input value.

float CalculateAngle(Finger finger, ThumbMovement movement, float value)

Calculate a thumb movement’s rotation, using an input value.

bool Equals(HandInterpolator other)

Check if this handInterpolator matches another.

Return

Parameters
  • other

void SetInterpolation(int finger, int movement, float inputAt0, float inputAt1, float angleAt0, float angleAt1)

Updates a particular joint movement interpolation, without changing its limits.

Parameters
  • finger
  • movement
  • inputAt0
  • inputAt1
  • angleAt0
  • angleAt1

void SetInterpolation(Finger finger, FingerMovement movement, float inputAt0, float inputAt1, float angleAt0, float angleAt1)

Updates a particular joint movement interpolation, without changing its limits

Parameters
  • finger
  • movement
  • inputAt0
  • inputAt1
  • angleAt0
  • angleAt1

void SetInterpolation(ThumbMovement movement, float inputAt0, float inputAt1, float angleAt0, float angleAt1)

Updates a particular joint movement interpolation, without changing its limits

Parameters
  • movement
  • inputAt0
  • inputAt1
  • angleAt0
  • angleAt1

InterpolationSet GetInterpolation(int finger, int movement)

Returns an interpolationSet

Return

Parameters
  • finger
  • movement

std::string Serialize()

Serialize this HandInterpolator into a string representation.

Return

Public Members

Quat cmcStartRot

Starting rotation of the thumb cmc joint.

summary> Interpolation sets for each finger. First index indicates which finger, Second index indicates the joint movement.

Public Static Functions

HandInterpolator Default(bool rightHand)

Create a default instance of a left- or right handed interpolator.

std::vector<Vect3D> InterpolateFingerAngles(Finger finger, HandInterpolator &interpolator, Vect3D totalGloveAngles)

Calculate all angles of a specific finger based on an Interpolator and input angles.

std::vector<Vect3D> InterpolateThumbAngles(HandInterpolator &interpolator, Vect3D totalGloveAngles)

Calculate all angles of the Thumb based on an Interpolator and input angles.

std::vector<std::vector<Vect3D>> InterpolateHandAngles(HandInterpolator &profile, std::vector<Vect3D> totalAngles)

Calculate all hand angles based on an interpolator and total xyz angles.

HandInterpolator Deserialize(std::string serializedString)

Convert a serialized HandInterpolator back into a class representation.

Return

Parameters
  • serializedString

class InterpolationSet
#include <InterpolationSet.h>

Set of variables to map a value from one range to the next.

Public Functions

InterpolationSet()

Creates a basic interpolation set, without limits.

InterpolationSet(float from1, float from2, float to1, float to2)

Create a new interpolation set without limits.

InterpolationSet(float from1, float from2, float to1, float to2, float min, float max)

Create a new interpolation set with limits.

~InterpolationSet()

Basic Destructor.

float Get(float value, bool limit, bool normalizeAngle = false)

Calculate an output value in range [x0…x1] to [y0..y1]

bool Equals(InterpolationSet other)

Returns true if this InterpolationSet has the same values as another set.

Return

Parameters
  • other

std::string Serialize()

Convert this InterpolationSet into a string notation so it can be stored on disk.

Return

Public Members

float x0

First value of input range.

float x1

Second value of input range.

float y0

First value of output range.

float y1

Second value of output range.

float min

Minumum range of the output value.

float max

Maximum range of the output value.

Public Static Functions

InterpolationSet Deserialize(std::string serializedString)

Convert a string notation of an InterpolationSet into a new class instance.

Return

Parameters
  • serializedString

class JointKinematics

Public Static Functions

bool ForwardKinematics(Vect3D startPosition, Quat startRotation, const std::vector<Vect3D> &jointLengths, const std::vector<Vect3D> &jointAngles, std::vector<Vect3D> &newPositions, std::vector<Quat> &newRotations)

Perform foward Kinematics on a set of joints, defined by a start position- and rotation, joint angles and the lenghts in between. Outputs the calculated positions and rotations.

bool ForwardKinematics(BasicHandModel &profile, Finger finger, const std::vector<Vect3D> &jointAngles, std::vector<Vect3D> &newPositions, std::vector<Quat> &newRotations)

Calculate positions and rotations of a finger based on input angles and profile.

class Quat
#include <Quat.h>

A rotation in 3D space that can be applied to a 3D vector or converted into Euler Angles.

Public Functions

Quat()

Create a new Quaternion rotation of 0, 0, 0, 1.

Quat(float X, float Y, float Z, float W)

Create a new Quaternion rotation.

~Quat()

Default Destructor.

std::string ToString()

Create a string representation of the Quaternion rotation.

Vect3D ToEuler()

Retrieve this Quaternion’s euler angle notation.

Vect3D Rotate(Vect3D myVect)

Rotate myVect by this quaternion rotation.

bool Equals(Quat that)

Check if two quaternions have equal values.

summary> Check if this Quaternion is the identity quaternion (meaning it does not rotate anything.)

float Magnitude()

Returns the magnitude of this Quaternion. Used in normalization.

Return

Public Members

float x

Quaternion element. Not directly related to a rotation or position.

Public Static Functions

Quat FromEuler(float xAngle, float yAngle, float zAngle)

Create a new Quaternion Rotation from its euler angle representation.

summary> Create a new Quaternion Rotation from its euler angle representation.

Quat FromAngleAxis(float angle, float axisX, float axisY, float axisZ)

summary> Create a new Quaternion Rotation from an angle-axis representation.

Quat Invert(Quat q)

Returns the inverse if q (a.k.a. a rotation in the other direction)

Quat Normalize(Quat q)

Normalizes a quaternion to have a lenght of 1.

Return

bool Deserialize(std::string str, Quat &result, const char delim = ',')

Parse a Quaternion from a string.

Public Static Attributes

const Quat identity

Represents ‘no rotation’ in quaternion space.

class Values
#include <Values.h>

Utility class to convert values into various formats.

Public Static Functions

Vect3D Radians(Vect3D degrees)

Convert a vector of degrees angles into radians.

Vect3D Degrees(Vect3D radians)

Convert a vector of radian angles into degrees.

float NormalizeAngle(float angle, float minAngle, float maxAngle)

Ensure that a single angle is within the [-Pi…Pi] range.

float NormalizeAngle(float angle)

Normalize and angle between a variable range.

Vect3D NormalizeAngles(Vect3D angles)

Normalize a set of angles in radians.

float Clamp(float value, float min, float max)

Ensure that a value remains within the [min…max] range.

int Clamp(int value, int min, int max)

Ensure that an integer value remains within the [min…max] range.

float Map(float value, float from1, float from2, float to1, float to2)

Map a value from one range [from1…from2] to another range [to1 .. to2]

float Map(float value, float from1, float from2, float to1, float to2, float min, float max)

Map a value from one range [from1…from2] to another range [to1 .. to2], while ensuring it stays within the [min…max] range.

bool FloatEquals(float value1, float value2)

Check if two floating points are roughly equal, taking into account the minor differences.

summary> Check if two arrays contain equal values.

bool Equal(std::vector<Vect3D> &array1, std::vector<Vect3D> &array2)

summary> Check if two arrays contain equal values.

bool Equal(std::vector<std::vector<Vect3D>> &array1, std::vector<std::vector<Vect3D>> &array2)

summary> Check if two arrays contain equal values.

bool Equal(std::vector<Quat> &array1, std::vector<Quat> &array2)

summary> Check if two arrays contain equal values.

std::vector<Vect3D> FillZero(int length)

Returns an array of Vect3D’s, all at 0, 0, 0. Used for quick generation and to avoid NullRefs

Return

Parameters
  • length

std::vector<std::vector<Vect3D>> FillZero(int length, int width)

Returns a 2D of Vect3D’s [Length, Width] all at 0, 0, 0. Used for quick generation and to avoid NullRefs

Return

Parameters
  • length
  • width

Public Static Attributes

const float Rad2Deg

Converts radians into degrees

const float Deg2Rad

Converts degrees into radians

const float _2PI

2*PI is used frequently in angle normalization

class Vect3D
#include <Vect3D.h>

Represents a vector with x,y,z coordinates.

Public Functions

Vect3D()

Creates an empty vector (0, 0, 0) for internal use

Vect3D(float X, float Y, float Z)

Create a new instance of a 3D vector.

~Vect3D()

Basic Destructor

float Magnitude()

Calculate the magnitude or ‘length’ of this Vector

void Normalize()

Returns this vector normalized to have a Magnitude on 1.

void Scale(float s)

Scale all elements of this vector by a certain factor.

float DistTo(Vect3D other)

Calculate the distance between this Vector and another one.

bool Equals(Vect3D that)

Check if this Vector is roughly equal to another.

std::string ToString()

Create a string representation of this Vector.

std::string Serialize(const char delim)

Convert a serialized Vect3D back into its class representation.

Return

Parameters
  • delim

Public Members

float x

x-component of the 3D vector.

summary> y-component of the 3D vector.

float y

summary> z-component of the 3D vector.

Public Static Functions

bool Deserialize(std::string str, Vect3D &result, const char delim)

Serialize a Vect3D into a string representation

Public Static Attributes

const Vect3D zero

Represents a vector with coordinates (0, 0, 0).

Utilities reference

namespace SGCore::Util

Enums

enum ListFormat

Indices to access DeviceList data in Shared Memory

Values:

enumerator LF_Connected
enumerator LF_PPS_Got
enumerator LF_DeviceType
enumerator LF_cString
enumerator LF_Address
enumerator LF_ConnectType
enumerator LF_PPS_Sent
enumerator LF_All
enum SensorFormat

Indices to access Sensor Data in Shared Memory

Values:

enumerator SF_Sensors
class Communications
#include <Communications.h>

“Database” containing communications bytes and conversions.

Public Static Functions

char ToSGByte(int lvl)

Convert a value between 0..100 to a Sense Glove char/byte

Public Static Attributes

const char cmdOpen

Byte indicating the start of a new command.

const char cmdClose

Byte indicating the end of a command.

const char senseOpen

Byte indicating the start of a new sensor data package.

const char senseClose

Byte indicating the end of a sensor data package.

summary> Denotes a block section of a DeviceList section.

const char sectionDelimiter

‘:’ - Used to split a set of different contant values into individual groups.

const char colDelimiter

‘;’ - Used to separate individual values

const char rowDelimiter

‘|’ - Used to group a set of values, for example per finger.

class FileIO

Public Static Functions

bool ReadTxtFile(std::string &filePath, std::vector<std::string> &lines)

Attempt to read all lines from a file and place them in the string[]. Returns true if succesful. If unable to open the file, the string[] will be empty.

Return

Parameters
  • filePath
  • lines

bool SaveTxtFile(std::string &directory, std::string &fileName, std::vector<std::string> &contents, bool append = false)

Attempt to save a string[] to a filename within a desired directory. Returns true if succesful.

Directory is added as a separate variable so we can more easily check for its existence.

Return

Parameters
  • directory
  • fileName
  • contents
  • append

bool CreateFullDirectory(std::string &dir)

Creates a new directory. Returns false if it already existed.

Return

Parameters
  • dir

bool DirectoryExists(std::string &dir)

Returns true if the directory exists

Return

Parameters
  • dir

bool FileExists(std::string &filePath)

Returns true if this file exists

Return

Parameters
  • filePath

std::string GetWorkingDirectory()

STUB - Gets the working directory of the current process.

Return

std::string GetMyDocumentsPath()

Get the Path to MyDocuments, but without ‘' at the nnd

Return

class Serializer
#include <Serializer.h>

Utility class to serialize / deserialize classes.

Public Static Functions

void FilterBrackets(std::string &serialized)

Filter opening / closing charaters at the beginning and end of a string, if they exist.

summary> Split a serialized string by its top level blocks

Parameters
  • serialized

std::string Enclose(std::string str)

Enclose a string with our opening / closing characters.

Return

Parameters
  • str

std::string Serialize(std::vector<float> &floatArray, bool enclosed = true)

Serialize a floating point array/vector

std::string Serialize(std::vector<std::vector<float>> &floatArray, bool enclosed = true)

Serialize a 2D floating point array/vector

std::string Serialize(Kinematics::Quat &quat, bool enclosed = true)

Serialize a Quaternion

std::string Serialize(std::vector<Kinematics::Quat> &quatArray, bool enclosed = true)

Serialize a Quaternion array/vector

std::string Serialize(std::vector<std::vector<Kinematics::Quat>> &quatArray, bool enclosed = true)

Serialize a 2D Quaternion array/vector

std::string Serialize(Kinematics::Vect3D &vect, bool enclosed = true)

Serialize a Vector

std::string Serialize(std::vector<Kinematics::Vect3D> &vectArray, bool enclosed = true)

Serialize a Vector array/vector

std::string Serialize(std::vector<std::vector<Kinematics::Vect3D>> &vectArray, bool enclosed = true)

Serialize a 2d Vector array/vector

std::string Serialize(std::vector<bool> &boolArray, bool enclosed = true)

Serialize a boolean array/vector

std::vector<float> DeserializeFloats(std::string &serialized)

Convert a serialized string back into an array of floating points

std::vector<std::vector<float>> DeserializeFloats2D(std::string &serialized)

Convert a serialized string back into a 2D array of floating points

Kinematics::Quat DeserializeQuat(std::string &serialized)

Convert a serialized string back into a Quaternion

std::vector<Kinematics::Quat> DeserializeQuats(std::string &serialized)

Convert a serialized string back into an array of Quaternions

std::vector<std::vector<Kinematics::Quat>> DeserializeQuats2D(std::string &serialized)

Convert a serialized string back into a 2D array of Quaternions

Kinematics::Vect3D DeserializeVect(std::string &serialized)

Convert a serialized string back into a Vector

std::vector<Kinematics::Vect3D> DeserializeVects(std::string &serialized)

Convert a serialized string back into an array of Vectors

std::vector<std::vector<Kinematics::Vect3D>> DeserializeVects2D(std::string &serialized)

Convert a serialized string back into a 2D array of Vectors

std::vector<bool> DeserializeBools(std::string &serialized)

Convert a serialized string back into an array of booleans

Public Static Attributes

const char openChar = '{'

Character opening a new block of data.

const char closeChar = '}'

Character closing a block of data.

const char valueDelim = ';'

Character to separate values.

summary> Filters spaces from a a string.

class StrStuff
#include <StrStuff.h>

Utility class to convert strings into useable values.

Public Static Functions

std::vector<std::string> Split(std::string s, const char delimiter)

Split a std::string into a vector of std::strings by a delimiter

int ToInt(std::string str, int fallback = 0)

Convert a string into an integer value.

float ToFloat(std::string str, float fallback = 0)

Convert a string into a decimal value.

std::string ToString(SGCore::Finger finger)

Convert a finger into a string notation.

std::string ReplaceChars(std::string str, char from, char to)

Replace all occurences of a character with another one.

std::string RoundedDegrees(float valInRad)

Convert a value in radians into a rounded integer, as a string. e.g. 4.999999999999999 -> 5.

template<class T>
std::string PrintSize(std::vector<std::vector<T>> &vect)

Print the different sizes within a 2D array

Return

Template Parameters
  • T
Parameters
  • vect