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);
}
}
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;
}
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;
}
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();
}
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);
}
Aggregations