Getting Started with the Forte Data Glove & Python

1. Prerequisites

To use the DataGlove Python SDK you will need the following:

2. Setup and Run the Sample Program

1. Install the module with pip: pip install dataglove

2. Optional: The dataglove module download files can also be found on the Python Package Index
https://pypi.org/project/dataglove/#files

3. Below is a basic sample program provided to print out the sensor and imu data:

from dataglove import *

leftHand = Forte_CreateDataGloveIO(1, "") # 0 for right-handed glove
try:
 while True:
  try:
   sensors = Forte_GetSensors(leftHand)
   imu = Forte_GetIMU(leftHand)
   print(sensors)
   print(imu)
  except(GloveDisconnectedException):
   print("Glove is Disconnected")
   pass
except(KeyboardInterrupt):
 Forte_DestroyDataGloveIO(leftHand)
 exit()

4. Copy and paste as test.py

5. Run: python test.py

6. The output should look something like the following:

3. Forte Data Glove Python API

Core API Functions:

  • Forte_CreateDataGloveIO(handType)
  • Forte_DestroyDataGloveIO(dataGloveIO)
  • Forte_GetIMU(dataGloveIO)
  • Forte_GetSensors(dataGloveIO)
  • Forte_GetBatteryLevel(dataGloveIO)
  • Forte_GetConnectionState(dataGloveIO)
  • Forte_GetHandType(dataGloveIO)
  • Forte_UploadFile(dataGloveIO, filePath, slot)
  • Forte_EnterBootloaderMode(dataGloveIO)
  • Forte_SetGloveDisplayID(dataGloveIO)
  • Forte_GetFullReport(dataGloveIO)

Raw Sensors/Fingers Functions:

  • Forte_GetSensorRaw(dataGloveIO, index)
  • Forte_GetSensorsRaw(dataGloveIO)
  • Forte_GetFingerRaw(dataGloveIO, index)
  • Forte_GetFingersRaw(dataGloveIO)

Normalized Sensors/Fingers Functions:

  • Forte_GetSensorNormalized(dataGloveIO, index)
  • Forte_GetSensorsNormalized(dataGloveIO)
  • Forte_GetFingerNormalized(dataGloveIO, index)
  • Forte_GetFingersNormalized(dataGloveIO)

Raw/Normalized Finger Sum Functions:

  • Forte_GetFingersSumRaw(dataGloveIO)
  • Forte_GetFingersSumNormalized(dataGloveIO)

Haptics Functions:

  • Forte_SendHaptic(dataGloveIO, actuatorID, note, amplitude)
  • Forte_SendOneShotHaptic(dataGloveIO, actuatorID, note, amplitude)
  • Forte_SendLoopHaptic(dataGloveIO, actuatorID, note, amplitude)
  • Forte_ToggleOneShot(dataGloveIO, actuatorID, makeOneShot)
  • Forte_SelectHapticWave(dataGloveIO, actuatorID, waveform)
  • Forte_SetGrainLocation(dataGloveIO, actuatorID, location)
  • Forte_SetAmplitude(dataGloveIO, actuatorID, amplitude)
  • Forte_SetPitchBend(dataGloveIO, actuatorID, pitch)
  • Forte_SetGrainSize(dataGloveIO, actuatorID, size)
  • Forte_SetGrainFade(dataGloveIO, actuatorID, fade)
  • Forte_ToggleHapticsOn(dataGloveIO, turnOn)
  • Forte_SilenceHaptics(dataGloveIO)

Calibration Functions:

  • Forte_CalibrateFlat(dataGloveIO)
  • Forte_CalibrateFingersIn(dataGloveIO)
  • Forte_CalibrateThumbIn(dataGloveIO)
  • Forte_LoadCalibration(dataGloveIO, slot)
  • Forte_SaveCalibration(dataGloveIO, slot)
  • Forte_ResetCalibration(dataGloveIO)

Device Info Functions:

  • Forte_GetHardwareRev(dataGloveIO)
  • Forte_GetHardwareVersion(dataGloveIO)
  • Forte_GetSAMDBootloaderVersion(dataGloveIO)
  • Forte_GetSAMDAppletVersion(dataGloveIO)
  • Forte_GetBLESoftDeviceVersion(dataGloveIO)
  • Forte_GetBLEBootloaderVersion(dataGloveIO)
  • Forte_GetBLEAppletVersion(dataGloveIO)

Device Info Functions:

  • Forte_HomeIMU(dataGloveIO)
  • Forte_GetQuaternionRaw(dataGloveIO)
  • Forte_GetQuaternionNormalized(dataGloveIO)
  • Forte_GetEulerAngles(dataGloveIO)
  • Forte_GetAxisAngle(dataGloveIO)
  • Forte_GetRotationMatrix(dataGloveIO)
  • Forte_GetSphericalCoordinates(dataGloveIO)

4. Depictions of Glove Sensors

5. Forte Data Glove Python API Functionality

Core API Functions 

  • Forte_CreateDataGloveIO(handType) – Initializes and returns a dataglove object. Input is 0 for right hand and 1 for left hand. 
  • Forte_DestroyDataGloveIO(dataGloveIO) – Destructor for dataglove object. Input is the dataglove object. 
  • Forte_GetIMU(dataGloveIO) – Function to return the IMU data from a data glove. Takes a dataglove object as an input, returns an array of 4 signed integers representing the IMU data. IMU data represents the positioning and rotation of the glove in 3-dimensional space. 

Output = [rotation left/right, positioning left/right, rotation up/down, positioning up/down] 

  • Forte_GetSensors(dataGloveIO) – Function that returns the sensor data from a data glove. Takes a dataglove object as an input and returns an array of floats from 0.0 – 1.0 representing the sensor data which interprets the curl of each finger. A value of 0.0 means that the finger is extended and a value of 1.0 means the finger is closed. The array will have 10 integers. 

Output = [thumb base bend, thumb tip bend, pointer finger base bend, pointer finger tip bend, middle finger base bend, middle finger tip bend, ring finger base bend, ring finger tip bend, little finger base bend, little finger tip bend] 

  • Forte_GetBatteryLevel(dataGloveIO) – Function that returns the battery remaining in a data glove. Takes a dataglove object as an input, returns a float representing the percentage of battery life remaining. 
  • Forte_GetConnectionState(dataGloveIO)- Function that checks if a data glove is connected. Takes a dataglove object as an input and returns an integer 1 if the gloves are connected and a 0 otherwise. 
  • Forte_GetHandType(dataGloveIO) – Function that returns the type (right or left hand) of a data glove. Takes a dataglove as an object and returns an integer 0 for right hand and 1 for left hand. 
  • Forte_UploadFile(dataGloveIO, filePath, slot)- Function that can be used to upload a new sample to a haptic slot. The sample file must be in the format: 8bit 4kHz mono wave. There are 16 haptic slots indexed 0-15. Takes a dataglove object, path to the sample as a string, and integer as input, then sets the haptic sample to the particular slot. 
  • Forte_EnterBootloaderMode(dataGloveIO) – Function that sets a data glove to “boot loader mode”. Takes a dataglove object as an input and returns the object in boot mode.  
  • Forte_SetGloveDisplayID(dataGloveIO) – Function that renames the ID of a data glove. Takes a dataglove object as input and sets the ID. 
  • Forte_GetFullReport(dataGloveIO) – Function that returns the data report from a data glove. Takes a dataglove object as an input and returns a list of integers representing the report. 

Output = [x, x, x, x, thumb base bend, thumb tip bend, pointer finger base bend, pointer finger tip bend, middle finger base bend, middle finger tip bend] 

 

 

Raw Sensors/Finger Functions: 

  • Forte_GetSensorRaw(dataGloveIO, index) – Function that returns the raw sensor data for a specific sensor of a data glove. Takes a dataglove object and integer as inputs and returns a signed integer representing the bend amount of the specified sensor.  
  • Forte_GetSensorsRaw(dataGloveIO) – Function that returns the raw sensor data from a data glove. Takes a dataglove object as an input and returns an array of signed integers representing the sensor data. 

Array structure= [thumb base bend, thumb tip bend, pointer finger base bend, pointer finger tip bend, middle finger base bend, middle finger tip bend, ring finger base bend, ring finger tip bend, little finger base bend, little finger tip bend] 

  • Forte_GetFingerRaw(dataGloveIO, index) –  Function that returns the finger locations for a specified finger. Takes a dataglove object and integer as inputs and returns a signed integer representing the finger curl. 
  • Forte_GetFingersRaw(dataGloveIO) – Function that returns the finger locations for each finger. Takes a dataglove object as input and returns an array of 10 signed integers representing each finger location. The first 5 elements will be for their respective fingers, while the last 5 will be 0.0. 

Array structure= [thumb bend, pointer finger bend, middle finger bend, ring finger bend, little finger bend, 0.0, 0.0, 0.0, 0.0, 0.0] 

 

Normalized Sensors/Finger Functions 

  • Forte_GetSensorNormalized(dataGloveIO, index) – Function that returns the sensor data from a data glove sensor. Takes a dataglove object and integer as an inputs and returns a floats from 0.0 – 1.0 representing the sensor data which interprets the curl of the indexed finger sensor. A value of 0.0 means that the finger is extended and a value of 1.0 means the finger is closed. 

Array to index = [thumb base bend, thumb tip bend, pointer finger base bend, pointer finger tip bend, middle finger base bend, middle finger tip bend, ring finger base bend, ring finger tip bend, little finger base bend, little finger tip bend] 

  • Forte_GetSensorsNormalized(dataGloveIO)- Function that returns the sensor data from a data glove. Takes a dataglove object as an input and returns an array of floats from 0.0 – 1.0 representing the sensor data which interprets the curl of each finger. A value of 0.0 means that the finger is extended and a value of 1.0 means the finger is closed. The array will have 10 integers. 

Output = [thumb base bend, thumb tip bend, pointer finger base bend, pointer finger tip bend, middle finger base bend, middle finger tip bend, ring finger base bend, ring finger tip bend, little finger base bend, little finger tip bend] 

  • Forte_GetFingerNormalized(dataGloveIO, index) – Function that returns the finger bend for a specified finger. Takes a dataglove object and integer as inputs and returns a float representing the specified finger bend. 

Array structure= [thumb bend, pointer finger bend, middle finger bend, ring finger bend, little finger bend, 0.0, 0.0, 0.0, 0.0, 0.0] 

  • Forte_GetFingersNormalized(dataGloveIO) – Function that returns the finger bend for each finger. Takes a dataglove object as input and returns an array of 10 floats representing each finger location. The first 5 elements will be for their respective fingers, while the last 5 will be 0.0. 

Array structure= [thumb bend, pointer finger bend, middle finger bend, ring finger bend, little finger bend, 0.0, 0.0, 0.0, 0.0, 0.0] 

 

Raw/Normalized Finger Sum Functions: 

  • Forte_GetFingersSumRaw(dataGloveIO) – Function that returns an integer that sums the raw values of the fingers. Takes a dataglove object as input and returns an integer. 
  • Forte_GetFingersSumNormalized(dataGloveIO) – Function that returns a float that sums the normalized values of the fingers. Takes a dataglove object as input and returns a float. 

 

 Haptics Functions 

  • Forte_SendHaptic(dataGloveIO, actuatorID, note, amplitude) 
  • Forte_SendOneShotHaptic(dataGloveIO, actuatorID, note, amplitude) 
  • Forte_SendLoopHaptic(dataGloveIO, actuatorID, note, amplitude) 
  • Forte_ToggleOneShot(dataGloveIO, actuatorID, makeOneShot) 
  • Forte_SelectHapticWave(dataGloveIO, actuatorID, waveform) 
  • Forte_SetGrainLocation(dataGloveIO, actuatorID, location) 
  • Forte_SetAmplitude(dataGloveIO, actuatorID, amplitude) 
  • Forte_SetPitchBend(dataGloveIO, actuatorID, pitch) 
  • Forte_SetGrainSize(dataGloveIO, actuatorID, size) 
  • Forte_SetGrainFade(dataGloveIO, actuatorID, fade) 
  • Forte_ToggleHapticsOn(dataGloveIO, turnOn) 
  • Forte_SilenceHaptics(dataGloveIO) 

Calibration Functions 

  • Forte_CalibrateFlat(dataGloveIO) – A function that sets the glove to the flat position. Takes a dataglove object as input and sets all sensor positions to 0.0 (float). Outputs a 1 to confirm the function was successful and a 0 otherwise. 
  • Forte_CalibrateFingersIn(dataGloveIO) – A function that sets the glove to the fingers in position. Takes a dataglove object as input and sets all sensor positions to 0.0 (float). Outputs a 1 to confirm the function was successful and a 0 otherwise. 
  • Forte_CalibrateThumbIn(dataGloveIO) – A function that sets the glove to the thumb in position. Takes a dataglove object as input and sets all sensor positions to 0.0 (float). Outputs a 1 to confirm the function was successful and a 0 otherwise. 
  • Forte_LoadCalibration(dataGloveIO, slot) – A function to set a calibration by the user. Takes a dataglove object and file location as inputs. Returns a 1 to confirm the function was successful and a 0 otherwise. 
  • Forte_SaveCalibration(dataGloveIO, slot) – A function to save a calibration to a file. Takes a dataglove object and file location as inputs. Returns a 1 to confirm the function was successful and a 0 otherwise. 
  • Forte_ResetCalibration(dataGloveIO) 

Device Info Functions 

  • Forte_GetHardwareRev(dataGloveIO) – Function that returns the hardware revision of a data glove. Takes a dataglove object as input and outputs a string “H”, representing the current board. 
  • Forte_GetHardwareVersion(dataGloveIO) – Function that returns the hardware version ID of a data glove. Takes a dataglove object as input and outputs a string of the Hardware version ID. 
  • Forte_GetSAMDBootloaderVersion(dataGloveIO) – Function that returns the bootloader version number of a data glove. Takes a dataglove object as input and outputs a string of the bootloader version number. 
  • Forte_GetSAMDAppletVersion(dataGloveIO) – Function that returns the device firmware version number of a data glove. Takes a dataglove object as input and outputs a string of the device firmware version number. 
  • Forte_GetBLESoftDeviceVersion(dataGloveIO) – Function that returns the BLE software device version number of a data glove. Takes a dataglove object as input and outputs a string of the BLE software device version number. 
  • Forte_GetBLEBootloaderVersion(dataGloveIO) – Function that returns the BLE Bootloader version number of a data glove. Takes a dataglove object as input and outputs a string of the BLE Bootloader version number. 
  • Forte_GetBLEAppletVersion(dataGloveIO) – Function that returns the BLE firmware version number of a data glove. Takes a dataglove object as input and outputs a string of the BLE firmware version number. 

Conversion and Rotation Functions 

  • Forte_HomeIMU(dataGloveIO) 
  • Forte_GetQuaternionRaw(dataGloveIO) 
  • Forte_GetQuaternionNormalized(dataGloveIO) 
  • Forte_GetEulerAngles(dataGloveIO) 
  • Forte_GetAxisAngle(dataGloveIO) 
  • Forte_GetRotationMatrix(dataGloveIO) 
  • Forte_GetSphericalCoordinates(dataGloveIO)