Hi Julian,
Based on FRDM-K64+FXS_MULT2-B with latest fusion, in demo project, did the following conversions for NED:
void ApplyAccelHAL(struct AccelSensor *Accel)
{
int8 i; // loop counter
// apply HAL to all measurements read from FIFO buffer
for (i = 0; i < Accel->iFIFOCount; i++)
{
// apply HAL mapping to coordinate system used
#if THISCOORDSYSTEM == NED
int16 itmp16 = Accel->iGsFIFO[i][CHX];
Accel->iGsFIFO[i][CHX] = Accel->iGsFIFO[i][CHY];
Accel->iGsFIFO[i][CHY] = itmp16;
#endif // NED
} // end of loop over FIFO count
return;
}
// function applies the hardware abstraction layer to the magnetometer readings
void ApplyMagHAL(struct MagSensor *Mag)
{
int8 i; // loop counter
// apply HAL to all measurements read from FIFO buffer
for (i = 0; i < Mag->iFIFOCount; i++)
{
// apply HAL mapping to coordinate system used
#if THISCOORDSYSTEM == NED
int16 itmp16 = Mag->iBsFIFO[i][CHX];
Mag->iBsFIFO[i][CHX] = -Mag->iBsFIFO[i][CHY];
Mag->iBsFIFO[i][CHY] = -itmp16;
Mag->iBsFIFO[i][CHZ] = -Mag->iBsFIFO[i][CHZ];
#endif // NED
} // end of loop over FIFO count
return;
}
// function applies the hardware abstraction layer to the gyro readings
void ApplyGyroHAL(struct GyroSensor *Gyro)
{
int8 i; // loop counter
// apply HAL to all measurements read from FIFO buffer
for (i = 0; i < Gyro->iFIFOCount; i++)
{
// apply HAL mapping to coordinate system used
#if THISCOORDSYSTEM == NED
int16 itmp16 = Gyro->iYsFIFO[i][CHX];
Gyro->iYsFIFO[i][CHX] = -Gyro->iYsFIFO[i][CHY];
Gyro->iYsFIFO[i][CHY] = -itmp16;
Gyro->iYsFIFO[i][CHZ] = -Gyro->iYsFIFO[i][CHZ];
#endif // NED
} // end of loop over FIFO count
return;
}
My questions:
1) Switch X and Y for NED. I understand this. I check sensor reading, when axis is UP, it 1g, when axis down, it is -1g. Why do not switch X,Y, Z to (-1) because NED down is positive?
2) For Gyro, check the sensor reading, it is positive if I follow right-hand. It switches to (-1) on X,Y,X because right-hand rule is opposite to clockwise definition?
3) For MAG, I check sensor reading, when axis is UP, it is MIN, when axis down, it is MAX. It did switch X,Y, Z to (-1) because NED down is positive for MAG?
Thanks,
Christie