44 #ifndef SENSOR_FUSION_TYPES_H 45 #define SENSOR_FUSION_TYPES_H 54 #include "issdk_hal.h" 64 typedef unsigned char byte;
107 #define PI 3.141592654F 108 #define PIOVER2 1.570796327F
109 #define FPIOVER180 0.01745329251994F
110 #define F180OVERPI 57.2957795130823F
111 #define F180OVERPISQ 3282.8063500117F
112 #define ONETHIRD 0.33333333F
113 #define ONESIXTH 0.166666667F
114 #define ONESIXTEENTH 0.0625F
115 #define ONEOVER12 0.083333333F
116 #define ONEOVER48 0.02083333333F
117 #define ONEOVER120 0.0083333333F
118 #define ONEOVER3840 0.0002604166667F
119 #define ONEOVERSQRT2 0.707106781F
120 #define SQRT15OVER4 0.968245837F
121 #define GTOMSEC2 9.80665
152 uint16_t read_loop_counter
164 #define SPI_ADDR 0x00 // Use SPI_ADDR as the address parameter to the installSensor function for SPI-based sensors. 400 float fQwCT6x3[6][3];
434 float fQwCT9x6[9][6];
537 #if F_6DOF_GB_BASIC // 6DOF accel and mag eCompass: (accel + mag) 543 #if F_9DOF_GBY_KALMAN 589 uint16_t numElements,
615 uint16_t maxFifoSize,
643 #endif // SENSOR_FUSION_TYPES_H float fCPerCount
degrees Celsius per count
float fgPerCount
g per count
void() ssUpdateStatus_t(struct StatusSubsystem *pStatus)
Initializing sensors and algorithms.
float fDeltaPl
a posteriori inclination angle from Kalman filter (deg)
void() conditionSensorReadings_t(struct SensorFusionGlobals *sfg)
enum quaternion quaternion_type
the quaternion type to be transmitted
Quaternion derived from full 9-axis sensor fusion.
void ApplyMagHAL(struct MagSensor *Mag)
Apply the magnetometer Hardware Abstraction Layer.
float fAlphaSqOver4
(PI / 180 * fdeltat)^2 / 4
uint16_t iFIFOExceeded
Number of samples received in excess of software FIFO size.
float fChi
tilt from vertical (deg)
int8_t() readSensor_t(struct PhysicalSensor *sensor, struct SensorFusionGlobals *sfg)
void conditionSensorReadings(SensorFusionGlobals *sfg)
void * bus_driver
should be of type (ARM_DRIVER_I2C* for I2C-based sensors, ARM_DRIVER_SPI* for SPI) ...
int32_t systick
systick timer
float fMaxGyroOffsetChange
maximum permissible gyro offset change per iteration (deg/s)
float fMaxGyroOffsetChange
maximum permissible gyro offset change per iteration (deg/s)
float fAlphaQwbOver6
(PI / 180 * fdeltat) * Qwb / 6
uint16_t iFIFOExceeded
Number of samples received in excess of software FIFO size.
float fdeltat
fusion time interval (s)
updateStatus_t * testStatus
increment to next enumerated status value (test only)
float fmPerCount
meters per count
float fsinDeltaPl
sin(fDeltaPl)
float fDegPerSecPerCount
deg/s per count
void ApplyAccelHAL(struct AccelSensor *Accel)
Apply the accelerometer Hardware Abstraction Layer.
struct PhysicalSensor * next
pointer to next sensor in this linked list
float fQv
measurement noise covariance matrix leading diagonal
volatile uint8_t iPerturbation
test perturbation to be applied
void initSensorFusionGlobals(SensorFusionGlobals *sfg, struct StatusSubsystem *pStatusSubsystem, struct ControlSubsystem *pControlSubsystem)
utility function to insert default values in the top level structure
int32_t systick
systick timer
int32_t systick
systick timer;
Receiving commands over wireless interface (momentary)
bool isEnabled
true if the device is sampling
int32_t systick_Spare
systick counter for counts spare waiting for timing interrupt
float fLPPsi
low pass yaw (deg)
Functions to convert between various orientation representations.
Quaternion derived from 3-axis mag only (auto compass algorithm)
uint8_t data[FXLS8962_DATA_SIZE]
float fH
most recent unaveraged height (m)
void conditionSample(int16_t sample[3])
conditionSample ensures that we never encounter the maximum negative two's complement value for a 16-...
uint16_t schedule
Parameter to control sensor sampling rate.
uint16_t iFIFOExceeded
Number of samples received in excess of software FIFO size.
int16_t iCountsPerg
counts per g
int32_t systick
systick timer
void() updateStatus_t(struct SensorFusionGlobals *sfg)
float fLPPhi
low pass roll (deg)
installSensor_t * installSensor
function for installing a new sensor into t
float fuTPerCount
uT per count
Quaternion fLPq
low pass filtered orientation quaternion
registerDeviceInfo_t * busInfo
information required for bus power management
struct SV_COMMON * SV_ptr
float fdeltat
fusion time interval (s)
This is the 3DOF basic magnetometer state vector structure/.
Quaternion fq
unfiltered orientation quaternion
#define MAG_FIFO_SIZE
FXOS8700 (mag), MAG3110 have no FIFO so equivalent to 1 element FIFO.
void clearFIFOs(SensorFusionGlobals *sfg)
Function to clear FIFO at the end of each fusion computation.
Quaternion derived from 3-axis gyro only (rotation)
These are the state definitions for the status subsystem.
uint8_t iWhoAmI
sensor whoami
updateStatus_t * updateStatus
status=next status
int16_t iT
most recent unaveraged temperature (counts)
Quaternion derived from 3-axis accel + 3 axis mag (eCompass)
int8_t resetflag
flag to request re-initialization on next pass
The AccelSensor structure stores raw and processed measurements for a 3-axis accelerometer.
float fAlphaSqQvYQwbOver12
(PI / 180 * fdeltat)^2 * (QvY + Qwb) / 12
he ControlSubsystem encapsulates command and data streaming functions.
Quaternion derived from 3-axis accel + 3-axis gyro (gaming)
#define ACCEL_FIFO_SIZE
FXOS8700 (accel), MMA8652, FXLS8952 all have 32 element FIFO.
void() initializeFusionEngine_t(struct SensorFusionGlobals *sfg)
Quaternion fq
unfiltered orientation quaternion
SV_9DOF_GBY_KALMAN is the 9DOF Kalman filter accelerometer, magnetometer and gyroscope state vector s...
float fDelta
unfiltered inclination angle (deg)
int16_t iCountsPerDegPerSec
counts per deg/s
The MagSensor structure stores raw and processed measurements for a 3-axis magnetic sensor...
bool isEnabled
true if the device is sampling
StatusSubsystem() provides an object-like interface for communicating status to the user...
The top level fusion structure.
struct PhysicalSensor * pSensors
a linked list of physical sensors
int8_t() initializeSensor_t(struct PhysicalSensor *sensor, struct SensorFusionGlobals *sfg)
void() clearFIFOs_t(struct SensorFusionGlobals *sfg)
float fT
most recent unaveraged temperature (C)
#define GYRO_FIFO_SIZE
FXAX21000, FXAS21002 have 32 element FIFO.
The SV_1DOF_P_BASIC structure contains state information for a pressure sensor/altimeter.
float fgdeltat
g (m/s2) * fdeltat
Recoverable FAULT = something went wrong, but we can keep going.
initializeSensor_t * initialize
pointer to function to initialize sensor using the supplied drivers
float flpf
low pass filter coefficient
accelerometer measurement buffer
applyPerturbation_t * applyPerturbation
apply step function for testing purposes
float fAlphaOver2
PI / 180 * fdeltat / 2.
SV_6DOF_GY_KALMAN is the 6DOF Kalman filter accelerometer and gyroscope state vector structure...
initializeFusionEngine_t initializeFusionEngine
int8_t iFirstAccelMagLock
denotes that 9DOF orientation has locked to 6DOF eCompass
int32_t systick
systick timer
initializeFusionEngine_t * initializeFusionEngine
set sensor fusion structures to initial values
float fLPThe
low pass pitch (deg)
float fLPChi
low pass tilt from vertical (deg)
float fLPPhi
low pass roll (deg)
uint16_t addr
I2C address if applicable.
int8_t resetflag
flag to request re-initialization on next pass
Quaternion fqPl
a posteriori orientation quaternion
quaternion
the quaternion type to be transmitted
int32_t systick
systick timer
float fAlphaSqQvYQwbOver12
(PI / 180 * fdeltat)^2 * (QvY + Qwb) / 12
Quaternion fq
unfiltered orientation quaternion
uint8_t iFIFOCount
number of measurements read from FIFO
int32_t iP
most recent unaveraged pressure (counts)
int8_t resetflag
flag to request re-initialization on next pass
setStatus_t * setStatus
change status indicator immediately
float fdeltat
fusion filter sampling interval (s)
Quaternion fqPl
a posteriori orientation quaternion
int32_t systick
systick timer;
The FifoSensor union allows us to use common pointers for Accel, Mag & Gyro logical sensor structures...
SV_3DOF_Y_BASIC structure is the 3DOF basic gyroscope state vector structure.
float flpf
low pass filter coefficient
float fLPT
low pass filtered temperature (C)
Implements accelerometer calibration routines.
Receiving commands over wired interface (momentary)
Running in reduced power mode.
uint16_t isInitialized
Bitfields to indicate sensor is active (use SensorBitFields from build.h)
spiSlaveSpecificParams_t slaveParams
SPI specific parameters. Not used for I2C.
precision accelerometer calibration structure
Matrix manipulation functions.
Lower level magnetic calibration interface.
registerDeviceInfo_t deviceInfo
I2C device context.
float flpf
low pass filter coefficient
float fAlphaSqOver4
(PI / 180 * fdeltat)^2 / 4
Quaternion fq
orientation quaternion
bool isEnabled
true if the device is sampling
clearFIFOs_t * clearFIFOs
clear sensor FIFOs
struct StatusSubsystem * pStatusSubsystem
float fCountsPerg
counts per g
float fLPRho
low pass compass (deg)
int8_t resetflag
flag to request re-initialization on next pass
void addToFifo(union FifoSensor *sensor, uint16_t maxFifoSize, int16_t sample[3])
addToFifo is called from within sensor driver read functions
float fAlphaOver2
PI / 180 * fdeltat / 2.
float fChi
tilt from vertical (deg)
int8_t() readSensors_t(struct SensorFusionGlobals *sfg, uint16_t read_loop_counter)
float fChiPl
tilt from vertical (deg)
uint8_t iFIFOCount
number of measurements read from FIFO
uint32_t iFlags
a bit-field of sensors and algorithms used
int16_t iCountsPeruT
counts per uT
Quaternion fLPq
low pass filtered orientation quaternion
float fLPThe
low pass pitch (deg)
int32_t iH
most recent unaveraged height (counts)
runFusion_t * runFusion
run the fusion routines
float fAlphaQwbOver6
(PI / 180 * fdeltat) * Qwb / 6
readSensors_t readSensors
struct SensorFusionGlobals SensorFusionGlobals
The top level fusion structure.
float fRhoPl
compass (deg)
Non-recoverable FAULT = something went very wrong.
Magnetic Calibration Structure.
Quaternion fLPq
low pass filtered orientation quaternion
int8_t resetflag
flag to request re-initialization on next pass
float fRhoPl
compass (deg)
float fcosDeltaPl
cos(fDeltaPl)
quaternion structure definition
void ApplyGyroHAL(struct GyroSensor *Gyro)
Apply the gyroscope Hardware Abstraction Layer.
int8_t() installSensor_t(struct SensorFusionGlobals *sfg, struct PhysicalSensor *sensor, uint16_t addr, uint16_t schedule, void *bus_driver, registerDeviceInfo_t *busInfo, initializeSensor_t *initialize, readSensor_t *read)
installSensor_t installSensor
int32_t systick_I2C
systick counter to benchmark I2C reads
uint8_t iWhoAmI
sensor whoami
Quaternion derived from 3-axis accel (tilt)
readSensors_t * readSensors
read all physical sensors
void() applyPerturbation_t(struct SensorFusionGlobals *sfg)
float fdeltat
sensor fusion interval (s)
conditionSensorReadings_t * conditionSensorReadings
preprocessing step for sensor fusion
struct ControlSubsystem * pControlSubsystem
float fdeltat
fusion time interval (s)
float fLPRho
low pass compass (deg)
void() setStatus_t(struct SensorFusionGlobals *sfg, fusion_status_t status)
float fChiPl
tilt from vertical (deg)
readSensor_t * read
pointer to function to read sensor using the supplied drivers
float fLPChi
low pass tilt from vertical (deg)
fusion_status_t
Application-specific serial communications system.
float fCountsPeruT
counts per uT
bool isEnabled
true if the device is sampling
float flpf
low pass filter coefficient
uint8_t iWhoAmI
sensor whoami
float fLPPsi
low pass yaw (deg)
float fLPRho
low pass compass (deg)
float fdeltat
fusion time interval (s)
SV_6DOF_GB_BASIC is the 6DOF basic accelerometer and magnetometer state vector structure.
void() ssSetStatus_t(struct StatusSubsystem *pStatus, fusion_status_t status)
This structure defines the device specific info required by register I/O.
float fLPChi
low pass tilt from vertical (deg)
setStatus_t * queueStatus
queue status change for next regular interval
This is the 3DOF basic accelerometer state vector structure.
float fLPThe
low pass pitch (deg)
float fLPPsi
low pass yaw (deg)
uint8_t iWhoAmI
sensor whoami
This structure defines the spi slave command format.
An instance of PhysicalSensor structure type should be allocated for each physical sensors (combo dev...
int8_t resetflag
flag to request re-initialization on next pass
The register_io_spi.h file declares low-level interface functions for reading and writing sensor regi...
uint8_t iFIFOCount
number of measurements read from FIFO
int32_t loopcounter
counter incrementing each iteration of sensor fusion (typically 25Hz)
The GyroSensor structure stores raw and processed measurements for a 3-axis gyroscope.
int32_t systick
systick timer;
applyPerturbation_t ApplyPerturbation
ApplyPerturbation is a reverse unit-step test function.
float fLPH
low pass filtered height (m)
int8_t resetflag
flag to request re-initialization on next pass
float fdeltat
sensor fusion interval (s)
void zeroArray(struct StatusSubsystem *pStatus, void *data, uint16_t size, uint16_t numElements, uint8_t check)
float fLPDelta
low pass filtered inclination angle (deg)
void() runFusion_t(struct SensorFusionGlobals *sfg)
Quaternion fq
unfiltered orientation quaternion
The PressureSensor structure stores raw and processed measurements for an altimeter.
float fLPPhi
low pass roll (deg)