use of org.firstinspires.ftc.robotcore.external.navigation.MagneticFlux in project robotcode by OutoftheBoxFTC.
the class ModernRoboticsI2cCompassSensor method getMagneticFlux.
public MagneticFlux getMagneticFlux() {
// Capture all the data at once so as to get them all from one read
TimestampedData ts = this.deviceClient.readTimeStamped(Register.MAGX.bVal, 3 * 2);
ByteBuffer buffer = ByteBuffer.wrap(ts.data).order(ByteOrder.LITTLE_ENDIAN);
// units are in Gauss. One Tesla is 10,000 Gauss.
int magX = (buffer.getShort());
int magY = (buffer.getShort());
int magZ = (buffer.getShort());
double scale = 0.0001;
return new MagneticFlux(magX * scale, magY * scale, magZ * scale, ts.nanoTime);
}
Aggregations