use of com.robo4j.hw.rpi.imu.bno.VectorEvent in project robo4j by Robo4J.
the class Bno080SPIDevice method createVectorEvent.
private DataEvent3f createVectorEvent(DataEventType type, long timeStamp, int... data) {
if (data == null || data.length < 6) {
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 int qReal = data[4] & 0xFFFF;
// Only available on
final int qRadianAccuracy = data[5] & 0xFFFF;
// rotation vector, not
// game rot vector
final Tuple3f tuple3f = ShtpUtils.createTupleFromFixed(type.getQ(), x, y, z);
return new VectorEvent(type, status, tuple3f, timeStamp, intToFloat(qReal, type.getQ()), intToFloat(qRadianAccuracy, type.getQ()));
}
use of com.robo4j.hw.rpi.imu.bno.VectorEvent in project robo4j by Robo4J.
the class VectorEventListenerUnit method onMessage.
@Override
public void onMessage(VectorEvent message) {
SimpleLoggingUtil.info(getClass(), "received:" + message);
RoboContext remoteContext = LookupServiceProvider.getDefaultLookupService().getContext(targetContext);
if (remoteContext != null) {
RoboReference<VectorEvent> roboReference = remoteContext.getReference(remoteUnit);
if (roboReference != null) {
roboReference.sendMessage(message);
}
} else {
SimpleLoggingUtil.info(getClass(), String.format("context not found: %s", targetContext));
}
}
Aggregations