use of com.qualcomm.robotcore.hardware.TimestampedData in project robotcode by OutoftheBoxFTC.
the class NavxMicroNavigationSensor method getAngularOrientation.
@Override
public Orientation getAngularOrientation(AxesReference reference, AxesOrder order, org.firstinspires.ftc.robotcore.external.navigation.AngleUnit angleUnit) {
TimestampedData data = this.deviceClient.readTimeStamped(Register.YAW_L.bVal, 3 * 2);
//
float zDegrees = -shortToSignedHundredths(TypeConversion.byteArrayToShort(data.data, 0, ByteOrder.LITTLE_ENDIAN));
float yDegrees = shortToSignedHundredths(TypeConversion.byteArrayToShort(data.data, 2, ByteOrder.LITTLE_ENDIAN));
float xDegrees = shortToSignedHundredths(TypeConversion.byteArrayToShort(data.data, 4, ByteOrder.LITTLE_ENDIAN));
//
return new Orientation(AxesReference.INTRINSIC, AxesOrder.ZYX, AngleUnit.DEGREES, zDegrees, yDegrees, xDegrees, data.nanoTime).toAxesReference(reference).toAxesOrder(order).toAngleUnit(angleUnit);
}
use of com.qualcomm.robotcore.hardware.TimestampedData 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);
}
use of com.qualcomm.robotcore.hardware.TimestampedData in project robotcode by OutoftheBoxFTC.
the class ModernRoboticsI2cCompassSensor method getAcceleration.
// ----------------------------------------------------------------------------------------------
// CompassSensor
// ----------------------------------------------------------------------------------------------
public Acceleration getAcceleration() {
// Capture all the data at once so as to get them all from one read
TimestampedData ts = this.deviceClient.readTimeStamped(Register.ACCELX.bVal, 3 * 2);
ByteBuffer buffer = ByteBuffer.wrap(ts.data).order(ByteOrder.LITTLE_ENDIAN);
// units are milli-earth's-gravity
int mgX = (buffer.getShort());
int mgY = (buffer.getShort());
int mgZ = (buffer.getShort());
double scale = 0.001;
return Acceleration.fromGravity(mgX * scale, mgY * scale, mgZ * scale, ts.nanoTime);
}
Aggregations