use of com.robo4j.hw.rpi.i2c.gyro.GyroL3GD20Device in project robo4j by Robo4J.
the class GyroL3GD20Unit method onInitialization.
@Override
protected void onInitialization(Configuration configuration) throws ConfigurationException {
super.onInitialization(configuration);
sensitivity = Sensitivity.valueOf(configuration.getString(PROPERTY_KEY_SENSITIVITY, "DPS_245"));
period = configuration.getInteger(PROPERTY_KEY_PERIOD, 10);
highPassFilter = configuration.getBoolean(PROPERTY_KEY_HIGH_PASS_FILTER, true);
try {
gyro = new CalibratedGyro(new GyroL3GD20Device(getBus(), getAddress(), sensitivity, highPassFilter));
} catch (IOException e) {
throw new ConfigurationException(String.format("Failed to initialize lidar device. Make sure it is hooked up to bus: %d address: %xd", getBus(), getAddress()), e);
}
}
use of com.robo4j.hw.rpi.i2c.gyro.GyroL3GD20Device in project robo4j by Robo4J.
the class GyroL3GD20Test method main.
public static void main(String[] args) throws IOException, InterruptedException {
System.out.println("Initializing...");
GyroL3GD20Device device = new GyroL3GD20Device(Sensitivity.DPS_245);
while (true) {
System.out.println(device.read());
Thread.sleep(200);
}
}
use of com.robo4j.hw.rpi.i2c.gyro.GyroL3GD20Device in project robo4j by Robo4J.
the class CalibratedGyroTest method main.
public static void main(String[] args) throws IOException, InterruptedException {
System.out.println("Initializing...");
GyroL3GD20Device device = new GyroL3GD20Device(Sensitivity.DPS_245);
CalibratedGyro gyro = new CalibratedGyro(device);
System.out.println("Keep the device still, and press enter to start calibration.");
System.in.read();
System.out.println("Calibrating...");
gyro.calibrate();
System.out.println("Calibration done!");
while (true) {
System.out.println(gyro.read());
Thread.sleep(200);
}
}
Aggregations