API Documentation
Loading...
Searching...
No Matches
IMUCalibrator.h
Go to the documentation of this file.
1#pragma once
2#include <NDEVR/Device.h>
3#include <NDEVR/Matrix.h>
4#include <NDEVR/Buffer.h>
5#include <NDEVR/INIInterface.h>
6#include <NDEVR/TranslatedString.h>
7
8namespace NDEVR
9{
10 /**--------------------------------------------------------------------------------------------------
11 \brief Represents a location used for calibrating an IMU. Described by the expected gravity vector for
12 that location.
13 **/
30 /**--------------------------------------------------------------------------------------------------
31 \brief Logic and storage for IMU calibration. An IMU calibration works by moving the sensor into a
32 series of predefined locations and using this motion to calibrated the accelerometer and gyro.
33 **/
35 {
36 Q_OBJECT
37 enum Status
38 {
39 e_idle
40 , e_rotate_to_position
41 , e_wait_to_stable
42 , e_collect_data
43 };
44 public:
45 IMUCalibrator(const UUID& id, const Model& model);
46 IMUCalibrator(const File& location, const Model& model);
47 bool isActive() const;
48 virtual fltp04 percent() const;
49 Status status() const;
53 void setMaxRotationThreshold(const Ray<3, fltp08>& rotation_threshold) { m_rotation_threshold = rotation_threshold;}
54 void setMaxNormalDeviation(const Ray<3, fltp08>& dev) { m_max_norm = dev; }
56 virtual TranslatedString message() const;
57 virtual String iconID() const;
58 void onReading(const Ray<3, fltp08>& accel, const Ray<3, fltp08>& gyro, Time t);
59 bool canCalibrate() const;
61 const Buffer<CalibrationPosition>& calibrationPositions() const { return m_calibration_positions; };
65 virtual void getINI(INIFactory& factory) override;
68 virtual void finishCalibration();
69 uint04 stepIndex() const { return m_calibration_idx; }
71 signals:
73 private:
74 Matrix<fltp08> m_accelerometer_calibration = Constant<Matrix<fltp08>>::Invalid;
75 Buffer<std::pair<Time, Ray<3, fltp08>>> m_collected_gyro_data;
76 Buffer<CalibrationPosition> m_calibration_positions;
77 Ray<3, fltp08> m_gyro_bias = Ray<3, fltp08>(0.0);
78 Ray<3, fltp08> m_rotation_threshold = Ray<3, fltp08>(0.1);
79 Ray<3, fltp08> m_max_norm = Vector<3, fltp08>(0.5);
80 TimeSpan m_time_to_stable = TimeSpan(3.0);
81 Time m_step_start_time = Constant<Time>::Invalid;
82 fltp04 m_percent = 1.0f;
83 uint04 m_samples_to_collect = 1000;
84 uint04 m_calibration_idx = 0;
85 Status m_state = Status::e_idle;
86 Time m_calibration_time = Constant<Time>::Invalid;
87 bool m_is_moving = false;
88 bool m_is_in_norm = false;
89 };
90}
#define HARDWARE_API
Definition DLLInfo.h:56
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:56
A root class which describes some physical object, such as a Motor, Sensor, or Connection....
Definition Device.h:52
Logic for reading or writing to a file as well as navigating filesystems.
Definition File.h:48
Logic and storage for IMU calibration. An IMU calibration works by moving the sensor into a series of...
Definition IMUCalibrator.h:35
virtual fltp04 percent() const
virtual void finishCalibration()
virtual void getINI(INIFactory &factory) override
bool canCalibrate() const
IMUCalibrator(const File &location, const Model &model)
Matrix< fltp08 > accelerometerTransform() const
Ray< 3, fltp08 > expectedGravity() const
Vertex< 3, fltp08 > gyroBias() const
bool isActive() const
Ray< 3, fltp08 > gravityTarget() const
virtual TranslatedString message() const
Time calibrationTime() const
Buffer< std::pair< Time, Ray< 3, fltp08 > > > & accData()
void setMaxRotationThreshold(const Ray< 3, fltp08 > &rotation_threshold)
Definition IMUCalibrator.h:53
const Buffer< CalibrationPosition > & calibrationPositions() const
Definition IMUCalibrator.h:61
virtual String iconID() const
uint04 stepIndex() const
Definition IMUCalibrator.h:69
void setSamplesToCollect(uint04 samples)
void setMaxNormalDeviation(const Ray< 3, fltp08 > &dev)
Definition IMUCalibrator.h:54
void setCalibrationPositions(const Buffer< CalibrationPosition > &postions)
Buffer< std::pair< Time, Ray< 3, fltp08 > > > & gyroData()
Status status() const
IMUCalibrator(const UUID &id, const Model &model)
void onReading(const Ray< 3, fltp08 > &accel, const Ray< 3, fltp08 > &gyro, Time t)
Contains methods for easily reading and writing to an INI file including efficient casting,...
Definition INIReader.h:68
Contains methods for easily reading and writing to an INI file including.
Definition INIInterface.h:45
Definition Matrix.hpp:176
A core class that represents a node on model heirarchy. This node may contain a Geometry or one or mo...
Definition Model.h:58
Definition Vertex.hpp:317
The core String class for the NDEVR API.
Definition String.h:69
Represents a timestamp with utilities for manipulation and conversion.
Definition Time.h:54
Stores a time span, or difference between two times, with an optional start time.
Definition TimeSpan.h:46
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
Definition TranslatedString.h:13
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
Definition UUID.h:60
A fixed-size array with better performance compared to dynamic containers.
Definition Vector.hpp:60
A vertex or point. A specific type of Vector used primarily for spacial location information.
Definition Vertex.hpp:48
Definition ACIColor.h:37
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
Definition BaseValues.hpp:127
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:96
Represents a location used for calibrating an IMU. Described by the expected gravity vector for that ...
Definition IMUCalibrator.h:15
String location_icon
Definition IMUCalibrator.h:24
Ray< 3, fltp08 > gravity
Definition IMUCalibrator.h:21
Buffer< std::pair< Time, Ray< 3, fltp08 > > > acc_data
Definition IMUCalibrator.h:22
void clearData()
Definition IMUCalibrator.h:25
CalibrationPosition(const TranslatedString &location_title, const String &image, const Ray< 3, fltp08 > &gravity)
Definition IMUCalibrator.h:16
TranslatedString location_title
Definition IMUCalibrator.h:23
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved 'invali...
Definition BaseValues.hpp:233