|
Sensor Fusion Library 0.6.1
Orientation sensing for Espressif (ESP32, ESP8266) processors
|
Hardware Abstraction layer for the particular sensors used. Depending on the design of the sensor PCB, the axes of the sensor ICs are not necessarily oriented as assumed by the fusion algorithm. This file defines the axis remapping functions that are always applied to the raw data before processing. More...
#include "sensor_fusion.h"
Go to the source code of this file.
Functions | |
| void | ApplyAccelHAL (struct AccelSensor *Accel) |
| Apply the accelerometer Hardware Abstraction Layer. | |
| void | ApplyMagHAL (struct MagSensor *Mag) |
| Apply the magnetometer Hardware Abstraction Layer. | |
| void | ApplyGyroHAL (struct GyroSensor *Gyro) |
| Apply the gyroscope Hardware Abstraction Layer. | |
Hardware Abstraction layer for the particular sensors used. Depending on the design of the sensor PCB, the axes of the sensor ICs are not necessarily oriented as assumed by the fusion algorithm. This file defines the axis remapping functions that are always applied to the raw data before processing.
With an unknown sensor board, the most straightforward way to determine the correct axis transformations is to use the Sensor Toolbox. Set the below transformations to your best guess (or start with no transformations). Load the software, launch the Toolbox, and then observe the orientation readouts while manipulating the board. Using the Digital Compass algorithm (which doesn't rely on accel or gyro), remap the axes as needed to get the Heading displaying correctly (i.e. near 0 degrees when your board is flat and pointing north, and the heading increases with clockwise rotation). Next adjust the accelerometer axes, using the Pitch and Roll readouts together with the Tilt-Compensated Compass algorithm. Finally, adjust the gyro axes by ensuring that rotations in all three axes give the expected response (i.e. that the magnetometer and accel are not 'fighting' the gyro, which causes the display to jerk around).
NXP Application Note AN5017 explains the coordinate systems used. NED (North-East-Down) also called Aerospace, is the most appropriate for marine use. It is oriented such that when X-axis points north, the Y-axis points east, and the Z-axis points down. The fusion algorithm uses a "gravity-positive" interpretation - i.e. it expects each accelerometer axis to read +1g when pointing down, and -1g when pointing up. This is reversed from most accelerometer ICs. Rotations are considered positive when they are Clockwise as viewed in the increasing positive direction along the axis. Magnetometer readings are considered positive when the earth's magnetic field (from S to N) points in the same direction as the axis (i.e. the increasing direction of the axis points north).
The present remapping is appropriate for the FXOS8700/FXAS21002C sensors on the Adafruit breakout board, with the NED coord system. Ax swapped with Ay.
Mx swapped with My, then Mx,My,Mz inverted.
Gx swapped with Gy, then Gx,Gy,Gz inverted. Checked 2020-11-13. Valid for NED: haven't checked other coord systems.
The present remapping is identical to the NXP FRDM-STBC-AGM01 breakout board using the FXOS8700/FXAS21002.
Definition in file hal_axis_remap.c.
| void ApplyAccelHAL | ( | struct AccelSensor * | Accel | ) |
Apply the accelerometer Hardware Abstraction Layer.
| Accel | pointer to accelerometer logical sensor |
Definition at line 58 of file hal_axis_remap.c.
| void ApplyGyroHAL | ( | struct GyroSensor * | Gyro | ) |
Apply the gyroscope Hardware Abstraction Layer.
| Gyro | pointer to gyroscope logical sensor |
Definition at line 104 of file hal_axis_remap.c.
| void ApplyMagHAL | ( | struct MagSensor * | Mag | ) |
Apply the magnetometer Hardware Abstraction Layer.
| Mag | pointer to magnetometer logical sensor |
Definition at line 81 of file hal_axis_remap.c.