calibration-simple module

This module implements the simple calibration process.

It considers a linear relationship between raw sensor-values and the corresponding angles. Thus, a gain(g) and an offset(o) is required for each sensor to fulfill the linear function theta = g * s + o where theta is the angle and s is the sensor value. Both gains and offsets are calculated by measuring two poses with predefined angles for each sensor.

For more information about the approach, please refer to the Bachelor’s thesis by Johannes Michaelis.

Note

This calibration ignores the wrist abduction as it is broken on the CyberGlove III used at LTD.

class cyberglove.calibration_simple.CalibrationSimple(s_id='', use_latest_timestamp=False)

The class implementing the simple calibration process.

__init__(s_id='', use_latest_timestamp=False)

The __init__()-method calls the parent-constructor (__init__()) which is taking care of asking for subject-information as well as creating and handling folder structure. It also creates a neutral_dataset, which is not needed for the simple calibration. The __init__()-method() itself creates 22 gains and offsets, it defines the visualization model to be of type roll and sensor-names are set to the corresponding sensor-index number.

Parameters
  • s_id (string, optional) – subject ID if already known. if not specified, the parent-class will ask for it

  • use_latest_timestamp (bool, optional) – if set to True, the last timestamp-folder of the subject will be used

calibrate(glove)

Runs the complete simple calibration process. It calls the method measure() and postprocess().

Parameters

glove (cyberglove.glove.Glove) – connected glove object

Returns

None

export_json()

Exports gains and offsets to the json-file simple.json in the filepath-folder.

Returns

None

Raises

FileNotFoundError – when file can’t be opened

import_json()

Reads gains and offsets from the json-file simple.json in the filepath-folder.

Returns

None

Raises

FileNotFoundError – when file can’t be opened

measure(glove)

Performs all measurements required for the simple calibration process. It tests for existing files in the corresponding folder and calls the private method _measure_static_postures().

Parameters

glove (cyberglove.glove.Glove) – connected glove object

Returns

the folderpath where the files with captured data are saved

Return type

str

postprocess(folderpath)

Calculates the gains and offsets from a given static_postures.txt-file. For each sensor, the sensor value of the 0° measurement and the sensor value of the second measurement is put into helper.get_linear_relationship_with_offset() to calculate a gain and an offset. This post-processing method assumes that the static_postures.txt-file is valid and holds all required information, and it does not perform error checking/handling.

Parameters

folderpath (str) – folderpath of parent-directory of the static_postures.txt-file

Returns

None

raw_to_angles(dataset)

Calculates angles from (absolute) raw sensor data with gains and offsets that are set as class-variables.

Parameters

dataset (numpy.ndarray) – 1-dimensional array of 22 raw-values

Returns

1-dimensional array of 22 corresponding angles

Return type

numpy.ndarray