use of com.robo4j.math.geometry.Float3D in project robo4j by Robo4J.
the class ContinuousGyroNotificationEntry method addDelta.
@Override
public void addDelta(Float3D data) {
getDelta().add(data);
Float3D diff = getDelta().diff(lastReported);
if (Math.abs(diff.x) > deltaToNotify.x || Math.abs(diff.y) > deltaToNotify.y || Math.abs(diff.z) > deltaToNotify.z) {
Float3D reportedInstance = getDelta().copy();
lastReported.set(reportedInstance);
report(reportedInstance);
}
}
use of com.robo4j.math.geometry.Float3D 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, true, true, new Float3D(1.0f, 1.0f, 1.0f)));
System.out.println("Will report angular changes indefinitely.\nPress enter to quit!");
System.in.read();
}
use of com.robo4j.math.geometry.Float3D in project robo4j by Robo4J.
the class MagnetometerLSM303Device method read.
public synchronized Float3D read() throws IOException {
Float3D rawData = new Float3D();
byte[] data = new byte[6];
int n = i2cDevice.read(OUT_X_H_M, data, 0, 6);
if (n != 6) {
getLogger().warning("Failed to read all data from accelerometer. Should have read 6, could only read " + n);
}
rawData.x = read16bitSigned(data, 0) / gain.getXY();
rawData.y = read16bitSigned(data, 2) / gain.getXY();
rawData.z = read16bitSigned(data, 4) / gain.getZ();
return rawData;
}
use of com.robo4j.math.geometry.Float3D in project robo4j by Robo4J.
the class AccelerometerLSM303Test method readValues.
private static Stats readValues(ReadableDevice<Float3D> device) throws IOException, InterruptedException {
Stats stats = new Stats();
for (int i = 0; i < 250; i++) {
Float3D fl = device.read();
stats.addValue(fl);
Thread.sleep(20);
if (i % 25 == 0) {
System.out.print(".");
}
}
System.out.println("");
return stats;
}
use of com.robo4j.math.geometry.Float3D in project robo4j by Robo4J.
the class CalibratedFloat3DDevice method read.
public Float3D read() throws IOException {
Float3D value = device.read();
value.add(centerOffsets);
value.multiply(rangeMultipliers);
return value;
}
Aggregations