Search in sources :

Example 1 with Tuple3f

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

the class ContinuousGyroNotificationEntry method addDelta.

@Override
public void addDelta(Tuple3f data) {
    getDelta().add(data);
    Tuple3f diff = getDelta().diff(lastReported);
    if (Math.abs(diff.x) > deltaToNotify.x || Math.abs(diff.y) > deltaToNotify.y || Math.abs(diff.z) > deltaToNotify.z) {
        Tuple3f reportedInstance = getDelta().copy();
        lastReported.set(reportedInstance);
        report(reportedInstance);
    }
}
Also used : Tuple3f(com.robo4j.math.geometry.Tuple3f)

Example 2 with Tuple3f

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

the class AbstractBno055Device method readVector.

private Tuple3f readVector(int register, Unit unit) throws IOException {
    byte[] data = read(register, 6);
    Tuple3f tuple = new Tuple3f();
    tuple.x = read16bitSigned(data, 0);
    tuple.y = read16bitSigned(data, 2);
    tuple.z = read16bitSigned(data, 4);
    if (unit.getFactor() != 1f) {
        tuple.x /= unit.getFactor();
        tuple.y /= unit.getFactor();
        tuple.z /= unit.getFactor();
    }
    return tuple;
}
Also used : Tuple3f(com.robo4j.math.geometry.Tuple3f)

Example 3 with Tuple3f

use of com.robo4j.math.geometry.Tuple3f 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 4 with Tuple3f

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

the class GyroExample method main.

public static void main(String[] args) throws RoboBuilderException, IOException {
    RoboBuilder builder = new RoboBuilder();
    InputStream settings = GyroExample.class.getClassLoader().getResourceAsStream("gyroexample.xml");
    if (settings == null) {
        System.out.println("Could not find the settings for the GyroExample!");
        System.exit(2);
    }
    builder.add(settings);
    builder.add(GyroProcessor.class, ID_PROCESSOR);
    RoboContext ctx = builder.build();
    System.out.println("State before start:");
    System.out.println(SystemUtil.printStateReport(ctx));
    ctx.start();
    System.out.println("State after start:");
    System.out.println(SystemUtil.printStateReport(ctx));
    RoboReference<GyroRequest> gyro = ctx.getReference("gyro");
    RoboReference<GyroEvent> processor = ctx.getReference(ID_PROCESSOR);
    System.out.println("Let the gyro unit be absolutely still, then press enter to calibrate and start!");
    System.in.read();
    gyro.sendMessage(new GyroRequest(processor, GyroAction.CONTINUOUS, new Tuple3f(1.0f, 1.0f, 1.0f)));
    System.out.println("Will report angular changes indefinitely.\nPress <Enter> to quit!");
    System.in.read();
}
Also used : Tuple3f(com.robo4j.math.geometry.Tuple3f) InputStream(java.io.InputStream) RoboBuilder(com.robo4j.RoboBuilder) RoboContext(com.robo4j.RoboContext)

Example 5 with Tuple3f

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

the class Bno080SPIDevice method createDataEvent.

private DataEvent3f createDataEvent(DataEventType type, long timeStamp, int... data) {
    if (data == null || data.length < 4) {
        return EMPTY_EVENT;
    }
    final int status = data[0] & 0xFFFF;
    final int x = data[1] & 0xFFFF;
    final int y = data[2] & 0xFFFF;
    final int z = data[3] & 0xFFFF;
    final Tuple3f tuple3f = ShtpUtils.createTupleFromFixed(type.getQ(), x, y, z);
    return new DataEvent3f(type, status, tuple3f, timeStamp);
}
Also used : Tuple3f(com.robo4j.math.geometry.Tuple3f) DataEvent3f(com.robo4j.hw.rpi.imu.bno.DataEvent3f)

Aggregations

Tuple3f (com.robo4j.math.geometry.Tuple3f)14 ConfigurationException (com.robo4j.ConfigurationException)1 RoboBuilder (com.robo4j.RoboBuilder)1 RoboContext (com.robo4j.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 DataEvent3f (com.robo4j.hw.rpi.imu.bno.DataEvent3f)1 VectorEvent (com.robo4j.hw.rpi.imu.bno.VectorEvent)1 Matrix3f (com.robo4j.math.geometry.Matrix3f)1 Tuple3i (com.robo4j.math.geometry.Tuple3i)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1