Monado OpenXR Runtime
Loading...
Searching...
No Matches
contactglove_calibration.h File Reference

ContactGlove device calibration implementation. More...

#include "math/m_api.h"
#include "math/m_vec2.h"
#include "util/u_logging.h"
#include "util/u_var.h"
#include "contactglove_protocol.h"
#include <float.h>
Include dependency graph for contactglove_calibration.h:

Go to the source code of this file.

Data Structures

struct  contactglove_sensor_calibration
 Represents the calibration of a single flex sensor. More...
 
struct  contactglove_stick_calibration
 Represents the calibration of the joystick. More...
 
struct  contactglove_trigger_calibration
 Represents the calibration of the trigger. More...
 
struct  contactglove_calibration
 A full calibration. More...
 
struct  contactglove_calibration_wizard_flex_sensor_state
 
struct  contactglove_calibration_wizard_joystick_center_state
 
struct  contactglove_calibration_wizard_joystick_range_state
 
struct  contactglove_calibration_wizard_joystick_deadzone_state
 
struct  contactglove_calibration_wizard
 A type which manages the state of the currently-running calibration step. More...
 

Macros

#define CONTACTGLOVE2_DEFAULT_DEADZONE   0.1f
 The default deadzone used on the ContactGlove2, straight from the spec document.
 
#define CONTACTGLOVE_CALIBRATION_MAGIC   0x15D04C50
 The magic for the calibration file, written to disk in big endian so on-disk visibly matches source code.
 
#define CONTACTGLOVE_CALIBRATION_CURRENT_VERSION   CONTACTGLOVE_CALIBRATION_VERSION_INITIAL
 The current version of the calibration file, increment with breaking changes.
 

Enumerations

enum  contactglove_calibration_version { CONTACTGLOVE_CALIBRATION_VERSION_INITIAL = 0 }
 
enum  contactglove_calibration_wizard_step {
  CONTACTGLOVE_CALIBRATION_WIZARD_NOT_CALIBRATING , CONTACTGLOVE_CALIBRATION_WIZARD_CALIBRATING_FLEX_SENSORS , CONTACTGLOVE_CALIBRATION_WIZARD_CALIBRATING_JOYSTICK_CENTER , CONTACTGLOVE_CALIBRATION_WIZARD_CALIBRATING_JOYSTICK_RANGE ,
  CONTACTGLOVE_CALIBRATION_WIZARD_CALIBRATING_JOYSTICK_DEADZONE , CONTACTGLOVE_CALIBRATION_WIZARD_CALIBRATING_JOYSTICK_FORWARD , CONTACTGLOVE_CALIBRATION_WIZARD_CALIBRATING_TRIGGER , CONTACTGLOVE_CALIBRATION_WIZARD_WRITING_OUTPUT
}
 

Functions

static float contactglove_apply_sensor_calibration (const struct contactglove_calibration calibration, int index, const uint16_t *adc_values)
 Applies a flex sensor calibration to a raw ADC value, clamped between 0 and 1.
 
static struct xrt_vec2 contactglove_apply_stick_calibration (const struct contactglove_stick_calibration calibration, const uint8_t stick_x, const uint8_t stick_y)
 Applies joystick calibration, returns an OpenXR joystick position.
 
static float contactglove_apply_trigger_calibration (struct contactglove_trigger_calibration calibration, uint8_t adc_value)
 Applies a trigger calibration to the raw ADC value, following the algorithm laid out in the spec document.
 
void contactglove_calibration_wizard_init (struct contactglove_calibration_wizard *wizard, struct contactglove_device *glove)
 
void contactglove_calibration_wizard_deinit (struct contactglove_calibration_wizard *wizard)
 
void contactglove_calibration_wizard_start (struct contactglove_calibration_wizard *wizard, bool calibrating_magnetra2)
 
void contactglove_calibration_wizard_push_button (struct contactglove_calibration_wizard *wizard, bool button)
 
void contactglove_calibration_wizard_push_flex_sensors (struct contactglove_calibration_wizard *wizard, const uint16_t *adc_values)
 
void contactglove_calibration_wizard_push_joystick (struct contactglove_calibration_wizard *wizard, uint8_t adc_x, uint8_t adc_y)
 
void contactglove_calibration_wizard_push_trigger (struct contactglove_calibration_wizard *wizard, uint8_t adc)
 

Detailed Description

ContactGlove device calibration implementation.

Author
Beyley Cardellio ep1cm.nosp@m.1n10.nosp@m.n123@.nosp@m.gmai.nosp@m.l.com

Macro Definition Documentation

◆ CONTACTGLOVE2_DEFAULT_DEADZONE

#define CONTACTGLOVE2_DEFAULT_DEADZONE   0.1f

The default deadzone used on the ContactGlove2, straight from the spec document.

◆ CONTACTGLOVE_CALIBRATION_CURRENT_VERSION

#define CONTACTGLOVE_CALIBRATION_CURRENT_VERSION   CONTACTGLOVE_CALIBRATION_VERSION_INITIAL

The current version of the calibration file, increment with breaking changes.

◆ CONTACTGLOVE_CALIBRATION_MAGIC

#define CONTACTGLOVE_CALIBRATION_MAGIC   0x15D04C50

The magic for the calibration file, written to disk in big endian so on-disk visibly matches source code.

Enumeration Type Documentation

◆ contactglove_calibration_version

Enumerator
CONTACTGLOVE_CALIBRATION_VERSION_INITIAL 

Initial structure is added.

Function Documentation

◆ contactglove_apply_sensor_calibration()

static float contactglove_apply_sensor_calibration ( const struct contactglove_calibration  calibration,
int  index,
const uint16_t *  adc_values 
)
inlinestatic

Applies a flex sensor calibration to a raw ADC value, clamped between 0 and 1.

References CLAMP, contactglove_sensor_calibration::max, and contactglove_sensor_calibration::min.

◆ contactglove_apply_stick_calibration()

static struct xrt_vec2 contactglove_apply_stick_calibration ( const struct contactglove_stick_calibration  calibration,
const uint8_t  stick_x,
const uint8_t  stick_y 
)
inlinestatic

Applies joystick calibration, returns an OpenXR joystick position.

References CLAMP, and xrt_vec2::XRT_VEC2_ZERO.

◆ contactglove_apply_trigger_calibration()

static float contactglove_apply_trigger_calibration ( struct contactglove_trigger_calibration  calibration,
uint8_t  adc_value 
)
inlinestatic

Applies a trigger calibration to the raw ADC value, following the algorithm laid out in the spec document.

References CLAMP, contactglove_trigger_calibration::max, and contactglove_trigger_calibration::min.