Search in sources :

Example 11 with Float3D

use of com.robo4j.math.geometry.Float3D in project robo4j by Robo4J.

the class GyroL3GD20Device method read.

public Float3D read() throws IOException {
    byte[] xyz = new byte[6];
    Float3D data = new Float3D();
    i2cDevice.write((byte) (REGISTER_OUT_X_L | 0x80));
    i2cDevice.read(REGISTER_OUT_X_H | 0x80, xyz, 0, 6);
    int x = (xyz[1] & 0xFF | (xyz[0] << 8));
    int y = (xyz[3] & 0xFF | (xyz[2] << 8));
    int z = (xyz[5] & 0xFF | (xyz[4] << 8));
    data.x = x * sensitivity.getSensitivityFactor();
    data.y = y * sensitivity.getSensitivityFactor();
    data.z = z * sensitivity.getSensitivityFactor();
    return data;
}
Also used : Float3D(com.robo4j.math.geometry.Float3D)

Aggregations

Float3D (com.robo4j.math.geometry.Float3D)11 ConfigurationException (com.robo4j.core.ConfigurationException)1 RoboBuilder (com.robo4j.core.RoboBuilder)1 RoboContext (com.robo4j.core.RoboContext)1 AccelerometerLSM303Device (com.robo4j.hw.rpi.i2c.accelerometer.AccelerometerLSM303Device)1 DataRate (com.robo4j.hw.rpi.i2c.accelerometer.AccelerometerLSM303Device.DataRate)1 FullScale (com.robo4j.hw.rpi.i2c.accelerometer.AccelerometerLSM303Device.FullScale)1 PowerMode (com.robo4j.hw.rpi.i2c.accelerometer.AccelerometerLSM303Device.PowerMode)1 CalibratedAccelerometer (com.robo4j.hw.rpi.i2c.accelerometer.CalibratedAccelerometer)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1