Search in sources :

Example 1 with Tuple3i

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

the class MagnetometerLSM303Device method read.

public synchronized Tuple3f read() throws IOException {
    Tuple3i rawData = readRaw();
    float x = rawData.x / gain.getXY();
    float y = rawData.y / gain.getXY();
    float z = rawData.z / gain.getZ();
    Tuple3f result = new Tuple3f(x, y, z);
    result.subtract(bias);
    calibrationMatrix.transform(result);
    return result;
}
Also used : Tuple3i(com.robo4j.math.geometry.Tuple3i) Tuple3f(com.robo4j.math.geometry.Tuple3f)

Example 2 with Tuple3i

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

the class MagnetometerLSM303Device method readRaw.

public synchronized Tuple3i readRaw() throws IOException {
    Tuple3i rawData = new Tuple3i();
    byte[] data = new byte[RESULT_BUFFER_SIZE];
    int n = i2cDevice.read(OUT_X_H_M, data, 0, RESULT_BUFFER_SIZE);
    if (n != RESULT_BUFFER_SIZE) {
        getLogger().warning("Failed to read all data from accelerometer. Should have read 6, could only read " + n);
    }
    // Yep, this is indeed the correct order ;)
    rawData.x = read16bitSigned(data, 0);
    rawData.z = read16bitSigned(data, 2);
    rawData.y = read16bitSigned(data, 4);
    return rawData;
}
Also used : Tuple3i(com.robo4j.math.geometry.Tuple3i)

Aggregations

Tuple3i (com.robo4j.math.geometry.Tuple3i)2 Tuple3f (com.robo4j.math.geometry.Tuple3f)1