![]() |
AntiMicroX
|
Opens calibration window used for calibration. More...
#include <calibration.h>
Public Types | |
enum | CalibrationType { CAL_NONE, CAL_STICK, CAL_ACCELEROMETER, CAL_GYROSCOPE, CAL_TYPE_MASK = 0x0000FFFF, CAL_INDEX_MASK = 0xFFFF0000, CAL_INDEX_POS = 16 } |
Public Slots | |
void | saveSettings () |
Save calibration values into the device object. More... | |
void | startAccelerometerCalibration () |
Shows user instructions for accelerometer calibration and initializes estimators. More... | |
void | startAccelerometerAngleCalibration () |
Show calibration message to the user and enable accelerometer data event handler. More... | |
void | startGyroscopeCalibration () |
Shows user instructions for gyroscope calibration and initializes estimators. More... | |
void | startGyroscopeOffsetCalibration () |
Show calibration message to the user and enable gyroscope data event handler. More... | |
void | startStickOffsetCalibration () |
Shows user instructions for stick offset calibration, initializes estimators and connects stick data event handlers. More... | |
void | startStickGainCalibration () |
Shows user instructions for stick gain calibration, initializes estimators and connects stick data event handlers. More... | |
Signals | |
void | propertyUpdated () |
Public Member Functions | |
Calibration (InputDevice *joystick, QDialog *parent=0) | |
~Calibration () | |
Protected Slots | |
void | closeEvent (QCloseEvent *event) override |
Ask for confirmation when the dialog is closed with unsafed changed. More... | |
void | resetSettings () |
Asks for confirmation and resets calibration values of the selected device afterwards. More... | |
void | deviceSelectionChanged (int index) |
Device change event handler. Asks for confirmation if there are unsaved changes. More... | |
void | onSensorOffsetData (float x, float y, float z) |
Sensor data event handler. Performs gyroscope offset and accelerometer neutral orientation estimation and stops itself if the value was found or the process timed out. More... | |
void | onStickOffsetData (int x, int y) |
Stick data event handler. Performs stick offset estimation and stops itself if the value was found or the process timed out. More... | |
void | onStickGainData (int x, int y) |
Stick data event handler. Performs stick gain estimation and stops itself if the value was found or the process timed out. More... | |
Protected Member Functions | |
void | resetCalibrationValues () |
Resets calibration values of the currently selected device and updates UI. More... | |
bool | askConfirmation (QString message, bool confirmed) |
Asks the user for confirmation with a given message if the given condition is false. More... | |
void | showSensorCalibrationValues (bool offsetXvalid, double offsetX, bool offsetYvalid, double offsetY, bool offsetZvalid, double offsetZ) |
Shows the sensor offset calibration values to the user. More... | |
void | showStickCalibrationValues (bool offsetXvalid, double offsetX, bool gainXvalid, double gainX, bool offsetYvalid, double offsetY, bool gainYvalid, double gainY) |
Shows the stick offset and gain calibration values to the user. More... | |
void | hideCalibrationData () |
hides all calibration values and their labels. More... | |
void | selectTypeIndex (unsigned int type_index) |
Prepares calibration for the selected device type. Show all used values and labels and connect buttons to the corresponding event handlers. More... | |
Static Protected Member Functions | |
static void | stickRegression (double *offset, double *gain, double xoffset, double xmin, double xmax) |
Performs linear regression on the measurement values of one axis to determine offset and gain. More... | |
Private Attributes | |
Ui::Calibration * | m_ui |
CalibrationType | m_type |
unsigned int | m_index |
bool | m_calibrated |
bool | m_changed |
JoyControlStick * | m_stick |
JoySensor * | m_sensor |
InputDevice * | m_joystick |
StatisticsEstimator | m_offset [3] |
StatisticsEstimator | m_min [2] |
StatisticsEstimator | m_max [2] |
PT1Filter | m_filter [2] |
double | m_last_slope [2] |
QDateTime | m_end_time |
QElapsedTimer | m_rate_timer |
int | m_sample_count |
int | m_phase |
Static Private Attributes | |
static const int | CAL_MIN_SAMPLES = 10 |
static const double | CAL_ACCURACY_SQ = 1e-4 |
static const double | STICK_CAL_TAU = 0.045 |
static const int | STICK_RATE_SAMPLES = 100 |
static const int | CAL_TIMEOUT = 30 |
Opens calibration window used for calibration.
Class used for calibration of joysticks, gyroscopes etc.
|
explicit |
Calibration::~Calibration | ( | ) |
|
protected |
Asks the user for confirmation with a given message if the given condition is false.
[in] | message | The message to show. |
[in] | confirmed | True, if the action is already confirmed or no confirmation is necessary. |
|
overrideprotectedslot |
Ask for confirmation when the dialog is closed with unsafed changed.
|
protectedslot |
Device change event handler. Asks for confirmation if there are unsaved changes.
|
protected |
hides all calibration values and their labels.
|
protectedslot |
Sensor data event handler. Performs gyroscope offset and accelerometer neutral orientation estimation and stops itself if the value was found or the process timed out.
The gyroscope is only offset calibrated since gain calibration would require an accurate turntable to apply a known rotation rate on all axes. The offset is determined by calculating the mean output value at rest.
The accelerometer calibration only rotates the coordinate system to the desired neutral orientation. Calibrating offset and gain would require an accurate fixture to align all axes parallel to gravity. The neutral angles are determined by calculating the mean output value at the desired position.
|
protectedslot |
Stick data event handler. Performs stick gain estimation and stops itself if the value was found or the process timed out.
It looks for local minima and maxima outside the sticks dead zone which are used to estimate the sticks minimum and maximum position.
|
protectedslot |
Stick data event handler. Performs stick offset estimation and stops itself if the value was found or the process timed out.
At the beginning, it waits for the first stick moved event and calculates the event rate for the denoise lag filter. Then it looks for local minima and maxima within the sticks dead zone which are used to estimate the sticks center position.
|
signal |
|
protected |
Resets calibration values of the currently selected device and updates UI.
|
protectedslot |
Asks for confirmation and resets calibration values of the selected device afterwards.
|
slot |
Save calibration values into the device object.
|
protected |
Prepares calibration for the selected device type. Show all used values and labels and connect buttons to the corresponding event handlers.
|
protected |
Shows the sensor offset calibration values to the user.
|
protected |
Shows the stick offset and gain calibration values to the user.
|
slot |
Show calibration message to the user and enable accelerometer data event handler.
|
slot |
Shows user instructions for accelerometer calibration and initializes estimators.
|
slot |
Shows user instructions for gyroscope calibration and initializes estimators.
|
slot |
Show calibration message to the user and enable gyroscope data event handler.
|
slot |
Shows user instructions for stick gain calibration, initializes estimators and connects stick data event handlers.
|
slot |
Shows user instructions for stick offset calibration, initializes estimators and connects stick data event handlers.
|
staticprotected |
Performs linear regression on the measurement values of one axis to determine offset and gain.
[out] | offset | The calculated offset. |
[out] | gain | The calculated gain. |
[in] | xoffset | The measured X value at the point (x, 0) |
[in] | xmin | The measured X value at the point (x, AXISMIN) |
[in] | xmax | The measured X value at the point (x, AXISMAX) |
Since the sum (AXISMIN + 0 + AXISMAX) is 0, the calculation below could be simplified.
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
staticprivate |
|
staticprivate |