33#include <NDEVR/Device.h>
34#include <NDEVR/Matrix.h>
87 class CalibrationData;
90 class DesignObjectLookup;
266 virtual Calibration createAlignmentObject(
DesignObjectLookup* lookup,
bool reference_previous);
317 [[nodiscard]]
virtual Ray<3, fltp08>
referenceDirection()
const {
return Ray<3, fltp08>(1.0, 0.0, 0.0); }
Stores an angle in an optimized internal format with support for efficient trigonometric operations.
A core class where all Design Objects including models, materials, and geometries are stored.
Device(const Model &model, LogPtr log, QObject *parent=nullptr)
Constructs a Device from a Model with the given log and optional Qt parent.
Logic and storage for IMU calibration.
A light-weight wrapper that will be a no-op if there is not a valid log reference,...
Templated logic for doing matrix multiplication.
A core class that represents a node on model hierarchy.
virtual bool supportsModes() const
Returns whether this sensor supports multiple deployment modes.
bool m_using_compass
Whether the compass/magnetometer is currently in use.
virtual Ray< 3, fltp08 > calibratedMagnetometerVector() const
Returns the calibrated magnetometer direction vector.
static Angle< fltp08 > calculateNorthFacing(const Matrix< fltp08, 3, 3 > &offset_mat)
Calculates the north-facing angle from an offset calibration matrix.
IMUCalibrator * m_imu_calibrator
Pointer to the IMU calibrator, if assigned.
virtual void clearCurrentDrift()
Clears the accumulated drift compensation, resetting drift tracking.
const Vector< 3, Angle< fltp08 > > & driftRate() const
Returns the angular drift rate per minute for each axis.
virtual bool requestMagnetometerCalibration(bool)
Requests starting or stopping a magnetometer calibration procedure.
Vector< 3, Angle< fltp08 > > m_angle_drift_rate
The angular drift rate per minute for each axis.
Vector< 3, Angle< fltp08 > > driftValue() const
Returns the accumulated angular drift value based on the current drift rate and elapsed time.
Vector< 3, Angle< fltp08 > > quaternionToAngle(const Vector< 4, fltp08 > &quaternion) const
Converts a quaternion orientation to Euler angles.
Vector< 3, Angle< fltp08 > > m_tilt_angle
The current tilt angles (pitch, roll, yaw).
virtual Time getGyroAlignmentTime() const
Returns the time at which the gyroscope alignment was established.
GyroState m_gyro_state
The current state of the gyroscope.
virtual void setDriftRate(const Vector< 3, Angle< fltp08 > > &drift_rate)
Sets the angular drift rate per minute for each axis.
Angle< fltp08 > m_roll_lock
The angle at which roll is locked, if applicable.
virtual UUID alignmentID() const
Returns the unique identifier for the current alignment.
Time m_angle_drift_start_time
The time when drift tracking started.
Vector< 3, Angle< fltp08 > > deviceOffsets() const
Returns the device-specified angular offsets applied to orientation readings.
virtual bool supportsRodded() const
Returns whether this sensor supports rodded deployment mode.
void deploymentModeOptionsUpdatedSignal()
Emitted when deployment mode options have changed.
virtual MagnetometerState magnetometerState() const
Returns the current state of the magnetometer.
virtual bool usingGyro() const
Returns whether the gyroscope is currently in use.
AccelerometerState m_accelerometer_state
The current state of the accelerometer.
virtual Ray< 3, fltp08 > referenceDirection() const
Returns the reference direction used for orientation calculations.
void setFromAngles(const Vector< 3, Angle< fltp08 > > &angles)
Sets the orientation from Euler angles.
virtual void clearLevelingLimit()
Clears the leveling limit, disabling tilt-based validation.
virtual bool isLocked() const
Returns whether the orientation sensor is currently locked and not updating.
Ray< 3, fltp08 > m_magnetometer_dir
The calibrated magnetometer direction vector.
Angle< fltp08 > m_leveling_limit
The maximum tilt before leveling is invalid.
void setUserSpecifiedOffsets(const Vector< 3, Angle< fltp08 > > &user_specified_offsets)
Sets the user-specified angular offsets for orientation correction.
OrientationSensor(const Model &model, LogPtr log, QObject *parent=nullptr)
Constructs an OrientationSensor with the given model, log, and optional parent.
MagnetometerState m_magnetometer_state
The current state of the magnetometer.
virtual bool hasLockedYaw() const
Returns whether the yaw axis is currently locked to a fixed value.
virtual bool hasCalibratedDrift() const
Returns whether the drift has been calibrated.
virtual bool requestUsingCompass(bool using_compass)
Requests enabling or disabling the compass/magnetometer.
virtual bool requestUsingAccelerometer(bool using_accelerometer)
Requests enabling or disabling the accelerometer.
void magnetometerCalibrationUpdatedSignal()
Emitted when magnetometer calibration data has changed.
bool m_using_accelerometer
Whether the accelerometer is currently in use.
virtual GyroState gyroState() const
Returns the current state of the gyroscope.
virtual bool hasLockedRoll() const
Returns whether the roll axis is currently locked to a fixed value.
void calibrationChangedSignal()
Emitted when the calibration state has changed.
virtual void setLevelingLimit(Angle< fltp08 > limit)
Sets the maximum tilt angle allowed before the leveling state becomes invalid.
bool m_using_gyro
Whether the gyroscope is currently in use.
Angle< fltp08 > magneticHeading() const
Returns the current magnetic heading angle.
virtual Ray< 3, fltp08 > rawMagnetometerVector() const
Returns the raw, uncalibrated magnetometer direction vector.
Angle< fltp08 > m_leveling_range
The tilt range at which a warning is issued.
bool m_is_magnet_field_acceptable
Whether the magnetic field strength is within acceptable limits.
bool m_is_gyro_updating
Whether the gyroscope is currently receiving updates.
Angle< fltp08 > m_roll_lock_reference_yaw
The yaw reference angle used when roll is locked.
virtual void lockYaw(bool lock_yaw, Angle< fltp08 > lock_heading=Constant< Angle< fltp08 > >::Invalid)
Locks or unlocks the yaw axis to a specified heading.
virtual bool requestAccelerationBiasLimit(fltp04 bias_limit)
Requests a change to the acceleration bias limit used for filtering.
virtual CalibrationData * magnetometerCalibrationObject()
Returns the magnetometer calibration data object, if available.
Angle< fltp08 > m_magnetic_azimuth
The current magnetic azimuth heading.
virtual Matrix< fltp08 > lastOrientation() const
Returns the last known orientation as a transformation matrix.
bool m_has_calibrated_drift
Whether drift calibration has been performed.
virtual void setLevelingRange(Angle< fltp08 > limit)
Sets the tilt angle range within which a warning is reported.
void setFromGravityAcceleration(const Vector< 3, fltp08 > &acceleration_vector)
Sets the orientation from a gravity acceleration vector.
virtual bool needsMagnetometerCalibration() const
Returns whether the magnetometer currently needs calibration.
Ray< 3, fltp08 > m_raw_acceleration_vector
The raw acceleration direction vector before calibration.
bool m_gyro_calibration_requested
Whether a gyro calibration has been requested.
virtual TranslatedString calibrationMessage() const
Returns a human-readable message describing the current calibration status.
Vector< 3, Angle< fltp08 > > m_user_specified_offsets
Angular offsets specified by the user.
virtual bool usingAccelerometer() const
Returns whether the accelerometer is currently in use.
Ray< 3, fltp08 > m_raw_magnetometer_vector
The raw magnetometer direction vector before calibration.
virtual bool requestUsingGyro(bool using_gyro, bool reset_state)
Requests enabling or disabling the gyroscope, optionally resetting state.
bool m_is_locked
Whether the orientation sensor is locked.
void checkForSetMagneticDeclination()
Checks for and applies the magnetic declination setting if available.
virtual void setFromQuaternion(const Vector< 4, fltp08 > &quaternion)
Sets the orientation from a quaternion.
fltp04 m_calibration_percent
The current calibration progress as a percentage.
IMUCalibrator * calibrator() const
Returns the current IMU calibrator.
virtual void lockRoll(bool lock_roll, Angle< fltp08 > roll=Constant< Angle< fltp08 > >::Invalid, Angle< fltp08 > yaw=Constant< Angle< fltp08 > >::Invalid)
Locks or unlocks the roll axis to a specified value.
virtual bool usingCompass() const
Returns whether the compass/magnetometer is currently in use.
Angle< fltp08 > m_yaw_lock
The angle at which yaw is locked, if applicable.
virtual bool usedForLeveling() const
Returns whether this sensor is being used for leveling validation.
Matrix< fltp08 > m_calibration_offset
The calibration offset matrix applied to orientation.
virtual LevelingState levelingState() const
Returns the current leveling state based on the current tilt and configured limits.
Angle< fltp08 > levelingRange() const
Returns the configured leveling range angle for warnings.
virtual bool supportsFixed() const
Returns whether this sensor supports fixed deployment mode.
Angle< fltp08 > levelingLimit() const
Returns the configured leveling limit angle.
static Matrix< fltp08, 3, 3 > offsetCalibration(TimeSpan time_since_calibration, const Matrix< fltp08, 3, 3 > ¤t_orientation, const Matrix< fltp08, 3, 3 > &dev_matrix)
Applies drift compensation to an orientation using a deviation matrix over time.
void driftRateUpdatedSignal()
Emitted when the drift rate has been updated.
static Matrix< fltp08, 3, 3 > calculateDeviation(TimeSpan time, const Vector< 4, fltp08 > &start, const Vector< 4, fltp08 > &end)
Calculates the angular deviation between two quaternion orientations over a time span.
Vector< 3, Angle< fltp08 > > gravityAccelerationToAngle(const Vector< 3, fltp08 > &acceleration_vector)
Converts a gravity acceleration vector to tilt angles.
void createCalibrationOffset(const Matrix< fltp08 > &map_from, const Matrix< fltp08 > &map_to)
Creates a calibration offset by computing the transformation between two matrices.
virtual bool requestGyroAlignment(bool reference_previous)
Requests a gyro alignment operation, optionally referencing a previous alignment.
Vector< 3, Angle< fltp08 > > userSpecifiedOffsets() const
Returns the user-specified angular offsets applied to orientation readings.
virtual void setUseGyro(bool use_gyro)
Sets whether the gyroscope should be used for orientation computation.
virtual Angle< fltp08 > compassAngle() const
Returns the compass heading angle from the magnetometer.
void setCalibrationOffset(const Matrix< fltp08 > &offset)
Sets the calibration offset matrix directly.
virtual Vector< 3, Angle< fltp08 > > lastOrientationAngle() const
Returns the last known orientation as Euler angles.
fltp04 calibrationPercent() const
Returns the current calibration progress as a percentage.
virtual bool isGyroUpdating() const
Returns whether the gyroscope is currently receiving updates.
UUID m_alignment_id
Unique identifier for the current alignment.
void setDeviceOffsets(Vector< 3, Angle< fltp08 > > device_offsets)
Sets the device-specified angular offsets for orientation correction.
virtual bool requestApplyMagnetometerCalibration()
Requests applying the current magnetometer calibration results.
virtual void clearLevelingRange()
Clears the leveling range, disabling tilt warning reporting.
virtual void setCalibrator(IMUCalibrator *imu_calibrator)
Sets the IMU calibrator to use for orientation calibration.
Ray< 3, fltp08 > m_acceleration_dir
The calibrated acceleration direction vector.
Time m_alignment_time
The time when the current alignment was created.
Vector< 3, Angle< fltp08 > > m_device_specified_offsets
Angular offsets specified by the device.
Stores a time span, or difference between two times, with an optional start time.
Represents a timestamp with utilities for manipulation and conversion.
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
A fixed-size array with N dimensions used as the basis for geometric and mathematical types.
The primary namespace for the NDEVR SDK.
MagnetometerState
Used by OrientationSensor to display the current state of any available magnetometer.
@ e_compass_valid
The magnetometer is present and reporting valid data.
@ e_calculating_bias
The magnetometer is currently calculating its bias offset.
@ e_no_compass
No magnetometer/compass is available on this device.
@ e_compass_invalid
The magnetometer is present but reporting invalid data.
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
static constexpr bool IsValid(const Angle< t_type > &value)
Checks whether the given Angle holds a valid value.
AccelerometerState
Reports the state of an accelerometer within a OrientationSensor.
@ e_accelerometer_invalid
The accelerometer is present but reporting invalid data.
@ e_no_accelerometer
No accelerometer is available on this device.
@ e_accelerometer_valid
The accelerometer is present and reporting valid data.
LevelingState
Reports the current leveling state of the orientation sensor, indicating whether the device is within...
@ e_level_valid
The current level reading is within acceptable bounds.
@ e_not_used
Leveling is not being used by this sensor.
@ e_level_warning
The current level reading is approaching the limit threshold.
@ e_level_invalid
The current level reading is invalid or outside acceptable bounds.
GyroState
Used by OrientationSensor to display the current state of any available gyro.
@ e_disabled
The gyroscope is present but has been disabled.
@ e_validating_drift
The gyroscope is validating its drift calculation.
@ e_calculating_drift
The gyroscope is calculating its drift compensation.
@ e_no_gyro
No gyroscope is available on this device.
@ e_stabalizing_temp
The gyroscope is stabilizing its temperature before reporting.
@ e_needs_reset
The gyroscope needs to be reset before further use.
@ e_gyro_invalid
The gyroscope is present but reporting invalid data.
@ e_initializing
The gyroscope is currently initializing.
@ e_gyro_valid
The gyroscope is present and reporting valid data.
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved 'invali...