# Configuration

<img src="https://2698598769-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MYpeL-Cll-FXMj9b3XC%2F-MZg3Tq6HxifYzmKZHbZ%2F-MZgEeLjN9c5HtwPrWra%2FinputConf1.PNG?alt=media&#x26;token=e1d70c81-5141-46df-be54-237d2f7f7cb6" alt="" data-size="original">&#x20;

<img src="https://2698598769-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MYpeL-Cll-FXMj9b3XC%2F-MZg3Tq6HxifYzmKZHbZ%2F-MZgEg2zYXl_mIS4Ms-C%2FinputConf2.PNG?alt=media&#x26;token=c93b4bca-7842-4125-b90c-446bc8ad00a5" alt="" data-size="original">&#x20;

## Introduction

Input module not only transfers hand data to master hand, but it also can apply filters and post-processing to this hand data by predicting movement when tracking is lost, smoothing tracking noise and clamping or limiting the maximum linear or rotational speed of wrist and fingers. These filters can be applied only if `InputModel.inputDataProvider.confidence` drops under a certain threshold.

## Variables

#### Control

* **Update Wrist:** Should the wrist be moved?
* **Update Forearm:** If appliable, should the forearm be moved?
* **Ignore Tracking Loss:** Should Input module react to tracking loss?

#### Tracking loss

* **Hand Tracking Lost Under Confidence:** Hand tracking will be considered lost when InputModel.inputDataProvider.confidence goes bellow this threshold.
* **Fingers Tracking Lost Under Confidence:** Fingers tracking will be considered lost when InputModel.inputDataProvider.confidence goes bellow this threshold.
* **Hide Master When Lost:** Shoud master visuals be disabled when hand tracking is lost?
* **Hide Slave When Lost:** Shoud slave visuals and puppet physics be disabled when hand tracking is lost?

{% hint style="info" %}
**Master or slave visuals** refers to the SkinnedMeshRenderer of a hand, referenced in the master os slave representation of the wrist:`InputModel.hand.root.reprs[representation].skinnedMeshRenderer`.
{% endhint %}

{% hint style="info" %}
**HandView** offers two functions to **toggle hand visuals and physics**:

* `HandView.SetHandVisuals(bool enabled, string representationKey);`
* `HandView.SetHandPhysics(bool enabled);`
  {% endhint %}

#### Predictive tracking

When tracking is lost, InputController can keep wrist moving, decelerating in a linear trajectory using last recorded speed and trayectory as starting state.

* **Use Predictive Tracking When Lost:** Should tracking be predicted on tracking loss?
* **Max Prediction Time:** How long (in seconds) should take wrist to stop from initial speed?
* **Max Prediction Displacement:** How far (in Unity units) should wrist move as maximum?

#### Noise reduction

Smoothed bone tracking is calculated with moving averages (weighted or not) from a window or historic of bone data of a certain size.

* **Record Tracking:** Should the bone data historic be updated?
* **Save Hand Historic Over Conficence:** Bone data historic (for noise smoothing) will be updated when confidence is greater than this threshold.
* **Moving Average:** What moving average algorithm should be used to calculate the smoothed bone data?
* **Window Size:** How big is the window size? How main entries shoudl the bone data historic have? The bigger the window size, the more smoothed the movements will be.
* **Apply To Wrist Position:** Should wrist position be smoothed?
* **Apply To Wrist Rotation:** Should wrist rotation be smoothed?
* **Apply To Fingers Position:** Should fingers position be smoothed?
* **Apply To Fingers Rotation:** Should fingers rotation be smoothed?

{% hint style="info" %}
**InputController don't apply finger bone positions** so smoothing fingers positions won't have any effect but their values would be smoothed anyways, which might be useful for other components or custom modules. Keep `InputConfiguration.applyToFingersPosition` disabled if this is not your case.
{% endhint %}

#### Hand clamping

* **Use Hand Clamping:** Should wrist's linear and angular speed be limited to a maximum value?
* **Gradual Hand Clamping:** Should wrist clamping increase as confidence decrease?
* **Start Decreasing Hand Clamping Under Confidence:** Confidence threshold from which clamping will be applied to wrist.

#### Finger clamping

* **Use Finger Clamping:** Should finger's angular speed be limited to a maximum value?
* **Gradual Finger Clamping:** Should finger clamping increase as confidence decrease?
* **Start Decreasing Finger Clamping Under Confidence:** Confidence threshold from which clamping will be applied to fingers.

## Samples

HPTK package contains 3 **samples** of InputConfiguration in `Packages/HPTK/Samples/Configurations/Input`:

* **Confident:** It uses noise smoothing and hand clamping. Fingers won't move under mid confidence but hand will keep moving under low confidence. Recommended for devices with high tracking noise and erratic movements under low confidence.
* **Predictive:** Similar to *Confident* but using tracking prediction.
* **Raw:** It transfers hand data to master hand without post-processing.
* **Unsmoothed:** It is the same configuration as Confident but without noise smoothing. Recommended for Quest hand tracking.
